documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = linear */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Classed used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * This function is deprecated. Use FromArray instead
  2671. * @param array defines the source array
  2672. * @param offset defines the offset in the source array
  2673. * @returns the new Vector3
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * This function is deprecated. Use FromArrayToRef instead.
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Creates a right-handed perspective projection matrix
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed perspective projection matrix
  4467. */
  4468. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed perspective projection into a given matrix
  4471. * @param fov defines the horizontal field of view
  4472. * @param aspect defines the aspect ratio
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4477. */
  4478. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4479. /**
  4480. * Stores a perspective projection for WebVR info a given matrix
  4481. * @param fov defines the field of view
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @param result defines the target matrix
  4485. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4486. */
  4487. static PerspectiveFovWebVRToRef(fov: {
  4488. upDegrees: number;
  4489. downDegrees: number;
  4490. leftDegrees: number;
  4491. rightDegrees: number;
  4492. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4493. /**
  4494. * Computes a complete transformation matrix
  4495. * @param viewport defines the viewport to use
  4496. * @param world defines the world matrix
  4497. * @param view defines the view matrix
  4498. * @param projection defines the projection matrix
  4499. * @param zmin defines the near clip plane
  4500. * @param zmax defines the far clip plane
  4501. * @returns the transformation matrix
  4502. */
  4503. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4504. /**
  4505. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4506. * @param matrix defines the matrix to use
  4507. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4508. */
  4509. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4510. /**
  4511. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4512. * @param matrix defines the matrix to use
  4513. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4514. */
  4515. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4516. /**
  4517. * Compute the transpose of a given matrix
  4518. * @param matrix defines the matrix to transpose
  4519. * @returns the new matrix
  4520. */
  4521. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4522. /**
  4523. * Compute the transpose of a matrix and store it in a target matrix
  4524. * @param matrix defines the matrix to transpose
  4525. * @param result defines the target matrix
  4526. */
  4527. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4528. /**
  4529. * Computes a reflection matrix from a plane
  4530. * @param plane defines the reflection plane
  4531. * @returns a new matrix
  4532. */
  4533. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4534. /**
  4535. * Computes a reflection matrix from a plane
  4536. * @param plane defines the reflection plane
  4537. * @param result defines the target matrix
  4538. */
  4539. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4540. /**
  4541. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4542. * @param xaxis defines the value of the 1st axis
  4543. * @param yaxis defines the value of the 2nd axis
  4544. * @param zaxis defines the value of the 3rd axis
  4545. * @param result defines the target matrix
  4546. */
  4547. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4550. * @param quat defines the quaternion to use
  4551. * @param result defines the target matrix
  4552. */
  4553. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4554. }
  4555. /**
  4556. * @hidden
  4557. */
  4558. export class TmpVectors {
  4559. static Vector2: Vector2[];
  4560. static Vector3: Vector3[];
  4561. static Vector4: Vector4[];
  4562. static Quaternion: Quaternion[];
  4563. static Matrix: Matrix[];
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Defines potential orientation for back face culling
  4569. */
  4570. export enum Orientation {
  4571. /**
  4572. * Clockwise
  4573. */
  4574. CW = 0,
  4575. /** Counter clockwise */
  4576. CCW = 1
  4577. }
  4578. /** Class used to represent a Bezier curve */
  4579. export class BezierCurve {
  4580. /**
  4581. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4582. * @param t defines the time
  4583. * @param x1 defines the left coordinate on X axis
  4584. * @param y1 defines the left coordinate on Y axis
  4585. * @param x2 defines the right coordinate on X axis
  4586. * @param y2 defines the right coordinate on Y axis
  4587. * @returns the interpolated value
  4588. */
  4589. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4590. }
  4591. /**
  4592. * Defines angle representation
  4593. */
  4594. export class Angle {
  4595. private _radians;
  4596. /**
  4597. * Creates an Angle object of "radians" radians (float).
  4598. * @param radians the angle in radians
  4599. */
  4600. constructor(radians: number);
  4601. /**
  4602. * Get value in degrees
  4603. * @returns the Angle value in degrees (float)
  4604. */
  4605. degrees(): number;
  4606. /**
  4607. * Get value in radians
  4608. * @returns the Angle value in radians (float)
  4609. */
  4610. radians(): number;
  4611. /**
  4612. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4613. * @param a defines first vector
  4614. * @param b defines second vector
  4615. * @returns a new Angle
  4616. */
  4617. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4618. /**
  4619. * Gets a new Angle object from the given float in radians
  4620. * @param radians defines the angle value in radians
  4621. * @returns a new Angle
  4622. */
  4623. static FromRadians(radians: number): Angle;
  4624. /**
  4625. * Gets a new Angle object from the given float in degrees
  4626. * @param degrees defines the angle value in degrees
  4627. * @returns a new Angle
  4628. */
  4629. static FromDegrees(degrees: number): Angle;
  4630. }
  4631. /**
  4632. * This represents an arc in a 2d space.
  4633. */
  4634. export class Arc2 {
  4635. /** Defines the start point of the arc */
  4636. startPoint: Vector2;
  4637. /** Defines the mid point of the arc */
  4638. midPoint: Vector2;
  4639. /** Defines the end point of the arc */
  4640. endPoint: Vector2;
  4641. /**
  4642. * Defines the center point of the arc.
  4643. */
  4644. centerPoint: Vector2;
  4645. /**
  4646. * Defines the radius of the arc.
  4647. */
  4648. radius: number;
  4649. /**
  4650. * Defines the angle of the arc (from mid point to end point).
  4651. */
  4652. angle: Angle;
  4653. /**
  4654. * Defines the start angle of the arc (from start point to middle point).
  4655. */
  4656. startAngle: Angle;
  4657. /**
  4658. * Defines the orientation of the arc (clock wise/counter clock wise).
  4659. */
  4660. orientation: Orientation;
  4661. /**
  4662. * Creates an Arc object from the three given points : start, middle and end.
  4663. * @param startPoint Defines the start point of the arc
  4664. * @param midPoint Defines the midlle point of the arc
  4665. * @param endPoint Defines the end point of the arc
  4666. */
  4667. constructor(
  4668. /** Defines the start point of the arc */
  4669. startPoint: Vector2,
  4670. /** Defines the mid point of the arc */
  4671. midPoint: Vector2,
  4672. /** Defines the end point of the arc */
  4673. endPoint: Vector2);
  4674. }
  4675. /**
  4676. * Represents a 2D path made up of multiple 2D points
  4677. */
  4678. export class Path2 {
  4679. private _points;
  4680. private _length;
  4681. /**
  4682. * If the path start and end point are the same
  4683. */
  4684. closed: boolean;
  4685. /**
  4686. * Creates a Path2 object from the starting 2D coordinates x and y.
  4687. * @param x the starting points x value
  4688. * @param y the starting points y value
  4689. */
  4690. constructor(x: number, y: number);
  4691. /**
  4692. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4693. * @param x the added points x value
  4694. * @param y the added points y value
  4695. * @returns the updated Path2.
  4696. */
  4697. addLineTo(x: number, y: number): Path2;
  4698. /**
  4699. * 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.
  4700. * @param midX middle point x value
  4701. * @param midY middle point y value
  4702. * @param endX end point x value
  4703. * @param endY end point y value
  4704. * @param numberOfSegments (default: 36)
  4705. * @returns the updated Path2.
  4706. */
  4707. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4708. /**
  4709. * Closes the Path2.
  4710. * @returns the Path2.
  4711. */
  4712. close(): Path2;
  4713. /**
  4714. * Gets the sum of the distance between each sequential point in the path
  4715. * @returns the Path2 total length (float).
  4716. */
  4717. length(): number;
  4718. /**
  4719. * Gets the points which construct the path
  4720. * @returns the Path2 internal array of points.
  4721. */
  4722. getPoints(): Vector2[];
  4723. /**
  4724. * Retreives the point at the distance aways from the starting point
  4725. * @param normalizedLengthPosition the length along the path to retreive the point from
  4726. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4727. */
  4728. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4729. /**
  4730. * Creates a new path starting from an x and y position
  4731. * @param x starting x value
  4732. * @param y starting y value
  4733. * @returns a new Path2 starting at the coordinates (x, y).
  4734. */
  4735. static StartingAt(x: number, y: number): Path2;
  4736. }
  4737. /**
  4738. * Represents a 3D path made up of multiple 3D points
  4739. */
  4740. export class Path3D {
  4741. /**
  4742. * an array of Vector3, the curve axis of the Path3D
  4743. */
  4744. path: Vector3[];
  4745. private _curve;
  4746. private _distances;
  4747. private _tangents;
  4748. private _normals;
  4749. private _binormals;
  4750. private _raw;
  4751. private _alignTangentsWithPath;
  4752. private readonly _pointAtData;
  4753. /**
  4754. * new Path3D(path, normal, raw)
  4755. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4756. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4757. * @param path an array of Vector3, the curve axis of the Path3D
  4758. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4759. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4760. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4761. */
  4762. constructor(
  4763. /**
  4764. * an array of Vector3, the curve axis of the Path3D
  4765. */
  4766. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4767. /**
  4768. * Returns the Path3D array of successive Vector3 designing its curve.
  4769. * @returns the Path3D array of successive Vector3 designing its curve.
  4770. */
  4771. getCurve(): Vector3[];
  4772. /**
  4773. * Returns the Path3D array of successive Vector3 designing its curve.
  4774. * @returns the Path3D array of successive Vector3 designing its curve.
  4775. */
  4776. getPoints(): Vector3[];
  4777. /**
  4778. * @returns the computed length (float) of the path.
  4779. */
  4780. length(): number;
  4781. /**
  4782. * Returns an array populated with tangent vectors on each Path3D curve point.
  4783. * @returns an array populated with tangent vectors on each Path3D curve point.
  4784. */
  4785. getTangents(): Vector3[];
  4786. /**
  4787. * Returns an array populated with normal vectors on each Path3D curve point.
  4788. * @returns an array populated with normal vectors on each Path3D curve point.
  4789. */
  4790. getNormals(): Vector3[];
  4791. /**
  4792. * Returns an array populated with binormal vectors on each Path3D curve point.
  4793. * @returns an array populated with binormal vectors on each Path3D curve point.
  4794. */
  4795. getBinormals(): Vector3[];
  4796. /**
  4797. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4798. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4799. */
  4800. getDistances(): number[];
  4801. /**
  4802. * Returns an interpolated point along this path
  4803. * @param position the position of the point along this path, from 0.0 to 1.0
  4804. * @returns a new Vector3 as the point
  4805. */
  4806. getPointAt(position: number): Vector3;
  4807. /**
  4808. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4809. * @param position the position of the point along this path, from 0.0 to 1.0
  4810. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4811. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4812. */
  4813. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4814. /**
  4815. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4816. * @param position the position of the point along this path, from 0.0 to 1.0
  4817. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4818. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4819. */
  4820. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4821. /**
  4822. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4823. * @param position the position of the point along this path, from 0.0 to 1.0
  4824. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4825. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4826. */
  4827. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4828. /**
  4829. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4830. * @param position the position of the point along this path, from 0.0 to 1.0
  4831. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4832. */
  4833. getDistanceAt(position: number): number;
  4834. /**
  4835. * Returns the array index of the previous point of an interpolated point along this path
  4836. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4837. * @returns the array index
  4838. */
  4839. getPreviousPointIndexAt(position: number): number;
  4840. /**
  4841. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4842. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4843. * @returns the sub position
  4844. */
  4845. getSubPositionAt(position: number): number;
  4846. /**
  4847. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4848. * @param target the vector of which to get the closest position to
  4849. * @returns the position of the closest virtual point on this path to the target vector
  4850. */
  4851. getClosestPositionTo(target: Vector3): number;
  4852. /**
  4853. * Returns a sub path (slice) of this path
  4854. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4855. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4856. * @returns a sub path (slice) of this path
  4857. */
  4858. slice(start?: number, end?: number): Path3D;
  4859. /**
  4860. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4861. * @param path path which all values are copied into the curves points
  4862. * @param firstNormal which should be projected onto the curve
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4864. * @returns the same object updated.
  4865. */
  4866. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4867. private _compute;
  4868. private _getFirstNonNullVector;
  4869. private _getLastNonNullVector;
  4870. private _normalVector;
  4871. /**
  4872. * Updates the point at data for an interpolated point along this curve
  4873. * @param position the position of the point along this curve, from 0.0 to 1.0
  4874. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4875. * @returns the (updated) point at data
  4876. */
  4877. private _updatePointAtData;
  4878. /**
  4879. * Updates the point at data from the specified parameters
  4880. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4881. * @param point the interpolated point
  4882. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4883. */
  4884. private _setPointAtData;
  4885. /**
  4886. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4887. */
  4888. private _updateInterpolationMatrix;
  4889. }
  4890. /**
  4891. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4892. * A Curve3 is designed from a series of successive Vector3.
  4893. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4894. */
  4895. export class Curve3 {
  4896. private _points;
  4897. private _length;
  4898. /**
  4899. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4900. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4901. * @param v1 (Vector3) the control point
  4902. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4903. * @param nbPoints (integer) the wanted number of points in the curve
  4904. * @returns the created Curve3
  4905. */
  4906. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4907. /**
  4908. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4909. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4910. * @param v1 (Vector3) the first control point
  4911. * @param v2 (Vector3) the second control point
  4912. * @param v3 (Vector3) the end point of the Cubic Bezier
  4913. * @param nbPoints (integer) the wanted number of points in the curve
  4914. * @returns the created Curve3
  4915. */
  4916. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4917. /**
  4918. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4919. * @param p1 (Vector3) the origin point of the Hermite Spline
  4920. * @param t1 (Vector3) the tangent vector at the origin point
  4921. * @param p2 (Vector3) the end point of the Hermite Spline
  4922. * @param t2 (Vector3) the tangent vector at the end point
  4923. * @param nbPoints (integer) the wanted number of points in the curve
  4924. * @returns the created Curve3
  4925. */
  4926. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4927. /**
  4928. * Returns a Curve3 object along a CatmullRom Spline curve :
  4929. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4930. * @param nbPoints (integer) the wanted number of points between each curve control points
  4931. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4932. * @returns the created Curve3
  4933. */
  4934. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4935. /**
  4936. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4937. * A Curve3 is designed from a series of successive Vector3.
  4938. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4939. * @param points points which make up the curve
  4940. */
  4941. constructor(points: Vector3[]);
  4942. /**
  4943. * @returns the Curve3 stored array of successive Vector3
  4944. */
  4945. getPoints(): Vector3[];
  4946. /**
  4947. * @returns the computed length (float) of the curve.
  4948. */
  4949. length(): number;
  4950. /**
  4951. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4952. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4953. * curveA and curveB keep unchanged.
  4954. * @param curve the curve to continue from this curve
  4955. * @returns the newly constructed curve
  4956. */
  4957. continue(curve: DeepImmutable<Curve3>): Curve3;
  4958. private _computeLength;
  4959. }
  4960. }
  4961. declare module BABYLON {
  4962. /**
  4963. * This represents the main contract an easing function should follow.
  4964. * Easing functions are used throughout the animation system.
  4965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4966. */
  4967. export interface IEasingFunction {
  4968. /**
  4969. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4970. * of the easing function.
  4971. * The link below provides some of the most common examples of easing functions.
  4972. * @see https://easings.net/
  4973. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4974. * @returns the corresponding value on the curve defined by the easing function
  4975. */
  4976. ease(gradient: number): number;
  4977. }
  4978. /**
  4979. * Base class used for every default easing function.
  4980. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4981. */
  4982. export class EasingFunction implements IEasingFunction {
  4983. /**
  4984. * Interpolation follows the mathematical formula associated with the easing function.
  4985. */
  4986. static readonly EASINGMODE_EASEIN: number;
  4987. /**
  4988. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4989. */
  4990. static readonly EASINGMODE_EASEOUT: number;
  4991. /**
  4992. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4993. */
  4994. static readonly EASINGMODE_EASEINOUT: number;
  4995. private _easingMode;
  4996. /**
  4997. * Sets the easing mode of the current function.
  4998. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4999. */
  5000. setEasingMode(easingMode: number): void;
  5001. /**
  5002. * Gets the current easing mode.
  5003. * @returns the easing mode
  5004. */
  5005. getEasingMode(): number;
  5006. /**
  5007. * @hidden
  5008. */
  5009. easeInCore(gradient: number): number;
  5010. /**
  5011. * Given an input gradient between 0 and 1, this returns the corresponding value
  5012. * of the easing function.
  5013. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5014. * @returns the corresponding value on the curve defined by the easing function
  5015. */
  5016. ease(gradient: number): number;
  5017. }
  5018. /**
  5019. * Easing function with a circle shape (see link below).
  5020. * @see https://easings.net/#easeInCirc
  5021. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5022. */
  5023. export class CircleEase extends EasingFunction implements IEasingFunction {
  5024. /** @hidden */
  5025. easeInCore(gradient: number): number;
  5026. }
  5027. /**
  5028. * Easing function with a ease back shape (see link below).
  5029. * @see https://easings.net/#easeInBack
  5030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5031. */
  5032. export class BackEase extends EasingFunction implements IEasingFunction {
  5033. /** Defines the amplitude of the function */
  5034. amplitude: number;
  5035. /**
  5036. * Instantiates a back ease easing
  5037. * @see https://easings.net/#easeInBack
  5038. * @param amplitude Defines the amplitude of the function
  5039. */
  5040. constructor(
  5041. /** Defines the amplitude of the function */
  5042. amplitude?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a bouncing shape (see link below).
  5048. * @see https://easings.net/#easeInBounce
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class BounceEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the number of bounces */
  5053. bounces: number;
  5054. /** Defines the amplitude of the bounce */
  5055. bounciness: number;
  5056. /**
  5057. * Instantiates a bounce easing
  5058. * @see https://easings.net/#easeInBounce
  5059. * @param bounces Defines the number of bounces
  5060. * @param bounciness Defines the amplitude of the bounce
  5061. */
  5062. constructor(
  5063. /** Defines the number of bounces */
  5064. bounces?: number,
  5065. /** Defines the amplitude of the bounce */
  5066. bounciness?: number);
  5067. /** @hidden */
  5068. easeInCore(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a power of 3 shape (see link below).
  5072. * @see https://easings.net/#easeInCubic
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CubicEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with an elastic shape (see link below).
  5081. * @see https://easings.net/#easeInElastic
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the number of oscillations*/
  5086. oscillations: number;
  5087. /** Defines the amplitude of the oscillations*/
  5088. springiness: number;
  5089. /**
  5090. * Instantiates an elastic easing function
  5091. * @see https://easings.net/#easeInElastic
  5092. * @param oscillations Defines the number of oscillations
  5093. * @param springiness Defines the amplitude of the oscillations
  5094. */
  5095. constructor(
  5096. /** Defines the number of oscillations*/
  5097. oscillations?: number,
  5098. /** Defines the amplitude of the oscillations*/
  5099. springiness?: number);
  5100. /** @hidden */
  5101. easeInCore(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with an exponential shape (see link below).
  5105. * @see https://easings.net/#easeInExpo
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5109. /** Defines the exponent of the function */
  5110. exponent: number;
  5111. /**
  5112. * Instantiates an exponential easing function
  5113. * @see https://easings.net/#easeInExpo
  5114. * @param exponent Defines the exponent of the function
  5115. */
  5116. constructor(
  5117. /** Defines the exponent of the function */
  5118. exponent?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power shape (see link below).
  5124. * @see https://easings.net/#easeInQuad
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class PowerEase extends EasingFunction implements IEasingFunction {
  5128. /** Defines the power of the function */
  5129. power: number;
  5130. /**
  5131. * Instantiates an power base easing function
  5132. * @see https://easings.net/#easeInQuad
  5133. * @param power Defines the power of the function
  5134. */
  5135. constructor(
  5136. /** Defines the power of the function */
  5137. power?: number);
  5138. /** @hidden */
  5139. easeInCore(gradient: number): number;
  5140. }
  5141. /**
  5142. * Easing function with a power of 2 shape (see link below).
  5143. * @see https://easings.net/#easeInQuad
  5144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5145. */
  5146. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5147. /** @hidden */
  5148. easeInCore(gradient: number): number;
  5149. }
  5150. /**
  5151. * Easing function with a power of 4 shape (see link below).
  5152. * @see https://easings.net/#easeInQuart
  5153. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5154. */
  5155. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5156. /** @hidden */
  5157. easeInCore(gradient: number): number;
  5158. }
  5159. /**
  5160. * Easing function with a power of 5 shape (see link below).
  5161. * @see https://easings.net/#easeInQuint
  5162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5163. */
  5164. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with a sin shape (see link below).
  5170. * @see https://easings.net/#easeInSine
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class SineEase extends EasingFunction implements IEasingFunction {
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a bezier shape (see link below).
  5179. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5183. /** Defines the x component of the start tangent in the bezier curve */
  5184. x1: number;
  5185. /** Defines the y component of the start tangent in the bezier curve */
  5186. y1: number;
  5187. /** Defines the x component of the end tangent in the bezier curve */
  5188. x2: number;
  5189. /** Defines the y component of the end tangent in the bezier curve */
  5190. y2: number;
  5191. /**
  5192. * Instantiates a bezier function
  5193. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5194. * @param x1 Defines the x component of the start tangent in the bezier curve
  5195. * @param y1 Defines the y component of the start tangent in the bezier curve
  5196. * @param x2 Defines the x component of the end tangent in the bezier curve
  5197. * @param y2 Defines the y component of the end tangent in the bezier curve
  5198. */
  5199. constructor(
  5200. /** Defines the x component of the start tangent in the bezier curve */
  5201. x1?: number,
  5202. /** Defines the y component of the start tangent in the bezier curve */
  5203. y1?: number,
  5204. /** Defines the x component of the end tangent in the bezier curve */
  5205. x2?: number,
  5206. /** Defines the y component of the end tangent in the bezier curve */
  5207. y2?: number);
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. }
  5212. declare module BABYLON {
  5213. /**
  5214. * Class used to hold a RBG color
  5215. */
  5216. export class Color3 {
  5217. /**
  5218. * Defines the red component (between 0 and 1, default is 0)
  5219. */
  5220. r: number;
  5221. /**
  5222. * Defines the green component (between 0 and 1, default is 0)
  5223. */
  5224. g: number;
  5225. /**
  5226. * Defines the blue component (between 0 and 1, default is 0)
  5227. */
  5228. b: number;
  5229. /**
  5230. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5231. * @param r defines the red component (between 0 and 1, default is 0)
  5232. * @param g defines the green component (between 0 and 1, default is 0)
  5233. * @param b defines the blue component (between 0 and 1, default is 0)
  5234. */
  5235. constructor(
  5236. /**
  5237. * Defines the red component (between 0 and 1, default is 0)
  5238. */
  5239. r?: number,
  5240. /**
  5241. * Defines the green component (between 0 and 1, default is 0)
  5242. */
  5243. g?: number,
  5244. /**
  5245. * Defines the blue component (between 0 and 1, default is 0)
  5246. */
  5247. b?: number);
  5248. /**
  5249. * Creates a string with the Color3 current values
  5250. * @returns the string representation of the Color3 object
  5251. */
  5252. toString(): string;
  5253. /**
  5254. * Returns the string "Color3"
  5255. * @returns "Color3"
  5256. */
  5257. getClassName(): string;
  5258. /**
  5259. * Compute the Color3 hash code
  5260. * @returns an unique number that can be used to hash Color3 objects
  5261. */
  5262. getHashCode(): number;
  5263. /**
  5264. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5265. * @param array defines the array where to store the r,g,b components
  5266. * @param index defines an optional index in the target array to define where to start storing values
  5267. * @returns the current Color3 object
  5268. */
  5269. toArray(array: FloatArray, index?: number): Color3;
  5270. /**
  5271. * Returns a new Color4 object from the current Color3 and the given alpha
  5272. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5273. * @returns a new Color4 object
  5274. */
  5275. toColor4(alpha?: number): Color4;
  5276. /**
  5277. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5278. * @returns the new array
  5279. */
  5280. asArray(): number[];
  5281. /**
  5282. * Returns the luminance value
  5283. * @returns a float value
  5284. */
  5285. toLuminance(): number;
  5286. /**
  5287. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5288. * @param otherColor defines the second operand
  5289. * @returns the new Color3 object
  5290. */
  5291. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5292. /**
  5293. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5294. * @param otherColor defines the second operand
  5295. * @param result defines the Color3 object where to store the result
  5296. * @returns the current Color3
  5297. */
  5298. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5299. /**
  5300. * Determines equality between Color3 objects
  5301. * @param otherColor defines the second operand
  5302. * @returns true if the rgb values are equal to the given ones
  5303. */
  5304. equals(otherColor: DeepImmutable<Color3>): boolean;
  5305. /**
  5306. * Determines equality between the current Color3 object and a set of r,b,g values
  5307. * @param r defines the red component to check
  5308. * @param g defines the green component to check
  5309. * @param b defines the blue component to check
  5310. * @returns true if the rgb values are equal to the given ones
  5311. */
  5312. equalsFloats(r: number, g: number, b: number): boolean;
  5313. /**
  5314. * Multiplies in place each rgb value by scale
  5315. * @param scale defines the scaling factor
  5316. * @returns the updated Color3
  5317. */
  5318. scale(scale: number): Color3;
  5319. /**
  5320. * Multiplies the rgb values by scale and stores the result into "result"
  5321. * @param scale defines the scaling factor
  5322. * @param result defines the Color3 object where to store the result
  5323. * @returns the unmodified current Color3
  5324. */
  5325. scaleToRef(scale: number, result: Color3): Color3;
  5326. /**
  5327. * Scale the current Color3 values by a factor and add the result to a given Color3
  5328. * @param scale defines the scale factor
  5329. * @param result defines color to store the result into
  5330. * @returns the unmodified current Color3
  5331. */
  5332. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5333. /**
  5334. * Clamps the rgb values by the min and max values and stores the result into "result"
  5335. * @param min defines minimum clamping value (default is 0)
  5336. * @param max defines maximum clamping value (default is 1)
  5337. * @param result defines color to store the result into
  5338. * @returns the original Color3
  5339. */
  5340. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5341. /**
  5342. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5343. * @param otherColor defines the second operand
  5344. * @returns the new Color3
  5345. */
  5346. add(otherColor: DeepImmutable<Color3>): Color3;
  5347. /**
  5348. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5349. * @param otherColor defines the second operand
  5350. * @param result defines Color3 object to store the result into
  5351. * @returns the unmodified current Color3
  5352. */
  5353. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5354. /**
  5355. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3
  5358. */
  5359. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines Color3 object to store the result into
  5364. * @returns the unmodified current Color3
  5365. */
  5366. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Copy the current object
  5369. * @returns a new Color3 copied the current one
  5370. */
  5371. clone(): Color3;
  5372. /**
  5373. * Copies the rgb values from the source in the current Color3
  5374. * @param source defines the source Color3 object
  5375. * @returns the updated Color3 object
  5376. */
  5377. copyFrom(source: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Updates the Color3 rgb values from the given floats
  5380. * @param r defines the red component to read from
  5381. * @param g defines the green component to read from
  5382. * @param b defines the blue component to read from
  5383. * @returns the current Color3 object
  5384. */
  5385. copyFromFloats(r: number, g: number, b: number): Color3;
  5386. /**
  5387. * Updates the Color3 rgb values from the given floats
  5388. * @param r defines the red component to read from
  5389. * @param g defines the green component to read from
  5390. * @param b defines the blue component to read from
  5391. * @returns the current Color3 object
  5392. */
  5393. set(r: number, g: number, b: number): Color3;
  5394. /**
  5395. * Compute the Color3 hexadecimal code as a string
  5396. * @returns a string containing the hexadecimal representation of the Color3 object
  5397. */
  5398. toHexString(): string;
  5399. /**
  5400. * Computes a new Color3 converted from the current one to linear space
  5401. * @returns a new Color3 object
  5402. */
  5403. toLinearSpace(): Color3;
  5404. /**
  5405. * Converts current color in rgb space to HSV values
  5406. * @returns a new color3 representing the HSV values
  5407. */
  5408. toHSV(): Color3;
  5409. /**
  5410. * Converts current color in rgb space to HSV values
  5411. * @param result defines the Color3 where to store the HSV values
  5412. */
  5413. toHSVToRef(result: Color3): void;
  5414. /**
  5415. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5416. * @param convertedColor defines the Color3 object where to store the linear space version
  5417. * @returns the unmodified Color3
  5418. */
  5419. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5420. /**
  5421. * Computes a new Color3 converted from the current one to gamma space
  5422. * @returns a new Color3 object
  5423. */
  5424. toGammaSpace(): Color3;
  5425. /**
  5426. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5427. * @param convertedColor defines the Color3 object where to store the gamma space version
  5428. * @returns the unmodified Color3
  5429. */
  5430. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5431. private static _BlackReadOnly;
  5432. /**
  5433. * Convert Hue, saturation and value to a Color3 (RGB)
  5434. * @param hue defines the hue
  5435. * @param saturation defines the saturation
  5436. * @param value defines the value
  5437. * @param result defines the Color3 where to store the RGB values
  5438. */
  5439. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5440. /**
  5441. * Creates a new Color3 from the string containing valid hexadecimal values
  5442. * @param hex defines a string containing valid hexadecimal values
  5443. * @returns a new Color3 object
  5444. */
  5445. static FromHexString(hex: string): Color3;
  5446. /**
  5447. * Creates a new Color3 from the starting index of the given array
  5448. * @param array defines the source array
  5449. * @param offset defines an offset in the source array
  5450. * @returns a new Color3 object
  5451. */
  5452. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5453. /**
  5454. * Creates a new Color3 from integer values (< 256)
  5455. * @param r defines the red component to read from (value between 0 and 255)
  5456. * @param g defines the green component to read from (value between 0 and 255)
  5457. * @param b defines the blue component to read from (value between 0 and 255)
  5458. * @returns a new Color3 object
  5459. */
  5460. static FromInts(r: number, g: number, b: number): Color3;
  5461. /**
  5462. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5463. * @param start defines the start Color3 value
  5464. * @param end defines the end Color3 value
  5465. * @param amount defines the gradient value between start and end
  5466. * @returns a new Color3 object
  5467. */
  5468. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5469. /**
  5470. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5471. * @param left defines the start value
  5472. * @param right defines the end value
  5473. * @param amount defines the gradient factor
  5474. * @param result defines the Color3 object where to store the result
  5475. */
  5476. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5477. /**
  5478. * Returns a Color3 value containing a red color
  5479. * @returns a new Color3 object
  5480. */
  5481. static Red(): Color3;
  5482. /**
  5483. * Returns a Color3 value containing a green color
  5484. * @returns a new Color3 object
  5485. */
  5486. static Green(): Color3;
  5487. /**
  5488. * Returns a Color3 value containing a blue color
  5489. * @returns a new Color3 object
  5490. */
  5491. static Blue(): Color3;
  5492. /**
  5493. * Returns a Color3 value containing a black color
  5494. * @returns a new Color3 object
  5495. */
  5496. static Black(): Color3;
  5497. /**
  5498. * Gets a Color3 value containing a black color that must not be updated
  5499. */
  5500. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5501. /**
  5502. * Returns a Color3 value containing a white color
  5503. * @returns a new Color3 object
  5504. */
  5505. static White(): Color3;
  5506. /**
  5507. * Returns a Color3 value containing a purple color
  5508. * @returns a new Color3 object
  5509. */
  5510. static Purple(): Color3;
  5511. /**
  5512. * Returns a Color3 value containing a magenta color
  5513. * @returns a new Color3 object
  5514. */
  5515. static Magenta(): Color3;
  5516. /**
  5517. * Returns a Color3 value containing a yellow color
  5518. * @returns a new Color3 object
  5519. */
  5520. static Yellow(): Color3;
  5521. /**
  5522. * Returns a Color3 value containing a gray color
  5523. * @returns a new Color3 object
  5524. */
  5525. static Gray(): Color3;
  5526. /**
  5527. * Returns a Color3 value containing a teal color
  5528. * @returns a new Color3 object
  5529. */
  5530. static Teal(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a random color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Random(): Color3;
  5536. }
  5537. /**
  5538. * Class used to hold a RBGA color
  5539. */
  5540. export class Color4 {
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r: number;
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g: number;
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b: number;
  5553. /**
  5554. * Defines the alpha component (between 0 and 1, default is 1)
  5555. */
  5556. a: number;
  5557. /**
  5558. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5559. * @param r defines the red component (between 0 and 1, default is 0)
  5560. * @param g defines the green component (between 0 and 1, default is 0)
  5561. * @param b defines the blue component (between 0 and 1, default is 0)
  5562. * @param a defines the alpha component (between 0 and 1, default is 1)
  5563. */
  5564. constructor(
  5565. /**
  5566. * Defines the red component (between 0 and 1, default is 0)
  5567. */
  5568. r?: number,
  5569. /**
  5570. * Defines the green component (between 0 and 1, default is 0)
  5571. */
  5572. g?: number,
  5573. /**
  5574. * Defines the blue component (between 0 and 1, default is 0)
  5575. */
  5576. b?: number,
  5577. /**
  5578. * Defines the alpha component (between 0 and 1, default is 1)
  5579. */
  5580. a?: number);
  5581. /**
  5582. * Adds in place the given Color4 values to the current Color4 object
  5583. * @param right defines the second operand
  5584. * @returns the current updated Color4 object
  5585. */
  5586. addInPlace(right: DeepImmutable<Color4>): Color4;
  5587. /**
  5588. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Stores from the starting index in the given array the Color4 successive values
  5594. * @param array defines the array where to store the r,g,b components
  5595. * @param index defines an optional index in the target array to define where to start storing values
  5596. * @returns the current Color4 object
  5597. */
  5598. toArray(array: number[], index?: number): Color4;
  5599. /**
  5600. * Determines equality between Color4 objects
  5601. * @param otherColor defines the second operand
  5602. * @returns true if the rgba values are equal to the given ones
  5603. */
  5604. equals(otherColor: DeepImmutable<Color4>): boolean;
  5605. /**
  5606. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5607. * @param right defines the second operand
  5608. * @returns a new Color4 object
  5609. */
  5610. add(right: DeepImmutable<Color4>): Color4;
  5611. /**
  5612. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5613. * @param right defines the second operand
  5614. * @returns a new Color4 object
  5615. */
  5616. subtract(right: DeepImmutable<Color4>): Color4;
  5617. /**
  5618. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5619. * @param right defines the second operand
  5620. * @param result defines the Color4 object where to store the result
  5621. * @returns the current Color4 object
  5622. */
  5623. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 with the current Color4 values multiplied by scale
  5626. * @param scale defines the scaling factor to apply
  5627. * @returns a new Color4 object
  5628. */
  5629. scale(scale: number): Color4;
  5630. /**
  5631. * Multiplies the current Color4 values by scale and stores the result in "result"
  5632. * @param scale defines the scaling factor to apply
  5633. * @param result defines the Color4 object where to store the result
  5634. * @returns the current unmodified Color4
  5635. */
  5636. scaleToRef(scale: number, result: Color4): Color4;
  5637. /**
  5638. * Scale the current Color4 values by a factor and add the result to a given Color4
  5639. * @param scale defines the scale factor
  5640. * @param result defines the Color4 object where to store the result
  5641. * @returns the unmodified current Color4
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into.
  5649. * @returns the cuurent Color4
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5652. /**
  5653. * Multipy an Color4 value by another and return a new Color4 object
  5654. * @param color defines the Color4 value to multiply by
  5655. * @returns a new Color4 object
  5656. */
  5657. multiply(color: Color4): Color4;
  5658. /**
  5659. * Multipy a Color4 value by another and push the result in a reference value
  5660. * @param color defines the Color4 value to multiply by
  5661. * @param result defines the Color4 to fill the result in
  5662. * @returns the result Color4
  5663. */
  5664. multiplyToRef(color: Color4, result: Color4): Color4;
  5665. /**
  5666. * Creates a string with the Color4 current values
  5667. * @returns the string representation of the Color4 object
  5668. */
  5669. toString(): string;
  5670. /**
  5671. * Returns the string "Color4"
  5672. * @returns "Color4"
  5673. */
  5674. getClassName(): string;
  5675. /**
  5676. * Compute the Color4 hash code
  5677. * @returns an unique number that can be used to hash Color4 objects
  5678. */
  5679. getHashCode(): number;
  5680. /**
  5681. * Creates a new Color4 copied from the current one
  5682. * @returns a new Color4 object
  5683. */
  5684. clone(): Color4;
  5685. /**
  5686. * Copies the given Color4 values into the current one
  5687. * @param source defines the source Color4 object
  5688. * @returns the current updated Color4 object
  5689. */
  5690. copyFrom(source: Color4): Color4;
  5691. /**
  5692. * Copies the given float values into the current one
  5693. * @param r defines the red component to read from
  5694. * @param g defines the green component to read from
  5695. * @param b defines the blue component to read from
  5696. * @param a defines the alpha component to read from
  5697. * @returns the current updated Color4 object
  5698. */
  5699. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5700. /**
  5701. * Copies the given float values into the current one
  5702. * @param r defines the red component to read from
  5703. * @param g defines the green component to read from
  5704. * @param b defines the blue component to read from
  5705. * @param a defines the alpha component to read from
  5706. * @returns the current updated Color4 object
  5707. */
  5708. set(r: number, g: number, b: number, a: number): Color4;
  5709. /**
  5710. * Compute the Color4 hexadecimal code as a string
  5711. * @returns a string containing the hexadecimal representation of the Color4 object
  5712. */
  5713. toHexString(): string;
  5714. /**
  5715. * Computes a new Color4 converted from the current one to linear space
  5716. * @returns a new Color4 object
  5717. */
  5718. toLinearSpace(): Color4;
  5719. /**
  5720. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5721. * @param convertedColor defines the Color4 object where to store the linear space version
  5722. * @returns the unmodified Color4
  5723. */
  5724. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5725. /**
  5726. * Computes a new Color4 converted from the current one to gamma space
  5727. * @returns a new Color4 object
  5728. */
  5729. toGammaSpace(): Color4;
  5730. /**
  5731. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5732. * @param convertedColor defines the Color4 object where to store the gamma space version
  5733. * @returns the unmodified Color4
  5734. */
  5735. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5736. /**
  5737. * Creates a new Color4 from the string containing valid hexadecimal values
  5738. * @param hex defines a string containing valid hexadecimal values
  5739. * @returns a new Color4 object
  5740. */
  5741. static FromHexString(hex: string): Color4;
  5742. /**
  5743. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5744. * @param left defines the start value
  5745. * @param right defines the end value
  5746. * @param amount defines the gradient factor
  5747. * @returns a new Color4 object
  5748. */
  5749. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5750. /**
  5751. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5752. * @param left defines the start value
  5753. * @param right defines the end value
  5754. * @param amount defines the gradient factor
  5755. * @param result defines the Color4 object where to store data
  5756. */
  5757. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5758. /**
  5759. * Creates a new Color4 from a Color3 and an alpha value
  5760. * @param color3 defines the source Color3 to read from
  5761. * @param alpha defines the alpha component (1.0 by default)
  5762. * @returns a new Color4 object
  5763. */
  5764. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5765. /**
  5766. * Creates a new Color4 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @returns a new Color4 object
  5770. */
  5771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @param a defines the alpha component to read from (value between 0 and 255)
  5778. * @returns a new Color3 object
  5779. */
  5780. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5781. /**
  5782. * Check the content of a given array and convert it to an array containing RGBA data
  5783. * If the original array was already containing count * 4 values then it is returned directly
  5784. * @param colors defines the array to check
  5785. * @param count defines the number of RGBA data to expect
  5786. * @returns an array containing count * 4 values (RGBA)
  5787. */
  5788. static CheckColors4(colors: number[], count: number): number[];
  5789. }
  5790. /**
  5791. * @hidden
  5792. */
  5793. export class TmpColors {
  5794. static Color3: Color3[];
  5795. static Color4: Color4[];
  5796. }
  5797. }
  5798. declare module BABYLON {
  5799. /**
  5800. * Defines an interface which represents an animation key frame
  5801. */
  5802. export interface IAnimationKey {
  5803. /**
  5804. * Frame of the key frame
  5805. */
  5806. frame: number;
  5807. /**
  5808. * Value at the specifies key frame
  5809. */
  5810. value: any;
  5811. /**
  5812. * The input tangent for the cubic hermite spline
  5813. */
  5814. inTangent?: any;
  5815. /**
  5816. * The output tangent for the cubic hermite spline
  5817. */
  5818. outTangent?: any;
  5819. /**
  5820. * The animation interpolation type
  5821. */
  5822. interpolation?: AnimationKeyInterpolation;
  5823. }
  5824. /**
  5825. * Enum for the animation key frame interpolation type
  5826. */
  5827. export enum AnimationKeyInterpolation {
  5828. /**
  5829. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5830. */
  5831. STEP = 1
  5832. }
  5833. }
  5834. declare module BABYLON {
  5835. /**
  5836. * Represents the range of an animation
  5837. */
  5838. export class AnimationRange {
  5839. /**The name of the animation range**/
  5840. name: string;
  5841. /**The starting frame of the animation */
  5842. from: number;
  5843. /**The ending frame of the animation*/
  5844. to: number;
  5845. /**
  5846. * Initializes the range of an animation
  5847. * @param name The name of the animation range
  5848. * @param from The starting frame of the animation
  5849. * @param to The ending frame of the animation
  5850. */
  5851. constructor(
  5852. /**The name of the animation range**/
  5853. name: string,
  5854. /**The starting frame of the animation */
  5855. from: number,
  5856. /**The ending frame of the animation*/
  5857. to: number);
  5858. /**
  5859. * Makes a copy of the animation range
  5860. * @returns A copy of the animation range
  5861. */
  5862. clone(): AnimationRange;
  5863. }
  5864. }
  5865. declare module BABYLON {
  5866. /**
  5867. * Composed of a frame, and an action function
  5868. */
  5869. export class AnimationEvent {
  5870. /** The frame for which the event is triggered **/
  5871. frame: number;
  5872. /** The event to perform when triggered **/
  5873. action: (currentFrame: number) => void;
  5874. /** Specifies if the event should be triggered only once**/
  5875. onlyOnce?: boolean | undefined;
  5876. /**
  5877. * Specifies if the animation event is done
  5878. */
  5879. isDone: boolean;
  5880. /**
  5881. * Initializes the animation event
  5882. * @param frame The frame for which the event is triggered
  5883. * @param action The event to perform when triggered
  5884. * @param onlyOnce Specifies if the event should be triggered only once
  5885. */
  5886. constructor(
  5887. /** The frame for which the event is triggered **/
  5888. frame: number,
  5889. /** The event to perform when triggered **/
  5890. action: (currentFrame: number) => void,
  5891. /** Specifies if the event should be triggered only once**/
  5892. onlyOnce?: boolean | undefined);
  5893. /** @hidden */
  5894. _clone(): AnimationEvent;
  5895. }
  5896. }
  5897. declare module BABYLON {
  5898. /**
  5899. * Interface used to define a behavior
  5900. */
  5901. export interface Behavior<T> {
  5902. /** gets or sets behavior's name */
  5903. name: string;
  5904. /**
  5905. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5906. */
  5907. init(): void;
  5908. /**
  5909. * Called when the behavior is attached to a target
  5910. * @param target defines the target where the behavior is attached to
  5911. */
  5912. attach(target: T): void;
  5913. /**
  5914. * Called when the behavior is detached from its target
  5915. */
  5916. detach(): void;
  5917. }
  5918. /**
  5919. * Interface implemented by classes supporting behaviors
  5920. */
  5921. export interface IBehaviorAware<T> {
  5922. /**
  5923. * Attach a behavior
  5924. * @param behavior defines the behavior to attach
  5925. * @returns the current host
  5926. */
  5927. addBehavior(behavior: Behavior<T>): T;
  5928. /**
  5929. * Remove a behavior from the current object
  5930. * @param behavior defines the behavior to detach
  5931. * @returns the current host
  5932. */
  5933. removeBehavior(behavior: Behavior<T>): T;
  5934. /**
  5935. * Gets a behavior using its name to search
  5936. * @param name defines the name to search
  5937. * @returns the behavior or null if not found
  5938. */
  5939. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5940. }
  5941. }
  5942. declare module BABYLON {
  5943. /**
  5944. * Defines an array and its length.
  5945. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5946. */
  5947. export interface ISmartArrayLike<T> {
  5948. /**
  5949. * The data of the array.
  5950. */
  5951. data: Array<T>;
  5952. /**
  5953. * The active length of the array.
  5954. */
  5955. length: number;
  5956. }
  5957. /**
  5958. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5959. */
  5960. export class SmartArray<T> implements ISmartArrayLike<T> {
  5961. /**
  5962. * The full set of data from the array.
  5963. */
  5964. data: Array<T>;
  5965. /**
  5966. * The active length of the array.
  5967. */
  5968. length: number;
  5969. protected _id: number;
  5970. /**
  5971. * Instantiates a Smart Array.
  5972. * @param capacity defines the default capacity of the array.
  5973. */
  5974. constructor(capacity: number);
  5975. /**
  5976. * Pushes a value at the end of the active data.
  5977. * @param value defines the object to push in the array.
  5978. */
  5979. push(value: T): void;
  5980. /**
  5981. * Iterates over the active data and apply the lambda to them.
  5982. * @param func defines the action to apply on each value.
  5983. */
  5984. forEach(func: (content: T) => void): void;
  5985. /**
  5986. * Sorts the full sets of data.
  5987. * @param compareFn defines the comparison function to apply.
  5988. */
  5989. sort(compareFn: (a: T, b: T) => number): void;
  5990. /**
  5991. * Resets the active data to an empty array.
  5992. */
  5993. reset(): void;
  5994. /**
  5995. * Releases all the data from the array as well as the array.
  5996. */
  5997. dispose(): void;
  5998. /**
  5999. * Concats the active data with a given array.
  6000. * @param array defines the data to concatenate with.
  6001. */
  6002. concat(array: any): void;
  6003. /**
  6004. * Returns the position of a value in the active data.
  6005. * @param value defines the value to find the index for
  6006. * @returns the index if found in the active data otherwise -1
  6007. */
  6008. indexOf(value: T): number;
  6009. /**
  6010. * Returns whether an element is part of the active data.
  6011. * @param value defines the value to look for
  6012. * @returns true if found in the active data otherwise false
  6013. */
  6014. contains(value: T): boolean;
  6015. private static _GlobalId;
  6016. }
  6017. /**
  6018. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6019. * The data in this array can only be present once
  6020. */
  6021. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6022. private _duplicateId;
  6023. /**
  6024. * Pushes a value at the end of the active data.
  6025. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6026. * @param value defines the object to push in the array.
  6027. */
  6028. push(value: T): void;
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * If the data is already present, it won t be added again
  6032. * @param value defines the object to push in the array.
  6033. * @returns true if added false if it was already present
  6034. */
  6035. pushNoDuplicate(value: T): boolean;
  6036. /**
  6037. * Resets the active data to an empty array.
  6038. */
  6039. reset(): void;
  6040. /**
  6041. * Concats the active data with a given array.
  6042. * This ensures no dupplicate will be present in the result.
  6043. * @param array defines the data to concatenate with.
  6044. */
  6045. concatWithNoDuplicate(array: any): void;
  6046. }
  6047. }
  6048. declare module BABYLON {
  6049. /**
  6050. * @ignore
  6051. * This is a list of all the different input types that are available in the application.
  6052. * Fo instance: ArcRotateCameraGamepadInput...
  6053. */
  6054. export var CameraInputTypes: {};
  6055. /**
  6056. * This is the contract to implement in order to create a new input class.
  6057. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6058. */
  6059. export interface ICameraInput<TCamera extends Camera> {
  6060. /**
  6061. * Defines the camera the input is attached to.
  6062. */
  6063. camera: Nullable<TCamera>;
  6064. /**
  6065. * Gets the class name of the current intput.
  6066. * @returns the class name
  6067. */
  6068. getClassName(): string;
  6069. /**
  6070. * Get the friendly name associated with the input class.
  6071. * @returns the input friendly name
  6072. */
  6073. getSimpleName(): string;
  6074. /**
  6075. * Attach the input controls to a specific dom element to get the input from.
  6076. * @param element Defines the element the controls should be listened from
  6077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6078. */
  6079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6080. /**
  6081. * Detach the current controls from the specified dom element.
  6082. * @param element Defines the element to stop listening the inputs from
  6083. */
  6084. detachControl(element: Nullable<HTMLElement>): void;
  6085. /**
  6086. * Update the current camera state depending on the inputs that have been used this frame.
  6087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6088. */
  6089. checkInputs?: () => void;
  6090. }
  6091. /**
  6092. * Represents a map of input types to input instance or input index to input instance.
  6093. */
  6094. export interface CameraInputsMap<TCamera extends Camera> {
  6095. /**
  6096. * Accessor to the input by input type.
  6097. */
  6098. [name: string]: ICameraInput<TCamera>;
  6099. /**
  6100. * Accessor to the input by input index.
  6101. */
  6102. [idx: number]: ICameraInput<TCamera>;
  6103. }
  6104. /**
  6105. * This represents the input manager used within a camera.
  6106. * It helps dealing with all the different kind of input attached to a camera.
  6107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6108. */
  6109. export class CameraInputsManager<TCamera extends Camera> {
  6110. /**
  6111. * Defines the list of inputs attahed to the camera.
  6112. */
  6113. attached: CameraInputsMap<TCamera>;
  6114. /**
  6115. * Defines the dom element the camera is collecting inputs from.
  6116. * This is null if the controls have not been attached.
  6117. */
  6118. attachedElement: Nullable<HTMLElement>;
  6119. /**
  6120. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6121. */
  6122. noPreventDefault: boolean;
  6123. /**
  6124. * Defined the camera the input manager belongs to.
  6125. */
  6126. camera: TCamera;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs: () => void;
  6132. /**
  6133. * Instantiate a new Camera Input Manager.
  6134. * @param camera Defines the camera the input manager blongs to
  6135. */
  6136. constructor(camera: TCamera);
  6137. /**
  6138. * Add an input method to a camera
  6139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6140. * @param input camera input method
  6141. */
  6142. add(input: ICameraInput<TCamera>): void;
  6143. /**
  6144. * Remove a specific input method from a camera
  6145. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6146. * @param inputToRemove camera input method
  6147. */
  6148. remove(inputToRemove: ICameraInput<TCamera>): void;
  6149. /**
  6150. * Remove a specific input type from a camera
  6151. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6152. * @param inputType the type of the input to remove
  6153. */
  6154. removeByType(inputType: string): void;
  6155. private _addCheckInputs;
  6156. /**
  6157. * Attach the input controls to the currently attached dom element to listen the events from.
  6158. * @param input Defines the input to attach
  6159. */
  6160. attachInput(input: ICameraInput<TCamera>): void;
  6161. /**
  6162. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6163. * @param element Defines the dom element to collect the events from
  6164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6165. */
  6166. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6167. /**
  6168. * Detach the current manager inputs controls from a specific dom element.
  6169. * @param element Defines the dom element to collect the events from
  6170. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6171. */
  6172. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6173. /**
  6174. * Rebuild the dynamic inputCheck function from the current list of
  6175. * defined inputs in the manager.
  6176. */
  6177. rebuildInputCheck(): void;
  6178. /**
  6179. * Remove all attached input methods from a camera
  6180. */
  6181. clear(): void;
  6182. /**
  6183. * Serialize the current input manager attached to a camera.
  6184. * This ensures than once parsed,
  6185. * the input associated to the camera will be identical to the current ones
  6186. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6187. */
  6188. serialize(serializedCamera: any): void;
  6189. /**
  6190. * Parses an input manager serialized JSON to restore the previous list of inputs
  6191. * and states associated to a camera.
  6192. * @param parsedCamera Defines the JSON to parse
  6193. */
  6194. parse(parsedCamera: any): void;
  6195. }
  6196. }
  6197. declare module BABYLON {
  6198. /**
  6199. * Class used to store data that will be store in GPU memory
  6200. */
  6201. export class Buffer {
  6202. private _engine;
  6203. private _buffer;
  6204. /** @hidden */
  6205. _data: Nullable<DataArray>;
  6206. private _updatable;
  6207. private _instanced;
  6208. private _divisor;
  6209. /**
  6210. * Gets the byte stride.
  6211. */
  6212. readonly byteStride: number;
  6213. /**
  6214. * Constructor
  6215. * @param engine the engine
  6216. * @param data the data to use for this buffer
  6217. * @param updatable whether the data is updatable
  6218. * @param stride the stride (optional)
  6219. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6220. * @param instanced whether the buffer is instanced (optional)
  6221. * @param useBytes set to true if the stride in in bytes (optional)
  6222. * @param divisor sets an optional divisor for instances (1 by default)
  6223. */
  6224. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6225. /**
  6226. * Create a new VertexBuffer based on the current buffer
  6227. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6228. * @param offset defines offset in the buffer (0 by default)
  6229. * @param size defines the size in floats of attributes (position is 3 for instance)
  6230. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6231. * @param instanced defines if the vertex buffer contains indexed data
  6232. * @param useBytes defines if the offset and stride are in bytes *
  6233. * @param divisor sets an optional divisor for instances (1 by default)
  6234. * @returns the new vertex buffer
  6235. */
  6236. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6237. /**
  6238. * Gets a boolean indicating if the Buffer is updatable?
  6239. * @returns true if the buffer is updatable
  6240. */
  6241. isUpdatable(): boolean;
  6242. /**
  6243. * Gets current buffer's data
  6244. * @returns a DataArray or null
  6245. */
  6246. getData(): Nullable<DataArray>;
  6247. /**
  6248. * Gets underlying native buffer
  6249. * @returns underlying native buffer
  6250. */
  6251. getBuffer(): Nullable<DataBuffer>;
  6252. /**
  6253. * Gets the stride in float32 units (i.e. byte stride / 4).
  6254. * May not be an integer if the byte stride is not divisible by 4.
  6255. * DEPRECATED. Use byteStride instead.
  6256. * @returns the stride in float32 units
  6257. */
  6258. getStrideSize(): number;
  6259. /**
  6260. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6261. * @param data defines the data to store
  6262. */
  6263. create(data?: Nullable<DataArray>): void;
  6264. /** @hidden */
  6265. _rebuild(): void;
  6266. /**
  6267. * Update current buffer data
  6268. * @param data defines the data to store
  6269. */
  6270. update(data: DataArray): void;
  6271. /**
  6272. * Updates the data directly.
  6273. * @param data the new data
  6274. * @param offset the new offset
  6275. * @param vertexCount the vertex count (optional)
  6276. * @param useBytes set to true if the offset is in bytes
  6277. */
  6278. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6279. /**
  6280. * Release all resources
  6281. */
  6282. dispose(): void;
  6283. }
  6284. /**
  6285. * Specialized buffer used to store vertex data
  6286. */
  6287. export class VertexBuffer {
  6288. /** @hidden */
  6289. _buffer: Buffer;
  6290. private _kind;
  6291. private _size;
  6292. private _ownsBuffer;
  6293. private _instanced;
  6294. private _instanceDivisor;
  6295. /**
  6296. * The byte type.
  6297. */
  6298. static readonly BYTE: number;
  6299. /**
  6300. * The unsigned byte type.
  6301. */
  6302. static readonly UNSIGNED_BYTE: number;
  6303. /**
  6304. * The short type.
  6305. */
  6306. static readonly SHORT: number;
  6307. /**
  6308. * The unsigned short type.
  6309. */
  6310. static readonly UNSIGNED_SHORT: number;
  6311. /**
  6312. * The integer type.
  6313. */
  6314. static readonly INT: number;
  6315. /**
  6316. * The unsigned integer type.
  6317. */
  6318. static readonly UNSIGNED_INT: number;
  6319. /**
  6320. * The float type.
  6321. */
  6322. static readonly FLOAT: number;
  6323. /**
  6324. * Gets or sets the instance divisor when in instanced mode
  6325. */
  6326. instanceDivisor: number;
  6327. /**
  6328. * Gets the byte stride.
  6329. */
  6330. readonly byteStride: number;
  6331. /**
  6332. * Gets the byte offset.
  6333. */
  6334. readonly byteOffset: number;
  6335. /**
  6336. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6337. */
  6338. readonly normalized: boolean;
  6339. /**
  6340. * Gets the data type of each component in the array.
  6341. */
  6342. readonly type: number;
  6343. /**
  6344. * Constructor
  6345. * @param engine the engine
  6346. * @param data the data to use for this vertex buffer
  6347. * @param kind the vertex buffer kind
  6348. * @param updatable whether the data is updatable
  6349. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6350. * @param stride the stride (optional)
  6351. * @param instanced whether the buffer is instanced (optional)
  6352. * @param offset the offset of the data (optional)
  6353. * @param size the number of components (optional)
  6354. * @param type the type of the component (optional)
  6355. * @param normalized whether the data contains normalized data (optional)
  6356. * @param useBytes set to true if stride and offset are in bytes (optional)
  6357. * @param divisor defines the instance divisor to use (1 by default)
  6358. */
  6359. 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, divisor?: number);
  6360. /** @hidden */
  6361. _rebuild(): void;
  6362. /**
  6363. * Returns the kind of the VertexBuffer (string)
  6364. * @returns a string
  6365. */
  6366. getKind(): string;
  6367. /**
  6368. * Gets a boolean indicating if the VertexBuffer is updatable?
  6369. * @returns true if the buffer is updatable
  6370. */
  6371. isUpdatable(): boolean;
  6372. /**
  6373. * Gets current buffer's data
  6374. * @returns a DataArray or null
  6375. */
  6376. getData(): Nullable<DataArray>;
  6377. /**
  6378. * Gets underlying native buffer
  6379. * @returns underlying native buffer
  6380. */
  6381. getBuffer(): Nullable<DataBuffer>;
  6382. /**
  6383. * Gets the stride in float32 units (i.e. byte stride / 4).
  6384. * May not be an integer if the byte stride is not divisible by 4.
  6385. * DEPRECATED. Use byteStride instead.
  6386. * @returns the stride in float32 units
  6387. */
  6388. getStrideSize(): number;
  6389. /**
  6390. * Returns the offset as a multiple of the type byte length.
  6391. * DEPRECATED. Use byteOffset instead.
  6392. * @returns the offset in bytes
  6393. */
  6394. getOffset(): number;
  6395. /**
  6396. * Returns the number of components per vertex attribute (integer)
  6397. * @returns the size in float
  6398. */
  6399. getSize(): number;
  6400. /**
  6401. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6402. * @returns true if this buffer is instanced
  6403. */
  6404. getIsInstanced(): boolean;
  6405. /**
  6406. * Returns the instancing divisor, zero for non-instanced (integer).
  6407. * @returns a number
  6408. */
  6409. getInstanceDivisor(): number;
  6410. /**
  6411. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6412. * @param data defines the data to store
  6413. */
  6414. create(data?: DataArray): void;
  6415. /**
  6416. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6417. * This function will create a new buffer if the current one is not updatable
  6418. * @param data defines the data to store
  6419. */
  6420. update(data: DataArray): void;
  6421. /**
  6422. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6423. * Returns the directly updated WebGLBuffer.
  6424. * @param data the new data
  6425. * @param offset the new offset
  6426. * @param useBytes set to true if the offset is in bytes
  6427. */
  6428. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6429. /**
  6430. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6431. */
  6432. dispose(): void;
  6433. /**
  6434. * Enumerates each value of this vertex buffer as numbers.
  6435. * @param count the number of values to enumerate
  6436. * @param callback the callback function called for each value
  6437. */
  6438. forEach(count: number, callback: (value: number, index: number) => void): void;
  6439. /**
  6440. * Positions
  6441. */
  6442. static readonly PositionKind: string;
  6443. /**
  6444. * Normals
  6445. */
  6446. static readonly NormalKind: string;
  6447. /**
  6448. * Tangents
  6449. */
  6450. static readonly TangentKind: string;
  6451. /**
  6452. * Texture coordinates
  6453. */
  6454. static readonly UVKind: string;
  6455. /**
  6456. * Texture coordinates 2
  6457. */
  6458. static readonly UV2Kind: string;
  6459. /**
  6460. * Texture coordinates 3
  6461. */
  6462. static readonly UV3Kind: string;
  6463. /**
  6464. * Texture coordinates 4
  6465. */
  6466. static readonly UV4Kind: string;
  6467. /**
  6468. * Texture coordinates 5
  6469. */
  6470. static readonly UV5Kind: string;
  6471. /**
  6472. * Texture coordinates 6
  6473. */
  6474. static readonly UV6Kind: string;
  6475. /**
  6476. * Colors
  6477. */
  6478. static readonly ColorKind: string;
  6479. /**
  6480. * Matrix indices (for bones)
  6481. */
  6482. static readonly MatricesIndicesKind: string;
  6483. /**
  6484. * Matrix weights (for bones)
  6485. */
  6486. static readonly MatricesWeightsKind: string;
  6487. /**
  6488. * Additional matrix indices (for bones)
  6489. */
  6490. static readonly MatricesIndicesExtraKind: string;
  6491. /**
  6492. * Additional matrix weights (for bones)
  6493. */
  6494. static readonly MatricesWeightsExtraKind: string;
  6495. /**
  6496. * Deduces the stride given a kind.
  6497. * @param kind The kind string to deduce
  6498. * @returns The deduced stride
  6499. */
  6500. static DeduceStride(kind: string): number;
  6501. /**
  6502. * Gets the byte length of the given type.
  6503. * @param type the type
  6504. * @returns the number of bytes
  6505. */
  6506. static GetTypeByteLength(type: number): number;
  6507. /**
  6508. * Enumerates each value of the given parameters as numbers.
  6509. * @param data the data to enumerate
  6510. * @param byteOffset the byte offset of the data
  6511. * @param byteStride the byte stride of the data
  6512. * @param componentCount the number of components per element
  6513. * @param componentType the type of the component
  6514. * @param count the number of values to enumerate
  6515. * @param normalized whether the data is normalized
  6516. * @param callback the callback function called for each value
  6517. */
  6518. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6519. private static _GetFloatValue;
  6520. }
  6521. }
  6522. declare module BABYLON {
  6523. /**
  6524. * @hidden
  6525. */
  6526. export class IntersectionInfo {
  6527. bu: Nullable<number>;
  6528. bv: Nullable<number>;
  6529. distance: number;
  6530. faceId: number;
  6531. subMeshId: number;
  6532. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6533. }
  6534. }
  6535. declare module BABYLON {
  6536. /**
  6537. * Represens a plane by the equation ax + by + cz + d = 0
  6538. */
  6539. export class Plane {
  6540. private static _TmpMatrix;
  6541. /**
  6542. * Normal of the plane (a,b,c)
  6543. */
  6544. normal: Vector3;
  6545. /**
  6546. * d component of the plane
  6547. */
  6548. d: number;
  6549. /**
  6550. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6551. * @param a a component of the plane
  6552. * @param b b component of the plane
  6553. * @param c c component of the plane
  6554. * @param d d component of the plane
  6555. */
  6556. constructor(a: number, b: number, c: number, d: number);
  6557. /**
  6558. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6559. */
  6560. asArray(): number[];
  6561. /**
  6562. * @returns a new plane copied from the current Plane.
  6563. */
  6564. clone(): Plane;
  6565. /**
  6566. * @returns the string "Plane".
  6567. */
  6568. getClassName(): string;
  6569. /**
  6570. * @returns the Plane hash code.
  6571. */
  6572. getHashCode(): number;
  6573. /**
  6574. * Normalize the current Plane in place.
  6575. * @returns the updated Plane.
  6576. */
  6577. normalize(): Plane;
  6578. /**
  6579. * Applies a transformation the plane and returns the result
  6580. * @param transformation the transformation matrix to be applied to the plane
  6581. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6582. */
  6583. transform(transformation: DeepImmutable<Matrix>): Plane;
  6584. /**
  6585. * Calcualtte the dot product between the point and the plane normal
  6586. * @param point point to calculate the dot product with
  6587. * @returns the dot product (float) of the point coordinates and the plane normal.
  6588. */
  6589. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6590. /**
  6591. * Updates the current Plane from the plane defined by the three given points.
  6592. * @param point1 one of the points used to contruct the plane
  6593. * @param point2 one of the points used to contruct the plane
  6594. * @param point3 one of the points used to contruct the plane
  6595. * @returns the updated Plane.
  6596. */
  6597. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6598. /**
  6599. * Checks if the plane is facing a given direction
  6600. * @param direction the direction to check if the plane is facing
  6601. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6602. * @returns True is the vector "direction" is the same side than the plane normal.
  6603. */
  6604. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6605. /**
  6606. * Calculates the distance to a point
  6607. * @param point point to calculate distance to
  6608. * @returns the signed distance (float) from the given point to the Plane.
  6609. */
  6610. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6611. /**
  6612. * Creates a plane from an array
  6613. * @param array the array to create a plane from
  6614. * @returns a new Plane from the given array.
  6615. */
  6616. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6617. /**
  6618. * Creates a plane from three points
  6619. * @param point1 point used to create the plane
  6620. * @param point2 point used to create the plane
  6621. * @param point3 point used to create the plane
  6622. * @returns a new Plane defined by the three given points.
  6623. */
  6624. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6625. /**
  6626. * Creates a plane from an origin point and a normal
  6627. * @param origin origin of the plane to be constructed
  6628. * @param normal normal of the plane to be constructed
  6629. * @returns a new Plane the normal vector to this plane at the given origin point.
  6630. * Note : the vector "normal" is updated because normalized.
  6631. */
  6632. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6633. /**
  6634. * Calculates the distance from a plane and a point
  6635. * @param origin origin of the plane to be constructed
  6636. * @param normal normal of the plane to be constructed
  6637. * @param point point to calculate distance to
  6638. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6639. */
  6640. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Class used to store bounding sphere information
  6646. */
  6647. export class BoundingSphere {
  6648. /**
  6649. * Gets the center of the bounding sphere in local space
  6650. */
  6651. readonly center: Vector3;
  6652. /**
  6653. * Radius of the bounding sphere in local space
  6654. */
  6655. radius: number;
  6656. /**
  6657. * Gets the center of the bounding sphere in world space
  6658. */
  6659. readonly centerWorld: Vector3;
  6660. /**
  6661. * Radius of the bounding sphere in world space
  6662. */
  6663. radiusWorld: number;
  6664. /**
  6665. * Gets the minimum vector in local space
  6666. */
  6667. readonly minimum: Vector3;
  6668. /**
  6669. * Gets the maximum vector in local space
  6670. */
  6671. readonly maximum: Vector3;
  6672. private _worldMatrix;
  6673. private static readonly TmpVector3;
  6674. /**
  6675. * Creates a new bounding sphere
  6676. * @param min defines the minimum vector (in local space)
  6677. * @param max defines the maximum vector (in local space)
  6678. * @param worldMatrix defines the new world matrix
  6679. */
  6680. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6681. /**
  6682. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6683. * @param min defines the new minimum vector (in local space)
  6684. * @param max defines the new maximum vector (in local space)
  6685. * @param worldMatrix defines the new world matrix
  6686. */
  6687. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6688. /**
  6689. * Scale the current bounding sphere by applying a scale factor
  6690. * @param factor defines the scale factor to apply
  6691. * @returns the current bounding box
  6692. */
  6693. scale(factor: number): BoundingSphere;
  6694. /**
  6695. * Gets the world matrix of the bounding box
  6696. * @returns a matrix
  6697. */
  6698. getWorldMatrix(): DeepImmutable<Matrix>;
  6699. /** @hidden */
  6700. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6701. /**
  6702. * Tests if the bounding sphere is intersecting the frustum planes
  6703. * @param frustumPlanes defines the frustum planes to test
  6704. * @returns true if there is an intersection
  6705. */
  6706. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6707. /**
  6708. * Tests if the bounding sphere center is in between the frustum planes.
  6709. * Used for optimistic fast inclusion.
  6710. * @param frustumPlanes defines the frustum planes to test
  6711. * @returns true if the sphere center is in between the frustum planes
  6712. */
  6713. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6714. /**
  6715. * Tests if a point is inside the bounding sphere
  6716. * @param point defines the point to test
  6717. * @returns true if the point is inside the bounding sphere
  6718. */
  6719. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6720. /**
  6721. * Checks if two sphere intersct
  6722. * @param sphere0 sphere 0
  6723. * @param sphere1 sphere 1
  6724. * @returns true if the speres intersect
  6725. */
  6726. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Class used to store bounding box information
  6732. */
  6733. export class BoundingBox implements ICullable {
  6734. /**
  6735. * Gets the 8 vectors representing the bounding box in local space
  6736. */
  6737. readonly vectors: Vector3[];
  6738. /**
  6739. * Gets the center of the bounding box in local space
  6740. */
  6741. readonly center: Vector3;
  6742. /**
  6743. * Gets the center of the bounding box in world space
  6744. */
  6745. readonly centerWorld: Vector3;
  6746. /**
  6747. * Gets the extend size in local space
  6748. */
  6749. readonly extendSize: Vector3;
  6750. /**
  6751. * Gets the extend size in world space
  6752. */
  6753. readonly extendSizeWorld: Vector3;
  6754. /**
  6755. * Gets the OBB (object bounding box) directions
  6756. */
  6757. readonly directions: Vector3[];
  6758. /**
  6759. * Gets the 8 vectors representing the bounding box in world space
  6760. */
  6761. readonly vectorsWorld: Vector3[];
  6762. /**
  6763. * Gets the minimum vector in world space
  6764. */
  6765. readonly minimumWorld: Vector3;
  6766. /**
  6767. * Gets the maximum vector in world space
  6768. */
  6769. readonly maximumWorld: Vector3;
  6770. /**
  6771. * Gets the minimum vector in local space
  6772. */
  6773. readonly minimum: Vector3;
  6774. /**
  6775. * Gets the maximum vector in local space
  6776. */
  6777. readonly maximum: Vector3;
  6778. private _worldMatrix;
  6779. private static readonly TmpVector3;
  6780. /**
  6781. * @hidden
  6782. */
  6783. _tag: number;
  6784. /**
  6785. * Creates a new bounding box
  6786. * @param min defines the minimum vector (in local space)
  6787. * @param max defines the maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6791. /**
  6792. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6793. * @param min defines the new minimum vector (in local space)
  6794. * @param max defines the new maximum vector (in local space)
  6795. * @param worldMatrix defines the new world matrix
  6796. */
  6797. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6798. /**
  6799. * Scale the current bounding box by applying a scale factor
  6800. * @param factor defines the scale factor to apply
  6801. * @returns the current bounding box
  6802. */
  6803. scale(factor: number): BoundingBox;
  6804. /**
  6805. * Gets the world matrix of the bounding box
  6806. * @returns a matrix
  6807. */
  6808. getWorldMatrix(): DeepImmutable<Matrix>;
  6809. /** @hidden */
  6810. _update(world: DeepImmutable<Matrix>): void;
  6811. /**
  6812. * Tests if the bounding box is intersecting the frustum planes
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if there is an intersection
  6815. */
  6816. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if the bounding box is entirely inside the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an inclusion
  6821. */
  6822. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if a point is inside the bounding box
  6825. * @param point defines the point to test
  6826. * @returns true if the point is inside the bounding box
  6827. */
  6828. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6829. /**
  6830. * Tests if the bounding box intersects with a bounding sphere
  6831. * @param sphere defines the sphere to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6835. /**
  6836. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6837. * @param min defines the min vector to use
  6838. * @param max defines the max vector to use
  6839. * @returns true if there is an intersection
  6840. */
  6841. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6842. /**
  6843. * Tests if two bounding boxes are intersections
  6844. * @param box0 defines the first box to test
  6845. * @param box1 defines the second box to test
  6846. * @returns true if there is an intersection
  6847. */
  6848. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6849. /**
  6850. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6851. * @param minPoint defines the minimum vector of the bounding box
  6852. * @param maxPoint defines the maximum vector of the bounding box
  6853. * @param sphereCenter defines the sphere center
  6854. * @param sphereRadius defines the sphere radius
  6855. * @returns true if there is an intersection
  6856. */
  6857. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6858. /**
  6859. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6860. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @return true if there is an inclusion
  6863. */
  6864. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6867. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @return true if there is an intersection
  6870. */
  6871. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /** @hidden */
  6876. export class Collider {
  6877. /** Define if a collision was found */
  6878. collisionFound: boolean;
  6879. /**
  6880. * Define last intersection point in local space
  6881. */
  6882. intersectionPoint: Vector3;
  6883. /**
  6884. * Define last collided mesh
  6885. */
  6886. collidedMesh: Nullable<AbstractMesh>;
  6887. private _collisionPoint;
  6888. private _planeIntersectionPoint;
  6889. private _tempVector;
  6890. private _tempVector2;
  6891. private _tempVector3;
  6892. private _tempVector4;
  6893. private _edge;
  6894. private _baseToVertex;
  6895. private _destinationPoint;
  6896. private _slidePlaneNormal;
  6897. private _displacementVector;
  6898. /** @hidden */
  6899. _radius: Vector3;
  6900. /** @hidden */
  6901. _retry: number;
  6902. private _velocity;
  6903. private _basePoint;
  6904. private _epsilon;
  6905. /** @hidden */
  6906. _velocityWorldLength: number;
  6907. /** @hidden */
  6908. _basePointWorld: Vector3;
  6909. private _velocityWorld;
  6910. private _normalizedVelocity;
  6911. /** @hidden */
  6912. _initialVelocity: Vector3;
  6913. /** @hidden */
  6914. _initialPosition: Vector3;
  6915. private _nearestDistance;
  6916. private _collisionMask;
  6917. collisionMask: number;
  6918. /**
  6919. * Gets the plane normal used to compute the sliding response (in local space)
  6920. */
  6921. readonly slidePlaneNormal: Vector3;
  6922. /** @hidden */
  6923. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6924. /** @hidden */
  6925. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6926. /** @hidden */
  6927. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6928. /** @hidden */
  6929. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6930. /** @hidden */
  6931. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6932. /** @hidden */
  6933. _getResponse(pos: Vector3, vel: Vector3): void;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Interface for cullable objects
  6939. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6940. */
  6941. export interface ICullable {
  6942. /**
  6943. * Checks if the object or part of the object is in the frustum
  6944. * @param frustumPlanes Camera near/planes
  6945. * @returns true if the object is in frustum otherwise false
  6946. */
  6947. isInFrustum(frustumPlanes: Plane[]): boolean;
  6948. /**
  6949. * Checks if a cullable object (mesh...) is in the camera frustum
  6950. * Unlike isInFrustum this cheks the full bounding box
  6951. * @param frustumPlanes Camera near/planes
  6952. * @returns true if the object is in frustum otherwise false
  6953. */
  6954. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6955. }
  6956. /**
  6957. * Info for a bounding data of a mesh
  6958. */
  6959. export class BoundingInfo implements ICullable {
  6960. /**
  6961. * Bounding box for the mesh
  6962. */
  6963. readonly boundingBox: BoundingBox;
  6964. /**
  6965. * Bounding sphere for the mesh
  6966. */
  6967. readonly boundingSphere: BoundingSphere;
  6968. private _isLocked;
  6969. private static readonly TmpVector3;
  6970. /**
  6971. * Constructs bounding info
  6972. * @param minimum min vector of the bounding box/sphere
  6973. * @param maximum max vector of the bounding box/sphere
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * min vector of the bounding box/sphere
  6986. */
  6987. readonly minimum: Vector3;
  6988. /**
  6989. * max vector of the bounding box/sphere
  6990. */
  6991. readonly maximum: Vector3;
  6992. /**
  6993. * If the info is locked and won't be updated to avoid perf overhead
  6994. */
  6995. isLocked: boolean;
  6996. /**
  6997. * Updates the bounding sphere and box
  6998. * @param world world matrix to be used to update
  6999. */
  7000. update(world: DeepImmutable<Matrix>): void;
  7001. /**
  7002. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7003. * @param center New center of the bounding info
  7004. * @param extend New extend of the bounding info
  7005. * @returns the current bounding info
  7006. */
  7007. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7008. /**
  7009. * Scale the current bounding info by applying a scale factor
  7010. * @param factor defines the scale factor to apply
  7011. * @returns the current bounding info
  7012. */
  7013. scale(factor: number): BoundingInfo;
  7014. /**
  7015. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7016. * @param frustumPlanes defines the frustum to test
  7017. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7018. * @returns true if the bounding info is in the frustum planes
  7019. */
  7020. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7021. /**
  7022. * Gets the world distance between the min and max points of the bounding box
  7023. */
  7024. readonly diagonalLength: number;
  7025. /**
  7026. * Checks if a cullable object (mesh...) is in the camera frustum
  7027. * Unlike isInFrustum this cheks the full bounding box
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7032. /** @hidden */
  7033. _checkCollision(collider: Collider): boolean;
  7034. /**
  7035. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7036. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7037. * @param point the point to check intersection with
  7038. * @returns if the point intersects
  7039. */
  7040. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7041. /**
  7042. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7043. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7044. * @param boundingInfo the bounding info to check intersection with
  7045. * @param precise if the intersection should be done using OBB
  7046. * @returns if the bounding info intersects
  7047. */
  7048. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7049. }
  7050. }
  7051. declare module BABYLON {
  7052. /**
  7053. * Extracts minimum and maximum values from a list of indexed positions
  7054. * @param positions defines the positions to use
  7055. * @param indices defines the indices to the positions
  7056. * @param indexStart defines the start index
  7057. * @param indexCount defines the end index
  7058. * @param bias defines bias value to add to the result
  7059. * @return minimum and maximum values
  7060. */
  7061. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7062. minimum: Vector3;
  7063. maximum: Vector3;
  7064. };
  7065. /**
  7066. * Extracts minimum and maximum values from a list of positions
  7067. * @param positions defines the positions to use
  7068. * @param start defines the start index in the positions array
  7069. * @param count defines the number of positions to handle
  7070. * @param bias defines bias value to add to the result
  7071. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7072. * @return minimum and maximum values
  7073. */
  7074. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7075. minimum: Vector3;
  7076. maximum: Vector3;
  7077. };
  7078. }
  7079. declare module BABYLON {
  7080. /** @hidden */
  7081. export class WebGLDataBuffer extends DataBuffer {
  7082. private _buffer;
  7083. constructor(resource: WebGLBuffer);
  7084. readonly underlyingResource: any;
  7085. }
  7086. }
  7087. declare module BABYLON {
  7088. /** @hidden */
  7089. export class WebGLPipelineContext implements IPipelineContext {
  7090. engine: ThinEngine;
  7091. program: Nullable<WebGLProgram>;
  7092. context?: WebGLRenderingContext;
  7093. vertexShader?: WebGLShader;
  7094. fragmentShader?: WebGLShader;
  7095. isParallelCompiled: boolean;
  7096. onCompiled?: () => void;
  7097. transformFeedback?: WebGLTransformFeedback | null;
  7098. readonly isAsync: boolean;
  7099. readonly isReady: boolean;
  7100. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7101. }
  7102. }
  7103. declare module BABYLON {
  7104. interface ThinEngine {
  7105. /**
  7106. * Create an uniform buffer
  7107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7108. * @param elements defines the content of the uniform buffer
  7109. * @returns the webGL uniform buffer
  7110. */
  7111. createUniformBuffer(elements: FloatArray): DataBuffer;
  7112. /**
  7113. * Create a dynamic uniform buffer
  7114. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7115. * @param elements defines the content of the uniform buffer
  7116. * @returns the webGL uniform buffer
  7117. */
  7118. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7119. /**
  7120. * Update an existing uniform buffer
  7121. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7122. * @param uniformBuffer defines the target uniform buffer
  7123. * @param elements defines the content to update
  7124. * @param offset defines the offset in the uniform buffer where update should start
  7125. * @param count defines the size of the data to update
  7126. */
  7127. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7128. /**
  7129. * Bind an uniform buffer to the current webGL context
  7130. * @param buffer defines the buffer to bind
  7131. */
  7132. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7133. /**
  7134. * Bind a buffer to the current webGL context at a given location
  7135. * @param buffer defines the buffer to bind
  7136. * @param location defines the index where to bind the buffer
  7137. */
  7138. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7139. /**
  7140. * Bind a specific block at a given index in a specific shader program
  7141. * @param pipelineContext defines the pipeline context to use
  7142. * @param blockName defines the block name
  7143. * @param index defines the index where to bind the block
  7144. */
  7145. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Uniform buffer objects.
  7151. *
  7152. * Handles blocks of uniform on the GPU.
  7153. *
  7154. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7155. *
  7156. * For more information, please refer to :
  7157. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7158. */
  7159. export class UniformBuffer {
  7160. private _engine;
  7161. private _buffer;
  7162. private _data;
  7163. private _bufferData;
  7164. private _dynamic?;
  7165. private _uniformLocations;
  7166. private _uniformSizes;
  7167. private _uniformLocationPointer;
  7168. private _needSync;
  7169. private _noUBO;
  7170. private _currentEffect;
  7171. /** @hidden */
  7172. _alreadyBound: boolean;
  7173. private static _MAX_UNIFORM_SIZE;
  7174. private static _tempBuffer;
  7175. /**
  7176. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7177. * This is dynamic to allow compat with webgl 1 and 2.
  7178. * You will need to pass the name of the uniform as well as the value.
  7179. */
  7180. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7181. /**
  7182. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a single float in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateFloat: (name: string, x: number) => void;
  7193. /**
  7194. * Lambda to Update a vec2 of float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7199. /**
  7200. * Lambda to Update a vec3 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec4 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateMatrix: (name: string, mat: Matrix) => void;
  7217. /**
  7218. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateVector3: (name: string, vector: Vector3) => void;
  7223. /**
  7224. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector4: (name: string, vector: Vector4) => void;
  7229. /**
  7230. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7235. /**
  7236. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7241. /**
  7242. * Instantiates a new Uniform buffer objects.
  7243. *
  7244. * Handles blocks of uniform on the GPU.
  7245. *
  7246. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7247. *
  7248. * For more information, please refer to :
  7249. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7250. * @param engine Define the engine the buffer is associated with
  7251. * @param data Define the data contained in the buffer
  7252. * @param dynamic Define if the buffer is updatable
  7253. */
  7254. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7255. /**
  7256. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7257. * or just falling back on setUniformXXX calls.
  7258. */
  7259. readonly useUbo: boolean;
  7260. /**
  7261. * Indicates if the WebGL underlying uniform buffer is in sync
  7262. * with the javascript cache data.
  7263. */
  7264. readonly isSync: boolean;
  7265. /**
  7266. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7267. * Also, a dynamic UniformBuffer will disable cache verification and always
  7268. * update the underlying WebGL uniform buffer to the GPU.
  7269. * @returns if Dynamic, otherwise false
  7270. */
  7271. isDynamic(): boolean;
  7272. /**
  7273. * The data cache on JS side.
  7274. * @returns the underlying data as a float array
  7275. */
  7276. getData(): Float32Array;
  7277. /**
  7278. * The underlying WebGL Uniform buffer.
  7279. * @returns the webgl buffer
  7280. */
  7281. getBuffer(): Nullable<DataBuffer>;
  7282. /**
  7283. * std140 layout specifies how to align data within an UBO structure.
  7284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7285. * for specs.
  7286. */
  7287. private _fillAlignment;
  7288. /**
  7289. * Adds an uniform in the buffer.
  7290. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7291. * for the layout to be correct !
  7292. * @param name Name of the uniform, as used in the uniform block in the shader.
  7293. * @param size Data size, or data directly.
  7294. */
  7295. addUniform(name: string, size: number | number[]): void;
  7296. /**
  7297. * Adds a Matrix 4x4 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param mat A 4x4 matrix.
  7300. */
  7301. addMatrix(name: string, mat: Matrix): void;
  7302. /**
  7303. * Adds a vec2 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param x Define the x component value of the vec2
  7306. * @param y Define the y component value of the vec2
  7307. */
  7308. addFloat2(name: string, x: number, y: number): void;
  7309. /**
  7310. * Adds a vec3 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param x Define the x component value of the vec3
  7313. * @param y Define the y component value of the vec3
  7314. * @param z Define the z component value of the vec3
  7315. */
  7316. addFloat3(name: string, x: number, y: number, z: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param color Define the vec3 from a Color
  7321. */
  7322. addColor3(name: string, color: Color3): void;
  7323. /**
  7324. * Adds a vec4 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the rgb components from a Color
  7327. * @param alpha Define the a component of the vec4
  7328. */
  7329. addColor4(name: string, color: Color3, alpha: number): void;
  7330. /**
  7331. * Adds a vec3 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param vector Define the vec3 components from a Vector
  7334. */
  7335. addVector3(name: string, vector: Vector3): void;
  7336. /**
  7337. * Adds a Matrix 3x3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. */
  7340. addMatrix3x3(name: string): void;
  7341. /**
  7342. * Adds a Matrix 2x2 to the uniform buffer.
  7343. * @param name Name of the uniform, as used in the uniform block in the shader.
  7344. */
  7345. addMatrix2x2(name: string): void;
  7346. /**
  7347. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7348. */
  7349. create(): void;
  7350. /** @hidden */
  7351. _rebuild(): void;
  7352. /**
  7353. * Updates the WebGL Uniform Buffer on the GPU.
  7354. * If the `dynamic` flag is set to true, no cache comparison is done.
  7355. * Otherwise, the buffer will be updated only if the cache differs.
  7356. */
  7357. update(): void;
  7358. /**
  7359. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7360. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7361. * @param data Define the flattened data
  7362. * @param size Define the size of the data.
  7363. */
  7364. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7365. private _valueCache;
  7366. private _cacheMatrix;
  7367. private _updateMatrix3x3ForUniform;
  7368. private _updateMatrix3x3ForEffect;
  7369. private _updateMatrix2x2ForEffect;
  7370. private _updateMatrix2x2ForUniform;
  7371. private _updateFloatForEffect;
  7372. private _updateFloatForUniform;
  7373. private _updateFloat2ForEffect;
  7374. private _updateFloat2ForUniform;
  7375. private _updateFloat3ForEffect;
  7376. private _updateFloat3ForUniform;
  7377. private _updateFloat4ForEffect;
  7378. private _updateFloat4ForUniform;
  7379. private _updateMatrixForEffect;
  7380. private _updateMatrixForUniform;
  7381. private _updateVector3ForEffect;
  7382. private _updateVector3ForUniform;
  7383. private _updateVector4ForEffect;
  7384. private _updateVector4ForUniform;
  7385. private _updateColor3ForEffect;
  7386. private _updateColor3ForUniform;
  7387. private _updateColor4ForEffect;
  7388. private _updateColor4ForUniform;
  7389. /**
  7390. * Sets a sampler uniform on the effect.
  7391. * @param name Define the name of the sampler.
  7392. * @param texture Define the texture to set in the sampler
  7393. */
  7394. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7395. /**
  7396. * Directly updates the value of the uniform in the cache AND on the GPU.
  7397. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7398. * @param data Define the flattened data
  7399. */
  7400. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7401. /**
  7402. * Binds this uniform buffer to an effect.
  7403. * @param effect Define the effect to bind the buffer to
  7404. * @param name Name of the uniform block in the shader.
  7405. */
  7406. bindToEffect(effect: Effect, name: string): void;
  7407. /**
  7408. * Disposes the uniform buffer.
  7409. */
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Enum that determines the text-wrapping mode to use.
  7416. */
  7417. export enum InspectableType {
  7418. /**
  7419. * Checkbox for booleans
  7420. */
  7421. Checkbox = 0,
  7422. /**
  7423. * Sliders for numbers
  7424. */
  7425. Slider = 1,
  7426. /**
  7427. * Vector3
  7428. */
  7429. Vector3 = 2,
  7430. /**
  7431. * Quaternions
  7432. */
  7433. Quaternion = 3,
  7434. /**
  7435. * Color3
  7436. */
  7437. Color3 = 4,
  7438. /**
  7439. * String
  7440. */
  7441. String = 5
  7442. }
  7443. /**
  7444. * Interface used to define custom inspectable properties.
  7445. * This interface is used by the inspector to display custom property grids
  7446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7447. */
  7448. export interface IInspectable {
  7449. /**
  7450. * Gets the label to display
  7451. */
  7452. label: string;
  7453. /**
  7454. * Gets the name of the property to edit
  7455. */
  7456. propertyName: string;
  7457. /**
  7458. * Gets the type of the editor to use
  7459. */
  7460. type: InspectableType;
  7461. /**
  7462. * Gets the minimum value of the property when using in "slider" mode
  7463. */
  7464. min?: number;
  7465. /**
  7466. * Gets the maximum value of the property when using in "slider" mode
  7467. */
  7468. max?: number;
  7469. /**
  7470. * Gets the setp to use when using in "slider" mode
  7471. */
  7472. step?: number;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class used to provide helper for timing
  7478. */
  7479. export class TimingTools {
  7480. /**
  7481. * Polyfill for setImmediate
  7482. * @param action defines the action to execute after the current execution block
  7483. */
  7484. static SetImmediate(action: () => void): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Class used to enable instatition of objects by class name
  7490. */
  7491. export class InstantiationTools {
  7492. /**
  7493. * Use this object to register external classes like custom textures or material
  7494. * to allow the laoders to instantiate them
  7495. */
  7496. static RegisteredExternalClasses: {
  7497. [key: string]: Object;
  7498. };
  7499. /**
  7500. * Tries to instantiate a new object from a given class name
  7501. * @param className defines the class name to instantiate
  7502. * @returns the new object or null if the system was not able to do the instantiation
  7503. */
  7504. static Instantiate(className: string): any;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Define options used to create a depth texture
  7510. */
  7511. export class DepthTextureCreationOptions {
  7512. /** Specifies whether or not a stencil should be allocated in the texture */
  7513. generateStencil?: boolean;
  7514. /** Specifies whether or not bilinear filtering is enable on the texture */
  7515. bilinearFiltering?: boolean;
  7516. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7517. comparisonFunction?: number;
  7518. /** Specifies if the created texture is a cube texture */
  7519. isCube?: boolean;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. interface ThinEngine {
  7524. /**
  7525. * Creates a depth stencil cube texture.
  7526. * This is only available in WebGL 2.
  7527. * @param size The size of face edge in the cube texture.
  7528. * @param options The options defining the cube texture.
  7529. * @returns The cube texture
  7530. */
  7531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7532. /**
  7533. * Creates a cube texture
  7534. * @param rootUrl defines the url where the files to load is located
  7535. * @param scene defines the current scene
  7536. * @param files defines the list of files to load (1 per face)
  7537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7538. * @param onLoad defines an optional callback raised when the texture is loaded
  7539. * @param onError defines an optional callback raised if there is an issue to load the texture
  7540. * @param format defines the format of the data
  7541. * @param forcedExtension defines the extension to use to pick the right loader
  7542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7547. * @returns the cube texture as an InternalTexture
  7548. */
  7549. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7550. /**
  7551. * Creates a cube texture
  7552. * @param rootUrl defines the url where the files to load is located
  7553. * @param scene defines the current scene
  7554. * @param files defines the list of files to load (1 per face)
  7555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7556. * @param onLoad defines an optional callback raised when the texture is loaded
  7557. * @param onError defines an optional callback raised if there is an issue to load the texture
  7558. * @param format defines the format of the data
  7559. * @param forcedExtension defines the extension to use to pick the right loader
  7560. * @returns the cube texture as an InternalTexture
  7561. */
  7562. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7563. /**
  7564. * Creates a cube texture
  7565. * @param rootUrl defines the url where the files to load is located
  7566. * @param scene defines the current scene
  7567. * @param files defines the list of files to load (1 per face)
  7568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7569. * @param onLoad defines an optional callback raised when the texture is loaded
  7570. * @param onError defines an optional callback raised if there is an issue to load the texture
  7571. * @param format defines the format of the data
  7572. * @param forcedExtension defines the extension to use to pick the right loader
  7573. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7574. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7575. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7579. /** @hidden */
  7580. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7581. /** @hidden */
  7582. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /** @hidden */
  7584. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7585. /** @hidden */
  7586. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7587. /**
  7588. * @hidden
  7589. */
  7590. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7591. }
  7592. }
  7593. declare module BABYLON {
  7594. /**
  7595. * Class for creating a cube texture
  7596. */
  7597. export class CubeTexture extends BaseTexture {
  7598. private _delayedOnLoad;
  7599. /**
  7600. * The url of the texture
  7601. */
  7602. url: string;
  7603. /**
  7604. * Gets or sets the center of the bounding box associated with the cube texture.
  7605. * It must define where the camera used to render the texture was set
  7606. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7607. */
  7608. boundingBoxPosition: Vector3;
  7609. private _boundingBoxSize;
  7610. /**
  7611. * Gets or sets the size of the bounding box associated with the cube texture
  7612. * When defined, the cubemap will switch to local mode
  7613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7614. * @example https://www.babylonjs-playground.com/#RNASML
  7615. */
  7616. /**
  7617. * Returns the bounding box size
  7618. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7619. */
  7620. boundingBoxSize: Vector3;
  7621. protected _rotationY: number;
  7622. /**
  7623. * Sets texture matrix rotation angle around Y axis in radians.
  7624. */
  7625. /**
  7626. * Gets texture matrix rotation angle around Y axis radians.
  7627. */
  7628. rotationY: number;
  7629. /**
  7630. * Are mip maps generated for this texture or not.
  7631. */
  7632. readonly noMipmap: boolean;
  7633. private _noMipmap;
  7634. private _files;
  7635. protected _forcedExtension: Nullable<string>;
  7636. private _extensions;
  7637. private _textureMatrix;
  7638. private _format;
  7639. private _createPolynomials;
  7640. /** @hidden */
  7641. _prefiltered: boolean;
  7642. /**
  7643. * Creates a cube texture from an array of image urls
  7644. * @param files defines an array of image urls
  7645. * @param scene defines the hosting scene
  7646. * @param noMipmap specifies if mip maps are not used
  7647. * @returns a cube texture
  7648. */
  7649. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7650. /**
  7651. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7652. * @param url defines the url of the prefiltered texture
  7653. * @param scene defines the scene the texture is attached to
  7654. * @param forcedExtension defines the extension of the file if different from the url
  7655. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7656. * @return the prefiltered texture
  7657. */
  7658. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7659. /**
  7660. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7661. * as prefiltered data.
  7662. * @param rootUrl defines the url of the texture or the root name of the six images
  7663. * @param scene defines the scene the texture is attached to
  7664. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7665. * @param noMipmap defines if mipmaps should be created or not
  7666. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7667. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7668. * @param onError defines a callback triggered in case of error during load
  7669. * @param format defines the internal format to use for the texture once loaded
  7670. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7671. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7672. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7673. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7674. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7675. * @return the cube texture
  7676. */
  7677. 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);
  7678. /**
  7679. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7680. */
  7681. readonly isPrefiltered: boolean;
  7682. /**
  7683. * Get the current class name of the texture useful for serialization or dynamic coding.
  7684. * @returns "CubeTexture"
  7685. */
  7686. getClassName(): string;
  7687. /**
  7688. * Update the url (and optional buffer) of this texture if url was null during construction.
  7689. * @param url the url of the texture
  7690. * @param forcedExtension defines the extension to use
  7691. * @param onLoad callback called when the texture is loaded (defaults to null)
  7692. */
  7693. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7694. /**
  7695. * Delays loading of the cube texture
  7696. * @param forcedExtension defines the extension to use
  7697. */
  7698. delayLoad(forcedExtension?: string): void;
  7699. /**
  7700. * Returns the reflection texture matrix
  7701. * @returns the reflection texture matrix
  7702. */
  7703. getReflectionTextureMatrix(): Matrix;
  7704. /**
  7705. * Sets the reflection texture matrix
  7706. * @param value Reflection texture matrix
  7707. */
  7708. setReflectionTextureMatrix(value: Matrix): void;
  7709. /**
  7710. * Parses text to create a cube texture
  7711. * @param parsedTexture define the serialized text to read from
  7712. * @param scene defines the hosting scene
  7713. * @param rootUrl defines the root url of the cube texture
  7714. * @returns a cube texture
  7715. */
  7716. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7717. /**
  7718. * Makes a clone, or deep copy, of the cube texture
  7719. * @returns a new cube texture
  7720. */
  7721. clone(): CubeTexture;
  7722. }
  7723. }
  7724. declare module BABYLON {
  7725. /**
  7726. * Manages the defines for the Material
  7727. */
  7728. export class MaterialDefines {
  7729. /** @hidden */
  7730. protected _keys: string[];
  7731. private _isDirty;
  7732. /** @hidden */
  7733. _renderId: number;
  7734. /** @hidden */
  7735. _areLightsDirty: boolean;
  7736. /** @hidden */
  7737. _areLightsDisposed: boolean;
  7738. /** @hidden */
  7739. _areAttributesDirty: boolean;
  7740. /** @hidden */
  7741. _areTexturesDirty: boolean;
  7742. /** @hidden */
  7743. _areFresnelDirty: boolean;
  7744. /** @hidden */
  7745. _areMiscDirty: boolean;
  7746. /** @hidden */
  7747. _areImageProcessingDirty: boolean;
  7748. /** @hidden */
  7749. _normals: boolean;
  7750. /** @hidden */
  7751. _uvs: boolean;
  7752. /** @hidden */
  7753. _needNormals: boolean;
  7754. /** @hidden */
  7755. _needUVs: boolean;
  7756. [id: string]: any;
  7757. /**
  7758. * Specifies if the material needs to be re-calculated
  7759. */
  7760. readonly isDirty: boolean;
  7761. /**
  7762. * Marks the material to indicate that it has been re-calculated
  7763. */
  7764. markAsProcessed(): void;
  7765. /**
  7766. * Marks the material to indicate that it needs to be re-calculated
  7767. */
  7768. markAsUnprocessed(): void;
  7769. /**
  7770. * Marks the material to indicate all of its defines need to be re-calculated
  7771. */
  7772. markAllAsDirty(): void;
  7773. /**
  7774. * Marks the material to indicate that image processing needs to be re-calculated
  7775. */
  7776. markAsImageProcessingDirty(): void;
  7777. /**
  7778. * Marks the material to indicate the lights need to be re-calculated
  7779. * @param disposed Defines whether the light is dirty due to dispose or not
  7780. */
  7781. markAsLightDirty(disposed?: boolean): void;
  7782. /**
  7783. * Marks the attribute state as changed
  7784. */
  7785. markAsAttributesDirty(): void;
  7786. /**
  7787. * Marks the texture state as changed
  7788. */
  7789. markAsTexturesDirty(): void;
  7790. /**
  7791. * Marks the fresnel state as changed
  7792. */
  7793. markAsFresnelDirty(): void;
  7794. /**
  7795. * Marks the misc state as changed
  7796. */
  7797. markAsMiscDirty(): void;
  7798. /**
  7799. * Rebuilds the material defines
  7800. */
  7801. rebuild(): void;
  7802. /**
  7803. * Specifies if two material defines are equal
  7804. * @param other - A material define instance to compare to
  7805. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7806. */
  7807. isEqual(other: MaterialDefines): boolean;
  7808. /**
  7809. * Clones this instance's defines to another instance
  7810. * @param other - material defines to clone values to
  7811. */
  7812. cloneTo(other: MaterialDefines): void;
  7813. /**
  7814. * Resets the material define values
  7815. */
  7816. reset(): void;
  7817. /**
  7818. * Converts the material define values to a string
  7819. * @returns - String of material define information
  7820. */
  7821. toString(): string;
  7822. }
  7823. }
  7824. declare module BABYLON {
  7825. /**
  7826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7828. * 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;
  7829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7830. */
  7831. export class ColorCurves {
  7832. private _dirty;
  7833. private _tempColor;
  7834. private _globalCurve;
  7835. private _highlightsCurve;
  7836. private _midtonesCurve;
  7837. private _shadowsCurve;
  7838. private _positiveCurve;
  7839. private _negativeCurve;
  7840. private _globalHue;
  7841. private _globalDensity;
  7842. private _globalSaturation;
  7843. private _globalExposure;
  7844. /**
  7845. * Gets the global Hue value.
  7846. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7847. */
  7848. /**
  7849. * Sets the global Hue value.
  7850. * 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).
  7851. */
  7852. globalHue: number;
  7853. /**
  7854. * Gets the global Density value.
  7855. * 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.
  7856. * Values less than zero provide a filter of opposite hue.
  7857. */
  7858. /**
  7859. * Sets the global Density value.
  7860. * 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.
  7861. * Values less than zero provide a filter of opposite hue.
  7862. */
  7863. globalDensity: number;
  7864. /**
  7865. * Gets the global Saturation value.
  7866. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7867. */
  7868. /**
  7869. * Sets the global Saturation value.
  7870. * 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.
  7871. */
  7872. globalSaturation: number;
  7873. /**
  7874. * Gets the global Exposure value.
  7875. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7876. */
  7877. /**
  7878. * Sets the global Exposure value.
  7879. * 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.
  7880. */
  7881. globalExposure: number;
  7882. private _highlightsHue;
  7883. private _highlightsDensity;
  7884. private _highlightsSaturation;
  7885. private _highlightsExposure;
  7886. /**
  7887. * Gets the highlights Hue value.
  7888. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7889. */
  7890. /**
  7891. * Sets the highlights Hue value.
  7892. * 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).
  7893. */
  7894. highlightsHue: number;
  7895. /**
  7896. * Gets the highlights Density value.
  7897. * 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.
  7898. * Values less than zero provide a filter of opposite hue.
  7899. */
  7900. /**
  7901. * Sets the highlights Density value.
  7902. * 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.
  7903. * Values less than zero provide a filter of opposite hue.
  7904. */
  7905. highlightsDensity: number;
  7906. /**
  7907. * Gets the highlights Saturation value.
  7908. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7909. */
  7910. /**
  7911. * Sets the highlights Saturation value.
  7912. * 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.
  7913. */
  7914. highlightsSaturation: number;
  7915. /**
  7916. * Gets the highlights Exposure value.
  7917. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7918. */
  7919. /**
  7920. * Sets the highlights Exposure value.
  7921. * 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.
  7922. */
  7923. highlightsExposure: number;
  7924. private _midtonesHue;
  7925. private _midtonesDensity;
  7926. private _midtonesSaturation;
  7927. private _midtonesExposure;
  7928. /**
  7929. * Gets the midtones Hue value.
  7930. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7931. */
  7932. /**
  7933. * Sets the midtones Hue value.
  7934. * 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).
  7935. */
  7936. midtonesHue: number;
  7937. /**
  7938. * Gets the midtones Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. /**
  7943. * Sets the midtones Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. midtonesDensity: number;
  7948. /**
  7949. * Gets the midtones Saturation value.
  7950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7951. */
  7952. /**
  7953. * Sets the midtones Saturation value.
  7954. * 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.
  7955. */
  7956. midtonesSaturation: number;
  7957. /**
  7958. * Gets the midtones Exposure value.
  7959. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7960. */
  7961. /**
  7962. * Sets the midtones Exposure value.
  7963. * 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.
  7964. */
  7965. midtonesExposure: number;
  7966. private _shadowsHue;
  7967. private _shadowsDensity;
  7968. private _shadowsSaturation;
  7969. private _shadowsExposure;
  7970. /**
  7971. * Gets the shadows Hue value.
  7972. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7973. */
  7974. /**
  7975. * Sets the shadows Hue value.
  7976. * 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).
  7977. */
  7978. shadowsHue: number;
  7979. /**
  7980. * Gets the shadows Density value.
  7981. * 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.
  7982. * Values less than zero provide a filter of opposite hue.
  7983. */
  7984. /**
  7985. * Sets the shadows Density value.
  7986. * 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.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. shadowsDensity: number;
  7990. /**
  7991. * Gets the shadows Saturation value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7993. */
  7994. /**
  7995. * Sets the shadows Saturation value.
  7996. * 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.
  7997. */
  7998. shadowsSaturation: number;
  7999. /**
  8000. * Gets the shadows Exposure value.
  8001. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8002. */
  8003. /**
  8004. * Sets the shadows Exposure value.
  8005. * 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.
  8006. */
  8007. shadowsExposure: number;
  8008. /**
  8009. * Returns the class name
  8010. * @returns The class name
  8011. */
  8012. getClassName(): string;
  8013. /**
  8014. * Binds the color curves to the shader.
  8015. * @param colorCurves The color curve to bind
  8016. * @param effect The effect to bind to
  8017. * @param positiveUniform The positive uniform shader parameter
  8018. * @param neutralUniform The neutral uniform shader parameter
  8019. * @param negativeUniform The negative uniform shader parameter
  8020. */
  8021. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8022. /**
  8023. * Prepare the list of uniforms associated with the ColorCurves effects.
  8024. * @param uniformsList The list of uniforms used in the effect
  8025. */
  8026. static PrepareUniforms(uniformsList: string[]): void;
  8027. /**
  8028. * Returns color grading data based on a hue, density, saturation and exposure value.
  8029. * @param filterHue The hue of the color filter.
  8030. * @param filterDensity The density of the color filter.
  8031. * @param saturation The saturation.
  8032. * @param exposure The exposure.
  8033. * @param result The result data container.
  8034. */
  8035. private getColorGradingDataToRef;
  8036. /**
  8037. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8038. * @param value The input slider value in range [-100,100].
  8039. * @returns Adjusted value.
  8040. */
  8041. private static applyColorGradingSliderNonlinear;
  8042. /**
  8043. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8044. * @param hue The hue (H) input.
  8045. * @param saturation The saturation (S) input.
  8046. * @param brightness The brightness (B) input.
  8047. * @result An RGBA color represented as Vector4.
  8048. */
  8049. private static fromHSBToRef;
  8050. /**
  8051. * Returns a value clamped between min and max
  8052. * @param value The value to clamp
  8053. * @param min The minimum of value
  8054. * @param max The maximum of value
  8055. * @returns The clamped value.
  8056. */
  8057. private static clamp;
  8058. /**
  8059. * Clones the current color curve instance.
  8060. * @return The cloned curves
  8061. */
  8062. clone(): ColorCurves;
  8063. /**
  8064. * Serializes the current color curve instance to a json representation.
  8065. * @return a JSON representation
  8066. */
  8067. serialize(): any;
  8068. /**
  8069. * Parses the color curve from a json representation.
  8070. * @param source the JSON source to parse
  8071. * @return The parsed curves
  8072. */
  8073. static Parse(source: any): ColorCurves;
  8074. }
  8075. }
  8076. declare module BABYLON {
  8077. /**
  8078. * Interface to follow in your material defines to integrate easily the
  8079. * Image proccessing functions.
  8080. * @hidden
  8081. */
  8082. export interface IImageProcessingConfigurationDefines {
  8083. IMAGEPROCESSING: boolean;
  8084. VIGNETTE: boolean;
  8085. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8086. VIGNETTEBLENDMODEOPAQUE: boolean;
  8087. TONEMAPPING: boolean;
  8088. TONEMAPPING_ACES: boolean;
  8089. CONTRAST: boolean;
  8090. EXPOSURE: boolean;
  8091. COLORCURVES: boolean;
  8092. COLORGRADING: boolean;
  8093. COLORGRADING3D: boolean;
  8094. SAMPLER3DGREENDEPTH: boolean;
  8095. SAMPLER3DBGRMAP: boolean;
  8096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8097. }
  8098. /**
  8099. * @hidden
  8100. */
  8101. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8102. IMAGEPROCESSING: boolean;
  8103. VIGNETTE: boolean;
  8104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8105. VIGNETTEBLENDMODEOPAQUE: boolean;
  8106. TONEMAPPING: boolean;
  8107. TONEMAPPING_ACES: boolean;
  8108. CONTRAST: boolean;
  8109. COLORCURVES: boolean;
  8110. COLORGRADING: boolean;
  8111. COLORGRADING3D: boolean;
  8112. SAMPLER3DGREENDEPTH: boolean;
  8113. SAMPLER3DBGRMAP: boolean;
  8114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8115. EXPOSURE: boolean;
  8116. constructor();
  8117. }
  8118. /**
  8119. * This groups together the common properties used for image processing either in direct forward pass
  8120. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8121. * or not.
  8122. */
  8123. export class ImageProcessingConfiguration {
  8124. /**
  8125. * Default tone mapping applied in BabylonJS.
  8126. */
  8127. static readonly TONEMAPPING_STANDARD: number;
  8128. /**
  8129. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8130. * to other engines rendering to increase portability.
  8131. */
  8132. static readonly TONEMAPPING_ACES: number;
  8133. /**
  8134. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8135. */
  8136. colorCurves: Nullable<ColorCurves>;
  8137. private _colorCurvesEnabled;
  8138. /**
  8139. * Gets wether the color curves effect is enabled.
  8140. */
  8141. /**
  8142. * Sets wether the color curves effect is enabled.
  8143. */
  8144. colorCurvesEnabled: boolean;
  8145. private _colorGradingTexture;
  8146. /**
  8147. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8148. */
  8149. /**
  8150. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8151. */
  8152. colorGradingTexture: Nullable<BaseTexture>;
  8153. private _colorGradingEnabled;
  8154. /**
  8155. * Gets wether the color grading effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the color grading effect is enabled.
  8159. */
  8160. colorGradingEnabled: boolean;
  8161. private _colorGradingWithGreenDepth;
  8162. /**
  8163. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8164. */
  8165. /**
  8166. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8167. */
  8168. colorGradingWithGreenDepth: boolean;
  8169. private _colorGradingBGR;
  8170. /**
  8171. * Gets wether the color grading texture contains BGR values.
  8172. */
  8173. /**
  8174. * Sets wether the color grading texture contains BGR values.
  8175. */
  8176. colorGradingBGR: boolean;
  8177. /** @hidden */
  8178. _exposure: number;
  8179. /**
  8180. * Gets the Exposure used in the effect.
  8181. */
  8182. /**
  8183. * Sets the Exposure used in the effect.
  8184. */
  8185. exposure: number;
  8186. private _toneMappingEnabled;
  8187. /**
  8188. * Gets wether the tone mapping effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the tone mapping effect is enabled.
  8192. */
  8193. toneMappingEnabled: boolean;
  8194. private _toneMappingType;
  8195. /**
  8196. * Gets the type of tone mapping effect.
  8197. */
  8198. /**
  8199. * Sets the type of tone mapping effect used in BabylonJS.
  8200. */
  8201. toneMappingType: number;
  8202. protected _contrast: number;
  8203. /**
  8204. * Gets the contrast used in the effect.
  8205. */
  8206. /**
  8207. * Sets the contrast used in the effect.
  8208. */
  8209. contrast: number;
  8210. /**
  8211. * Vignette stretch size.
  8212. */
  8213. vignetteStretch: number;
  8214. /**
  8215. * Vignette centre X Offset.
  8216. */
  8217. vignetteCentreX: number;
  8218. /**
  8219. * Vignette centre Y Offset.
  8220. */
  8221. vignetteCentreY: number;
  8222. /**
  8223. * Vignette weight or intensity of the vignette effect.
  8224. */
  8225. vignetteWeight: number;
  8226. /**
  8227. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8228. * if vignetteEnabled is set to true.
  8229. */
  8230. vignetteColor: Color4;
  8231. /**
  8232. * Camera field of view used by the Vignette effect.
  8233. */
  8234. vignetteCameraFov: number;
  8235. private _vignetteBlendMode;
  8236. /**
  8237. * Gets the vignette blend mode allowing different kind of effect.
  8238. */
  8239. /**
  8240. * Sets the vignette blend mode allowing different kind of effect.
  8241. */
  8242. vignetteBlendMode: number;
  8243. private _vignetteEnabled;
  8244. /**
  8245. * Gets wether the vignette effect is enabled.
  8246. */
  8247. /**
  8248. * Sets wether the vignette effect is enabled.
  8249. */
  8250. vignetteEnabled: boolean;
  8251. private _applyByPostProcess;
  8252. /**
  8253. * Gets wether the image processing is applied through a post process or not.
  8254. */
  8255. /**
  8256. * Sets wether the image processing is applied through a post process or not.
  8257. */
  8258. applyByPostProcess: boolean;
  8259. private _isEnabled;
  8260. /**
  8261. * Gets wether the image processing is enabled or not.
  8262. */
  8263. /**
  8264. * Sets wether the image processing is enabled or not.
  8265. */
  8266. isEnabled: boolean;
  8267. /**
  8268. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8269. */
  8270. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8271. /**
  8272. * Method called each time the image processing information changes requires to recompile the effect.
  8273. */
  8274. protected _updateParameters(): void;
  8275. /**
  8276. * Gets the current class name.
  8277. * @return "ImageProcessingConfiguration"
  8278. */
  8279. getClassName(): string;
  8280. /**
  8281. * Prepare the list of uniforms associated with the Image Processing effects.
  8282. * @param uniforms The list of uniforms used in the effect
  8283. * @param defines the list of defines currently in use
  8284. */
  8285. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8286. /**
  8287. * Prepare the list of samplers associated with the Image Processing effects.
  8288. * @param samplersList The list of uniforms used in the effect
  8289. * @param defines the list of defines currently in use
  8290. */
  8291. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8292. /**
  8293. * Prepare the list of defines associated to the shader.
  8294. * @param defines the list of defines to complete
  8295. * @param forPostProcess Define if we are currently in post process mode or not
  8296. */
  8297. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8298. /**
  8299. * Returns true if all the image processing information are ready.
  8300. * @returns True if ready, otherwise, false
  8301. */
  8302. isReady(): boolean;
  8303. /**
  8304. * Binds the image processing to the shader.
  8305. * @param effect The effect to bind to
  8306. * @param overrideAspectRatio Override the aspect ratio of the effect
  8307. */
  8308. bind(effect: Effect, overrideAspectRatio?: number): void;
  8309. /**
  8310. * Clones the current image processing instance.
  8311. * @return The cloned image processing
  8312. */
  8313. clone(): ImageProcessingConfiguration;
  8314. /**
  8315. * Serializes the current image processing instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the image processing from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed image processing
  8323. */
  8324. static Parse(source: any): ImageProcessingConfiguration;
  8325. private static _VIGNETTEMODE_MULTIPLY;
  8326. private static _VIGNETTEMODE_OPAQUE;
  8327. /**
  8328. * Used to apply the vignette as a mix with the pixel color.
  8329. */
  8330. static readonly VIGNETTEMODE_MULTIPLY: number;
  8331. /**
  8332. * Used to apply the vignette as a replacement of the pixel color.
  8333. */
  8334. static readonly VIGNETTEMODE_OPAQUE: number;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. /** @hidden */
  8339. export var postprocessVertexShader: {
  8340. name: string;
  8341. shader: string;
  8342. };
  8343. }
  8344. declare module BABYLON {
  8345. interface ThinEngine {
  8346. /**
  8347. * Creates a new render target texture
  8348. * @param size defines the size of the texture
  8349. * @param options defines the options used to create the texture
  8350. * @returns a new render target texture stored in an InternalTexture
  8351. */
  8352. createRenderTargetTexture(size: number | {
  8353. width: number;
  8354. height: number;
  8355. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8356. /**
  8357. * Creates a depth stencil texture.
  8358. * This is only available in WebGL 2 or with the depth texture extension available.
  8359. * @param size The size of face edge in the texture.
  8360. * @param options The options defining the texture.
  8361. * @returns The texture
  8362. */
  8363. createDepthStencilTexture(size: number | {
  8364. width: number;
  8365. height: number;
  8366. }, options: DepthTextureCreationOptions): InternalTexture;
  8367. /** @hidden */
  8368. _createDepthStencilTexture(size: number | {
  8369. width: number;
  8370. height: number;
  8371. }, options: DepthTextureCreationOptions): InternalTexture;
  8372. }
  8373. }
  8374. declare module BABYLON {
  8375. /** Defines supported spaces */
  8376. export enum Space {
  8377. /** Local (object) space */
  8378. LOCAL = 0,
  8379. /** World space */
  8380. WORLD = 1,
  8381. /** Bone space */
  8382. BONE = 2
  8383. }
  8384. /** Defines the 3 main axes */
  8385. export class Axis {
  8386. /** X axis */
  8387. static X: Vector3;
  8388. /** Y axis */
  8389. static Y: Vector3;
  8390. /** Z axis */
  8391. static Z: Vector3;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /**
  8396. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. */
  8400. export class TargetCamera extends Camera {
  8401. private static _RigCamTransformMatrix;
  8402. private static _TargetTransformMatrix;
  8403. private static _TargetFocalPoint;
  8404. /**
  8405. * Define the current direction the camera is moving to
  8406. */
  8407. cameraDirection: Vector3;
  8408. /**
  8409. * Define the current rotation the camera is rotating to
  8410. */
  8411. cameraRotation: Vector2;
  8412. /**
  8413. * When set, the up vector of the camera will be updated by the rotation of the camera
  8414. */
  8415. updateUpVectorFromRotation: boolean;
  8416. private _tmpQuaternion;
  8417. /**
  8418. * Define the current rotation of the camera
  8419. */
  8420. rotation: Vector3;
  8421. /**
  8422. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8423. */
  8424. rotationQuaternion: Quaternion;
  8425. /**
  8426. * Define the current speed of the camera
  8427. */
  8428. speed: number;
  8429. /**
  8430. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8431. * around all axis.
  8432. */
  8433. noRotationConstraint: boolean;
  8434. /**
  8435. * Define the current target of the camera as an object or a position.
  8436. */
  8437. lockedTarget: any;
  8438. /** @hidden */
  8439. _currentTarget: Vector3;
  8440. /** @hidden */
  8441. _initialFocalDistance: number;
  8442. /** @hidden */
  8443. _viewMatrix: Matrix;
  8444. /** @hidden */
  8445. _camMatrix: Matrix;
  8446. /** @hidden */
  8447. _cameraTransformMatrix: Matrix;
  8448. /** @hidden */
  8449. _cameraRotationMatrix: Matrix;
  8450. /** @hidden */
  8451. _referencePoint: Vector3;
  8452. /** @hidden */
  8453. _transformedReferencePoint: Vector3;
  8454. protected _globalCurrentTarget: Vector3;
  8455. protected _globalCurrentUpVector: Vector3;
  8456. /** @hidden */
  8457. _reset: () => void;
  8458. private _defaultUp;
  8459. /**
  8460. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8461. * This is the base of the follow, arc rotate cameras and Free camera
  8462. * @see http://doc.babylonjs.com/features/cameras
  8463. * @param name Defines the name of the camera in the scene
  8464. * @param position Defines the start position of the camera in the scene
  8465. * @param scene Defines the scene the camera belongs to
  8466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8467. */
  8468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8469. /**
  8470. * Gets the position in front of the camera at a given distance.
  8471. * @param distance The distance from the camera we want the position to be
  8472. * @returns the position
  8473. */
  8474. getFrontPosition(distance: number): Vector3;
  8475. /** @hidden */
  8476. _getLockedTargetPosition(): Nullable<Vector3>;
  8477. private _storedPosition;
  8478. private _storedRotation;
  8479. private _storedRotationQuaternion;
  8480. /**
  8481. * Store current camera state of the camera (fov, position, rotation, etc..)
  8482. * @returns the camera
  8483. */
  8484. storeState(): Camera;
  8485. /**
  8486. * Restored camera state. You must call storeState() first
  8487. * @returns whether it was successful or not
  8488. * @hidden
  8489. */
  8490. _restoreStateValues(): boolean;
  8491. /** @hidden */
  8492. _initCache(): void;
  8493. /** @hidden */
  8494. _updateCache(ignoreParentClass?: boolean): void;
  8495. /** @hidden */
  8496. _isSynchronizedViewMatrix(): boolean;
  8497. /** @hidden */
  8498. _computeLocalCameraSpeed(): number;
  8499. /**
  8500. * Defines the target the camera should look at.
  8501. * @param target Defines the new target as a Vector or a mesh
  8502. */
  8503. setTarget(target: Vector3): void;
  8504. /**
  8505. * Return the current target position of the camera. This value is expressed in local space.
  8506. * @returns the target position
  8507. */
  8508. getTarget(): Vector3;
  8509. /** @hidden */
  8510. _decideIfNeedsToMove(): boolean;
  8511. /** @hidden */
  8512. _updatePosition(): void;
  8513. /** @hidden */
  8514. _checkInputs(): void;
  8515. protected _updateCameraRotationMatrix(): void;
  8516. /**
  8517. * 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)
  8518. * @returns the current camera
  8519. */
  8520. private _rotateUpVectorWithCameraRotationMatrix;
  8521. private _cachedRotationZ;
  8522. private _cachedQuaternionRotationZ;
  8523. /** @hidden */
  8524. _getViewMatrix(): Matrix;
  8525. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8526. /**
  8527. * @hidden
  8528. */
  8529. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8530. /**
  8531. * @hidden
  8532. */
  8533. _updateRigCameras(): void;
  8534. private _getRigCamPositionAndTarget;
  8535. /**
  8536. * Gets the current object class name.
  8537. * @return the class name
  8538. */
  8539. getClassName(): string;
  8540. }
  8541. }
  8542. declare module BABYLON {
  8543. /**
  8544. * Gather the list of keyboard event types as constants.
  8545. */
  8546. export class KeyboardEventTypes {
  8547. /**
  8548. * The keydown event is fired when a key becomes active (pressed).
  8549. */
  8550. static readonly KEYDOWN: number;
  8551. /**
  8552. * The keyup event is fired when a key has been released.
  8553. */
  8554. static readonly KEYUP: number;
  8555. }
  8556. /**
  8557. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8558. */
  8559. export class KeyboardInfo {
  8560. /**
  8561. * Defines the type of event (KeyboardEventTypes)
  8562. */
  8563. type: number;
  8564. /**
  8565. * Defines the related dom event
  8566. */
  8567. event: KeyboardEvent;
  8568. /**
  8569. * Instantiates a new keyboard info.
  8570. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8571. * @param type Defines the type of event (KeyboardEventTypes)
  8572. * @param event Defines the related dom event
  8573. */
  8574. constructor(
  8575. /**
  8576. * Defines the type of event (KeyboardEventTypes)
  8577. */
  8578. type: number,
  8579. /**
  8580. * Defines the related dom event
  8581. */
  8582. event: KeyboardEvent);
  8583. }
  8584. /**
  8585. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8586. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8587. */
  8588. export class KeyboardInfoPre extends KeyboardInfo {
  8589. /**
  8590. * Defines the type of event (KeyboardEventTypes)
  8591. */
  8592. type: number;
  8593. /**
  8594. * Defines the related dom event
  8595. */
  8596. event: KeyboardEvent;
  8597. /**
  8598. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8599. */
  8600. skipOnPointerObservable: boolean;
  8601. /**
  8602. * Instantiates a new keyboard pre info.
  8603. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8604. * @param type Defines the type of event (KeyboardEventTypes)
  8605. * @param event Defines the related dom event
  8606. */
  8607. constructor(
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number,
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent);
  8616. }
  8617. }
  8618. declare module BABYLON {
  8619. /**
  8620. * Manage the keyboard inputs to control the movement of a free camera.
  8621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8622. */
  8623. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8624. /**
  8625. * Defines the camera the input is attached to.
  8626. */
  8627. camera: FreeCamera;
  8628. /**
  8629. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8630. */
  8631. keysUp: number[];
  8632. /**
  8633. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8634. */
  8635. keysDown: number[];
  8636. /**
  8637. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8638. */
  8639. keysLeft: number[];
  8640. /**
  8641. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8642. */
  8643. keysRight: number[];
  8644. private _keys;
  8645. private _onCanvasBlurObserver;
  8646. private _onKeyboardObserver;
  8647. private _engine;
  8648. private _scene;
  8649. /**
  8650. * Attach the input controls to a specific dom element to get the input from.
  8651. * @param element Defines the element the controls should be listened from
  8652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8653. */
  8654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8655. /**
  8656. * Detach the current controls from the specified dom element.
  8657. * @param element Defines the element to stop listening the inputs from
  8658. */
  8659. detachControl(element: Nullable<HTMLElement>): void;
  8660. /**
  8661. * Update the current camera state depending on the inputs that have been used this frame.
  8662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8663. */
  8664. checkInputs(): void;
  8665. /**
  8666. * Gets the class name of the current intput.
  8667. * @returns the class name
  8668. */
  8669. getClassName(): string;
  8670. /** @hidden */
  8671. _onLostFocus(): void;
  8672. /**
  8673. * Get the friendly name associated with the input class.
  8674. * @returns the input friendly name
  8675. */
  8676. getSimpleName(): string;
  8677. }
  8678. }
  8679. declare module BABYLON {
  8680. /**
  8681. * Interface describing all the common properties and methods a shadow light needs to implement.
  8682. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8683. * as well as binding the different shadow properties to the effects.
  8684. */
  8685. export interface IShadowLight extends Light {
  8686. /**
  8687. * The light id in the scene (used in scene.findLighById for instance)
  8688. */
  8689. id: string;
  8690. /**
  8691. * The position the shdow will be casted from.
  8692. */
  8693. position: Vector3;
  8694. /**
  8695. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8696. */
  8697. direction: Vector3;
  8698. /**
  8699. * The transformed position. Position of the light in world space taking parenting in account.
  8700. */
  8701. transformedPosition: Vector3;
  8702. /**
  8703. * The transformed direction. Direction of the light in world space taking parenting in account.
  8704. */
  8705. transformedDirection: Vector3;
  8706. /**
  8707. * The friendly name of the light in the scene.
  8708. */
  8709. name: string;
  8710. /**
  8711. * Defines the shadow projection clipping minimum z value.
  8712. */
  8713. shadowMinZ: number;
  8714. /**
  8715. * Defines the shadow projection clipping maximum z value.
  8716. */
  8717. shadowMaxZ: number;
  8718. /**
  8719. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8720. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8721. */
  8722. computeTransformedInformation(): boolean;
  8723. /**
  8724. * Gets the scene the light belongs to.
  8725. * @returns The scene
  8726. */
  8727. getScene(): Scene;
  8728. /**
  8729. * Callback defining a custom Projection Matrix Builder.
  8730. * This can be used to override the default projection matrix computation.
  8731. */
  8732. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8733. /**
  8734. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8735. * @param matrix The materix to updated with the projection information
  8736. * @param viewMatrix The transform matrix of the light
  8737. * @param renderList The list of mesh to render in the map
  8738. * @returns The current light
  8739. */
  8740. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8741. /**
  8742. * Gets the current depth scale used in ESM.
  8743. * @returns The scale
  8744. */
  8745. getDepthScale(): number;
  8746. /**
  8747. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8748. * @returns true if a cube texture needs to be use
  8749. */
  8750. needCube(): boolean;
  8751. /**
  8752. * Detects if the projection matrix requires to be recomputed this frame.
  8753. * @returns true if it requires to be recomputed otherwise, false.
  8754. */
  8755. needProjectionMatrixCompute(): boolean;
  8756. /**
  8757. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8758. */
  8759. forceProjectionMatrixCompute(): void;
  8760. /**
  8761. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8762. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8763. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8764. */
  8765. getShadowDirection(faceIndex?: number): Vector3;
  8766. /**
  8767. * Gets the minZ used for shadow according to both the scene and the light.
  8768. * @param activeCamera The camera we are returning the min for
  8769. * @returns the depth min z
  8770. */
  8771. getDepthMinZ(activeCamera: Camera): number;
  8772. /**
  8773. * Gets the maxZ used for shadow according to both the scene and the light.
  8774. * @param activeCamera The camera we are returning the max for
  8775. * @returns the depth max z
  8776. */
  8777. getDepthMaxZ(activeCamera: Camera): number;
  8778. }
  8779. /**
  8780. * Base implementation IShadowLight
  8781. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8782. */
  8783. export abstract class ShadowLight extends Light implements IShadowLight {
  8784. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8785. protected _position: Vector3;
  8786. protected _setPosition(value: Vector3): void;
  8787. /**
  8788. * Sets the position the shadow will be casted from. Also use as the light position for both
  8789. * point and spot lights.
  8790. */
  8791. /**
  8792. * Sets the position the shadow will be casted from. Also use as the light position for both
  8793. * point and spot lights.
  8794. */
  8795. position: Vector3;
  8796. protected _direction: Vector3;
  8797. protected _setDirection(value: Vector3): void;
  8798. /**
  8799. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8800. * Also use as the light direction on spot and directional lights.
  8801. */
  8802. /**
  8803. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8804. * Also use as the light direction on spot and directional lights.
  8805. */
  8806. direction: Vector3;
  8807. private _shadowMinZ;
  8808. /**
  8809. * Gets the shadow projection clipping minimum z value.
  8810. */
  8811. /**
  8812. * Sets the shadow projection clipping minimum z value.
  8813. */
  8814. shadowMinZ: number;
  8815. private _shadowMaxZ;
  8816. /**
  8817. * Sets the shadow projection clipping maximum z value.
  8818. */
  8819. /**
  8820. * Gets the shadow projection clipping maximum z value.
  8821. */
  8822. shadowMaxZ: number;
  8823. /**
  8824. * Callback defining a custom Projection Matrix Builder.
  8825. * This can be used to override the default projection matrix computation.
  8826. */
  8827. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8828. /**
  8829. * The transformed position. Position of the light in world space taking parenting in account.
  8830. */
  8831. transformedPosition: Vector3;
  8832. /**
  8833. * The transformed direction. Direction of the light in world space taking parenting in account.
  8834. */
  8835. transformedDirection: Vector3;
  8836. private _needProjectionMatrixCompute;
  8837. /**
  8838. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8839. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8840. */
  8841. computeTransformedInformation(): boolean;
  8842. /**
  8843. * Return the depth scale used for the shadow map.
  8844. * @returns the depth scale.
  8845. */
  8846. getDepthScale(): number;
  8847. /**
  8848. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8849. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8850. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8851. */
  8852. getShadowDirection(faceIndex?: number): Vector3;
  8853. /**
  8854. * Returns the ShadowLight absolute position in the World.
  8855. * @returns the position vector in world space
  8856. */
  8857. getAbsolutePosition(): Vector3;
  8858. /**
  8859. * Sets the ShadowLight direction toward the passed target.
  8860. * @param target The point to target in local space
  8861. * @returns the updated ShadowLight direction
  8862. */
  8863. setDirectionToTarget(target: Vector3): Vector3;
  8864. /**
  8865. * Returns the light rotation in euler definition.
  8866. * @returns the x y z rotation in local space.
  8867. */
  8868. getRotation(): Vector3;
  8869. /**
  8870. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8871. * @returns true if a cube texture needs to be use
  8872. */
  8873. needCube(): boolean;
  8874. /**
  8875. * Detects if the projection matrix requires to be recomputed this frame.
  8876. * @returns true if it requires to be recomputed otherwise, false.
  8877. */
  8878. needProjectionMatrixCompute(): boolean;
  8879. /**
  8880. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8881. */
  8882. forceProjectionMatrixCompute(): void;
  8883. /** @hidden */
  8884. _initCache(): void;
  8885. /** @hidden */
  8886. _isSynchronized(): boolean;
  8887. /**
  8888. * Computes the world matrix of the node
  8889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8890. * @returns the world matrix
  8891. */
  8892. computeWorldMatrix(force?: boolean): Matrix;
  8893. /**
  8894. * Gets the minZ used for shadow according to both the scene and the light.
  8895. * @param activeCamera The camera we are returning the min for
  8896. * @returns the depth min z
  8897. */
  8898. getDepthMinZ(activeCamera: Camera): number;
  8899. /**
  8900. * Gets the maxZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the max for
  8902. * @returns the depth max z
  8903. */
  8904. getDepthMaxZ(activeCamera: Camera): number;
  8905. /**
  8906. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8907. * @param matrix The materix to updated with the projection information
  8908. * @param viewMatrix The transform matrix of the light
  8909. * @param renderList The list of mesh to render in the map
  8910. * @returns The current light
  8911. */
  8912. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8913. }
  8914. }
  8915. declare module BABYLON {
  8916. /**
  8917. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8918. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8919. */
  8920. export class EffectFallbacks implements IEffectFallbacks {
  8921. private _defines;
  8922. private _currentRank;
  8923. private _maxRank;
  8924. private _mesh;
  8925. /**
  8926. * Removes the fallback from the bound mesh.
  8927. */
  8928. unBindMesh(): void;
  8929. /**
  8930. * Adds a fallback on the specified property.
  8931. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8932. * @param define The name of the define in the shader
  8933. */
  8934. addFallback(rank: number, define: string): void;
  8935. /**
  8936. * Sets the mesh to use CPU skinning when needing to fallback.
  8937. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8938. * @param mesh The mesh to use the fallbacks.
  8939. */
  8940. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8941. /**
  8942. * Checks to see if more fallbacks are still availible.
  8943. */
  8944. readonly hasMoreFallbacks: boolean;
  8945. /**
  8946. * Removes the defines that should be removed when falling back.
  8947. * @param currentDefines defines the current define statements for the shader.
  8948. * @param effect defines the current effect we try to compile
  8949. * @returns The resulting defines with defines of the current rank removed.
  8950. */
  8951. reduce(currentDefines: string, effect: Effect): string;
  8952. }
  8953. }
  8954. declare module BABYLON {
  8955. /**
  8956. * "Static Class" containing the most commonly used helper while dealing with material for
  8957. * rendering purpose.
  8958. *
  8959. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8960. *
  8961. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8962. */
  8963. export class MaterialHelper {
  8964. /**
  8965. * Bind the current view position to an effect.
  8966. * @param effect The effect to be bound
  8967. * @param scene The scene the eyes position is used from
  8968. */
  8969. static BindEyePosition(effect: Effect, scene: Scene): void;
  8970. /**
  8971. * Helps preparing the defines values about the UVs in used in the effect.
  8972. * UVs are shared as much as we can accross channels in the shaders.
  8973. * @param texture The texture we are preparing the UVs for
  8974. * @param defines The defines to update
  8975. * @param key The channel key "diffuse", "specular"... used in the shader
  8976. */
  8977. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8978. /**
  8979. * Binds a texture matrix value to its corrsponding uniform
  8980. * @param texture The texture to bind the matrix for
  8981. * @param uniformBuffer The uniform buffer receivin the data
  8982. * @param key The channel key "diffuse", "specular"... used in the shader
  8983. */
  8984. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8985. /**
  8986. * Gets the current status of the fog (should it be enabled?)
  8987. * @param mesh defines the mesh to evaluate for fog support
  8988. * @param scene defines the hosting scene
  8989. * @returns true if fog must be enabled
  8990. */
  8991. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8992. /**
  8993. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8994. * @param mesh defines the current mesh
  8995. * @param scene defines the current scene
  8996. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8997. * @param pointsCloud defines if point cloud rendering has to be turned on
  8998. * @param fogEnabled defines if fog has to be turned on
  8999. * @param alphaTest defines if alpha testing has to be turned on
  9000. * @param defines defines the current list of defines
  9001. */
  9002. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9003. /**
  9004. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9005. * @param scene defines the current scene
  9006. * @param engine defines the current engine
  9007. * @param defines specifies the list of active defines
  9008. * @param useInstances defines if instances have to be turned on
  9009. * @param useClipPlane defines if clip plane have to be turned on
  9010. */
  9011. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9012. /**
  9013. * Prepares the defines for bones
  9014. * @param mesh The mesh containing the geometry data we will draw
  9015. * @param defines The defines to update
  9016. */
  9017. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9018. /**
  9019. * Prepares the defines for morph targets
  9020. * @param mesh The mesh containing the geometry data we will draw
  9021. * @param defines The defines to update
  9022. */
  9023. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9024. /**
  9025. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9026. * @param mesh The mesh containing the geometry data we will draw
  9027. * @param defines The defines to update
  9028. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9029. * @param useBones Precise whether bones should be used or not (override mesh info)
  9030. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9031. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9032. * @returns false if defines are considered not dirty and have not been checked
  9033. */
  9034. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9035. /**
  9036. * Prepares the defines related to multiview
  9037. * @param scene The scene we are intending to draw
  9038. * @param defines The defines to update
  9039. */
  9040. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9041. /**
  9042. * Prepares the defines related to the light information passed in parameter
  9043. * @param scene The scene we are intending to draw
  9044. * @param mesh The mesh the effect is compiling for
  9045. * @param light The light the effect is compiling for
  9046. * @param lightIndex The index of the light
  9047. * @param defines The defines to update
  9048. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9049. * @param state Defines the current state regarding what is needed (normals, etc...)
  9050. */
  9051. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9052. needNormals: boolean;
  9053. needRebuild: boolean;
  9054. shadowEnabled: boolean;
  9055. specularEnabled: boolean;
  9056. lightmapMode: boolean;
  9057. }): void;
  9058. /**
  9059. * Prepares the defines related to the light information passed in parameter
  9060. * @param scene The scene we are intending to draw
  9061. * @param mesh The mesh the effect is compiling for
  9062. * @param defines The defines to update
  9063. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9064. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9065. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9066. * @returns true if normals will be required for the rest of the effect
  9067. */
  9068. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9069. /**
  9070. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9071. * @param lightIndex defines the light index
  9072. * @param uniformsList The uniform list
  9073. * @param samplersList The sampler list
  9074. * @param projectedLightTexture defines if projected texture must be used
  9075. * @param uniformBuffersList defines an optional list of uniform buffers
  9076. */
  9077. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9078. /**
  9079. * Prepares the uniforms and samplers list to be used in the effect
  9080. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9081. * @param samplersList The sampler list
  9082. * @param defines The defines helping in the list generation
  9083. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9084. */
  9085. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9086. /**
  9087. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9088. * @param defines The defines to update while falling back
  9089. * @param fallbacks The authorized effect fallbacks
  9090. * @param maxSimultaneousLights The maximum number of lights allowed
  9091. * @param rank the current rank of the Effect
  9092. * @returns The newly affected rank
  9093. */
  9094. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9095. private static _TmpMorphInfluencers;
  9096. /**
  9097. * Prepares the list of attributes required for morph targets according to the effect defines.
  9098. * @param attribs The current list of supported attribs
  9099. * @param mesh The mesh to prepare the morph targets attributes for
  9100. * @param influencers The number of influencers
  9101. */
  9102. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9103. /**
  9104. * Prepares the list of attributes required for morph targets according to the effect defines.
  9105. * @param attribs The current list of supported attribs
  9106. * @param mesh The mesh to prepare the morph targets attributes for
  9107. * @param defines The current Defines of the effect
  9108. */
  9109. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9110. /**
  9111. * Prepares the list of attributes required for bones according to the effect defines.
  9112. * @param attribs The current list of supported attribs
  9113. * @param mesh The mesh to prepare the bones attributes for
  9114. * @param defines The current Defines of the effect
  9115. * @param fallbacks The current efffect fallback strategy
  9116. */
  9117. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9118. /**
  9119. * Check and prepare the list of attributes required for instances according to the effect defines.
  9120. * @param attribs The current list of supported attribs
  9121. * @param defines The current MaterialDefines of the effect
  9122. */
  9123. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9124. /**
  9125. * Add the list of attributes required for instances to the attribs array.
  9126. * @param attribs The current list of supported attribs
  9127. */
  9128. static PushAttributesForInstances(attribs: string[]): void;
  9129. /**
  9130. * Binds the light information to the effect.
  9131. * @param light The light containing the generator
  9132. * @param effect The effect we are binding the data to
  9133. * @param lightIndex The light index in the effect used to render
  9134. */
  9135. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9136. /**
  9137. * Binds the lights information from the scene to the effect for the given mesh.
  9138. * @param light Light to bind
  9139. * @param lightIndex Light index
  9140. * @param scene The scene where the light belongs to
  9141. * @param effect The effect we are binding the data to
  9142. * @param useSpecular Defines if specular is supported
  9143. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9145. */
  9146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9147. /**
  9148. * Binds the lights information from the scene to the effect for the given mesh.
  9149. * @param scene The scene the lights belongs to
  9150. * @param mesh The mesh we are binding the information to render
  9151. * @param effect The effect we are binding the data to
  9152. * @param defines The generated defines for the effect
  9153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9154. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9156. */
  9157. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9158. private static _tempFogColor;
  9159. /**
  9160. * Binds the fog information from the scene to the effect for the given mesh.
  9161. * @param scene The scene the lights belongs to
  9162. * @param mesh The mesh we are binding the information to render
  9163. * @param effect The effect we are binding the data to
  9164. * @param linearSpace Defines if the fog effect is applied in linear space
  9165. */
  9166. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9167. /**
  9168. * Binds the bones information from the mesh to the effect.
  9169. * @param mesh The mesh we are binding the information to render
  9170. * @param effect The effect we are binding the data to
  9171. */
  9172. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9173. /**
  9174. * Binds the morph targets information from the mesh to the effect.
  9175. * @param abstractMesh The mesh we are binding the information to render
  9176. * @param effect The effect we are binding the data to
  9177. */
  9178. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9179. /**
  9180. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9181. * @param defines The generated defines used in the effect
  9182. * @param effect The effect we are binding the data to
  9183. * @param scene The scene we are willing to render with logarithmic scale for
  9184. */
  9185. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9186. /**
  9187. * Binds the clip plane information from the scene to the effect.
  9188. * @param scene The scene the clip plane information are extracted from
  9189. * @param effect The effect we are binding the data to
  9190. */
  9191. static BindClipPlane(effect: Effect, scene: Scene): void;
  9192. }
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var packingFunctions: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var shadowMapPixelShader: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesDeclaration: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var morphTargetsVertexGlobalDeclaration: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var morphTargetsVertexDeclaration: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var instancesDeclaration: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var helperFunctions: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var morphTargetsVertex: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var instancesVertex: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var bonesVertex: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /** @hidden */
  9266. export var shadowMapVertexShader: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module BABYLON {
  9272. /** @hidden */
  9273. export var depthBoxBlurPixelShader: {
  9274. name: string;
  9275. shader: string;
  9276. };
  9277. }
  9278. declare module BABYLON {
  9279. /**
  9280. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9281. */
  9282. export interface ICustomShaderOptions {
  9283. /**
  9284. * Gets or sets the custom shader name to use
  9285. */
  9286. shaderName: string;
  9287. /**
  9288. * The list of attribute names used in the shader
  9289. */
  9290. attributes?: string[];
  9291. /**
  9292. * The list of unifrom names used in the shader
  9293. */
  9294. uniforms?: string[];
  9295. /**
  9296. * The list of sampler names used in the shader
  9297. */
  9298. samplers?: string[];
  9299. /**
  9300. * The list of defines used in the shader
  9301. */
  9302. defines?: string[];
  9303. }
  9304. /**
  9305. * Interface to implement to create a shadow generator compatible with BJS.
  9306. */
  9307. export interface IShadowGenerator {
  9308. /**
  9309. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9310. * @returns The render target texture if present otherwise, null
  9311. */
  9312. getShadowMap(): Nullable<RenderTargetTexture>;
  9313. /**
  9314. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9315. * @returns The render target texture if the shadow map is present otherwise, null
  9316. */
  9317. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9318. /**
  9319. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9320. * @param subMesh The submesh we want to render in the shadow map
  9321. * @param useInstances Defines wether will draw in the map using instances
  9322. * @returns true if ready otherwise, false
  9323. */
  9324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9325. /**
  9326. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9327. * @param defines Defines of the material we want to update
  9328. * @param lightIndex Index of the light in the enabled light list of the material
  9329. */
  9330. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9331. /**
  9332. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9333. * defined in the generator but impacting the effect).
  9334. * It implies the unifroms available on the materials are the standard BJS ones.
  9335. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9336. * @param effect The effect we are binfing the information for
  9337. */
  9338. bindShadowLight(lightIndex: string, effect: Effect): void;
  9339. /**
  9340. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9341. * (eq to shadow prjection matrix * light transform matrix)
  9342. * @returns The transform matrix used to create the shadow map
  9343. */
  9344. getTransformMatrix(): Matrix;
  9345. /**
  9346. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9347. * Cube and 2D textures for instance.
  9348. */
  9349. recreateShadowMap(): void;
  9350. /**
  9351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9352. * @param onCompiled Callback triggered at the and of the effects compilation
  9353. * @param options Sets of optional options forcing the compilation with different modes
  9354. */
  9355. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9356. useInstances: boolean;
  9357. }>): void;
  9358. /**
  9359. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9360. * @param options Sets of optional options forcing the compilation with different modes
  9361. * @returns A promise that resolves when the compilation completes
  9362. */
  9363. forceCompilationAsync(options?: Partial<{
  9364. useInstances: boolean;
  9365. }>): Promise<void>;
  9366. /**
  9367. * Serializes the shadow generator setup to a json object.
  9368. * @returns The serialized JSON object
  9369. */
  9370. serialize(): any;
  9371. /**
  9372. * Disposes the Shadow map and related Textures and effects.
  9373. */
  9374. dispose(): void;
  9375. }
  9376. /**
  9377. * Default implementation IShadowGenerator.
  9378. * This is the main object responsible of generating shadows in the framework.
  9379. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9380. */
  9381. export class ShadowGenerator implements IShadowGenerator {
  9382. /**
  9383. * Shadow generator mode None: no filtering applied.
  9384. */
  9385. static readonly FILTER_NONE: number;
  9386. /**
  9387. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9393. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9394. */
  9395. static readonly FILTER_POISSONSAMPLING: number;
  9396. /**
  9397. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9398. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9399. */
  9400. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9401. /**
  9402. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9403. * edge artifacts on steep falloff.
  9404. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9405. */
  9406. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9407. /**
  9408. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9409. * edge artifacts on steep falloff.
  9410. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9411. */
  9412. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9413. /**
  9414. * Shadow generator mode PCF: Percentage Closer Filtering
  9415. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9416. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9417. */
  9418. static readonly FILTER_PCF: number;
  9419. /**
  9420. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9421. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9422. * Contact Hardening
  9423. */
  9424. static readonly FILTER_PCSS: number;
  9425. /**
  9426. * Reserved for PCF and PCSS
  9427. * Highest Quality.
  9428. *
  9429. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9430. *
  9431. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9432. */
  9433. static readonly QUALITY_HIGH: number;
  9434. /**
  9435. * Reserved for PCF and PCSS
  9436. * Good tradeoff for quality/perf cross devices
  9437. *
  9438. * Execute PCF on a 3*3 kernel.
  9439. *
  9440. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9441. */
  9442. static readonly QUALITY_MEDIUM: number;
  9443. /**
  9444. * Reserved for PCF and PCSS
  9445. * The lowest quality but the fastest.
  9446. *
  9447. * Execute PCF on a 1*1 kernel.
  9448. *
  9449. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9450. */
  9451. static readonly QUALITY_LOW: number;
  9452. /** Gets or sets the custom shader name to use */
  9453. customShaderOptions: ICustomShaderOptions;
  9454. /**
  9455. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9456. */
  9457. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9458. /**
  9459. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9460. */
  9461. onAfterShadowMapRenderObservable: Observable<Effect>;
  9462. /**
  9463. * Observable triggered before a mesh is rendered in the shadow map.
  9464. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9465. */
  9466. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9467. /**
  9468. * Observable triggered after a mesh is rendered in the shadow map.
  9469. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9470. */
  9471. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9472. private _bias;
  9473. /**
  9474. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9475. */
  9476. /**
  9477. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9478. */
  9479. bias: number;
  9480. private _normalBias;
  9481. /**
  9482. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9483. */
  9484. /**
  9485. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9486. */
  9487. normalBias: number;
  9488. private _blurBoxOffset;
  9489. /**
  9490. * Gets the blur box offset: offset applied during the blur pass.
  9491. * Only useful if useKernelBlur = false
  9492. */
  9493. /**
  9494. * Sets the blur box offset: offset applied during the blur pass.
  9495. * Only useful if useKernelBlur = false
  9496. */
  9497. blurBoxOffset: number;
  9498. private _blurScale;
  9499. /**
  9500. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9501. * 2 means half of the size.
  9502. */
  9503. /**
  9504. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9505. * 2 means half of the size.
  9506. */
  9507. blurScale: number;
  9508. private _blurKernel;
  9509. /**
  9510. * Gets the blur kernel: kernel size of the blur pass.
  9511. * Only useful if useKernelBlur = true
  9512. */
  9513. /**
  9514. * Sets the blur kernel: kernel size of the blur pass.
  9515. * Only useful if useKernelBlur = true
  9516. */
  9517. blurKernel: number;
  9518. private _useKernelBlur;
  9519. /**
  9520. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9521. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9522. */
  9523. /**
  9524. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9525. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9526. */
  9527. useKernelBlur: boolean;
  9528. private _depthScale;
  9529. /**
  9530. * Gets the depth scale used in ESM mode.
  9531. */
  9532. /**
  9533. * Sets the depth scale used in ESM mode.
  9534. * This can override the scale stored on the light.
  9535. */
  9536. depthScale: number;
  9537. private _filter;
  9538. /**
  9539. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9540. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9541. */
  9542. /**
  9543. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9544. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9545. */
  9546. filter: number;
  9547. /**
  9548. * Gets if the current filter is set to Poisson Sampling.
  9549. */
  9550. /**
  9551. * Sets the current filter to Poisson Sampling.
  9552. */
  9553. usePoissonSampling: boolean;
  9554. /**
  9555. * Gets if the current filter is set to ESM.
  9556. */
  9557. /**
  9558. * Sets the current filter is to ESM.
  9559. */
  9560. useExponentialShadowMap: boolean;
  9561. /**
  9562. * Gets if the current filter is set to filtered ESM.
  9563. */
  9564. /**
  9565. * Gets if the current filter is set to filtered ESM.
  9566. */
  9567. useBlurExponentialShadowMap: boolean;
  9568. /**
  9569. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9570. * exponential to prevent steep falloff artifacts).
  9571. */
  9572. /**
  9573. * Sets the current filter to "close ESM" (using the inverse of the
  9574. * exponential to prevent steep falloff artifacts).
  9575. */
  9576. useCloseExponentialShadowMap: boolean;
  9577. /**
  9578. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9579. * exponential to prevent steep falloff artifacts).
  9580. */
  9581. /**
  9582. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9583. * exponential to prevent steep falloff artifacts).
  9584. */
  9585. useBlurCloseExponentialShadowMap: boolean;
  9586. /**
  9587. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9588. */
  9589. /**
  9590. * Sets the current filter to "PCF" (percentage closer filtering).
  9591. */
  9592. usePercentageCloserFiltering: boolean;
  9593. private _filteringQuality;
  9594. /**
  9595. * Gets the PCF or PCSS Quality.
  9596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9597. */
  9598. /**
  9599. * Sets the PCF or PCSS Quality.
  9600. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9601. */
  9602. filteringQuality: number;
  9603. /**
  9604. * Gets if the current filter is set to "PCSS" (contact hardening).
  9605. */
  9606. /**
  9607. * Sets the current filter to "PCSS" (contact hardening).
  9608. */
  9609. useContactHardeningShadow: boolean;
  9610. private _contactHardeningLightSizeUVRatio;
  9611. /**
  9612. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9613. * Using a ratio helps keeping shape stability independently of the map size.
  9614. *
  9615. * It does not account for the light projection as it was having too much
  9616. * instability during the light setup or during light position changes.
  9617. *
  9618. * Only valid if useContactHardeningShadow is true.
  9619. */
  9620. /**
  9621. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9622. * Using a ratio helps keeping shape stability independently of the map size.
  9623. *
  9624. * It does not account for the light projection as it was having too much
  9625. * instability during the light setup or during light position changes.
  9626. *
  9627. * Only valid if useContactHardeningShadow is true.
  9628. */
  9629. contactHardeningLightSizeUVRatio: number;
  9630. private _darkness;
  9631. /** Gets or sets the actual darkness of a shadow */
  9632. darkness: number;
  9633. /**
  9634. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9635. * 0 means strongest and 1 would means no shadow.
  9636. * @returns the darkness.
  9637. */
  9638. getDarkness(): number;
  9639. /**
  9640. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9641. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9642. * @returns the shadow generator allowing fluent coding.
  9643. */
  9644. setDarkness(darkness: number): ShadowGenerator;
  9645. private _transparencyShadow;
  9646. /** Gets or sets the ability to have transparent shadow */
  9647. transparencyShadow: boolean;
  9648. /**
  9649. * Sets the ability to have transparent shadow (boolean).
  9650. * @param transparent True if transparent else False
  9651. * @returns the shadow generator allowing fluent coding
  9652. */
  9653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9654. private _shadowMap;
  9655. private _shadowMap2;
  9656. /**
  9657. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9658. * @returns The render target texture if present otherwise, null
  9659. */
  9660. getShadowMap(): Nullable<RenderTargetTexture>;
  9661. /**
  9662. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9663. * @returns The render target texture if the shadow map is present otherwise, null
  9664. */
  9665. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9666. /**
  9667. * Gets the class name of that object
  9668. * @returns "ShadowGenerator"
  9669. */
  9670. getClassName(): string;
  9671. /**
  9672. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9673. * @param mesh Mesh to add
  9674. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9675. * @returns the Shadow Generator itself
  9676. */
  9677. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9678. /**
  9679. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9680. * @param mesh Mesh to remove
  9681. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9682. * @returns the Shadow Generator itself
  9683. */
  9684. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9685. /**
  9686. * Controls the extent to which the shadows fade out at the edge of the frustum
  9687. * Used only by directionals and spots
  9688. */
  9689. frustumEdgeFalloff: number;
  9690. private _light;
  9691. /**
  9692. * Returns the associated light object.
  9693. * @returns the light generating the shadow
  9694. */
  9695. getLight(): IShadowLight;
  9696. /**
  9697. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9698. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9699. * It might on the other hand introduce peter panning.
  9700. */
  9701. forceBackFacesOnly: boolean;
  9702. private _scene;
  9703. private _lightDirection;
  9704. private _effect;
  9705. private _viewMatrix;
  9706. private _projectionMatrix;
  9707. private _transformMatrix;
  9708. private _cachedPosition;
  9709. private _cachedDirection;
  9710. private _cachedDefines;
  9711. private _currentRenderID;
  9712. private _boxBlurPostprocess;
  9713. private _kernelBlurXPostprocess;
  9714. private _kernelBlurYPostprocess;
  9715. private _blurPostProcesses;
  9716. private _mapSize;
  9717. private _currentFaceIndex;
  9718. private _currentFaceIndexCache;
  9719. private _textureType;
  9720. private _defaultTextureMatrix;
  9721. private _storedUniqueId;
  9722. /** @hidden */
  9723. static _SceneComponentInitialization: (scene: Scene) => void;
  9724. /**
  9725. * Creates a ShadowGenerator object.
  9726. * A ShadowGenerator is the required tool to use the shadows.
  9727. * Each light casting shadows needs to use its own ShadowGenerator.
  9728. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9729. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9730. * @param light The light object generating the shadows.
  9731. * @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.
  9732. */
  9733. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9734. private _initializeGenerator;
  9735. private _initializeShadowMap;
  9736. private _initializeBlurRTTAndPostProcesses;
  9737. private _renderForShadowMap;
  9738. private _renderSubMeshForShadowMap;
  9739. private _applyFilterValues;
  9740. /**
  9741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9742. * @param onCompiled Callback triggered at the and of the effects compilation
  9743. * @param options Sets of optional options forcing the compilation with different modes
  9744. */
  9745. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9746. useInstances: boolean;
  9747. }>): void;
  9748. /**
  9749. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9750. * @param options Sets of optional options forcing the compilation with different modes
  9751. * @returns A promise that resolves when the compilation completes
  9752. */
  9753. forceCompilationAsync(options?: Partial<{
  9754. useInstances: boolean;
  9755. }>): Promise<void>;
  9756. /**
  9757. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9758. * @param subMesh The submesh we want to render in the shadow map
  9759. * @param useInstances Defines wether will draw in the map using instances
  9760. * @returns true if ready otherwise, false
  9761. */
  9762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9763. /**
  9764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9765. * @param defines Defines of the material we want to update
  9766. * @param lightIndex Index of the light in the enabled light list of the material
  9767. */
  9768. prepareDefines(defines: any, lightIndex: number): void;
  9769. /**
  9770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9771. * defined in the generator but impacting the effect).
  9772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9773. * @param effect The effect we are binfing the information for
  9774. */
  9775. bindShadowLight(lightIndex: string, effect: Effect): void;
  9776. /**
  9777. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9778. * (eq to shadow prjection matrix * light transform matrix)
  9779. * @returns The transform matrix used to create the shadow map
  9780. */
  9781. getTransformMatrix(): Matrix;
  9782. /**
  9783. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9784. * Cube and 2D textures for instance.
  9785. */
  9786. recreateShadowMap(): void;
  9787. private _disposeBlurPostProcesses;
  9788. private _disposeRTTandPostProcesses;
  9789. /**
  9790. * Disposes the ShadowGenerator.
  9791. * Returns nothing.
  9792. */
  9793. dispose(): void;
  9794. /**
  9795. * Serializes the shadow generator setup to a json object.
  9796. * @returns The serialized JSON object
  9797. */
  9798. serialize(): any;
  9799. /**
  9800. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9801. * @param parsedShadowGenerator The JSON object to parse
  9802. * @param scene The scene to create the shadow map for
  9803. * @returns The parsed shadow generator
  9804. */
  9805. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9806. }
  9807. }
  9808. declare module BABYLON {
  9809. /**
  9810. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9811. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9812. * 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.
  9813. */
  9814. export abstract class Light extends Node {
  9815. /**
  9816. * Falloff Default: light is falling off following the material specification:
  9817. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9818. */
  9819. static readonly FALLOFF_DEFAULT: number;
  9820. /**
  9821. * Falloff Physical: light is falling off following the inverse squared distance law.
  9822. */
  9823. static readonly FALLOFF_PHYSICAL: number;
  9824. /**
  9825. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9826. * to enhance interoperability with other engines.
  9827. */
  9828. static readonly FALLOFF_GLTF: number;
  9829. /**
  9830. * Falloff Standard: light is falling off like in the standard material
  9831. * to enhance interoperability with other materials.
  9832. */
  9833. static readonly FALLOFF_STANDARD: number;
  9834. /**
  9835. * If every light affecting the material is in this lightmapMode,
  9836. * material.lightmapTexture adds or multiplies
  9837. * (depends on material.useLightmapAsShadowmap)
  9838. * after every other light calculations.
  9839. */
  9840. static readonly LIGHTMAP_DEFAULT: number;
  9841. /**
  9842. * material.lightmapTexture as only diffuse lighting from this light
  9843. * adds only specular lighting from this light
  9844. * adds dynamic shadows
  9845. */
  9846. static readonly LIGHTMAP_SPECULAR: number;
  9847. /**
  9848. * material.lightmapTexture as only lighting
  9849. * no light calculation from this light
  9850. * only adds dynamic shadows from this light
  9851. */
  9852. static readonly LIGHTMAP_SHADOWSONLY: number;
  9853. /**
  9854. * Each light type uses the default quantity according to its type:
  9855. * point/spot lights use luminous intensity
  9856. * directional lights use illuminance
  9857. */
  9858. static readonly INTENSITYMODE_AUTOMATIC: number;
  9859. /**
  9860. * lumen (lm)
  9861. */
  9862. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9863. /**
  9864. * candela (lm/sr)
  9865. */
  9866. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9867. /**
  9868. * lux (lm/m^2)
  9869. */
  9870. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9871. /**
  9872. * nit (cd/m^2)
  9873. */
  9874. static readonly INTENSITYMODE_LUMINANCE: number;
  9875. /**
  9876. * Light type const id of the point light.
  9877. */
  9878. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9879. /**
  9880. * Light type const id of the directional light.
  9881. */
  9882. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9883. /**
  9884. * Light type const id of the spot light.
  9885. */
  9886. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9887. /**
  9888. * Light type const id of the hemispheric light.
  9889. */
  9890. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9891. /**
  9892. * Diffuse gives the basic color to an object.
  9893. */
  9894. diffuse: Color3;
  9895. /**
  9896. * Specular produces a highlight color on an object.
  9897. * Note: This is note affecting PBR materials.
  9898. */
  9899. specular: Color3;
  9900. /**
  9901. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9902. * falling off base on range or angle.
  9903. * This can be set to any values in Light.FALLOFF_x.
  9904. *
  9905. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9906. * other types of materials.
  9907. */
  9908. falloffType: number;
  9909. /**
  9910. * Strength of the light.
  9911. * Note: By default it is define in the framework own unit.
  9912. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9913. */
  9914. intensity: number;
  9915. private _range;
  9916. protected _inverseSquaredRange: number;
  9917. /**
  9918. * Defines how far from the source the light is impacting in scene units.
  9919. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9920. */
  9921. /**
  9922. * Defines how far from the source the light is impacting in scene units.
  9923. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9924. */
  9925. range: number;
  9926. /**
  9927. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9928. * of light.
  9929. */
  9930. private _photometricScale;
  9931. private _intensityMode;
  9932. /**
  9933. * Gets the photometric scale used to interpret the intensity.
  9934. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9935. */
  9936. /**
  9937. * Sets the photometric scale used to interpret the intensity.
  9938. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9939. */
  9940. intensityMode: number;
  9941. private _radius;
  9942. /**
  9943. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9944. */
  9945. /**
  9946. * sets the light radius used by PBR Materials to simulate soft area lights.
  9947. */
  9948. radius: number;
  9949. private _renderPriority;
  9950. /**
  9951. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9952. * exceeding the number allowed of the materials.
  9953. */
  9954. renderPriority: number;
  9955. private _shadowEnabled;
  9956. /**
  9957. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9958. * the current shadow generator.
  9959. */
  9960. /**
  9961. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9962. * the current shadow generator.
  9963. */
  9964. shadowEnabled: boolean;
  9965. private _includedOnlyMeshes;
  9966. /**
  9967. * Gets the only meshes impacted by this light.
  9968. */
  9969. /**
  9970. * Sets the only meshes impacted by this light.
  9971. */
  9972. includedOnlyMeshes: AbstractMesh[];
  9973. private _excludedMeshes;
  9974. /**
  9975. * Gets the meshes not impacted by this light.
  9976. */
  9977. /**
  9978. * Sets the meshes not impacted by this light.
  9979. */
  9980. excludedMeshes: AbstractMesh[];
  9981. private _excludeWithLayerMask;
  9982. /**
  9983. * Gets the layer id use to find what meshes are not impacted by the light.
  9984. * Inactive if 0
  9985. */
  9986. /**
  9987. * Sets the layer id use to find what meshes are not impacted by the light.
  9988. * Inactive if 0
  9989. */
  9990. excludeWithLayerMask: number;
  9991. private _includeOnlyWithLayerMask;
  9992. /**
  9993. * Gets the layer id use to find what meshes are impacted by the light.
  9994. * Inactive if 0
  9995. */
  9996. /**
  9997. * Sets the layer id use to find what meshes are impacted by the light.
  9998. * Inactive if 0
  9999. */
  10000. includeOnlyWithLayerMask: number;
  10001. private _lightmapMode;
  10002. /**
  10003. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10004. */
  10005. /**
  10006. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10007. */
  10008. lightmapMode: number;
  10009. /**
  10010. * Shadow generator associted to the light.
  10011. * @hidden Internal use only.
  10012. */
  10013. _shadowGenerator: Nullable<IShadowGenerator>;
  10014. /**
  10015. * @hidden Internal use only.
  10016. */
  10017. _excludedMeshesIds: string[];
  10018. /**
  10019. * @hidden Internal use only.
  10020. */
  10021. _includedOnlyMeshesIds: string[];
  10022. /**
  10023. * The current light unifom buffer.
  10024. * @hidden Internal use only.
  10025. */
  10026. _uniformBuffer: UniformBuffer;
  10027. /** @hidden */
  10028. _renderId: number;
  10029. /**
  10030. * Creates a Light object in the scene.
  10031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10032. * @param name The firendly name of the light
  10033. * @param scene The scene the light belongs too
  10034. */
  10035. constructor(name: string, scene: Scene);
  10036. protected abstract _buildUniformLayout(): void;
  10037. /**
  10038. * Sets the passed Effect "effect" with the Light information.
  10039. * @param effect The effect to update
  10040. * @param lightIndex The index of the light in the effect to update
  10041. * @returns The light
  10042. */
  10043. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10044. /**
  10045. * Sets the passed Effect "effect" with the Light information.
  10046. * @param effect The effect to update
  10047. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10048. * @returns The light
  10049. */
  10050. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10051. /**
  10052. * Returns the string "Light".
  10053. * @returns the class name
  10054. */
  10055. getClassName(): string;
  10056. /** @hidden */
  10057. readonly _isLight: boolean;
  10058. /**
  10059. * Converts the light information to a readable string for debug purpose.
  10060. * @param fullDetails Supports for multiple levels of logging within scene loading
  10061. * @returns the human readable light info
  10062. */
  10063. toString(fullDetails?: boolean): string;
  10064. /** @hidden */
  10065. protected _syncParentEnabledState(): void;
  10066. /**
  10067. * Set the enabled state of this node.
  10068. * @param value - the new enabled state
  10069. */
  10070. setEnabled(value: boolean): void;
  10071. /**
  10072. * Returns the Light associated shadow generator if any.
  10073. * @return the associated shadow generator.
  10074. */
  10075. getShadowGenerator(): Nullable<IShadowGenerator>;
  10076. /**
  10077. * Returns a Vector3, the absolute light position in the World.
  10078. * @returns the world space position of the light
  10079. */
  10080. getAbsolutePosition(): Vector3;
  10081. /**
  10082. * Specifies if the light will affect the passed mesh.
  10083. * @param mesh The mesh to test against the light
  10084. * @return true the mesh is affected otherwise, false.
  10085. */
  10086. canAffectMesh(mesh: AbstractMesh): boolean;
  10087. /**
  10088. * Sort function to order lights for rendering.
  10089. * @param a First Light object to compare to second.
  10090. * @param b Second Light object to compare first.
  10091. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10092. */
  10093. static CompareLightsPriority(a: Light, b: Light): number;
  10094. /**
  10095. * Releases resources associated with this node.
  10096. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10097. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10098. */
  10099. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10100. /**
  10101. * Returns the light type ID (integer).
  10102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10103. */
  10104. getTypeID(): number;
  10105. /**
  10106. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10107. * @returns the scaled intensity in intensity mode unit
  10108. */
  10109. getScaledIntensity(): number;
  10110. /**
  10111. * Returns a new Light object, named "name", from the current one.
  10112. * @param name The name of the cloned light
  10113. * @returns the new created light
  10114. */
  10115. clone(name: string): Nullable<Light>;
  10116. /**
  10117. * Serializes the current light into a Serialization object.
  10118. * @returns the serialized object.
  10119. */
  10120. serialize(): any;
  10121. /**
  10122. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10123. * This new light is named "name" and added to the passed scene.
  10124. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10125. * @param name The friendly name of the light
  10126. * @param scene The scene the new light will belong to
  10127. * @returns the constructor function
  10128. */
  10129. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10130. /**
  10131. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10132. * @param parsedLight The JSON representation of the light
  10133. * @param scene The scene to create the parsed light in
  10134. * @returns the created light after parsing
  10135. */
  10136. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10137. private _hookArrayForExcluded;
  10138. private _hookArrayForIncludedOnly;
  10139. private _resyncMeshes;
  10140. /**
  10141. * Forces the meshes to update their light related information in their rendering used effects
  10142. * @hidden Internal Use Only
  10143. */
  10144. _markMeshesAsLightDirty(): void;
  10145. /**
  10146. * Recomputes the cached photometric scale if needed.
  10147. */
  10148. private _computePhotometricScale;
  10149. /**
  10150. * Returns the Photometric Scale according to the light type and intensity mode.
  10151. */
  10152. private _getPhotometricScale;
  10153. /**
  10154. * Reorder the light in the scene according to their defined priority.
  10155. * @hidden Internal Use Only
  10156. */
  10157. _reorderLightsInScene(): void;
  10158. /**
  10159. * Prepares the list of defines specific to the light type.
  10160. * @param defines the list of defines
  10161. * @param lightIndex defines the index of the light for the effect
  10162. */
  10163. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10164. }
  10165. }
  10166. declare module BABYLON {
  10167. /**
  10168. * Interface used to define Action
  10169. */
  10170. export interface IAction {
  10171. /**
  10172. * Trigger for the action
  10173. */
  10174. trigger: number;
  10175. /** Options of the trigger */
  10176. triggerOptions: any;
  10177. /**
  10178. * Gets the trigger parameters
  10179. * @returns the trigger parameters
  10180. */
  10181. getTriggerParameter(): any;
  10182. /**
  10183. * Internal only - executes current action event
  10184. * @hidden
  10185. */
  10186. _executeCurrent(evt?: ActionEvent): void;
  10187. /**
  10188. * Serialize placeholder for child classes
  10189. * @param parent of child
  10190. * @returns the serialized object
  10191. */
  10192. serialize(parent: any): any;
  10193. /**
  10194. * Internal only
  10195. * @hidden
  10196. */
  10197. _prepare(): void;
  10198. /**
  10199. * Internal only - manager for action
  10200. * @hidden
  10201. */
  10202. _actionManager: AbstractActionManager;
  10203. /**
  10204. * Adds action to chain of actions, may be a DoNothingAction
  10205. * @param action defines the next action to execute
  10206. * @returns The action passed in
  10207. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10208. */
  10209. then(action: IAction): IAction;
  10210. }
  10211. /**
  10212. * The action to be carried out following a trigger
  10213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10214. */
  10215. export class Action implements IAction {
  10216. /** the trigger, with or without parameters, for the action */
  10217. triggerOptions: any;
  10218. /**
  10219. * Trigger for the action
  10220. */
  10221. trigger: number;
  10222. /**
  10223. * Internal only - manager for action
  10224. * @hidden
  10225. */
  10226. _actionManager: ActionManager;
  10227. private _nextActiveAction;
  10228. private _child;
  10229. private _condition?;
  10230. private _triggerParameter;
  10231. /**
  10232. * An event triggered prior to action being executed.
  10233. */
  10234. onBeforeExecuteObservable: Observable<Action>;
  10235. /**
  10236. * Creates a new Action
  10237. * @param triggerOptions the trigger, with or without parameters, for the action
  10238. * @param condition an optional determinant of action
  10239. */
  10240. constructor(
  10241. /** the trigger, with or without parameters, for the action */
  10242. triggerOptions: any, condition?: Condition);
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _prepare(): void;
  10248. /**
  10249. * Gets the trigger parameters
  10250. * @returns the trigger parameters
  10251. */
  10252. getTriggerParameter(): any;
  10253. /**
  10254. * Internal only - executes current action event
  10255. * @hidden
  10256. */
  10257. _executeCurrent(evt?: ActionEvent): void;
  10258. /**
  10259. * Execute placeholder for child classes
  10260. * @param evt optional action event
  10261. */
  10262. execute(evt?: ActionEvent): void;
  10263. /**
  10264. * Skips to next active action
  10265. */
  10266. skipToNextActiveAction(): void;
  10267. /**
  10268. * Adds action to chain of actions, may be a DoNothingAction
  10269. * @param action defines the next action to execute
  10270. * @returns The action passed in
  10271. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10272. */
  10273. then(action: Action): Action;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _getProperty(propertyPath: string): string;
  10279. /**
  10280. * Internal only
  10281. * @hidden
  10282. */
  10283. _getEffectiveTarget(target: any, propertyPath: string): any;
  10284. /**
  10285. * Serialize placeholder for child classes
  10286. * @param parent of child
  10287. * @returns the serialized object
  10288. */
  10289. serialize(parent: any): any;
  10290. /**
  10291. * Internal only called by serialize
  10292. * @hidden
  10293. */
  10294. protected _serialize(serializedAction: any, parent?: any): any;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. static _SerializeValueAsString: (value: any) => string;
  10300. /**
  10301. * Internal only
  10302. * @hidden
  10303. */
  10304. static _GetTargetProperty: (target: Node | Scene) => {
  10305. name: string;
  10306. targetType: string;
  10307. value: string;
  10308. };
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * A Condition applied to an Action
  10314. */
  10315. export class Condition {
  10316. /**
  10317. * Internal only - manager for action
  10318. * @hidden
  10319. */
  10320. _actionManager: ActionManager;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. _evaluationId: number;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _currentResult: boolean;
  10331. /**
  10332. * Creates a new Condition
  10333. * @param actionManager the manager of the action the condition is applied to
  10334. */
  10335. constructor(actionManager: ActionManager);
  10336. /**
  10337. * Check if the current condition is valid
  10338. * @returns a boolean
  10339. */
  10340. isValid(): boolean;
  10341. /**
  10342. * Internal only
  10343. * @hidden
  10344. */
  10345. _getProperty(propertyPath: string): string;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. _getEffectiveTarget(target: any, propertyPath: string): any;
  10351. /**
  10352. * Serialize placeholder for child classes
  10353. * @returns the serialized object
  10354. */
  10355. serialize(): any;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. protected _serialize(serializedCondition: any): any;
  10361. }
  10362. /**
  10363. * Defines specific conditional operators as extensions of Condition
  10364. */
  10365. export class ValueCondition extends Condition {
  10366. /** path to specify the property of the target the conditional operator uses */
  10367. propertyPath: string;
  10368. /** the value compared by the conditional operator against the current value of the property */
  10369. value: any;
  10370. /** the conditional operator, default ValueCondition.IsEqual */
  10371. operator: number;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. private static _IsEqual;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. private static _IsDifferent;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. private static _IsGreater;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. private static _IsLesser;
  10392. /**
  10393. * returns the number for IsEqual
  10394. */
  10395. static readonly IsEqual: number;
  10396. /**
  10397. * Returns the number for IsDifferent
  10398. */
  10399. static readonly IsDifferent: number;
  10400. /**
  10401. * Returns the number for IsGreater
  10402. */
  10403. static readonly IsGreater: number;
  10404. /**
  10405. * Returns the number for IsLesser
  10406. */
  10407. static readonly IsLesser: number;
  10408. /**
  10409. * Internal only The action manager for the condition
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. private _target;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. private _effectiveTarget;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. private _property;
  10428. /**
  10429. * Creates a new ValueCondition
  10430. * @param actionManager manager for the action the condition applies to
  10431. * @param target for the action
  10432. * @param propertyPath path to specify the property of the target the conditional operator uses
  10433. * @param value the value compared by the conditional operator against the current value of the property
  10434. * @param operator the conditional operator, default ValueCondition.IsEqual
  10435. */
  10436. constructor(actionManager: ActionManager, target: any,
  10437. /** path to specify the property of the target the conditional operator uses */
  10438. propertyPath: string,
  10439. /** the value compared by the conditional operator against the current value of the property */
  10440. value: any,
  10441. /** the conditional operator, default ValueCondition.IsEqual */
  10442. operator?: number);
  10443. /**
  10444. * Compares the given value with the property value for the specified conditional operator
  10445. * @returns the result of the comparison
  10446. */
  10447. isValid(): boolean;
  10448. /**
  10449. * Serialize the ValueCondition into a JSON compatible object
  10450. * @returns serialization object
  10451. */
  10452. serialize(): any;
  10453. /**
  10454. * Gets the name of the conditional operator for the ValueCondition
  10455. * @param operator the conditional operator
  10456. * @returns the name
  10457. */
  10458. static GetOperatorName(operator: number): string;
  10459. }
  10460. /**
  10461. * Defines a predicate condition as an extension of Condition
  10462. */
  10463. export class PredicateCondition extends Condition {
  10464. /** defines the predicate function used to validate the condition */
  10465. predicate: () => boolean;
  10466. /**
  10467. * Internal only - manager for action
  10468. * @hidden
  10469. */
  10470. _actionManager: ActionManager;
  10471. /**
  10472. * Creates a new PredicateCondition
  10473. * @param actionManager manager for the action the condition applies to
  10474. * @param predicate defines the predicate function used to validate the condition
  10475. */
  10476. constructor(actionManager: ActionManager,
  10477. /** defines the predicate function used to validate the condition */
  10478. predicate: () => boolean);
  10479. /**
  10480. * @returns the validity of the predicate condition
  10481. */
  10482. isValid(): boolean;
  10483. }
  10484. /**
  10485. * Defines a state condition as an extension of Condition
  10486. */
  10487. export class StateCondition extends Condition {
  10488. /** Value to compare with target state */
  10489. value: string;
  10490. /**
  10491. * Internal only - manager for action
  10492. * @hidden
  10493. */
  10494. _actionManager: ActionManager;
  10495. /**
  10496. * Internal only
  10497. * @hidden
  10498. */
  10499. private _target;
  10500. /**
  10501. * Creates a new StateCondition
  10502. * @param actionManager manager for the action the condition applies to
  10503. * @param target of the condition
  10504. * @param value to compare with target state
  10505. */
  10506. constructor(actionManager: ActionManager, target: any,
  10507. /** Value to compare with target state */
  10508. value: string);
  10509. /**
  10510. * Gets a boolean indicating if the current condition is met
  10511. * @returns the validity of the state
  10512. */
  10513. isValid(): boolean;
  10514. /**
  10515. * Serialize the StateCondition into a JSON compatible object
  10516. * @returns serialization object
  10517. */
  10518. serialize(): any;
  10519. }
  10520. }
  10521. declare module BABYLON {
  10522. /**
  10523. * This defines an action responsible to toggle a boolean once triggered.
  10524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10525. */
  10526. export class SwitchBooleanAction extends Action {
  10527. /**
  10528. * The path to the boolean property in the target object
  10529. */
  10530. propertyPath: string;
  10531. private _target;
  10532. private _effectiveTarget;
  10533. private _property;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the boolean
  10538. * @param propertyPath defines the path to the boolean property in the target object
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10542. /** @hidden */
  10543. _prepare(): void;
  10544. /**
  10545. * Execute the action toggle the boolean value.
  10546. */
  10547. execute(): void;
  10548. /**
  10549. * Serializes the actions and its related information.
  10550. * @param parent defines the object to serialize in
  10551. * @returns the serialized object
  10552. */
  10553. serialize(parent: any): any;
  10554. }
  10555. /**
  10556. * This defines an action responsible to set a the state field of the target
  10557. * to a desired value once triggered.
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10559. */
  10560. export class SetStateAction extends Action {
  10561. /**
  10562. * The value to store in the state field.
  10563. */
  10564. value: string;
  10565. private _target;
  10566. /**
  10567. * Instantiate the action
  10568. * @param triggerOptions defines the trigger options
  10569. * @param target defines the object containing the state property
  10570. * @param value defines the value to store in the state field
  10571. * @param condition defines the trigger related conditions
  10572. */
  10573. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10574. /**
  10575. * Execute the action and store the value on the target state property.
  10576. */
  10577. execute(): void;
  10578. /**
  10579. * Serializes the actions and its related information.
  10580. * @param parent defines the object to serialize in
  10581. * @returns the serialized object
  10582. */
  10583. serialize(parent: any): any;
  10584. }
  10585. /**
  10586. * This defines an action responsible to set a property of the target
  10587. * to a desired value once triggered.
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10589. */
  10590. export class SetValueAction extends Action {
  10591. /**
  10592. * The path of the property to set in the target.
  10593. */
  10594. propertyPath: string;
  10595. /**
  10596. * The value to set in the property
  10597. */
  10598. value: any;
  10599. private _target;
  10600. private _effectiveTarget;
  10601. private _property;
  10602. /**
  10603. * Instantiate the action
  10604. * @param triggerOptions defines the trigger options
  10605. * @param target defines the object containing the property
  10606. * @param propertyPath defines the path of the property to set in the target
  10607. * @param value defines the value to set in the property
  10608. * @param condition defines the trigger related conditions
  10609. */
  10610. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10611. /** @hidden */
  10612. _prepare(): void;
  10613. /**
  10614. * Execute the action and set the targetted property to the desired value.
  10615. */
  10616. execute(): void;
  10617. /**
  10618. * Serializes the actions and its related information.
  10619. * @param parent defines the object to serialize in
  10620. * @returns the serialized object
  10621. */
  10622. serialize(parent: any): any;
  10623. }
  10624. /**
  10625. * This defines an action responsible to increment the target value
  10626. * to a desired value once triggered.
  10627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10628. */
  10629. export class IncrementValueAction extends Action {
  10630. /**
  10631. * The path of the property to increment in the target.
  10632. */
  10633. propertyPath: string;
  10634. /**
  10635. * The value we should increment the property by.
  10636. */
  10637. value: any;
  10638. private _target;
  10639. private _effectiveTarget;
  10640. private _property;
  10641. /**
  10642. * Instantiate the action
  10643. * @param triggerOptions defines the trigger options
  10644. * @param target defines the object containing the property
  10645. * @param propertyPath defines the path of the property to increment in the target
  10646. * @param value defines the value value we should increment the property by
  10647. * @param condition defines the trigger related conditions
  10648. */
  10649. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10650. /** @hidden */
  10651. _prepare(): void;
  10652. /**
  10653. * Execute the action and increment the target of the value amount.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to start an animation once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class PlayAnimationAction extends Action {
  10668. /**
  10669. * Where the animation should start (animation frame)
  10670. */
  10671. from: number;
  10672. /**
  10673. * Where the animation should stop (animation frame)
  10674. */
  10675. to: number;
  10676. /**
  10677. * Define if the animation should loop or stop after the first play.
  10678. */
  10679. loop?: boolean;
  10680. private _target;
  10681. /**
  10682. * Instantiate the action
  10683. * @param triggerOptions defines the trigger options
  10684. * @param target defines the target animation or animation name
  10685. * @param from defines from where the animation should start (animation frame)
  10686. * @param end defines where the animation should stop (animation frame)
  10687. * @param loop defines if the animation should loop or stop after the first play
  10688. * @param condition defines the trigger related conditions
  10689. */
  10690. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10691. /** @hidden */
  10692. _prepare(): void;
  10693. /**
  10694. * Execute the action and play the animation.
  10695. */
  10696. execute(): void;
  10697. /**
  10698. * Serializes the actions and its related information.
  10699. * @param parent defines the object to serialize in
  10700. * @returns the serialized object
  10701. */
  10702. serialize(parent: any): any;
  10703. }
  10704. /**
  10705. * This defines an action responsible to stop an animation once triggered.
  10706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10707. */
  10708. export class StopAnimationAction extends Action {
  10709. private _target;
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param target defines the target animation or animation name
  10714. * @param condition defines the trigger related conditions
  10715. */
  10716. constructor(triggerOptions: any, target: any, condition?: Condition);
  10717. /** @hidden */
  10718. _prepare(): void;
  10719. /**
  10720. * Execute the action and stop the animation.
  10721. */
  10722. execute(): void;
  10723. /**
  10724. * Serializes the actions and its related information.
  10725. * @param parent defines the object to serialize in
  10726. * @returns the serialized object
  10727. */
  10728. serialize(parent: any): any;
  10729. }
  10730. /**
  10731. * This defines an action responsible that does nothing once triggered.
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10733. */
  10734. export class DoNothingAction extends Action {
  10735. /**
  10736. * Instantiate the action
  10737. * @param triggerOptions defines the trigger options
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions?: any, condition?: Condition);
  10741. /**
  10742. * Execute the action and do nothing.
  10743. */
  10744. execute(): void;
  10745. /**
  10746. * Serializes the actions and its related information.
  10747. * @param parent defines the object to serialize in
  10748. * @returns the serialized object
  10749. */
  10750. serialize(parent: any): any;
  10751. }
  10752. /**
  10753. * This defines an action responsible to trigger several actions once triggered.
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10755. */
  10756. export class CombineAction extends Action {
  10757. /**
  10758. * The list of aggregated animations to run.
  10759. */
  10760. children: Action[];
  10761. /**
  10762. * Instantiate the action
  10763. * @param triggerOptions defines the trigger options
  10764. * @param children defines the list of aggregated animations to run
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and executes all the aggregated actions.
  10772. */
  10773. execute(evt: ActionEvent): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. /**
  10782. * This defines an action responsible to run code (external event) once triggered.
  10783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10784. */
  10785. export class ExecuteCodeAction extends Action {
  10786. /**
  10787. * The callback function to run.
  10788. */
  10789. func: (evt: ActionEvent) => void;
  10790. /**
  10791. * Instantiate the action
  10792. * @param triggerOptions defines the trigger options
  10793. * @param func defines the callback function to run
  10794. * @param condition defines the trigger related conditions
  10795. */
  10796. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10797. /**
  10798. * Execute the action and run the attached code.
  10799. */
  10800. execute(evt: ActionEvent): void;
  10801. }
  10802. /**
  10803. * This defines an action responsible to set the parent property of the target once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class SetParentAction extends Action {
  10807. private _parent;
  10808. private _target;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the target containing the parent property
  10813. * @param parent defines from where the animation should start (animation frame)
  10814. * @param condition defines the trigger related conditions
  10815. */
  10816. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10817. /** @hidden */
  10818. _prepare(): void;
  10819. /**
  10820. * Execute the action and set the parent property.
  10821. */
  10822. execute(): void;
  10823. /**
  10824. * Serializes the actions and its related information.
  10825. * @param parent defines the object to serialize in
  10826. * @returns the serialized object
  10827. */
  10828. serialize(parent: any): any;
  10829. }
  10830. }
  10831. declare module BABYLON {
  10832. /**
  10833. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10834. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class ActionManager extends AbstractActionManager {
  10838. /**
  10839. * Nothing
  10840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10841. */
  10842. static readonly NothingTrigger: number;
  10843. /**
  10844. * On pick
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10846. */
  10847. static readonly OnPickTrigger: number;
  10848. /**
  10849. * On left pick
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10851. */
  10852. static readonly OnLeftPickTrigger: number;
  10853. /**
  10854. * On right pick
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnRightPickTrigger: number;
  10858. /**
  10859. * On center pick
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnCenterPickTrigger: number;
  10863. /**
  10864. * On pick down
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPickDownTrigger: number;
  10868. /**
  10869. * On double pick
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnDoublePickTrigger: number;
  10873. /**
  10874. * On pick up
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnPickUpTrigger: number;
  10878. /**
  10879. * On pick out.
  10880. * This trigger will only be raised if you also declared a OnPickDown
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10882. */
  10883. static readonly OnPickOutTrigger: number;
  10884. /**
  10885. * On long press
  10886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10887. */
  10888. static readonly OnLongPressTrigger: number;
  10889. /**
  10890. * On pointer over
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10892. */
  10893. static readonly OnPointerOverTrigger: number;
  10894. /**
  10895. * On pointer out
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10897. */
  10898. static readonly OnPointerOutTrigger: number;
  10899. /**
  10900. * On every frame
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnEveryFrameTrigger: number;
  10904. /**
  10905. * On intersection enter
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnIntersectionEnterTrigger: number;
  10909. /**
  10910. * On intersection exit
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnIntersectionExitTrigger: number;
  10914. /**
  10915. * On key down
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnKeyDownTrigger: number;
  10919. /**
  10920. * On key up
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnKeyUpTrigger: number;
  10924. private _scene;
  10925. /**
  10926. * Creates a new action manager
  10927. * @param scene defines the hosting scene
  10928. */
  10929. constructor(scene: Scene);
  10930. /**
  10931. * Releases all associated resources
  10932. */
  10933. dispose(): void;
  10934. /**
  10935. * Gets hosting scene
  10936. * @returns the hosting scene
  10937. */
  10938. getScene(): Scene;
  10939. /**
  10940. * Does this action manager handles actions of any of the given triggers
  10941. * @param triggers defines the triggers to be tested
  10942. * @return a boolean indicating whether one (or more) of the triggers is handled
  10943. */
  10944. hasSpecificTriggers(triggers: number[]): boolean;
  10945. /**
  10946. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10947. * speed.
  10948. * @param triggerA defines the trigger to be tested
  10949. * @param triggerB defines the trigger to be tested
  10950. * @return a boolean indicating whether one (or more) of the triggers is handled
  10951. */
  10952. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10953. /**
  10954. * Does this action manager handles actions of a given trigger
  10955. * @param trigger defines the trigger to be tested
  10956. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10957. * @return whether the trigger is handled
  10958. */
  10959. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10960. /**
  10961. * Does this action manager has pointer triggers
  10962. */
  10963. readonly hasPointerTriggers: boolean;
  10964. /**
  10965. * Does this action manager has pick triggers
  10966. */
  10967. readonly hasPickTriggers: boolean;
  10968. /**
  10969. * Registers an action to this action manager
  10970. * @param action defines the action to be registered
  10971. * @return the action amended (prepared) after registration
  10972. */
  10973. registerAction(action: IAction): Nullable<IAction>;
  10974. /**
  10975. * Unregisters an action to this action manager
  10976. * @param action defines the action to be unregistered
  10977. * @return a boolean indicating whether the action has been unregistered
  10978. */
  10979. unregisterAction(action: IAction): Boolean;
  10980. /**
  10981. * Process a specific trigger
  10982. * @param trigger defines the trigger to process
  10983. * @param evt defines the event details to be processed
  10984. */
  10985. processTrigger(trigger: number, evt?: IActionEvent): void;
  10986. /** @hidden */
  10987. _getEffectiveTarget(target: any, propertyPath: string): any;
  10988. /** @hidden */
  10989. _getProperty(propertyPath: string): string;
  10990. /**
  10991. * Serialize this manager to a JSON object
  10992. * @param name defines the property name to store this manager
  10993. * @returns a JSON representation of this manager
  10994. */
  10995. serialize(name: string): any;
  10996. /**
  10997. * Creates a new ActionManager from a JSON data
  10998. * @param parsedActions defines the JSON data to read from
  10999. * @param object defines the hosting mesh
  11000. * @param scene defines the hosting scene
  11001. */
  11002. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11003. /**
  11004. * Get a trigger name by index
  11005. * @param trigger defines the trigger index
  11006. * @returns a trigger name
  11007. */
  11008. static GetTriggerName(trigger: number): string;
  11009. }
  11010. }
  11011. declare module BABYLON {
  11012. /**
  11013. * Class representing a ray with position and direction
  11014. */
  11015. export class Ray {
  11016. /** origin point */
  11017. origin: Vector3;
  11018. /** direction */
  11019. direction: Vector3;
  11020. /** length of the ray */
  11021. length: number;
  11022. private static readonly TmpVector3;
  11023. private _tmpRay;
  11024. /**
  11025. * Creates a new ray
  11026. * @param origin origin point
  11027. * @param direction direction
  11028. * @param length length of the ray
  11029. */
  11030. constructor(
  11031. /** origin point */
  11032. origin: Vector3,
  11033. /** direction */
  11034. direction: Vector3,
  11035. /** length of the ray */
  11036. length?: number);
  11037. /**
  11038. * Checks if the ray intersects a box
  11039. * @param minimum bound of the box
  11040. * @param maximum bound of the box
  11041. * @param intersectionTreshold extra extend to be added to the box in all direction
  11042. * @returns if the box was hit
  11043. */
  11044. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11045. /**
  11046. * Checks if the ray intersects a box
  11047. * @param box the bounding box to check
  11048. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11049. * @returns if the box was hit
  11050. */
  11051. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11052. /**
  11053. * If the ray hits a sphere
  11054. * @param sphere the bounding sphere to check
  11055. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11056. * @returns true if it hits the sphere
  11057. */
  11058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11059. /**
  11060. * If the ray hits a triange
  11061. * @param vertex0 triangle vertex
  11062. * @param vertex1 triangle vertex
  11063. * @param vertex2 triangle vertex
  11064. * @returns intersection information if hit
  11065. */
  11066. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11067. /**
  11068. * Checks if ray intersects a plane
  11069. * @param plane the plane to check
  11070. * @returns the distance away it was hit
  11071. */
  11072. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11073. /**
  11074. * Calculate the intercept of a ray on a given axis
  11075. * @param axis to check 'x' | 'y' | 'z'
  11076. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11077. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11078. */
  11079. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11080. /**
  11081. * Checks if ray intersects a mesh
  11082. * @param mesh the mesh to check
  11083. * @param fastCheck if only the bounding box should checked
  11084. * @returns picking info of the intersecton
  11085. */
  11086. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11087. /**
  11088. * Checks if ray intersects a mesh
  11089. * @param meshes the meshes to check
  11090. * @param fastCheck if only the bounding box should checked
  11091. * @param results array to store result in
  11092. * @returns Array of picking infos
  11093. */
  11094. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11095. private _comparePickingInfo;
  11096. private static smallnum;
  11097. private static rayl;
  11098. /**
  11099. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11100. * @param sega the first point of the segment to test the intersection against
  11101. * @param segb the second point of the segment to test the intersection against
  11102. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11103. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11104. */
  11105. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11106. /**
  11107. * Update the ray from viewport position
  11108. * @param x position
  11109. * @param y y position
  11110. * @param viewportWidth viewport width
  11111. * @param viewportHeight viewport height
  11112. * @param world world matrix
  11113. * @param view view matrix
  11114. * @param projection projection matrix
  11115. * @returns this ray updated
  11116. */
  11117. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11118. /**
  11119. * Creates a ray with origin and direction of 0,0,0
  11120. * @returns the new ray
  11121. */
  11122. static Zero(): Ray;
  11123. /**
  11124. * Creates a new ray from screen space and viewport
  11125. * @param x position
  11126. * @param y y position
  11127. * @param viewportWidth viewport width
  11128. * @param viewportHeight viewport height
  11129. * @param world world matrix
  11130. * @param view view matrix
  11131. * @param projection projection matrix
  11132. * @returns new ray
  11133. */
  11134. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11135. /**
  11136. * 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
  11137. * transformed to the given world matrix.
  11138. * @param origin The origin point
  11139. * @param end The end point
  11140. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11141. * @returns the new ray
  11142. */
  11143. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11144. /**
  11145. * Transforms a ray by a matrix
  11146. * @param ray ray to transform
  11147. * @param matrix matrix to apply
  11148. * @returns the resulting new ray
  11149. */
  11150. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11151. /**
  11152. * Transforms a ray by a matrix
  11153. * @param ray ray to transform
  11154. * @param matrix matrix to apply
  11155. * @param result ray to store result in
  11156. */
  11157. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11158. /**
  11159. * Unproject a ray from screen space to object space
  11160. * @param sourceX defines the screen space x coordinate to use
  11161. * @param sourceY defines the screen space y coordinate to use
  11162. * @param viewportWidth defines the current width of the viewport
  11163. * @param viewportHeight defines the current height of the viewport
  11164. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11165. * @param view defines the view matrix to use
  11166. * @param projection defines the projection matrix to use
  11167. */
  11168. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11169. }
  11170. /**
  11171. * Type used to define predicate used to select faces when a mesh intersection is detected
  11172. */
  11173. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11174. interface Scene {
  11175. /** @hidden */
  11176. _tempPickingRay: Nullable<Ray>;
  11177. /** @hidden */
  11178. _cachedRayForTransform: Ray;
  11179. /** @hidden */
  11180. _pickWithRayInverseMatrix: Matrix;
  11181. /** @hidden */
  11182. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11183. /** @hidden */
  11184. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11185. }
  11186. }
  11187. declare module BABYLON {
  11188. /**
  11189. * Groups all the scene component constants in one place to ease maintenance.
  11190. * @hidden
  11191. */
  11192. export class SceneComponentConstants {
  11193. static readonly NAME_EFFECTLAYER: string;
  11194. static readonly NAME_LAYER: string;
  11195. static readonly NAME_LENSFLARESYSTEM: string;
  11196. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11197. static readonly NAME_PARTICLESYSTEM: string;
  11198. static readonly NAME_GAMEPAD: string;
  11199. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11200. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11201. static readonly NAME_DEPTHRENDERER: string;
  11202. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11203. static readonly NAME_SPRITE: string;
  11204. static readonly NAME_OUTLINERENDERER: string;
  11205. static readonly NAME_PROCEDURALTEXTURE: string;
  11206. static readonly NAME_SHADOWGENERATOR: string;
  11207. static readonly NAME_OCTREE: string;
  11208. static readonly NAME_PHYSICSENGINE: string;
  11209. static readonly NAME_AUDIO: string;
  11210. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11211. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11212. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11215. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11217. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11219. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11222. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11224. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11225. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11226. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11228. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11229. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11230. static readonly STEP_AFTERRENDER_AUDIO: number;
  11231. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11235. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11236. static readonly STEP_POINTERMOVE_SPRITE: number;
  11237. static readonly STEP_POINTERDOWN_SPRITE: number;
  11238. static readonly STEP_POINTERUP_SPRITE: number;
  11239. }
  11240. /**
  11241. * This represents a scene component.
  11242. *
  11243. * This is used to decouple the dependency the scene is having on the different workloads like
  11244. * layers, post processes...
  11245. */
  11246. export interface ISceneComponent {
  11247. /**
  11248. * The name of the component. Each component must have a unique name.
  11249. */
  11250. name: string;
  11251. /**
  11252. * The scene the component belongs to.
  11253. */
  11254. scene: Scene;
  11255. /**
  11256. * Register the component to one instance of a scene.
  11257. */
  11258. register(): void;
  11259. /**
  11260. * Rebuilds the elements related to this component in case of
  11261. * context lost for instance.
  11262. */
  11263. rebuild(): void;
  11264. /**
  11265. * Disposes the component and the associated ressources.
  11266. */
  11267. dispose(): void;
  11268. }
  11269. /**
  11270. * This represents a SERIALIZABLE scene component.
  11271. *
  11272. * This extends Scene Component to add Serialization methods on top.
  11273. */
  11274. export interface ISceneSerializableComponent extends ISceneComponent {
  11275. /**
  11276. * Adds all the elements from the container to the scene
  11277. * @param container the container holding the elements
  11278. */
  11279. addFromContainer(container: AbstractScene): void;
  11280. /**
  11281. * Removes all the elements in the container from the scene
  11282. * @param container contains the elements to remove
  11283. * @param dispose if the removed element should be disposed (default: false)
  11284. */
  11285. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11286. /**
  11287. * Serializes the component data to the specified json object
  11288. * @param serializationObject The object to serialize to
  11289. */
  11290. serialize(serializationObject: any): void;
  11291. }
  11292. /**
  11293. * Strong typing of a Mesh related stage step action
  11294. */
  11295. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11296. /**
  11297. * Strong typing of a Evaluate Sub Mesh related stage step action
  11298. */
  11299. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11300. /**
  11301. * Strong typing of a Active Mesh related stage step action
  11302. */
  11303. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11304. /**
  11305. * Strong typing of a Camera related stage step action
  11306. */
  11307. export type CameraStageAction = (camera: Camera) => void;
  11308. /**
  11309. * Strong typing of a Camera Frame buffer related stage step action
  11310. */
  11311. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11312. /**
  11313. * Strong typing of a Render Target related stage step action
  11314. */
  11315. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11316. /**
  11317. * Strong typing of a RenderingGroup related stage step action
  11318. */
  11319. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11320. /**
  11321. * Strong typing of a Mesh Render related stage step action
  11322. */
  11323. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11324. /**
  11325. * Strong typing of a simple stage step action
  11326. */
  11327. export type SimpleStageAction = () => void;
  11328. /**
  11329. * Strong typing of a render target action.
  11330. */
  11331. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11332. /**
  11333. * Strong typing of a pointer move action.
  11334. */
  11335. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11336. /**
  11337. * Strong typing of a pointer up/down action.
  11338. */
  11339. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11340. /**
  11341. * Representation of a stage in the scene (Basically a list of ordered steps)
  11342. * @hidden
  11343. */
  11344. export class Stage<T extends Function> extends Array<{
  11345. index: number;
  11346. component: ISceneComponent;
  11347. action: T;
  11348. }> {
  11349. /**
  11350. * Hide ctor from the rest of the world.
  11351. * @param items The items to add.
  11352. */
  11353. private constructor();
  11354. /**
  11355. * Creates a new Stage.
  11356. * @returns A new instance of a Stage
  11357. */
  11358. static Create<T extends Function>(): Stage<T>;
  11359. /**
  11360. * Registers a step in an ordered way in the targeted stage.
  11361. * @param index Defines the position to register the step in
  11362. * @param component Defines the component attached to the step
  11363. * @param action Defines the action to launch during the step
  11364. */
  11365. registerStep(index: number, component: ISceneComponent, action: T): void;
  11366. /**
  11367. * Clears all the steps from the stage.
  11368. */
  11369. clear(): void;
  11370. }
  11371. }
  11372. declare module BABYLON {
  11373. interface Scene {
  11374. /** @hidden */
  11375. _pointerOverSprite: Nullable<Sprite>;
  11376. /** @hidden */
  11377. _pickedDownSprite: Nullable<Sprite>;
  11378. /** @hidden */
  11379. _tempSpritePickingRay: Nullable<Ray>;
  11380. /**
  11381. * All of the sprite managers added to this scene
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. spriteManagers: Array<ISpriteManager>;
  11385. /**
  11386. * An event triggered when sprites rendering is about to start
  11387. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11388. */
  11389. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11390. /**
  11391. * An event triggered when sprites rendering is done
  11392. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11393. */
  11394. onAfterSpritesRenderingObservable: Observable<Scene>;
  11395. /** @hidden */
  11396. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11397. /** Launch a ray to try to pick a sprite in the scene
  11398. * @param x position on screen
  11399. * @param y position on screen
  11400. * @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
  11401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11402. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11403. * @returns a PickingInfo
  11404. */
  11405. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11406. /** Use the given ray to pick a sprite in the scene
  11407. * @param ray The ray (in world space) to use to pick meshes
  11408. * @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
  11409. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11410. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11411. * @returns a PickingInfo
  11412. */
  11413. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11414. /** @hidden */
  11415. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11416. /** Launch a ray to try to pick sprites in the scene
  11417. * @param x position on screen
  11418. * @param y position on screen
  11419. * @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
  11420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11421. * @returns a PickingInfo array
  11422. */
  11423. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11424. /** Use the given ray to pick sprites in the scene
  11425. * @param ray The ray (in world space) to use to pick meshes
  11426. * @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
  11427. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11428. * @returns a PickingInfo array
  11429. */
  11430. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11431. /**
  11432. * Force the sprite under the pointer
  11433. * @param sprite defines the sprite to use
  11434. */
  11435. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11436. /**
  11437. * Gets the sprite under the pointer
  11438. * @returns a Sprite or null if no sprite is under the pointer
  11439. */
  11440. getPointerOverSprite(): Nullable<Sprite>;
  11441. }
  11442. /**
  11443. * Defines the sprite scene component responsible to manage sprites
  11444. * in a given scene.
  11445. */
  11446. export class SpriteSceneComponent implements ISceneComponent {
  11447. /**
  11448. * The component name helpfull to identify the component in the list of scene components.
  11449. */
  11450. readonly name: string;
  11451. /**
  11452. * The scene the component belongs to.
  11453. */
  11454. scene: Scene;
  11455. /** @hidden */
  11456. private _spritePredicate;
  11457. /**
  11458. * Creates a new instance of the component for the given scene
  11459. * @param scene Defines the scene to register the component in
  11460. */
  11461. constructor(scene: Scene);
  11462. /**
  11463. * Registers the component in a given scene
  11464. */
  11465. register(): void;
  11466. /**
  11467. * Rebuilds the elements related to this component in case of
  11468. * context lost for instance.
  11469. */
  11470. rebuild(): void;
  11471. /**
  11472. * Disposes the component and the associated ressources.
  11473. */
  11474. dispose(): void;
  11475. private _pickSpriteButKeepRay;
  11476. private _pointerMove;
  11477. private _pointerDown;
  11478. private _pointerUp;
  11479. }
  11480. }
  11481. declare module BABYLON {
  11482. /** @hidden */
  11483. export var fogFragmentDeclaration: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module BABYLON {
  11489. /** @hidden */
  11490. export var fogFragment: {
  11491. name: string;
  11492. shader: string;
  11493. };
  11494. }
  11495. declare module BABYLON {
  11496. /** @hidden */
  11497. export var spritesPixelShader: {
  11498. name: string;
  11499. shader: string;
  11500. };
  11501. }
  11502. declare module BABYLON {
  11503. /** @hidden */
  11504. export var fogVertexDeclaration: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module BABYLON {
  11510. /** @hidden */
  11511. export var spritesVertexShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module BABYLON {
  11517. /**
  11518. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11519. */
  11520. export interface ISpriteManager extends IDisposable {
  11521. /**
  11522. * Restricts the camera to viewing objects with the same layerMask.
  11523. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11524. */
  11525. layerMask: number;
  11526. /**
  11527. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11528. */
  11529. isPickable: boolean;
  11530. /**
  11531. * Specifies the rendering group id for this mesh (0 by default)
  11532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11533. */
  11534. renderingGroupId: number;
  11535. /**
  11536. * Defines the list of sprites managed by the manager.
  11537. */
  11538. sprites: Array<Sprite>;
  11539. /**
  11540. * Tests the intersection of a sprite with a specific ray.
  11541. * @param ray The ray we are sending to test the collision
  11542. * @param camera The camera space we are sending rays in
  11543. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11544. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11545. * @returns picking info or null.
  11546. */
  11547. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11548. /**
  11549. * Intersects the sprites with a ray
  11550. * @param ray defines the ray to intersect with
  11551. * @param camera defines the current active camera
  11552. * @param predicate defines a predicate used to select candidate sprites
  11553. * @returns null if no hit or a PickingInfo array
  11554. */
  11555. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11556. /**
  11557. * Renders the list of sprites on screen.
  11558. */
  11559. render(): void;
  11560. }
  11561. /**
  11562. * Class used to manage multiple sprites on the same spritesheet
  11563. * @see http://doc.babylonjs.com/babylon101/sprites
  11564. */
  11565. export class SpriteManager implements ISpriteManager {
  11566. /** defines the manager's name */
  11567. name: string;
  11568. /** Gets the list of sprites */
  11569. sprites: Sprite[];
  11570. /** Gets or sets the rendering group id (0 by default) */
  11571. renderingGroupId: number;
  11572. /** Gets or sets camera layer mask */
  11573. layerMask: number;
  11574. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11575. fogEnabled: boolean;
  11576. /** Gets or sets a boolean indicating if the sprites are pickable */
  11577. isPickable: boolean;
  11578. /** Defines the default width of a cell in the spritesheet */
  11579. cellWidth: number;
  11580. /** Defines the default height of a cell in the spritesheet */
  11581. cellHeight: number;
  11582. /** Associative array from JSON sprite data file */
  11583. private _cellData;
  11584. /** Array of sprite names from JSON sprite data file */
  11585. private _spriteMap;
  11586. /** True when packed cell data from JSON file is ready*/
  11587. private _packedAndReady;
  11588. /**
  11589. * An event triggered when the manager is disposed.
  11590. */
  11591. onDisposeObservable: Observable<SpriteManager>;
  11592. private _onDisposeObserver;
  11593. /**
  11594. * Callback called when the manager is disposed
  11595. */
  11596. onDispose: () => void;
  11597. private _capacity;
  11598. private _fromPacked;
  11599. private _spriteTexture;
  11600. private _epsilon;
  11601. private _scene;
  11602. private _vertexData;
  11603. private _buffer;
  11604. private _vertexBuffers;
  11605. private _indexBuffer;
  11606. private _effectBase;
  11607. private _effectFog;
  11608. /**
  11609. * Gets or sets the spritesheet texture
  11610. */
  11611. texture: Texture;
  11612. /**
  11613. * Creates a new sprite manager
  11614. * @param name defines the manager's name
  11615. * @param imgUrl defines the sprite sheet url
  11616. * @param capacity defines the maximum allowed number of sprites
  11617. * @param cellSize defines the size of a sprite cell
  11618. * @param scene defines the hosting scene
  11619. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11620. * @param samplingMode defines the smapling mode to use with spritesheet
  11621. * @param fromPacked set to false; do not alter
  11622. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11623. */
  11624. constructor(
  11625. /** defines the manager's name */
  11626. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11627. private _makePacked;
  11628. private _appendSpriteVertex;
  11629. /**
  11630. * Intersects the sprites with a ray
  11631. * @param ray defines the ray to intersect with
  11632. * @param camera defines the current active camera
  11633. * @param predicate defines a predicate used to select candidate sprites
  11634. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11635. * @returns null if no hit or a PickingInfo
  11636. */
  11637. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11638. /**
  11639. * Intersects the sprites with a ray
  11640. * @param ray defines the ray to intersect with
  11641. * @param camera defines the current active camera
  11642. * @param predicate defines a predicate used to select candidate sprites
  11643. * @returns null if no hit or a PickingInfo array
  11644. */
  11645. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11646. /**
  11647. * Render all child sprites
  11648. */
  11649. render(): void;
  11650. /**
  11651. * Release associated resources
  11652. */
  11653. dispose(): void;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /**
  11658. * Class used to represent a sprite
  11659. * @see http://doc.babylonjs.com/babylon101/sprites
  11660. */
  11661. export class Sprite {
  11662. /** defines the name */
  11663. name: string;
  11664. /** Gets or sets the current world position */
  11665. position: Vector3;
  11666. /** Gets or sets the main color */
  11667. color: Color4;
  11668. /** Gets or sets the width */
  11669. width: number;
  11670. /** Gets or sets the height */
  11671. height: number;
  11672. /** Gets or sets rotation angle */
  11673. angle: number;
  11674. /** Gets or sets the cell index in the sprite sheet */
  11675. cellIndex: number;
  11676. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11677. cellRef: string;
  11678. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11679. invertU: number;
  11680. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11681. invertV: number;
  11682. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11683. disposeWhenFinishedAnimating: boolean;
  11684. /** Gets the list of attached animations */
  11685. animations: Animation[];
  11686. /** Gets or sets a boolean indicating if the sprite can be picked */
  11687. isPickable: boolean;
  11688. /**
  11689. * Gets or sets the associated action manager
  11690. */
  11691. actionManager: Nullable<ActionManager>;
  11692. private _animationStarted;
  11693. private _loopAnimation;
  11694. private _fromIndex;
  11695. private _toIndex;
  11696. private _delay;
  11697. private _direction;
  11698. private _manager;
  11699. private _time;
  11700. private _onAnimationEnd;
  11701. /**
  11702. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11703. */
  11704. isVisible: boolean;
  11705. /**
  11706. * Gets or sets the sprite size
  11707. */
  11708. size: number;
  11709. /**
  11710. * Creates a new Sprite
  11711. * @param name defines the name
  11712. * @param manager defines the manager
  11713. */
  11714. constructor(
  11715. /** defines the name */
  11716. name: string, manager: ISpriteManager);
  11717. /**
  11718. * Starts an animation
  11719. * @param from defines the initial key
  11720. * @param to defines the end key
  11721. * @param loop defines if the animation must loop
  11722. * @param delay defines the start delay (in ms)
  11723. * @param onAnimationEnd defines a callback to call when animation ends
  11724. */
  11725. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11726. /** Stops current animation (if any) */
  11727. stopAnimation(): void;
  11728. /** @hidden */
  11729. _animate(deltaTime: number): void;
  11730. /** Release associated resources */
  11731. dispose(): void;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. /**
  11736. * Information about the result of picking within a scene
  11737. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11738. */
  11739. export class PickingInfo {
  11740. /** @hidden */
  11741. _pickingUnavailable: boolean;
  11742. /**
  11743. * If the pick collided with an object
  11744. */
  11745. hit: boolean;
  11746. /**
  11747. * Distance away where the pick collided
  11748. */
  11749. distance: number;
  11750. /**
  11751. * The location of pick collision
  11752. */
  11753. pickedPoint: Nullable<Vector3>;
  11754. /**
  11755. * The mesh corresponding the the pick collision
  11756. */
  11757. pickedMesh: Nullable<AbstractMesh>;
  11758. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11759. bu: number;
  11760. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11761. bv: number;
  11762. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11763. faceId: number;
  11764. /** Id of the the submesh that was picked */
  11765. subMeshId: number;
  11766. /** If a sprite was picked, this will be the sprite the pick collided with */
  11767. pickedSprite: Nullable<Sprite>;
  11768. /**
  11769. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11770. */
  11771. originMesh: Nullable<AbstractMesh>;
  11772. /**
  11773. * The ray that was used to perform the picking.
  11774. */
  11775. ray: Nullable<Ray>;
  11776. /**
  11777. * Gets the normal correspodning to the face the pick collided with
  11778. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11779. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11780. * @returns The normal correspodning to the face the pick collided with
  11781. */
  11782. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11783. /**
  11784. * Gets the texture coordinates of where the pick occured
  11785. * @returns the vector containing the coordnates of the texture
  11786. */
  11787. getTextureCoordinates(): Nullable<Vector2>;
  11788. }
  11789. }
  11790. declare module BABYLON {
  11791. /**
  11792. * Gather the list of pointer event types as constants.
  11793. */
  11794. export class PointerEventTypes {
  11795. /**
  11796. * 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.
  11797. */
  11798. static readonly POINTERDOWN: number;
  11799. /**
  11800. * The pointerup event is fired when a pointer is no longer active.
  11801. */
  11802. static readonly POINTERUP: number;
  11803. /**
  11804. * The pointermove event is fired when a pointer changes coordinates.
  11805. */
  11806. static readonly POINTERMOVE: number;
  11807. /**
  11808. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11809. */
  11810. static readonly POINTERWHEEL: number;
  11811. /**
  11812. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11813. */
  11814. static readonly POINTERPICK: number;
  11815. /**
  11816. * The pointertap event is fired when a the object has been touched and released without drag.
  11817. */
  11818. static readonly POINTERTAP: number;
  11819. /**
  11820. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11821. */
  11822. static readonly POINTERDOUBLETAP: number;
  11823. }
  11824. /**
  11825. * Base class of pointer info types.
  11826. */
  11827. export class PointerInfoBase {
  11828. /**
  11829. * Defines the type of event (PointerEventTypes)
  11830. */
  11831. type: number;
  11832. /**
  11833. * Defines the related dom event
  11834. */
  11835. event: PointerEvent | MouseWheelEvent;
  11836. /**
  11837. * Instantiates the base class of pointers info.
  11838. * @param type Defines the type of event (PointerEventTypes)
  11839. * @param event Defines the related dom event
  11840. */
  11841. constructor(
  11842. /**
  11843. * Defines the type of event (PointerEventTypes)
  11844. */
  11845. type: number,
  11846. /**
  11847. * Defines the related dom event
  11848. */
  11849. event: PointerEvent | MouseWheelEvent);
  11850. }
  11851. /**
  11852. * This class is used to store pointer related info for the onPrePointerObservable event.
  11853. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11854. */
  11855. export class PointerInfoPre extends PointerInfoBase {
  11856. /**
  11857. * Ray from a pointer if availible (eg. 6dof controller)
  11858. */
  11859. ray: Nullable<Ray>;
  11860. /**
  11861. * Defines the local position of the pointer on the canvas.
  11862. */
  11863. localPosition: Vector2;
  11864. /**
  11865. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11866. */
  11867. skipOnPointerObservable: boolean;
  11868. /**
  11869. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. * @param localX Defines the local x coordinates of the pointer when the event occured
  11873. * @param localY Defines the local y coordinates of the pointer when the event occured
  11874. */
  11875. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11876. }
  11877. /**
  11878. * This type contains all the data related to a pointer event in Babylon.js.
  11879. * 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.
  11880. */
  11881. export class PointerInfo extends PointerInfoBase {
  11882. /**
  11883. * Defines the picking info associated to the info (if any)\
  11884. */
  11885. pickInfo: Nullable<PickingInfo>;
  11886. /**
  11887. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11888. * @param type Defines the type of event (PointerEventTypes)
  11889. * @param event Defines the related dom event
  11890. * @param pickInfo Defines the picking info associated to the info (if any)\
  11891. */
  11892. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11893. /**
  11894. * Defines the picking info associated to the info (if any)\
  11895. */
  11896. pickInfo: Nullable<PickingInfo>);
  11897. }
  11898. /**
  11899. * Data relating to a touch event on the screen.
  11900. */
  11901. export interface PointerTouch {
  11902. /**
  11903. * X coordinate of touch.
  11904. */
  11905. x: number;
  11906. /**
  11907. * Y coordinate of touch.
  11908. */
  11909. y: number;
  11910. /**
  11911. * Id of touch. Unique for each finger.
  11912. */
  11913. pointerId: number;
  11914. /**
  11915. * Event type passed from DOM.
  11916. */
  11917. type: any;
  11918. }
  11919. }
  11920. declare module BABYLON {
  11921. /**
  11922. * Manage the mouse inputs to control the movement of a free camera.
  11923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11924. */
  11925. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11926. /**
  11927. * Define if touch is enabled in the mouse input
  11928. */
  11929. touchEnabled: boolean;
  11930. /**
  11931. * Defines the camera the input is attached to.
  11932. */
  11933. camera: FreeCamera;
  11934. /**
  11935. * Defines the buttons associated with the input to handle camera move.
  11936. */
  11937. buttons: number[];
  11938. /**
  11939. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11940. */
  11941. angularSensibility: number;
  11942. private _pointerInput;
  11943. private _onMouseMove;
  11944. private _observer;
  11945. private previousPosition;
  11946. /**
  11947. * Observable for when a pointer move event occurs containing the move offset
  11948. */
  11949. onPointerMovedObservable: Observable<{
  11950. offsetX: number;
  11951. offsetY: number;
  11952. }>;
  11953. /**
  11954. * @hidden
  11955. * If the camera should be rotated automatically based on pointer movement
  11956. */
  11957. _allowCameraRotation: boolean;
  11958. /**
  11959. * Manage the mouse inputs to control the movement of a free camera.
  11960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11961. * @param touchEnabled Defines if touch is enabled or not
  11962. */
  11963. constructor(
  11964. /**
  11965. * Define if touch is enabled in the mouse input
  11966. */
  11967. touchEnabled?: boolean);
  11968. /**
  11969. * Attach the input controls to a specific dom element to get the input from.
  11970. * @param element Defines the element the controls should be listened from
  11971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11972. */
  11973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11974. /**
  11975. * Called on JS contextmenu event.
  11976. * Override this method to provide functionality.
  11977. */
  11978. protected onContextMenu(evt: PointerEvent): void;
  11979. /**
  11980. * Detach the current controls from the specified dom element.
  11981. * @param element Defines the element to stop listening the inputs from
  11982. */
  11983. detachControl(element: Nullable<HTMLElement>): void;
  11984. /**
  11985. * Gets the class name of the current intput.
  11986. * @returns the class name
  11987. */
  11988. getClassName(): string;
  11989. /**
  11990. * Get the friendly name associated with the input class.
  11991. * @returns the input friendly name
  11992. */
  11993. getSimpleName(): string;
  11994. }
  11995. }
  11996. declare module BABYLON {
  11997. /**
  11998. * Manage the touch inputs to control the movement of a free camera.
  11999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12000. */
  12001. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12002. /**
  12003. * Defines the camera the input is attached to.
  12004. */
  12005. camera: FreeCamera;
  12006. /**
  12007. * Defines the touch sensibility for rotation.
  12008. * The higher the faster.
  12009. */
  12010. touchAngularSensibility: number;
  12011. /**
  12012. * Defines the touch sensibility for move.
  12013. * The higher the faster.
  12014. */
  12015. touchMoveSensibility: number;
  12016. private _offsetX;
  12017. private _offsetY;
  12018. private _pointerPressed;
  12019. private _pointerInput;
  12020. private _observer;
  12021. private _onLostFocus;
  12022. /**
  12023. * Attach the input controls to a specific dom element to get the input from.
  12024. * @param element Defines the element the controls should be listened from
  12025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12026. */
  12027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12028. /**
  12029. * Detach the current controls from the specified dom element.
  12030. * @param element Defines the element to stop listening the inputs from
  12031. */
  12032. detachControl(element: Nullable<HTMLElement>): void;
  12033. /**
  12034. * Update the current camera state depending on the inputs that have been used this frame.
  12035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12036. */
  12037. checkInputs(): void;
  12038. /**
  12039. * Gets the class name of the current intput.
  12040. * @returns the class name
  12041. */
  12042. getClassName(): string;
  12043. /**
  12044. * Get the friendly name associated with the input class.
  12045. * @returns the input friendly name
  12046. */
  12047. getSimpleName(): string;
  12048. }
  12049. }
  12050. declare module BABYLON {
  12051. /**
  12052. * Default Inputs manager for the FreeCamera.
  12053. * It groups all the default supported inputs for ease of use.
  12054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12055. */
  12056. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12057. /**
  12058. * @hidden
  12059. */
  12060. _mouseInput: Nullable<FreeCameraMouseInput>;
  12061. /**
  12062. * Instantiates a new FreeCameraInputsManager.
  12063. * @param camera Defines the camera the inputs belong to
  12064. */
  12065. constructor(camera: FreeCamera);
  12066. /**
  12067. * Add keyboard input support to the input manager.
  12068. * @returns the current input manager
  12069. */
  12070. addKeyboard(): FreeCameraInputsManager;
  12071. /**
  12072. * Add mouse input support to the input manager.
  12073. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12074. * @returns the current input manager
  12075. */
  12076. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12077. /**
  12078. * Removes the mouse input support from the manager
  12079. * @returns the current input manager
  12080. */
  12081. removeMouse(): FreeCameraInputsManager;
  12082. /**
  12083. * Add touch input support to the input manager.
  12084. * @returns the current input manager
  12085. */
  12086. addTouch(): FreeCameraInputsManager;
  12087. /**
  12088. * Remove all attached input methods from a camera
  12089. */
  12090. clear(): void;
  12091. }
  12092. }
  12093. declare module BABYLON {
  12094. /**
  12095. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12096. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12097. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12098. */
  12099. export class FreeCamera extends TargetCamera {
  12100. /**
  12101. * Define the collision ellipsoid of the camera.
  12102. * This is helpful to simulate a camera body like the player body around the camera
  12103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12104. */
  12105. ellipsoid: Vector3;
  12106. /**
  12107. * Define an offset for the position of the ellipsoid around the camera.
  12108. * This can be helpful to determine the center of the body near the gravity center of the body
  12109. * instead of its head.
  12110. */
  12111. ellipsoidOffset: Vector3;
  12112. /**
  12113. * Enable or disable collisions of the camera with the rest of the scene objects.
  12114. */
  12115. checkCollisions: boolean;
  12116. /**
  12117. * Enable or disable gravity on the camera.
  12118. */
  12119. applyGravity: boolean;
  12120. /**
  12121. * Define the input manager associated to the camera.
  12122. */
  12123. inputs: FreeCameraInputsManager;
  12124. /**
  12125. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12126. * Higher values reduce sensitivity.
  12127. */
  12128. /**
  12129. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12130. * Higher values reduce sensitivity.
  12131. */
  12132. angularSensibility: number;
  12133. /**
  12134. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12135. */
  12136. keysUp: number[];
  12137. /**
  12138. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12139. */
  12140. keysDown: number[];
  12141. /**
  12142. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12143. */
  12144. keysLeft: number[];
  12145. /**
  12146. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12147. */
  12148. keysRight: number[];
  12149. /**
  12150. * Event raised when the camera collide with a mesh in the scene.
  12151. */
  12152. onCollide: (collidedMesh: AbstractMesh) => void;
  12153. private _collider;
  12154. private _needMoveForGravity;
  12155. private _oldPosition;
  12156. private _diffPosition;
  12157. private _newPosition;
  12158. /** @hidden */
  12159. _localDirection: Vector3;
  12160. /** @hidden */
  12161. _transformedDirection: Vector3;
  12162. /**
  12163. * Instantiates a Free Camera.
  12164. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12165. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12167. * @param name Define the name of the camera in the scene
  12168. * @param position Define the start position of the camera in the scene
  12169. * @param scene Define the scene the camera belongs to
  12170. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12171. */
  12172. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12173. /**
  12174. * Attached controls to the current camera.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Detach the current controls from the camera.
  12181. * The camera will stop reacting to inputs.
  12182. * @param element Defines the element to stop listening the inputs from
  12183. */
  12184. detachControl(element: HTMLElement): void;
  12185. private _collisionMask;
  12186. /**
  12187. * Define a collision mask to limit the list of object the camera can collide with
  12188. */
  12189. collisionMask: number;
  12190. /** @hidden */
  12191. _collideWithWorld(displacement: Vector3): void;
  12192. private _onCollisionPositionChange;
  12193. /** @hidden */
  12194. _checkInputs(): void;
  12195. /** @hidden */
  12196. _decideIfNeedsToMove(): boolean;
  12197. /** @hidden */
  12198. _updatePosition(): void;
  12199. /**
  12200. * Destroy the camera and release the current resources hold by it.
  12201. */
  12202. dispose(): void;
  12203. /**
  12204. * Gets the current object class name.
  12205. * @return the class name
  12206. */
  12207. getClassName(): string;
  12208. }
  12209. }
  12210. declare module BABYLON {
  12211. /**
  12212. * Represents a gamepad control stick position
  12213. */
  12214. export class StickValues {
  12215. /**
  12216. * The x component of the control stick
  12217. */
  12218. x: number;
  12219. /**
  12220. * The y component of the control stick
  12221. */
  12222. y: number;
  12223. /**
  12224. * Initializes the gamepad x and y control stick values
  12225. * @param x The x component of the gamepad control stick value
  12226. * @param y The y component of the gamepad control stick value
  12227. */
  12228. constructor(
  12229. /**
  12230. * The x component of the control stick
  12231. */
  12232. x: number,
  12233. /**
  12234. * The y component of the control stick
  12235. */
  12236. y: number);
  12237. }
  12238. /**
  12239. * An interface which manages callbacks for gamepad button changes
  12240. */
  12241. export interface GamepadButtonChanges {
  12242. /**
  12243. * Called when a gamepad has been changed
  12244. */
  12245. changed: boolean;
  12246. /**
  12247. * Called when a gamepad press event has been triggered
  12248. */
  12249. pressChanged: boolean;
  12250. /**
  12251. * Called when a touch event has been triggered
  12252. */
  12253. touchChanged: boolean;
  12254. /**
  12255. * Called when a value has changed
  12256. */
  12257. valueChanged: boolean;
  12258. }
  12259. /**
  12260. * Represents a gamepad
  12261. */
  12262. export class Gamepad {
  12263. /**
  12264. * The id of the gamepad
  12265. */
  12266. id: string;
  12267. /**
  12268. * The index of the gamepad
  12269. */
  12270. index: number;
  12271. /**
  12272. * The browser gamepad
  12273. */
  12274. browserGamepad: any;
  12275. /**
  12276. * Specifies what type of gamepad this represents
  12277. */
  12278. type: number;
  12279. private _leftStick;
  12280. private _rightStick;
  12281. /** @hidden */
  12282. _isConnected: boolean;
  12283. private _leftStickAxisX;
  12284. private _leftStickAxisY;
  12285. private _rightStickAxisX;
  12286. private _rightStickAxisY;
  12287. /**
  12288. * Triggered when the left control stick has been changed
  12289. */
  12290. private _onleftstickchanged;
  12291. /**
  12292. * Triggered when the right control stick has been changed
  12293. */
  12294. private _onrightstickchanged;
  12295. /**
  12296. * Represents a gamepad controller
  12297. */
  12298. static GAMEPAD: number;
  12299. /**
  12300. * Represents a generic controller
  12301. */
  12302. static GENERIC: number;
  12303. /**
  12304. * Represents an XBox controller
  12305. */
  12306. static XBOX: number;
  12307. /**
  12308. * Represents a pose-enabled controller
  12309. */
  12310. static POSE_ENABLED: number;
  12311. /**
  12312. * Represents an Dual Shock controller
  12313. */
  12314. static DUALSHOCK: number;
  12315. /**
  12316. * Specifies whether the left control stick should be Y-inverted
  12317. */
  12318. protected _invertLeftStickY: boolean;
  12319. /**
  12320. * Specifies if the gamepad has been connected
  12321. */
  12322. readonly isConnected: boolean;
  12323. /**
  12324. * Initializes the gamepad
  12325. * @param id The id of the gamepad
  12326. * @param index The index of the gamepad
  12327. * @param browserGamepad The browser gamepad
  12328. * @param leftStickX The x component of the left joystick
  12329. * @param leftStickY The y component of the left joystick
  12330. * @param rightStickX The x component of the right joystick
  12331. * @param rightStickY The y component of the right joystick
  12332. */
  12333. constructor(
  12334. /**
  12335. * The id of the gamepad
  12336. */
  12337. id: string,
  12338. /**
  12339. * The index of the gamepad
  12340. */
  12341. index: number,
  12342. /**
  12343. * The browser gamepad
  12344. */
  12345. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12346. /**
  12347. * Callback triggered when the left joystick has changed
  12348. * @param callback
  12349. */
  12350. onleftstickchanged(callback: (values: StickValues) => void): void;
  12351. /**
  12352. * Callback triggered when the right joystick has changed
  12353. * @param callback
  12354. */
  12355. onrightstickchanged(callback: (values: StickValues) => void): void;
  12356. /**
  12357. * Gets the left joystick
  12358. */
  12359. /**
  12360. * Sets the left joystick values
  12361. */
  12362. leftStick: StickValues;
  12363. /**
  12364. * Gets the right joystick
  12365. */
  12366. /**
  12367. * Sets the right joystick value
  12368. */
  12369. rightStick: StickValues;
  12370. /**
  12371. * Updates the gamepad joystick positions
  12372. */
  12373. update(): void;
  12374. /**
  12375. * Disposes the gamepad
  12376. */
  12377. dispose(): void;
  12378. }
  12379. /**
  12380. * Represents a generic gamepad
  12381. */
  12382. export class GenericPad extends Gamepad {
  12383. private _buttons;
  12384. private _onbuttondown;
  12385. private _onbuttonup;
  12386. /**
  12387. * Observable triggered when a button has been pressed
  12388. */
  12389. onButtonDownObservable: Observable<number>;
  12390. /**
  12391. * Observable triggered when a button has been released
  12392. */
  12393. onButtonUpObservable: Observable<number>;
  12394. /**
  12395. * Callback triggered when a button has been pressed
  12396. * @param callback Called when a button has been pressed
  12397. */
  12398. onbuttondown(callback: (buttonPressed: number) => void): void;
  12399. /**
  12400. * Callback triggered when a button has been released
  12401. * @param callback Called when a button has been released
  12402. */
  12403. onbuttonup(callback: (buttonReleased: number) => void): void;
  12404. /**
  12405. * Initializes the generic gamepad
  12406. * @param id The id of the generic gamepad
  12407. * @param index The index of the generic gamepad
  12408. * @param browserGamepad The browser gamepad
  12409. */
  12410. constructor(id: string, index: number, browserGamepad: any);
  12411. private _setButtonValue;
  12412. /**
  12413. * Updates the generic gamepad
  12414. */
  12415. update(): void;
  12416. /**
  12417. * Disposes the generic gamepad
  12418. */
  12419. dispose(): void;
  12420. }
  12421. }
  12422. declare module BABYLON {
  12423. interface Engine {
  12424. /**
  12425. * Creates a raw texture
  12426. * @param data defines the data to store in the texture
  12427. * @param width defines the width of the texture
  12428. * @param height defines the height of the texture
  12429. * @param format defines the format of the data
  12430. * @param generateMipMaps defines if the engine should generate the mip levels
  12431. * @param invertY defines if data must be stored with Y axis inverted
  12432. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12433. * @param compression defines the compression used (null by default)
  12434. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12435. * @returns the raw texture inside an InternalTexture
  12436. */
  12437. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12438. /**
  12439. * Update a raw texture
  12440. * @param texture defines the texture to update
  12441. * @param data defines the data to store in the texture
  12442. * @param format defines the format of the data
  12443. * @param invertY defines if data must be stored with Y axis inverted
  12444. */
  12445. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12446. /**
  12447. * Update a raw texture
  12448. * @param texture defines the texture to update
  12449. * @param data defines the data to store in the texture
  12450. * @param format defines the format of the data
  12451. * @param invertY defines if data must be stored with Y axis inverted
  12452. * @param compression defines the compression used (null by default)
  12453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12454. */
  12455. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12456. /**
  12457. * Creates a new raw cube texture
  12458. * @param data defines the array of data to use to create each face
  12459. * @param size defines the size of the textures
  12460. * @param format defines the format of the data
  12461. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12462. * @param generateMipMaps defines if the engine should generate the mip levels
  12463. * @param invertY defines if data must be stored with Y axis inverted
  12464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12465. * @param compression defines the compression used (null by default)
  12466. * @returns the cube texture as an InternalTexture
  12467. */
  12468. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12469. /**
  12470. * Update a raw cube texture
  12471. * @param texture defines the texture to udpdate
  12472. * @param data defines the data to store
  12473. * @param format defines the data format
  12474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12475. * @param invertY defines if data must be stored with Y axis inverted
  12476. */
  12477. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12478. /**
  12479. * Update a raw cube texture
  12480. * @param texture defines the texture to udpdate
  12481. * @param data defines the data to store
  12482. * @param format defines the data format
  12483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param compression defines the compression used (null by default)
  12486. */
  12487. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12488. /**
  12489. * Update a raw cube texture
  12490. * @param texture defines the texture to udpdate
  12491. * @param data defines the data to store
  12492. * @param format defines the data format
  12493. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12494. * @param invertY defines if data must be stored with Y axis inverted
  12495. * @param compression defines the compression used (null by default)
  12496. * @param level defines which level of the texture to update
  12497. */
  12498. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12499. /**
  12500. * Creates a new raw cube texture from a specified url
  12501. * @param url defines the url where the data is located
  12502. * @param scene defines the current scene
  12503. * @param size defines the size of the textures
  12504. * @param format defines the format of the data
  12505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12506. * @param noMipmap defines if the engine should avoid generating the mip levels
  12507. * @param callback defines a callback used to extract texture data from loaded data
  12508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12509. * @param onLoad defines a callback called when texture is loaded
  12510. * @param onError defines a callback called if there is an error
  12511. * @returns the cube texture as an InternalTexture
  12512. */
  12513. 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;
  12514. /**
  12515. * Creates a new raw cube texture from a specified url
  12516. * @param url defines the url where the data is located
  12517. * @param scene defines the current scene
  12518. * @param size defines the size of the textures
  12519. * @param format defines the format of the data
  12520. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12521. * @param noMipmap defines if the engine should avoid generating the mip levels
  12522. * @param callback defines a callback used to extract texture data from loaded data
  12523. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12524. * @param onLoad defines a callback called when texture is loaded
  12525. * @param onError defines a callback called if there is an error
  12526. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12527. * @param invertY defines if data must be stored with Y axis inverted
  12528. * @returns the cube texture as an InternalTexture
  12529. */
  12530. 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;
  12531. /**
  12532. * Creates a new raw 3D texture
  12533. * @param data defines the data used to create the texture
  12534. * @param width defines the width of the texture
  12535. * @param height defines the height of the texture
  12536. * @param depth defines the depth of the texture
  12537. * @param format defines the format of the texture
  12538. * @param generateMipMaps defines if the engine must generate mip levels
  12539. * @param invertY defines if data must be stored with Y axis inverted
  12540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12541. * @param compression defines the compressed used (can be null)
  12542. * @param textureType defines the compressed used (can be null)
  12543. * @returns a new raw 3D texture (stored in an InternalTexture)
  12544. */
  12545. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12546. /**
  12547. * Update a raw 3D texture
  12548. * @param texture defines the texture to update
  12549. * @param data defines the data to store
  12550. * @param format defines the data format
  12551. * @param invertY defines if data must be stored with Y axis inverted
  12552. */
  12553. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12554. /**
  12555. * Update a raw 3D texture
  12556. * @param texture defines the texture to update
  12557. * @param data defines the data to store
  12558. * @param format defines the data format
  12559. * @param invertY defines if data must be stored with Y axis inverted
  12560. * @param compression defines the used compression (can be null)
  12561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12562. */
  12563. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12564. /**
  12565. * Creates a new raw 2D array texture
  12566. * @param data defines the data used to create the texture
  12567. * @param width defines the width of the texture
  12568. * @param height defines the height of the texture
  12569. * @param depth defines the number of layers of the texture
  12570. * @param format defines the format of the texture
  12571. * @param generateMipMaps defines if the engine must generate mip levels
  12572. * @param invertY defines if data must be stored with Y axis inverted
  12573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12574. * @param compression defines the compressed used (can be null)
  12575. * @param textureType defines the compressed used (can be null)
  12576. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12577. */
  12578. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12579. /**
  12580. * Update a raw 2D array texture
  12581. * @param texture defines the texture to update
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param invertY defines if data must be stored with Y axis inverted
  12585. */
  12586. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12587. /**
  12588. * Update a raw 2D array texture
  12589. * @param texture defines the texture to update
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param compression defines the used compression (can be null)
  12594. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12595. */
  12596. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12597. }
  12598. }
  12599. declare module BABYLON {
  12600. /**
  12601. * Raw texture can help creating a texture directly from an array of data.
  12602. * This can be super useful if you either get the data from an uncompressed source or
  12603. * if you wish to create your texture pixel by pixel.
  12604. */
  12605. export class RawTexture extends Texture {
  12606. /**
  12607. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12608. */
  12609. format: number;
  12610. private _engine;
  12611. /**
  12612. * Instantiates a new RawTexture.
  12613. * Raw texture can help creating a texture directly from an array of data.
  12614. * This can be super useful if you either get the data from an uncompressed source or
  12615. * if you wish to create your texture pixel by pixel.
  12616. * @param data define the array of data to use to create the texture
  12617. * @param width define the width of the texture
  12618. * @param height define the height of the texture
  12619. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12620. * @param scene define the scene the texture belongs to
  12621. * @param generateMipMaps define whether mip maps should be generated or not
  12622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12624. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12625. */
  12626. constructor(data: ArrayBufferView, width: number, height: number,
  12627. /**
  12628. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12629. */
  12630. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12631. /**
  12632. * Updates the texture underlying data.
  12633. * @param data Define the new data of the texture
  12634. */
  12635. update(data: ArrayBufferView): void;
  12636. /**
  12637. * Creates a luminance texture from some data.
  12638. * @param data Define the texture data
  12639. * @param width Define the width of the texture
  12640. * @param height Define the height of the texture
  12641. * @param scene Define the scene the texture belongs to
  12642. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12643. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12644. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12645. * @returns the luminance texture
  12646. */
  12647. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12648. /**
  12649. * Creates a luminance alpha texture from some data.
  12650. * @param data Define the texture data
  12651. * @param width Define the width of the texture
  12652. * @param height Define the height of the texture
  12653. * @param scene Define the scene the texture belongs to
  12654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12657. * @returns the luminance alpha texture
  12658. */
  12659. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12660. /**
  12661. * Creates an alpha texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the alpha texture
  12670. */
  12671. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a RGB texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12682. * @returns the RGB alpha texture
  12683. */
  12684. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12685. /**
  12686. * Creates a RGBA texture from some data.
  12687. * @param data Define the texture data
  12688. * @param width Define the width of the texture
  12689. * @param height Define the height of the texture
  12690. * @param scene Define the scene the texture belongs to
  12691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12695. * @returns the RGBA texture
  12696. */
  12697. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12698. /**
  12699. * Creates a R texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12708. * @returns the R texture
  12709. */
  12710. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12711. }
  12712. }
  12713. declare module BABYLON {
  12714. /**
  12715. * Interface for the size containing width and height
  12716. */
  12717. export interface ISize {
  12718. /**
  12719. * Width
  12720. */
  12721. width: number;
  12722. /**
  12723. * Heighht
  12724. */
  12725. height: number;
  12726. }
  12727. /**
  12728. * Size containing widht and height
  12729. */
  12730. export class Size implements ISize {
  12731. /**
  12732. * Width
  12733. */
  12734. width: number;
  12735. /**
  12736. * Height
  12737. */
  12738. height: number;
  12739. /**
  12740. * Creates a Size object from the given width and height (floats).
  12741. * @param width width of the new size
  12742. * @param height height of the new size
  12743. */
  12744. constructor(width: number, height: number);
  12745. /**
  12746. * Returns a string with the Size width and height
  12747. * @returns a string with the Size width and height
  12748. */
  12749. toString(): string;
  12750. /**
  12751. * "Size"
  12752. * @returns the string "Size"
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Returns the Size hash code.
  12757. * @returns a hash code for a unique width and height
  12758. */
  12759. getHashCode(): number;
  12760. /**
  12761. * Updates the current size from the given one.
  12762. * @param src the given size
  12763. */
  12764. copyFrom(src: Size): void;
  12765. /**
  12766. * Updates in place the current Size from the given floats.
  12767. * @param width width of the new size
  12768. * @param height height of the new size
  12769. * @returns the updated Size.
  12770. */
  12771. copyFromFloats(width: number, height: number): Size;
  12772. /**
  12773. * Updates in place the current Size from the given floats.
  12774. * @param width width to set
  12775. * @param height height to set
  12776. * @returns the updated Size.
  12777. */
  12778. set(width: number, height: number): Size;
  12779. /**
  12780. * Multiplies the width and height by numbers
  12781. * @param w factor to multiple the width by
  12782. * @param h factor to multiple the height by
  12783. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12784. */
  12785. multiplyByFloats(w: number, h: number): Size;
  12786. /**
  12787. * Clones the size
  12788. * @returns a new Size copied from the given one.
  12789. */
  12790. clone(): Size;
  12791. /**
  12792. * True if the current Size and the given one width and height are strictly equal.
  12793. * @param other the other size to compare against
  12794. * @returns True if the current Size and the given one width and height are strictly equal.
  12795. */
  12796. equals(other: Size): boolean;
  12797. /**
  12798. * The surface of the Size : width * height (float).
  12799. */
  12800. readonly surface: number;
  12801. /**
  12802. * Create a new size of zero
  12803. * @returns a new Size set to (0.0, 0.0)
  12804. */
  12805. static Zero(): Size;
  12806. /**
  12807. * Sums the width and height of two sizes
  12808. * @param otherSize size to add to this size
  12809. * @returns a new Size set as the addition result of the current Size and the given one.
  12810. */
  12811. add(otherSize: Size): Size;
  12812. /**
  12813. * Subtracts the width and height of two
  12814. * @param otherSize size to subtract to this size
  12815. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12816. */
  12817. subtract(otherSize: Size): Size;
  12818. /**
  12819. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12820. * @param start starting size to lerp between
  12821. * @param end end size to lerp between
  12822. * @param amount amount to lerp between the start and end values
  12823. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12824. */
  12825. static Lerp(start: Size, end: Size, amount: number): Size;
  12826. }
  12827. }
  12828. declare module BABYLON {
  12829. /**
  12830. * Defines a runtime animation
  12831. */
  12832. export class RuntimeAnimation {
  12833. private _events;
  12834. /**
  12835. * The current frame of the runtime animation
  12836. */
  12837. private _currentFrame;
  12838. /**
  12839. * The animation used by the runtime animation
  12840. */
  12841. private _animation;
  12842. /**
  12843. * The target of the runtime animation
  12844. */
  12845. private _target;
  12846. /**
  12847. * The initiating animatable
  12848. */
  12849. private _host;
  12850. /**
  12851. * The original value of the runtime animation
  12852. */
  12853. private _originalValue;
  12854. /**
  12855. * The original blend value of the runtime animation
  12856. */
  12857. private _originalBlendValue;
  12858. /**
  12859. * The offsets cache of the runtime animation
  12860. */
  12861. private _offsetsCache;
  12862. /**
  12863. * The high limits cache of the runtime animation
  12864. */
  12865. private _highLimitsCache;
  12866. /**
  12867. * Specifies if the runtime animation has been stopped
  12868. */
  12869. private _stopped;
  12870. /**
  12871. * The blending factor of the runtime animation
  12872. */
  12873. private _blendingFactor;
  12874. /**
  12875. * The BabylonJS scene
  12876. */
  12877. private _scene;
  12878. /**
  12879. * The current value of the runtime animation
  12880. */
  12881. private _currentValue;
  12882. /** @hidden */
  12883. _animationState: _IAnimationState;
  12884. /**
  12885. * The active target of the runtime animation
  12886. */
  12887. private _activeTargets;
  12888. private _currentActiveTarget;
  12889. private _directTarget;
  12890. /**
  12891. * The target path of the runtime animation
  12892. */
  12893. private _targetPath;
  12894. /**
  12895. * The weight of the runtime animation
  12896. */
  12897. private _weight;
  12898. /**
  12899. * The ratio offset of the runtime animation
  12900. */
  12901. private _ratioOffset;
  12902. /**
  12903. * The previous delay of the runtime animation
  12904. */
  12905. private _previousDelay;
  12906. /**
  12907. * The previous ratio of the runtime animation
  12908. */
  12909. private _previousRatio;
  12910. private _enableBlending;
  12911. private _keys;
  12912. private _minFrame;
  12913. private _maxFrame;
  12914. private _minValue;
  12915. private _maxValue;
  12916. private _targetIsArray;
  12917. /**
  12918. * Gets the current frame of the runtime animation
  12919. */
  12920. readonly currentFrame: number;
  12921. /**
  12922. * Gets the weight of the runtime animation
  12923. */
  12924. readonly weight: number;
  12925. /**
  12926. * Gets the current value of the runtime animation
  12927. */
  12928. readonly currentValue: any;
  12929. /**
  12930. * Gets the target path of the runtime animation
  12931. */
  12932. readonly targetPath: string;
  12933. /**
  12934. * Gets the actual target of the runtime animation
  12935. */
  12936. readonly target: any;
  12937. /** @hidden */
  12938. _onLoop: () => void;
  12939. /**
  12940. * Create a new RuntimeAnimation object
  12941. * @param target defines the target of the animation
  12942. * @param animation defines the source animation object
  12943. * @param scene defines the hosting scene
  12944. * @param host defines the initiating Animatable
  12945. */
  12946. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12947. private _preparePath;
  12948. /**
  12949. * Gets the animation from the runtime animation
  12950. */
  12951. readonly animation: Animation;
  12952. /**
  12953. * Resets the runtime animation to the beginning
  12954. * @param restoreOriginal defines whether to restore the target property to the original value
  12955. */
  12956. reset(restoreOriginal?: boolean): void;
  12957. /**
  12958. * Specifies if the runtime animation is stopped
  12959. * @returns Boolean specifying if the runtime animation is stopped
  12960. */
  12961. isStopped(): boolean;
  12962. /**
  12963. * Disposes of the runtime animation
  12964. */
  12965. dispose(): void;
  12966. /**
  12967. * Apply the interpolated value to the target
  12968. * @param currentValue defines the value computed by the animation
  12969. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12970. */
  12971. setValue(currentValue: any, weight: number): void;
  12972. private _getOriginalValues;
  12973. private _setValue;
  12974. /**
  12975. * Gets the loop pmode of the runtime animation
  12976. * @returns Loop Mode
  12977. */
  12978. private _getCorrectLoopMode;
  12979. /**
  12980. * Move the current animation to a given frame
  12981. * @param frame defines the frame to move to
  12982. */
  12983. goToFrame(frame: number): void;
  12984. /**
  12985. * @hidden Internal use only
  12986. */
  12987. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12988. /**
  12989. * Execute the current animation
  12990. * @param delay defines the delay to add to the current frame
  12991. * @param from defines the lower bound of the animation range
  12992. * @param to defines the upper bound of the animation range
  12993. * @param loop defines if the current animation must loop
  12994. * @param speedRatio defines the current speed ratio
  12995. * @param weight defines the weight of the animation (default is -1 so no weight)
  12996. * @param onLoop optional callback called when animation loops
  12997. * @returns a boolean indicating if the animation is running
  12998. */
  12999. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13000. }
  13001. }
  13002. declare module BABYLON {
  13003. /**
  13004. * Class used to store an actual running animation
  13005. */
  13006. export class Animatable {
  13007. /** defines the target object */
  13008. target: any;
  13009. /** defines the starting frame number (default is 0) */
  13010. fromFrame: number;
  13011. /** defines the ending frame number (default is 100) */
  13012. toFrame: number;
  13013. /** defines if the animation must loop (default is false) */
  13014. loopAnimation: boolean;
  13015. /** defines a callback to call when animation ends if it is not looping */
  13016. onAnimationEnd?: (() => void) | null | undefined;
  13017. /** defines a callback to call when animation loops */
  13018. onAnimationLoop?: (() => void) | null | undefined;
  13019. private _localDelayOffset;
  13020. private _pausedDelay;
  13021. private _runtimeAnimations;
  13022. private _paused;
  13023. private _scene;
  13024. private _speedRatio;
  13025. private _weight;
  13026. private _syncRoot;
  13027. /**
  13028. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13029. * This will only apply for non looping animation (default is true)
  13030. */
  13031. disposeOnEnd: boolean;
  13032. /**
  13033. * Gets a boolean indicating if the animation has started
  13034. */
  13035. animationStarted: boolean;
  13036. /**
  13037. * Observer raised when the animation ends
  13038. */
  13039. onAnimationEndObservable: Observable<Animatable>;
  13040. /**
  13041. * Observer raised when the animation loops
  13042. */
  13043. onAnimationLoopObservable: Observable<Animatable>;
  13044. /**
  13045. * Gets the root Animatable used to synchronize and normalize animations
  13046. */
  13047. readonly syncRoot: Nullable<Animatable>;
  13048. /**
  13049. * Gets the current frame of the first RuntimeAnimation
  13050. * Used to synchronize Animatables
  13051. */
  13052. readonly masterFrame: number;
  13053. /**
  13054. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13055. */
  13056. weight: number;
  13057. /**
  13058. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13059. */
  13060. speedRatio: number;
  13061. /**
  13062. * Creates a new Animatable
  13063. * @param scene defines the hosting scene
  13064. * @param target defines the target object
  13065. * @param fromFrame defines the starting frame number (default is 0)
  13066. * @param toFrame defines the ending frame number (default is 100)
  13067. * @param loopAnimation defines if the animation must loop (default is false)
  13068. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13069. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13070. * @param animations defines a group of animation to add to the new Animatable
  13071. * @param onAnimationLoop defines a callback to call when animation loops
  13072. */
  13073. constructor(scene: Scene,
  13074. /** defines the target object */
  13075. target: any,
  13076. /** defines the starting frame number (default is 0) */
  13077. fromFrame?: number,
  13078. /** defines the ending frame number (default is 100) */
  13079. toFrame?: number,
  13080. /** defines if the animation must loop (default is false) */
  13081. loopAnimation?: boolean, speedRatio?: number,
  13082. /** defines a callback to call when animation ends if it is not looping */
  13083. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13084. /** defines a callback to call when animation loops */
  13085. onAnimationLoop?: (() => void) | null | undefined);
  13086. /**
  13087. * Synchronize and normalize current Animatable with a source Animatable
  13088. * This is useful when using animation weights and when animations are not of the same length
  13089. * @param root defines the root Animatable to synchronize with
  13090. * @returns the current Animatable
  13091. */
  13092. syncWith(root: Animatable): Animatable;
  13093. /**
  13094. * Gets the list of runtime animations
  13095. * @returns an array of RuntimeAnimation
  13096. */
  13097. getAnimations(): RuntimeAnimation[];
  13098. /**
  13099. * Adds more animations to the current animatable
  13100. * @param target defines the target of the animations
  13101. * @param animations defines the new animations to add
  13102. */
  13103. appendAnimations(target: any, animations: Animation[]): void;
  13104. /**
  13105. * Gets the source animation for a specific property
  13106. * @param property defines the propertyu to look for
  13107. * @returns null or the source animation for the given property
  13108. */
  13109. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13110. /**
  13111. * Gets the runtime animation for a specific property
  13112. * @param property defines the propertyu to look for
  13113. * @returns null or the runtime animation for the given property
  13114. */
  13115. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13116. /**
  13117. * Resets the animatable to its original state
  13118. */
  13119. reset(): void;
  13120. /**
  13121. * Allows the animatable to blend with current running animations
  13122. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13123. * @param blendingSpeed defines the blending speed to use
  13124. */
  13125. enableBlending(blendingSpeed: number): void;
  13126. /**
  13127. * Disable animation blending
  13128. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13129. */
  13130. disableBlending(): void;
  13131. /**
  13132. * Jump directly to a given frame
  13133. * @param frame defines the frame to jump to
  13134. */
  13135. goToFrame(frame: number): void;
  13136. /**
  13137. * Pause the animation
  13138. */
  13139. pause(): void;
  13140. /**
  13141. * Restart the animation
  13142. */
  13143. restart(): void;
  13144. private _raiseOnAnimationEnd;
  13145. /**
  13146. * Stop and delete the current animation
  13147. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13148. * @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)
  13149. */
  13150. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13151. /**
  13152. * Wait asynchronously for the animation to end
  13153. * @returns a promise which will be fullfilled when the animation ends
  13154. */
  13155. waitAsync(): Promise<Animatable>;
  13156. /** @hidden */
  13157. _animate(delay: number): boolean;
  13158. }
  13159. interface Scene {
  13160. /** @hidden */
  13161. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13162. /** @hidden */
  13163. _processLateAnimationBindingsForMatrices(holder: {
  13164. totalWeight: number;
  13165. animations: RuntimeAnimation[];
  13166. originalValue: Matrix;
  13167. }): any;
  13168. /** @hidden */
  13169. _processLateAnimationBindingsForQuaternions(holder: {
  13170. totalWeight: number;
  13171. animations: RuntimeAnimation[];
  13172. originalValue: Quaternion;
  13173. }, refQuaternion: Quaternion): Quaternion;
  13174. /** @hidden */
  13175. _processLateAnimationBindings(): void;
  13176. /**
  13177. * Will start the animation sequence of a given target
  13178. * @param target defines the target
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param weight defines the weight to apply to the animation (1.0 by default)
  13182. * @param loop defines if the animation loops
  13183. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13184. * @param onAnimationEnd defines the function to be executed when the animation ends
  13185. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the animatable object created for this animation
  13189. */
  13190. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13191. /**
  13192. * Will start the animation sequence of a given target
  13193. * @param target defines the target
  13194. * @param from defines from which frame should animation start
  13195. * @param to defines until which frame should animation run.
  13196. * @param loop defines if the animation loops
  13197. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13198. * @param onAnimationEnd defines the function to be executed when the animation ends
  13199. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13200. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13201. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13202. * @param onAnimationLoop defines the callback to call when an animation loops
  13203. * @returns the animatable object created for this animation
  13204. */
  13205. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13206. /**
  13207. * Will start the animation sequence of a given target and its hierarchy
  13208. * @param target defines the target
  13209. * @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.
  13210. * @param from defines from which frame should animation start
  13211. * @param to defines until which frame should animation run.
  13212. * @param loop defines if the animation loops
  13213. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13214. * @param onAnimationEnd defines the function to be executed when the animation ends
  13215. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13216. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13217. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13218. * @param onAnimationLoop defines the callback to call when an animation loops
  13219. * @returns the list of created animatables
  13220. */
  13221. 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[];
  13222. /**
  13223. * Begin a new animation on a given node
  13224. * @param target defines the target where the animation will take place
  13225. * @param animations defines the list of animations to start
  13226. * @param from defines the initial value
  13227. * @param to defines the final value
  13228. * @param loop defines if you want animation to loop (off by default)
  13229. * @param speedRatio defines the speed ratio to apply to all animations
  13230. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13231. * @param onAnimationLoop defines the callback to call when an animation loops
  13232. * @returns the list of created animatables
  13233. */
  13234. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13235. /**
  13236. * Begin a new animation on a given node and its hierarchy
  13237. * @param target defines the root node where the animation will take place
  13238. * @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.
  13239. * @param animations defines the list of animations to start
  13240. * @param from defines the initial value
  13241. * @param to defines the final value
  13242. * @param loop defines if you want animation to loop (off by default)
  13243. * @param speedRatio defines the speed ratio to apply to all animations
  13244. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13245. * @param onAnimationLoop defines the callback to call when an animation loops
  13246. * @returns the list of animatables created for all nodes
  13247. */
  13248. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13249. /**
  13250. * Gets the animatable associated with a specific target
  13251. * @param target defines the target of the animatable
  13252. * @returns the required animatable if found
  13253. */
  13254. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13255. /**
  13256. * Gets all animatables associated with a given target
  13257. * @param target defines the target to look animatables for
  13258. * @returns an array of Animatables
  13259. */
  13260. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13261. /**
  13262. * Stops and removes all animations that have been applied to the scene
  13263. */
  13264. stopAllAnimations(): void;
  13265. /**
  13266. * Gets the current delta time used by animation engine
  13267. */
  13268. deltaTime: number;
  13269. }
  13270. interface Bone {
  13271. /**
  13272. * Copy an animation range from another bone
  13273. * @param source defines the source bone
  13274. * @param rangeName defines the range name to copy
  13275. * @param frameOffset defines the frame offset
  13276. * @param rescaleAsRequired defines if rescaling must be applied if required
  13277. * @param skelDimensionsRatio defines the scaling ratio
  13278. * @returns true if operation was successful
  13279. */
  13280. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13281. }
  13282. }
  13283. declare module BABYLON {
  13284. /**
  13285. * Class used to override all child animations of a given target
  13286. */
  13287. export class AnimationPropertiesOverride {
  13288. /**
  13289. * Gets or sets a value indicating if animation blending must be used
  13290. */
  13291. enableBlending: boolean;
  13292. /**
  13293. * Gets or sets the blending speed to use when enableBlending is true
  13294. */
  13295. blendingSpeed: number;
  13296. /**
  13297. * Gets or sets the default loop mode to use
  13298. */
  13299. loopMode: number;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * Class used to handle skinning animations
  13305. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13306. */
  13307. export class Skeleton implements IAnimatable {
  13308. /** defines the skeleton name */
  13309. name: string;
  13310. /** defines the skeleton Id */
  13311. id: string;
  13312. /**
  13313. * Defines the list of child bones
  13314. */
  13315. bones: Bone[];
  13316. /**
  13317. * Defines an estimate of the dimension of the skeleton at rest
  13318. */
  13319. dimensionsAtRest: Vector3;
  13320. /**
  13321. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13322. */
  13323. needInitialSkinMatrix: boolean;
  13324. /**
  13325. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13326. */
  13327. overrideMesh: Nullable<AbstractMesh>;
  13328. /**
  13329. * Gets the list of animations attached to this skeleton
  13330. */
  13331. animations: Array<Animation>;
  13332. private _scene;
  13333. private _isDirty;
  13334. private _transformMatrices;
  13335. private _transformMatrixTexture;
  13336. private _meshesWithPoseMatrix;
  13337. private _animatables;
  13338. private _identity;
  13339. private _synchronizedWithMesh;
  13340. private _ranges;
  13341. private _lastAbsoluteTransformsUpdateId;
  13342. private _canUseTextureForBones;
  13343. private _uniqueId;
  13344. /** @hidden */
  13345. _numBonesWithLinkedTransformNode: number;
  13346. /** @hidden */
  13347. _hasWaitingData: Nullable<boolean>;
  13348. /**
  13349. * Specifies if the skeleton should be serialized
  13350. */
  13351. doNotSerialize: boolean;
  13352. private _useTextureToStoreBoneMatrices;
  13353. /**
  13354. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13355. * Please note that this option is not available if the hardware does not support it
  13356. */
  13357. useTextureToStoreBoneMatrices: boolean;
  13358. private _animationPropertiesOverride;
  13359. /**
  13360. * Gets or sets the animation properties override
  13361. */
  13362. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13363. /**
  13364. * List of inspectable custom properties (used by the Inspector)
  13365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13366. */
  13367. inspectableCustomProperties: IInspectable[];
  13368. /**
  13369. * An observable triggered before computing the skeleton's matrices
  13370. */
  13371. onBeforeComputeObservable: Observable<Skeleton>;
  13372. /**
  13373. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13374. */
  13375. readonly isUsingTextureForMatrices: boolean;
  13376. /**
  13377. * Gets the unique ID of this skeleton
  13378. */
  13379. readonly uniqueId: number;
  13380. /**
  13381. * Creates a new skeleton
  13382. * @param name defines the skeleton name
  13383. * @param id defines the skeleton Id
  13384. * @param scene defines the hosting scene
  13385. */
  13386. constructor(
  13387. /** defines the skeleton name */
  13388. name: string,
  13389. /** defines the skeleton Id */
  13390. id: string, scene: Scene);
  13391. /**
  13392. * Gets the current object class name.
  13393. * @return the class name
  13394. */
  13395. getClassName(): string;
  13396. /**
  13397. * Returns an array containing the root bones
  13398. * @returns an array containing the root bones
  13399. */
  13400. getChildren(): Array<Bone>;
  13401. /**
  13402. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13403. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13404. * @returns a Float32Array containing matrices data
  13405. */
  13406. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13407. /**
  13408. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13409. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13410. * @returns a raw texture containing the data
  13411. */
  13412. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13413. /**
  13414. * Gets the current hosting scene
  13415. * @returns a scene object
  13416. */
  13417. getScene(): Scene;
  13418. /**
  13419. * Gets a string representing the current skeleton data
  13420. * @param fullDetails defines a boolean indicating if we want a verbose version
  13421. * @returns a string representing the current skeleton data
  13422. */
  13423. toString(fullDetails?: boolean): string;
  13424. /**
  13425. * Get bone's index searching by name
  13426. * @param name defines bone's name to search for
  13427. * @return the indice of the bone. Returns -1 if not found
  13428. */
  13429. getBoneIndexByName(name: string): number;
  13430. /**
  13431. * Creater a new animation range
  13432. * @param name defines the name of the range
  13433. * @param from defines the start key
  13434. * @param to defines the end key
  13435. */
  13436. createAnimationRange(name: string, from: number, to: number): void;
  13437. /**
  13438. * Delete a specific animation range
  13439. * @param name defines the name of the range
  13440. * @param deleteFrames defines if frames must be removed as well
  13441. */
  13442. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13443. /**
  13444. * Gets a specific animation range
  13445. * @param name defines the name of the range to look for
  13446. * @returns the requested animation range or null if not found
  13447. */
  13448. getAnimationRange(name: string): Nullable<AnimationRange>;
  13449. /**
  13450. * Gets the list of all animation ranges defined on this skeleton
  13451. * @returns an array
  13452. */
  13453. getAnimationRanges(): Nullable<AnimationRange>[];
  13454. /**
  13455. * Copy animation range from a source skeleton.
  13456. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13457. * @param source defines the source skeleton
  13458. * @param name defines the name of the range to copy
  13459. * @param rescaleAsRequired defines if rescaling must be applied if required
  13460. * @returns true if operation was successful
  13461. */
  13462. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13463. /**
  13464. * Forces the skeleton to go to rest pose
  13465. */
  13466. returnToRest(): void;
  13467. private _getHighestAnimationFrame;
  13468. /**
  13469. * Begin a specific animation range
  13470. * @param name defines the name of the range to start
  13471. * @param loop defines if looping must be turned on (false by default)
  13472. * @param speedRatio defines the speed ratio to apply (1 by default)
  13473. * @param onAnimationEnd defines a callback which will be called when animation will end
  13474. * @returns a new animatable
  13475. */
  13476. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13477. /** @hidden */
  13478. _markAsDirty(): void;
  13479. /** @hidden */
  13480. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13481. /** @hidden */
  13482. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13483. private _computeTransformMatrices;
  13484. /**
  13485. * Build all resources required to render a skeleton
  13486. */
  13487. prepare(): void;
  13488. /**
  13489. * Gets the list of animatables currently running for this skeleton
  13490. * @returns an array of animatables
  13491. */
  13492. getAnimatables(): IAnimatable[];
  13493. /**
  13494. * Clone the current skeleton
  13495. * @param name defines the name of the new skeleton
  13496. * @param id defines the id of the new skeleton
  13497. * @returns the new skeleton
  13498. */
  13499. clone(name: string, id?: string): Skeleton;
  13500. /**
  13501. * Enable animation blending for this skeleton
  13502. * @param blendingSpeed defines the blending speed to apply
  13503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13504. */
  13505. enableBlending(blendingSpeed?: number): void;
  13506. /**
  13507. * Releases all resources associated with the current skeleton
  13508. */
  13509. dispose(): void;
  13510. /**
  13511. * Serialize the skeleton in a JSON object
  13512. * @returns a JSON object
  13513. */
  13514. serialize(): any;
  13515. /**
  13516. * Creates a new skeleton from serialized data
  13517. * @param parsedSkeleton defines the serialized data
  13518. * @param scene defines the hosting scene
  13519. * @returns a new skeleton
  13520. */
  13521. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13522. /**
  13523. * Compute all node absolute transforms
  13524. * @param forceUpdate defines if computation must be done even if cache is up to date
  13525. */
  13526. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13527. /**
  13528. * Gets the root pose matrix
  13529. * @returns a matrix
  13530. */
  13531. getPoseMatrix(): Nullable<Matrix>;
  13532. /**
  13533. * Sorts bones per internal index
  13534. */
  13535. sortBones(): void;
  13536. private _sortBones;
  13537. }
  13538. }
  13539. declare module BABYLON {
  13540. /**
  13541. * Class used to store bone information
  13542. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13543. */
  13544. export class Bone extends Node {
  13545. /**
  13546. * defines the bone name
  13547. */
  13548. name: string;
  13549. private static _tmpVecs;
  13550. private static _tmpQuat;
  13551. private static _tmpMats;
  13552. /**
  13553. * Gets the list of child bones
  13554. */
  13555. children: Bone[];
  13556. /** Gets the animations associated with this bone */
  13557. animations: Animation[];
  13558. /**
  13559. * Gets or sets bone length
  13560. */
  13561. length: number;
  13562. /**
  13563. * @hidden Internal only
  13564. * Set this value to map this bone to a different index in the transform matrices
  13565. * Set this value to -1 to exclude the bone from the transform matrices
  13566. */
  13567. _index: Nullable<number>;
  13568. private _skeleton;
  13569. private _localMatrix;
  13570. private _restPose;
  13571. private _baseMatrix;
  13572. private _absoluteTransform;
  13573. private _invertedAbsoluteTransform;
  13574. private _parent;
  13575. private _scalingDeterminant;
  13576. private _worldTransform;
  13577. private _localScaling;
  13578. private _localRotation;
  13579. private _localPosition;
  13580. private _needToDecompose;
  13581. private _needToCompose;
  13582. /** @hidden */
  13583. _linkedTransformNode: Nullable<TransformNode>;
  13584. /** @hidden */
  13585. _waitingTransformNodeId: Nullable<string>;
  13586. /** @hidden */
  13587. /** @hidden */
  13588. _matrix: Matrix;
  13589. /**
  13590. * Create a new bone
  13591. * @param name defines the bone name
  13592. * @param skeleton defines the parent skeleton
  13593. * @param parentBone defines the parent (can be null if the bone is the root)
  13594. * @param localMatrix defines the local matrix
  13595. * @param restPose defines the rest pose matrix
  13596. * @param baseMatrix defines the base matrix
  13597. * @param index defines index of the bone in the hiearchy
  13598. */
  13599. constructor(
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13604. /**
  13605. * Gets the current object class name.
  13606. * @return the class name
  13607. */
  13608. getClassName(): string;
  13609. /**
  13610. * Gets the parent skeleton
  13611. * @returns a skeleton
  13612. */
  13613. getSkeleton(): Skeleton;
  13614. /**
  13615. * Gets parent bone
  13616. * @returns a bone or null if the bone is the root of the bone hierarchy
  13617. */
  13618. getParent(): Nullable<Bone>;
  13619. /**
  13620. * Returns an array containing the root bones
  13621. * @returns an array containing the root bones
  13622. */
  13623. getChildren(): Array<Bone>;
  13624. /**
  13625. * Gets the node index in matrix array generated for rendering
  13626. * @returns the node index
  13627. */
  13628. getIndex(): number;
  13629. /**
  13630. * Sets the parent bone
  13631. * @param parent defines the parent (can be null if the bone is the root)
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. */
  13634. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13635. /**
  13636. * Gets the local matrix
  13637. * @returns a matrix
  13638. */
  13639. getLocalMatrix(): Matrix;
  13640. /**
  13641. * Gets the base matrix (initial matrix which remains unchanged)
  13642. * @returns a matrix
  13643. */
  13644. getBaseMatrix(): Matrix;
  13645. /**
  13646. * Gets the rest pose matrix
  13647. * @returns a matrix
  13648. */
  13649. getRestPose(): Matrix;
  13650. /**
  13651. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13652. */
  13653. getWorldMatrix(): Matrix;
  13654. /**
  13655. * Sets the local matrix to rest pose matrix
  13656. */
  13657. returnToRest(): void;
  13658. /**
  13659. * Gets the inverse of the absolute transform matrix.
  13660. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13661. * @returns a matrix
  13662. */
  13663. getInvertedAbsoluteTransform(): Matrix;
  13664. /**
  13665. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13666. * @returns a matrix
  13667. */
  13668. getAbsoluteTransform(): Matrix;
  13669. /**
  13670. * Links with the given transform node.
  13671. * The local matrix of this bone is copied from the transform node every frame.
  13672. * @param transformNode defines the transform node to link to
  13673. */
  13674. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13675. /**
  13676. * Gets the node used to drive the bone's transformation
  13677. * @returns a transform node or null
  13678. */
  13679. getTransformNode(): Nullable<TransformNode>;
  13680. /** Gets or sets current position (in local space) */
  13681. position: Vector3;
  13682. /** Gets or sets current rotation (in local space) */
  13683. rotation: Vector3;
  13684. /** Gets or sets current rotation quaternion (in local space) */
  13685. rotationQuaternion: Quaternion;
  13686. /** Gets or sets current scaling (in local space) */
  13687. scaling: Vector3;
  13688. /**
  13689. * Gets the animation properties override
  13690. */
  13691. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. private _decompose;
  13693. private _compose;
  13694. /**
  13695. * Update the base and local matrices
  13696. * @param matrix defines the new base or local matrix
  13697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13698. * @param updateLocalMatrix defines if the local matrix should be updated
  13699. */
  13700. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13701. /** @hidden */
  13702. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13703. /**
  13704. * Flag the bone as dirty (Forcing it to update everything)
  13705. */
  13706. markAsDirty(): void;
  13707. /** @hidden */
  13708. _markAsDirtyAndCompose(): void;
  13709. private _markAsDirtyAndDecompose;
  13710. /**
  13711. * Translate the bone in local or world space
  13712. * @param vec The amount to translate the bone
  13713. * @param space The space that the translation is in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Set the postion of the bone in local or world space
  13719. * @param position The position to set the bone
  13720. * @param space The space that the position is in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. */
  13723. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13724. /**
  13725. * Set the absolute position of the bone (world space)
  13726. * @param position The position to set the bone
  13727. * @param mesh The mesh that this bone is attached to
  13728. */
  13729. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13730. /**
  13731. * Scale the bone on the x, y and z axes (in local space)
  13732. * @param x The amount to scale the bone on the x axis
  13733. * @param y The amount to scale the bone on the y axis
  13734. * @param z The amount to scale the bone on the z axis
  13735. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13736. */
  13737. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13738. /**
  13739. * Set the bone scaling in local space
  13740. * @param scale defines the scaling vector
  13741. */
  13742. setScale(scale: Vector3): void;
  13743. /**
  13744. * Gets the current scaling in local space
  13745. * @returns the current scaling vector
  13746. */
  13747. getScale(): Vector3;
  13748. /**
  13749. * Gets the current scaling in local space and stores it in a target vector
  13750. * @param result defines the target vector
  13751. */
  13752. getScaleToRef(result: Vector3): void;
  13753. /**
  13754. * Set the yaw, pitch, and roll of the bone in local or world space
  13755. * @param yaw The rotation of the bone on the y axis
  13756. * @param pitch The rotation of the bone on the x axis
  13757. * @param roll The rotation of the bone on the z axis
  13758. * @param space The space that the axes of rotation are in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Add a rotation to the bone on an axis in local or world space
  13764. * @param axis The axis to rotate the bone on
  13765. * @param amount The amount to rotate the bone
  13766. * @param space The space that the axis is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the rotation of the bone to a particular axis angle in local or world space
  13772. * @param axis The axis to rotate the bone on
  13773. * @param angle The angle that the bone should be rotated to
  13774. * @param space The space that the axis is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13778. /**
  13779. * Set the euler rotation of the bone in local of world space
  13780. * @param rotation The euler rotation that the bone should be set to
  13781. * @param space The space that the rotation is in
  13782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13783. */
  13784. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13785. /**
  13786. * Set the quaternion rotation of the bone in local of world space
  13787. * @param quat The quaternion rotation that the bone should be set to
  13788. * @param space The space that the rotation is in
  13789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13790. */
  13791. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13792. /**
  13793. * Set the rotation matrix of the bone in local of world space
  13794. * @param rotMat The rotation matrix that the bone should be set to
  13795. * @param space The space that the rotation is in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13799. private _rotateWithMatrix;
  13800. private _getNegativeRotationToRef;
  13801. /**
  13802. * Get the position of the bone in local or world space
  13803. * @param space The space that the returned position is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @returns The position of the bone
  13806. */
  13807. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13808. /**
  13809. * Copy the position of the bone to a vector3 in local or world space
  13810. * @param space The space that the returned position is in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @param result The vector3 to copy the position to
  13813. */
  13814. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13815. /**
  13816. * Get the absolute position of the bone (world space)
  13817. * @param mesh The mesh that this bone is attached to
  13818. * @returns The absolute position of the bone
  13819. */
  13820. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13821. /**
  13822. * Copy the absolute position of the bone (world space) to the result param
  13823. * @param mesh The mesh that this bone is attached to
  13824. * @param result The vector3 to copy the absolute position to
  13825. */
  13826. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13827. /**
  13828. * Compute the absolute transforms of this bone and its children
  13829. */
  13830. computeAbsoluteTransforms(): void;
  13831. /**
  13832. * Get the world direction from an axis that is in the local space of the bone
  13833. * @param localAxis The local direction that is used to compute the world direction
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The world direction
  13836. */
  13837. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13840. * @param localAxis The local direction that is used to compute the world direction
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the world direction will be copied to
  13843. */
  13844. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. /**
  13846. * Get the euler rotation of the bone in local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @returns The euler rotation
  13850. */
  13851. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13852. /**
  13853. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @param result The vector3 that the rotation should be copied to
  13857. */
  13858. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13859. /**
  13860. * Get the quaternion rotation of the bone in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @returns The quaternion rotation
  13864. */
  13865. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13866. /**
  13867. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13868. * @param space The space that the rotation should be in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. * @param result The quaternion that the rotation should be copied to
  13871. */
  13872. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13873. /**
  13874. * Get the rotation matrix of the bone in local or world space
  13875. * @param space The space that the rotation should be in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. * @returns The rotation matrix
  13878. */
  13879. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13880. /**
  13881. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13882. * @param space The space that the rotation should be in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. * @param result The quaternion that the rotation should be copied to
  13885. */
  13886. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13887. /**
  13888. * Get the world position of a point that is in the local space of the bone
  13889. * @param position The local position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @returns The world position
  13892. */
  13893. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13896. * @param position The local position
  13897. * @param mesh The mesh that this bone is attached to
  13898. * @param result The vector3 that the world position should be copied to
  13899. */
  13900. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the local position of a point that is in world space
  13903. * @param position The world position
  13904. * @param mesh The mesh that this bone is attached to
  13905. * @returns The local position
  13906. */
  13907. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13908. /**
  13909. * Get the local position of a point that is in world space and copy it to the result param
  13910. * @param position The world position
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 that the local position should be copied to
  13913. */
  13914. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13915. }
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * 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.
  13920. * @see https://doc.babylonjs.com/how_to/transformnode
  13921. */
  13922. export class TransformNode extends Node {
  13923. /**
  13924. * Object will not rotate to face the camera
  13925. */
  13926. static BILLBOARDMODE_NONE: number;
  13927. /**
  13928. * Object will rotate to face the camera but only on the x axis
  13929. */
  13930. static BILLBOARDMODE_X: number;
  13931. /**
  13932. * Object will rotate to face the camera but only on the y axis
  13933. */
  13934. static BILLBOARDMODE_Y: number;
  13935. /**
  13936. * Object will rotate to face the camera but only on the z axis
  13937. */
  13938. static BILLBOARDMODE_Z: number;
  13939. /**
  13940. * Object will rotate to face the camera
  13941. */
  13942. static BILLBOARDMODE_ALL: number;
  13943. /**
  13944. * Object will rotate to face the camera's position instead of orientation
  13945. */
  13946. static BILLBOARDMODE_USE_POSITION: number;
  13947. private _forward;
  13948. private _forwardInverted;
  13949. private _up;
  13950. private _right;
  13951. private _rightInverted;
  13952. private _position;
  13953. private _rotation;
  13954. private _rotationQuaternion;
  13955. protected _scaling: Vector3;
  13956. protected _isDirty: boolean;
  13957. private _transformToBoneReferal;
  13958. private _isAbsoluteSynced;
  13959. private _billboardMode;
  13960. /**
  13961. * Gets or sets the billboard mode. Default is 0.
  13962. *
  13963. * | Value | Type | Description |
  13964. * | --- | --- | --- |
  13965. * | 0 | BILLBOARDMODE_NONE | |
  13966. * | 1 | BILLBOARDMODE_X | |
  13967. * | 2 | BILLBOARDMODE_Y | |
  13968. * | 4 | BILLBOARDMODE_Z | |
  13969. * | 7 | BILLBOARDMODE_ALL | |
  13970. *
  13971. */
  13972. billboardMode: number;
  13973. private _preserveParentRotationForBillboard;
  13974. /**
  13975. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13976. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13977. */
  13978. preserveParentRotationForBillboard: boolean;
  13979. /**
  13980. * 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
  13981. */
  13982. scalingDeterminant: number;
  13983. private _infiniteDistance;
  13984. /**
  13985. * Gets or sets the distance of the object to max, often used by skybox
  13986. */
  13987. infiniteDistance: boolean;
  13988. /**
  13989. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13990. * By default the system will update normals to compensate
  13991. */
  13992. ignoreNonUniformScaling: boolean;
  13993. /**
  13994. * 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
  13995. */
  13996. reIntegrateRotationIntoRotationQuaternion: boolean;
  13997. /** @hidden */
  13998. _poseMatrix: Nullable<Matrix>;
  13999. /** @hidden */
  14000. _localMatrix: Matrix;
  14001. private _usePivotMatrix;
  14002. private _absolutePosition;
  14003. private _absoluteScaling;
  14004. private _absoluteRotationQuaternion;
  14005. private _pivotMatrix;
  14006. private _pivotMatrixInverse;
  14007. protected _postMultiplyPivotMatrix: boolean;
  14008. protected _isWorldMatrixFrozen: boolean;
  14009. /** @hidden */
  14010. _indexInSceneTransformNodesArray: number;
  14011. /**
  14012. * An event triggered after the world matrix is updated
  14013. */
  14014. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14015. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14016. /**
  14017. * Gets a string identifying the name of the class
  14018. * @returns "TransformNode" string
  14019. */
  14020. getClassName(): string;
  14021. /**
  14022. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14023. */
  14024. position: Vector3;
  14025. /**
  14026. * 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)).
  14027. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14028. */
  14029. rotation: Vector3;
  14030. /**
  14031. * 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)).
  14032. */
  14033. scaling: Vector3;
  14034. /**
  14035. * 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).
  14036. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14037. */
  14038. rotationQuaternion: Nullable<Quaternion>;
  14039. /**
  14040. * The forward direction of that transform in world space.
  14041. */
  14042. readonly forward: Vector3;
  14043. /**
  14044. * The up direction of that transform in world space.
  14045. */
  14046. readonly up: Vector3;
  14047. /**
  14048. * The right direction of that transform in world space.
  14049. */
  14050. readonly right: Vector3;
  14051. /**
  14052. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14053. * @param matrix the matrix to copy the pose from
  14054. * @returns this TransformNode.
  14055. */
  14056. updatePoseMatrix(matrix: Matrix): TransformNode;
  14057. /**
  14058. * Returns the mesh Pose matrix.
  14059. * @returns the pose matrix
  14060. */
  14061. getPoseMatrix(): Matrix;
  14062. /** @hidden */
  14063. _isSynchronized(): boolean;
  14064. /** @hidden */
  14065. _initCache(): void;
  14066. /**
  14067. * Flag the transform node as dirty (Forcing it to update everything)
  14068. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14069. * @returns this transform node
  14070. */
  14071. markAsDirty(property: string): TransformNode;
  14072. /**
  14073. * Returns the current mesh absolute position.
  14074. * Returns a Vector3.
  14075. */
  14076. readonly absolutePosition: Vector3;
  14077. /**
  14078. * Returns the current mesh absolute scaling.
  14079. * Returns a Vector3.
  14080. */
  14081. readonly absoluteScaling: Vector3;
  14082. /**
  14083. * Returns the current mesh absolute rotation.
  14084. * Returns a Quaternion.
  14085. */
  14086. readonly absoluteRotationQuaternion: Quaternion;
  14087. /**
  14088. * Sets a new matrix to apply before all other transformation
  14089. * @param matrix defines the transform matrix
  14090. * @returns the current TransformNode
  14091. */
  14092. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14093. /**
  14094. * Sets a new pivot matrix to the current node
  14095. * @param matrix defines the new pivot matrix to use
  14096. * @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
  14097. * @returns the current TransformNode
  14098. */
  14099. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14100. /**
  14101. * Returns the mesh pivot matrix.
  14102. * Default : Identity.
  14103. * @returns the matrix
  14104. */
  14105. getPivotMatrix(): Matrix;
  14106. /**
  14107. * Instantiate (when possible) or clone that node with its hierarchy
  14108. * @param newParent defines the new parent to use for the instance (or clone)
  14109. * @param options defines options to configure how copy is done
  14110. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14111. * @returns an instance (or a clone) of the current node with its hiearchy
  14112. */
  14113. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14114. doNotInstantiate: boolean;
  14115. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14116. /**
  14117. * Prevents the World matrix to be computed any longer
  14118. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14119. * @returns the TransformNode.
  14120. */
  14121. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14122. /**
  14123. * Allows back the World matrix computation.
  14124. * @returns the TransformNode.
  14125. */
  14126. unfreezeWorldMatrix(): this;
  14127. /**
  14128. * True if the World matrix has been frozen.
  14129. */
  14130. readonly isWorldMatrixFrozen: boolean;
  14131. /**
  14132. * Retuns the mesh absolute position in the World.
  14133. * @returns a Vector3.
  14134. */
  14135. getAbsolutePosition(): Vector3;
  14136. /**
  14137. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14138. * @param absolutePosition the absolute position to set
  14139. * @returns the TransformNode.
  14140. */
  14141. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14142. /**
  14143. * Sets the mesh position in its local space.
  14144. * @param vector3 the position to set in localspace
  14145. * @returns the TransformNode.
  14146. */
  14147. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14148. /**
  14149. * Returns the mesh position in the local space from the current World matrix values.
  14150. * @returns a new Vector3.
  14151. */
  14152. getPositionExpressedInLocalSpace(): Vector3;
  14153. /**
  14154. * Translates the mesh along the passed Vector3 in its local space.
  14155. * @param vector3 the distance to translate in localspace
  14156. * @returns the TransformNode.
  14157. */
  14158. locallyTranslate(vector3: Vector3): TransformNode;
  14159. private static _lookAtVectorCache;
  14160. /**
  14161. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14162. * @param targetPoint the position (must be in same space as current mesh) to look at
  14163. * @param yawCor optional yaw (y-axis) correction in radians
  14164. * @param pitchCor optional pitch (x-axis) correction in radians
  14165. * @param rollCor optional roll (z-axis) correction in radians
  14166. * @param space the choosen space of the target
  14167. * @returns the TransformNode.
  14168. */
  14169. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14170. /**
  14171. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14172. * This Vector3 is expressed in the World space.
  14173. * @param localAxis axis to rotate
  14174. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14175. */
  14176. getDirection(localAxis: Vector3): Vector3;
  14177. /**
  14178. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14179. * localAxis is expressed in the mesh local space.
  14180. * result is computed in the Wordl space from the mesh World matrix.
  14181. * @param localAxis axis to rotate
  14182. * @param result the resulting transformnode
  14183. * @returns this TransformNode.
  14184. */
  14185. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14186. /**
  14187. * Sets this transform node rotation to the given local axis.
  14188. * @param localAxis the axis in local space
  14189. * @param yawCor optional yaw (y-axis) correction in radians
  14190. * @param pitchCor optional pitch (x-axis) correction in radians
  14191. * @param rollCor optional roll (z-axis) correction in radians
  14192. * @returns this TransformNode
  14193. */
  14194. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14195. /**
  14196. * Sets a new pivot point to the current node
  14197. * @param point defines the new pivot point to use
  14198. * @param space defines if the point is in world or local space (local by default)
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14202. /**
  14203. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14204. * @returns the pivot point
  14205. */
  14206. getPivotPoint(): Vector3;
  14207. /**
  14208. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14209. * @param result the vector3 to store the result
  14210. * @returns this TransformNode.
  14211. */
  14212. getPivotPointToRef(result: Vector3): TransformNode;
  14213. /**
  14214. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14215. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14216. */
  14217. getAbsolutePivotPoint(): Vector3;
  14218. /**
  14219. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14220. * @param result vector3 to store the result
  14221. * @returns this TransformNode.
  14222. */
  14223. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14224. /**
  14225. * Defines the passed node as the parent of the current node.
  14226. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14227. * @see https://doc.babylonjs.com/how_to/parenting
  14228. * @param node the node ot set as the parent
  14229. * @returns this TransformNode.
  14230. */
  14231. setParent(node: Nullable<Node>): TransformNode;
  14232. private _nonUniformScaling;
  14233. /**
  14234. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14235. */
  14236. readonly nonUniformScaling: boolean;
  14237. /** @hidden */
  14238. _updateNonUniformScalingState(value: boolean): boolean;
  14239. /**
  14240. * Attach the current TransformNode to another TransformNode associated with a bone
  14241. * @param bone Bone affecting the TransformNode
  14242. * @param affectedTransformNode TransformNode associated with the bone
  14243. * @returns this object
  14244. */
  14245. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14246. /**
  14247. * Detach the transform node if its associated with a bone
  14248. * @returns this object
  14249. */
  14250. detachFromBone(): TransformNode;
  14251. private static _rotationAxisCache;
  14252. /**
  14253. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14254. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14255. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14256. * The passed axis is also normalized.
  14257. * @param axis the axis to rotate around
  14258. * @param amount the amount to rotate in radians
  14259. * @param space Space to rotate in (Default: local)
  14260. * @returns the TransformNode.
  14261. */
  14262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14263. /**
  14264. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14265. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14266. * The passed axis is also normalized. .
  14267. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14268. * @param point the point to rotate around
  14269. * @param axis the axis to rotate around
  14270. * @param amount the amount to rotate in radians
  14271. * @returns the TransformNode
  14272. */
  14273. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14274. /**
  14275. * Translates the mesh along the axis vector for the passed distance in the given space.
  14276. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14277. * @param axis the axis to translate in
  14278. * @param distance the distance to translate
  14279. * @param space Space to rotate in (Default: local)
  14280. * @returns the TransformNode.
  14281. */
  14282. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14283. /**
  14284. * Adds a rotation step to the mesh current rotation.
  14285. * x, y, z are Euler angles expressed in radians.
  14286. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14287. * This means this rotation is made in the mesh local space only.
  14288. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14289. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14290. * ```javascript
  14291. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14292. * ```
  14293. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14294. * 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.
  14295. * @param x Rotation to add
  14296. * @param y Rotation to add
  14297. * @param z Rotation to add
  14298. * @returns the TransformNode.
  14299. */
  14300. addRotation(x: number, y: number, z: number): TransformNode;
  14301. /**
  14302. * @hidden
  14303. */
  14304. protected _getEffectiveParent(): Nullable<Node>;
  14305. /**
  14306. * Computes the world matrix of the node
  14307. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14308. * @returns the world matrix
  14309. */
  14310. computeWorldMatrix(force?: boolean): Matrix;
  14311. protected _afterComputeWorldMatrix(): void;
  14312. /**
  14313. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14314. * @param func callback function to add
  14315. *
  14316. * @returns the TransformNode.
  14317. */
  14318. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14319. /**
  14320. * Removes a registered callback function.
  14321. * @param func callback function to remove
  14322. * @returns the TransformNode.
  14323. */
  14324. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14325. /**
  14326. * Gets the position of the current mesh in camera space
  14327. * @param camera defines the camera to use
  14328. * @returns a position
  14329. */
  14330. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14331. /**
  14332. * Returns the distance from the mesh to the active camera
  14333. * @param camera defines the camera to use
  14334. * @returns the distance
  14335. */
  14336. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14337. /**
  14338. * Clone the current transform node
  14339. * @param name Name of the new clone
  14340. * @param newParent New parent for the clone
  14341. * @param doNotCloneChildren Do not clone children hierarchy
  14342. * @returns the new transform node
  14343. */
  14344. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14345. /**
  14346. * Serializes the objects information.
  14347. * @param currentSerializationObject defines the object to serialize in
  14348. * @returns the serialized object
  14349. */
  14350. serialize(currentSerializationObject?: any): any;
  14351. /**
  14352. * Returns a new TransformNode object parsed from the source provided.
  14353. * @param parsedTransformNode is the source.
  14354. * @param scene the scne the object belongs to
  14355. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14356. * @returns a new TransformNode object parsed from the source provided.
  14357. */
  14358. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14359. /**
  14360. * Get all child-transformNodes of this node
  14361. * @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
  14362. * @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
  14363. * @returns an array of TransformNode
  14364. */
  14365. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14366. /**
  14367. * Releases resources associated with this transform node.
  14368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14370. */
  14371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14372. /**
  14373. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14374. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14375. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14376. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14377. * @returns the current mesh
  14378. */
  14379. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14380. private _syncAbsoluteScalingAndRotation;
  14381. }
  14382. }
  14383. declare module BABYLON {
  14384. /**
  14385. * Defines the types of pose enabled controllers that are supported
  14386. */
  14387. export enum PoseEnabledControllerType {
  14388. /**
  14389. * HTC Vive
  14390. */
  14391. VIVE = 0,
  14392. /**
  14393. * Oculus Rift
  14394. */
  14395. OCULUS = 1,
  14396. /**
  14397. * Windows mixed reality
  14398. */
  14399. WINDOWS = 2,
  14400. /**
  14401. * Samsung gear VR
  14402. */
  14403. GEAR_VR = 3,
  14404. /**
  14405. * Google Daydream
  14406. */
  14407. DAYDREAM = 4,
  14408. /**
  14409. * Generic
  14410. */
  14411. GENERIC = 5
  14412. }
  14413. /**
  14414. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14415. */
  14416. export interface MutableGamepadButton {
  14417. /**
  14418. * Value of the button/trigger
  14419. */
  14420. value: number;
  14421. /**
  14422. * If the button/trigger is currently touched
  14423. */
  14424. touched: boolean;
  14425. /**
  14426. * If the button/trigger is currently pressed
  14427. */
  14428. pressed: boolean;
  14429. }
  14430. /**
  14431. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14432. * @hidden
  14433. */
  14434. export interface ExtendedGamepadButton extends GamepadButton {
  14435. /**
  14436. * If the button/trigger is currently pressed
  14437. */
  14438. readonly pressed: boolean;
  14439. /**
  14440. * If the button/trigger is currently touched
  14441. */
  14442. readonly touched: boolean;
  14443. /**
  14444. * Value of the button/trigger
  14445. */
  14446. readonly value: number;
  14447. }
  14448. /** @hidden */
  14449. export interface _GamePadFactory {
  14450. /**
  14451. * Returns wether or not the current gamepad can be created for this type of controller.
  14452. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14453. * @returns true if it can be created, otherwise false
  14454. */
  14455. canCreate(gamepadInfo: any): boolean;
  14456. /**
  14457. * Creates a new instance of the Gamepad.
  14458. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14459. * @returns the new gamepad instance
  14460. */
  14461. create(gamepadInfo: any): Gamepad;
  14462. }
  14463. /**
  14464. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14465. */
  14466. export class PoseEnabledControllerHelper {
  14467. /** @hidden */
  14468. static _ControllerFactories: _GamePadFactory[];
  14469. /** @hidden */
  14470. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14471. /**
  14472. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14473. * @param vrGamepad the gamepad to initialized
  14474. * @returns a vr controller of the type the gamepad identified as
  14475. */
  14476. static InitiateController(vrGamepad: any): Gamepad;
  14477. }
  14478. /**
  14479. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14480. */
  14481. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14482. /**
  14483. * If the controller is used in a webXR session
  14484. */
  14485. isXR: boolean;
  14486. private _deviceRoomPosition;
  14487. private _deviceRoomRotationQuaternion;
  14488. /**
  14489. * The device position in babylon space
  14490. */
  14491. devicePosition: Vector3;
  14492. /**
  14493. * The device rotation in babylon space
  14494. */
  14495. deviceRotationQuaternion: Quaternion;
  14496. /**
  14497. * The scale factor of the device in babylon space
  14498. */
  14499. deviceScaleFactor: number;
  14500. /**
  14501. * (Likely devicePosition should be used instead) The device position in its room space
  14502. */
  14503. position: Vector3;
  14504. /**
  14505. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14506. */
  14507. rotationQuaternion: Quaternion;
  14508. /**
  14509. * The type of controller (Eg. Windows mixed reality)
  14510. */
  14511. controllerType: PoseEnabledControllerType;
  14512. protected _calculatedPosition: Vector3;
  14513. private _calculatedRotation;
  14514. /**
  14515. * The raw pose from the device
  14516. */
  14517. rawPose: DevicePose;
  14518. private _trackPosition;
  14519. private _maxRotationDistFromHeadset;
  14520. private _draggedRoomRotation;
  14521. /**
  14522. * @hidden
  14523. */
  14524. _disableTrackPosition(fixedPosition: Vector3): void;
  14525. /**
  14526. * Internal, the mesh attached to the controller
  14527. * @hidden
  14528. */
  14529. _mesh: Nullable<AbstractMesh>;
  14530. private _poseControlledCamera;
  14531. private _leftHandSystemQuaternion;
  14532. /**
  14533. * Internal, matrix used to convert room space to babylon space
  14534. * @hidden
  14535. */
  14536. _deviceToWorld: Matrix;
  14537. /**
  14538. * Node to be used when casting a ray from the controller
  14539. * @hidden
  14540. */
  14541. _pointingPoseNode: Nullable<TransformNode>;
  14542. /**
  14543. * Name of the child mesh that can be used to cast a ray from the controller
  14544. */
  14545. static readonly POINTING_POSE: string;
  14546. /**
  14547. * Creates a new PoseEnabledController from a gamepad
  14548. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14549. */
  14550. constructor(browserGamepad: any);
  14551. private _workingMatrix;
  14552. /**
  14553. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14554. */
  14555. update(): void;
  14556. /**
  14557. * Updates only the pose device and mesh without doing any button event checking
  14558. */
  14559. protected _updatePoseAndMesh(): void;
  14560. /**
  14561. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14562. * @param poseData raw pose fromthe device
  14563. */
  14564. updateFromDevice(poseData: DevicePose): void;
  14565. /**
  14566. * @hidden
  14567. */
  14568. _meshAttachedObservable: Observable<AbstractMesh>;
  14569. /**
  14570. * Attaches a mesh to the controller
  14571. * @param mesh the mesh to be attached
  14572. */
  14573. attachToMesh(mesh: AbstractMesh): void;
  14574. /**
  14575. * Attaches the controllers mesh to a camera
  14576. * @param camera the camera the mesh should be attached to
  14577. */
  14578. attachToPoseControlledCamera(camera: TargetCamera): void;
  14579. /**
  14580. * Disposes of the controller
  14581. */
  14582. dispose(): void;
  14583. /**
  14584. * The mesh that is attached to the controller
  14585. */
  14586. readonly mesh: Nullable<AbstractMesh>;
  14587. /**
  14588. * Gets the ray of the controller in the direction the controller is pointing
  14589. * @param length the length the resulting ray should be
  14590. * @returns a ray in the direction the controller is pointing
  14591. */
  14592. getForwardRay(length?: number): Ray;
  14593. }
  14594. }
  14595. declare module BABYLON {
  14596. /**
  14597. * Defines the WebVRController object that represents controllers tracked in 3D space
  14598. */
  14599. export abstract class WebVRController extends PoseEnabledController {
  14600. /**
  14601. * Internal, the default controller model for the controller
  14602. */
  14603. protected _defaultModel: Nullable<AbstractMesh>;
  14604. /**
  14605. * Fired when the trigger state has changed
  14606. */
  14607. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14608. /**
  14609. * Fired when the main button state has changed
  14610. */
  14611. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14612. /**
  14613. * Fired when the secondary button state has changed
  14614. */
  14615. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14616. /**
  14617. * Fired when the pad state has changed
  14618. */
  14619. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14620. /**
  14621. * Fired when controllers stick values have changed
  14622. */
  14623. onPadValuesChangedObservable: Observable<StickValues>;
  14624. /**
  14625. * Array of button availible on the controller
  14626. */
  14627. protected _buttons: Array<MutableGamepadButton>;
  14628. private _onButtonStateChange;
  14629. /**
  14630. * Fired when a controller button's state has changed
  14631. * @param callback the callback containing the button that was modified
  14632. */
  14633. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14634. /**
  14635. * X and Y axis corresponding to the controllers joystick
  14636. */
  14637. pad: StickValues;
  14638. /**
  14639. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14640. */
  14641. hand: string;
  14642. /**
  14643. * The default controller model for the controller
  14644. */
  14645. readonly defaultModel: Nullable<AbstractMesh>;
  14646. /**
  14647. * Creates a new WebVRController from a gamepad
  14648. * @param vrGamepad the gamepad that the WebVRController should be created from
  14649. */
  14650. constructor(vrGamepad: any);
  14651. /**
  14652. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14653. */
  14654. update(): void;
  14655. /**
  14656. * Function to be called when a button is modified
  14657. */
  14658. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14659. /**
  14660. * Loads a mesh and attaches it to the controller
  14661. * @param scene the scene the mesh should be added to
  14662. * @param meshLoaded callback for when the mesh has been loaded
  14663. */
  14664. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14665. private _setButtonValue;
  14666. private _changes;
  14667. private _checkChanges;
  14668. /**
  14669. * Disposes of th webVRCOntroller
  14670. */
  14671. dispose(): void;
  14672. }
  14673. }
  14674. declare module BABYLON {
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * 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.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14725. /**
  14726. * Computes the world matrix of the node
  14727. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14728. * @param useWasUpdatedFlag defines a reserved property
  14729. * @returns the world matrix
  14730. */
  14731. computeWorldMatrix(): Matrix;
  14732. /**
  14733. * Returns the integer 3.
  14734. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14735. */
  14736. getTypeID(): number;
  14737. /**
  14738. * Prepares the list of defines specific to the light type.
  14739. * @param defines the list of defines
  14740. * @param lightIndex defines the index of the light for the effect
  14741. */
  14742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14743. }
  14744. }
  14745. declare module BABYLON {
  14746. /** @hidden */
  14747. export var vrMultiviewToSingleviewPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module BABYLON {
  14753. /**
  14754. * Renders to multiple views with a single draw call
  14755. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14756. */
  14757. export class MultiviewRenderTarget extends RenderTargetTexture {
  14758. /**
  14759. * Creates a multiview render target
  14760. * @param scene scene used with the render target
  14761. * @param size the size of the render target (used for each view)
  14762. */
  14763. constructor(scene: Scene, size?: number | {
  14764. width: number;
  14765. height: number;
  14766. } | {
  14767. ratio: number;
  14768. });
  14769. /**
  14770. * @hidden
  14771. * @param faceIndex the face index, if its a cube texture
  14772. */
  14773. _bindFrameBuffer(faceIndex?: number): void;
  14774. /**
  14775. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14776. * @returns the view count
  14777. */
  14778. getViewCount(): number;
  14779. }
  14780. }
  14781. declare module BABYLON {
  14782. /**
  14783. * Represents a camera frustum
  14784. */
  14785. export class Frustum {
  14786. /**
  14787. * Gets the planes representing the frustum
  14788. * @param transform matrix to be applied to the returned planes
  14789. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14790. */
  14791. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14792. /**
  14793. * Gets the near frustum plane transformed by the transform matrix
  14794. * @param transform transformation matrix to be applied to the resulting frustum plane
  14795. * @param frustumPlane the resuling frustum plane
  14796. */
  14797. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14798. /**
  14799. * Gets the far frustum plane transformed by the transform matrix
  14800. * @param transform transformation matrix to be applied to the resulting frustum plane
  14801. * @param frustumPlane the resuling frustum plane
  14802. */
  14803. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14804. /**
  14805. * Gets the left frustum plane transformed by the transform matrix
  14806. * @param transform transformation matrix to be applied to the resulting frustum plane
  14807. * @param frustumPlane the resuling frustum plane
  14808. */
  14809. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14810. /**
  14811. * Gets the right frustum plane transformed by the transform matrix
  14812. * @param transform transformation matrix to be applied to the resulting frustum plane
  14813. * @param frustumPlane the resuling frustum plane
  14814. */
  14815. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14816. /**
  14817. * Gets the top frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the bottom frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14830. * @param transform transformation matrix to be applied to the resulting frustum planes
  14831. * @param frustumPlanes the resuling frustum planes
  14832. */
  14833. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14834. }
  14835. }
  14836. declare module BABYLON {
  14837. interface Engine {
  14838. /**
  14839. * Creates a new multiview render target
  14840. * @param width defines the width of the texture
  14841. * @param height defines the height of the texture
  14842. * @returns the created multiview texture
  14843. */
  14844. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14845. /**
  14846. * Binds a multiview framebuffer to be drawn to
  14847. * @param multiviewTexture texture to bind
  14848. */
  14849. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14850. }
  14851. interface Camera {
  14852. /**
  14853. * @hidden
  14854. * 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)
  14855. */
  14856. _useMultiviewToSingleView: boolean;
  14857. /**
  14858. * @hidden
  14859. * 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)
  14860. */
  14861. _multiviewTexture: Nullable<RenderTargetTexture>;
  14862. /**
  14863. * @hidden
  14864. * ensures the multiview texture of the camera exists and has the specified width/height
  14865. * @param width height to set on the multiview texture
  14866. * @param height width to set on the multiview texture
  14867. */
  14868. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14869. }
  14870. interface Scene {
  14871. /** @hidden */
  14872. _transformMatrixR: Matrix;
  14873. /** @hidden */
  14874. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14875. /** @hidden */
  14876. _createMultiviewUbo(): void;
  14877. /** @hidden */
  14878. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14879. /** @hidden */
  14880. _renderMultiviewToSingleView(camera: Camera): void;
  14881. }
  14882. }
  14883. declare module BABYLON {
  14884. /**
  14885. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14886. * This will not be used for webXR as it supports displaying texture arrays directly
  14887. */
  14888. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14889. /**
  14890. * Initializes a VRMultiviewToSingleview
  14891. * @param name name of the post process
  14892. * @param camera camera to be applied to
  14893. * @param scaleFactor scaling factor to the size of the output texture
  14894. */
  14895. constructor(name: string, camera: Camera, scaleFactor: number);
  14896. }
  14897. }
  14898. declare module BABYLON {
  14899. /**
  14900. * Interface used to define additional presentation attributes
  14901. */
  14902. export interface IVRPresentationAttributes {
  14903. /**
  14904. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14905. */
  14906. highRefreshRate: boolean;
  14907. /**
  14908. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14909. */
  14910. foveationLevel: number;
  14911. }
  14912. interface Engine {
  14913. /** @hidden */
  14914. _vrDisplay: any;
  14915. /** @hidden */
  14916. _vrSupported: boolean;
  14917. /** @hidden */
  14918. _oldSize: Size;
  14919. /** @hidden */
  14920. _oldHardwareScaleFactor: number;
  14921. /** @hidden */
  14922. _vrExclusivePointerMode: boolean;
  14923. /** @hidden */
  14924. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14925. /** @hidden */
  14926. _onVRDisplayPointerRestricted: () => void;
  14927. /** @hidden */
  14928. _onVRDisplayPointerUnrestricted: () => void;
  14929. /** @hidden */
  14930. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14931. /** @hidden */
  14932. _onVrDisplayDisconnect: Nullable<() => void>;
  14933. /** @hidden */
  14934. _onVrDisplayPresentChange: Nullable<() => void>;
  14935. /**
  14936. * Observable signaled when VR display mode changes
  14937. */
  14938. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14939. /**
  14940. * Observable signaled when VR request present is complete
  14941. */
  14942. onVRRequestPresentComplete: Observable<boolean>;
  14943. /**
  14944. * Observable signaled when VR request present starts
  14945. */
  14946. onVRRequestPresentStart: Observable<Engine>;
  14947. /**
  14948. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14949. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14950. */
  14951. isInVRExclusivePointerMode: boolean;
  14952. /**
  14953. * Gets a boolean indicating if a webVR device was detected
  14954. * @returns true if a webVR device was detected
  14955. */
  14956. isVRDevicePresent(): boolean;
  14957. /**
  14958. * Gets the current webVR device
  14959. * @returns the current webVR device (or null)
  14960. */
  14961. getVRDevice(): any;
  14962. /**
  14963. * Initializes a webVR display and starts listening to display change events
  14964. * The onVRDisplayChangedObservable will be notified upon these changes
  14965. * @returns A promise containing a VRDisplay and if vr is supported
  14966. */
  14967. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14968. /** @hidden */
  14969. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14970. /**
  14971. * Gets or sets the presentation attributes used to configure VR rendering
  14972. */
  14973. vrPresentationAttributes?: IVRPresentationAttributes;
  14974. /**
  14975. * Call this function to switch to webVR mode
  14976. * Will do nothing if webVR is not supported or if there is no webVR device
  14977. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14978. */
  14979. enableVR(): void;
  14980. /** @hidden */
  14981. _onVRFullScreenTriggered(): void;
  14982. }
  14983. }
  14984. declare module BABYLON {
  14985. /**
  14986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14987. * IMPORTANT!! The data is right-hand data.
  14988. * @export
  14989. * @interface DevicePose
  14990. */
  14991. export interface DevicePose {
  14992. /**
  14993. * The position of the device, values in array are [x,y,z].
  14994. */
  14995. readonly position: Nullable<Float32Array>;
  14996. /**
  14997. * The linearVelocity of the device, values in array are [x,y,z].
  14998. */
  14999. readonly linearVelocity: Nullable<Float32Array>;
  15000. /**
  15001. * The linearAcceleration of the device, values in array are [x,y,z].
  15002. */
  15003. readonly linearAcceleration: Nullable<Float32Array>;
  15004. /**
  15005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15006. */
  15007. readonly orientation: Nullable<Float32Array>;
  15008. /**
  15009. * The angularVelocity of the device, values in array are [x,y,z].
  15010. */
  15011. readonly angularVelocity: Nullable<Float32Array>;
  15012. /**
  15013. * The angularAcceleration of the device, values in array are [x,y,z].
  15014. */
  15015. readonly angularAcceleration: Nullable<Float32Array>;
  15016. }
  15017. /**
  15018. * Interface representing a pose controlled object in Babylon.
  15019. * A pose controlled object has both regular pose values as well as pose values
  15020. * from an external device such as a VR head mounted display
  15021. */
  15022. export interface PoseControlled {
  15023. /**
  15024. * The position of the object in babylon space.
  15025. */
  15026. position: Vector3;
  15027. /**
  15028. * The rotation quaternion of the object in babylon space.
  15029. */
  15030. rotationQuaternion: Quaternion;
  15031. /**
  15032. * The position of the device in babylon space.
  15033. */
  15034. devicePosition?: Vector3;
  15035. /**
  15036. * The rotation quaternion of the device in babylon space.
  15037. */
  15038. deviceRotationQuaternion: Quaternion;
  15039. /**
  15040. * The raw pose coming from the device.
  15041. */
  15042. rawPose: Nullable<DevicePose>;
  15043. /**
  15044. * The scale of the device to be used when translating from device space to babylon space.
  15045. */
  15046. deviceScaleFactor: number;
  15047. /**
  15048. * Updates the poseControlled values based on the input device pose.
  15049. * @param poseData the pose data to update the object with
  15050. */
  15051. updateFromDevice(poseData: DevicePose): void;
  15052. }
  15053. /**
  15054. * Set of options to customize the webVRCamera
  15055. */
  15056. export interface WebVROptions {
  15057. /**
  15058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15059. */
  15060. trackPosition?: boolean;
  15061. /**
  15062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15063. */
  15064. positionScale?: number;
  15065. /**
  15066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15067. */
  15068. displayName?: string;
  15069. /**
  15070. * Should the native controller meshes be initialized. (default: true)
  15071. */
  15072. controllerMeshes?: boolean;
  15073. /**
  15074. * Creating a default HemiLight only on controllers. (default: true)
  15075. */
  15076. defaultLightingOnControllers?: boolean;
  15077. /**
  15078. * If you don't want to use the default VR button of the helper. (default: false)
  15079. */
  15080. useCustomVRButton?: boolean;
  15081. /**
  15082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15083. */
  15084. customVRButton?: HTMLButtonElement;
  15085. /**
  15086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15087. */
  15088. rayLength?: number;
  15089. /**
  15090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15091. */
  15092. defaultHeight?: number;
  15093. /**
  15094. * If multiview should be used if availible (default: false)
  15095. */
  15096. useMultiview?: boolean;
  15097. }
  15098. /**
  15099. * This represents a WebVR camera.
  15100. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15101. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15102. */
  15103. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15104. private webVROptions;
  15105. /**
  15106. * @hidden
  15107. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15108. */
  15109. _vrDevice: any;
  15110. /**
  15111. * The rawPose of the vrDevice.
  15112. */
  15113. rawPose: Nullable<DevicePose>;
  15114. private _onVREnabled;
  15115. private _specsVersion;
  15116. private _attached;
  15117. private _frameData;
  15118. protected _descendants: Array<Node>;
  15119. private _deviceRoomPosition;
  15120. /** @hidden */
  15121. _deviceRoomRotationQuaternion: Quaternion;
  15122. private _standingMatrix;
  15123. /**
  15124. * Represents device position in babylon space.
  15125. */
  15126. devicePosition: Vector3;
  15127. /**
  15128. * Represents device rotation in babylon space.
  15129. */
  15130. deviceRotationQuaternion: Quaternion;
  15131. /**
  15132. * The scale of the device to be used when translating from device space to babylon space.
  15133. */
  15134. deviceScaleFactor: number;
  15135. private _deviceToWorld;
  15136. private _worldToDevice;
  15137. /**
  15138. * References to the webVR controllers for the vrDevice.
  15139. */
  15140. controllers: Array<WebVRController>;
  15141. /**
  15142. * Emits an event when a controller is attached.
  15143. */
  15144. onControllersAttachedObservable: Observable<WebVRController[]>;
  15145. /**
  15146. * Emits an event when a controller's mesh has been loaded;
  15147. */
  15148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15149. /**
  15150. * Emits an event when the HMD's pose has been updated.
  15151. */
  15152. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15153. private _poseSet;
  15154. /**
  15155. * If the rig cameras be used as parent instead of this camera.
  15156. */
  15157. rigParenting: boolean;
  15158. private _lightOnControllers;
  15159. private _defaultHeight?;
  15160. /**
  15161. * Instantiates a WebVRFreeCamera.
  15162. * @param name The name of the WebVRFreeCamera
  15163. * @param position The starting anchor position for the camera
  15164. * @param scene The scene the camera belongs to
  15165. * @param webVROptions a set of customizable options for the webVRCamera
  15166. */
  15167. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15168. /**
  15169. * Gets the device distance from the ground in meters.
  15170. * @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.
  15171. */
  15172. deviceDistanceToRoomGround(): number;
  15173. /**
  15174. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15175. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15176. */
  15177. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15178. /**
  15179. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15180. * @returns A promise with a boolean set to if the standing matrix is supported.
  15181. */
  15182. useStandingMatrixAsync(): Promise<boolean>;
  15183. /**
  15184. * Disposes the camera
  15185. */
  15186. dispose(): void;
  15187. /**
  15188. * Gets a vrController by name.
  15189. * @param name The name of the controller to retreive
  15190. * @returns the controller matching the name specified or null if not found
  15191. */
  15192. getControllerByName(name: string): Nullable<WebVRController>;
  15193. private _leftController;
  15194. /**
  15195. * The controller corresponding to the users left hand.
  15196. */
  15197. readonly leftController: Nullable<WebVRController>;
  15198. private _rightController;
  15199. /**
  15200. * The controller corresponding to the users right hand.
  15201. */
  15202. readonly rightController: Nullable<WebVRController>;
  15203. /**
  15204. * Casts a ray forward from the vrCamera's gaze.
  15205. * @param length Length of the ray (default: 100)
  15206. * @returns the ray corresponding to the gaze
  15207. */
  15208. getForwardRay(length?: number): Ray;
  15209. /**
  15210. * @hidden
  15211. * Updates the camera based on device's frame data
  15212. */
  15213. _checkInputs(): void;
  15214. /**
  15215. * Updates the poseControlled values based on the input device pose.
  15216. * @param poseData Pose coming from the device
  15217. */
  15218. updateFromDevice(poseData: DevicePose): void;
  15219. private _htmlElementAttached;
  15220. private _detachIfAttached;
  15221. /**
  15222. * WebVR's attach control will start broadcasting frames to the device.
  15223. * Note that in certain browsers (chrome for example) this function must be called
  15224. * within a user-interaction callback. Example:
  15225. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15226. *
  15227. * @param element html element to attach the vrDevice to
  15228. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15229. */
  15230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15231. /**
  15232. * Detaches the camera from the html element and disables VR
  15233. *
  15234. * @param element html element to detach from
  15235. */
  15236. detachControl(element: HTMLElement): void;
  15237. /**
  15238. * @returns the name of this class
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Calls resetPose on the vrDisplay
  15243. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15244. */
  15245. resetToCurrentRotation(): void;
  15246. /**
  15247. * @hidden
  15248. * Updates the rig cameras (left and right eye)
  15249. */
  15250. _updateRigCameras(): void;
  15251. private _workingVector;
  15252. private _oneVector;
  15253. private _workingMatrix;
  15254. private updateCacheCalled;
  15255. private _correctPositionIfNotTrackPosition;
  15256. /**
  15257. * @hidden
  15258. * Updates the cached values of the camera
  15259. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15260. */
  15261. _updateCache(ignoreParentClass?: boolean): void;
  15262. /**
  15263. * @hidden
  15264. * Get current device position in babylon world
  15265. */
  15266. _computeDevicePosition(): void;
  15267. /**
  15268. * Updates the current device position and rotation in the babylon world
  15269. */
  15270. update(): void;
  15271. /**
  15272. * @hidden
  15273. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15274. * @returns an identity matrix
  15275. */
  15276. _getViewMatrix(): Matrix;
  15277. private _tmpMatrix;
  15278. /**
  15279. * This function is called by the two RIG cameras.
  15280. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15281. * @hidden
  15282. */
  15283. _getWebVRViewMatrix(): Matrix;
  15284. /** @hidden */
  15285. _getWebVRProjectionMatrix(): Matrix;
  15286. private _onGamepadConnectedObserver;
  15287. private _onGamepadDisconnectedObserver;
  15288. private _updateCacheWhenTrackingDisabledObserver;
  15289. /**
  15290. * Initializes the controllers and their meshes
  15291. */
  15292. initControllers(): void;
  15293. }
  15294. }
  15295. declare module BABYLON {
  15296. /**
  15297. * Size options for a post process
  15298. */
  15299. export type PostProcessOptions = {
  15300. width: number;
  15301. height: number;
  15302. };
  15303. /**
  15304. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15305. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15306. */
  15307. export class PostProcess {
  15308. /** Name of the PostProcess. */
  15309. name: string;
  15310. /**
  15311. * Gets or sets the unique id of the post process
  15312. */
  15313. uniqueId: number;
  15314. /**
  15315. * Width of the texture to apply the post process on
  15316. */
  15317. width: number;
  15318. /**
  15319. * Height of the texture to apply the post process on
  15320. */
  15321. height: number;
  15322. /**
  15323. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15324. * @hidden
  15325. */
  15326. _outputTexture: Nullable<InternalTexture>;
  15327. /**
  15328. * Sampling mode used by the shader
  15329. * See https://doc.babylonjs.com/classes/3.1/texture
  15330. */
  15331. renderTargetSamplingMode: number;
  15332. /**
  15333. * Clear color to use when screen clearing
  15334. */
  15335. clearColor: Color4;
  15336. /**
  15337. * If the buffer needs to be cleared before applying the post process. (default: true)
  15338. * Should be set to false if shader will overwrite all previous pixels.
  15339. */
  15340. autoClear: boolean;
  15341. /**
  15342. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15343. */
  15344. alphaMode: number;
  15345. /**
  15346. * Sets the setAlphaBlendConstants of the babylon engine
  15347. */
  15348. alphaConstants: Color4;
  15349. /**
  15350. * Animations to be used for the post processing
  15351. */
  15352. animations: Animation[];
  15353. /**
  15354. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15355. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15356. */
  15357. enablePixelPerfectMode: boolean;
  15358. /**
  15359. * Force the postprocess to be applied without taking in account viewport
  15360. */
  15361. forceFullscreenViewport: boolean;
  15362. /**
  15363. * List of inspectable custom properties (used by the Inspector)
  15364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15365. */
  15366. inspectableCustomProperties: IInspectable[];
  15367. /**
  15368. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15369. *
  15370. * | Value | Type | Description |
  15371. * | ----- | ----------------------------------- | ----------- |
  15372. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15373. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15374. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15375. *
  15376. */
  15377. scaleMode: number;
  15378. /**
  15379. * Force textures to be a power of two (default: false)
  15380. */
  15381. alwaysForcePOT: boolean;
  15382. private _samples;
  15383. /**
  15384. * Number of sample textures (default: 1)
  15385. */
  15386. samples: number;
  15387. /**
  15388. * Modify the scale of the post process to be the same as the viewport (default: false)
  15389. */
  15390. adaptScaleToCurrentViewport: boolean;
  15391. private _camera;
  15392. private _scene;
  15393. private _engine;
  15394. private _options;
  15395. private _reusable;
  15396. private _textureType;
  15397. /**
  15398. * Smart array of input and output textures for the post process.
  15399. * @hidden
  15400. */
  15401. _textures: SmartArray<InternalTexture>;
  15402. /**
  15403. * The index in _textures that corresponds to the output texture.
  15404. * @hidden
  15405. */
  15406. _currentRenderTextureInd: number;
  15407. private _effect;
  15408. private _samplers;
  15409. private _fragmentUrl;
  15410. private _vertexUrl;
  15411. private _parameters;
  15412. private _scaleRatio;
  15413. protected _indexParameters: any;
  15414. private _shareOutputWithPostProcess;
  15415. private _texelSize;
  15416. private _forcedOutputTexture;
  15417. /**
  15418. * Returns the fragment url or shader name used in the post process.
  15419. * @returns the fragment url or name in the shader store.
  15420. */
  15421. getEffectName(): string;
  15422. /**
  15423. * An event triggered when the postprocess is activated.
  15424. */
  15425. onActivateObservable: Observable<Camera>;
  15426. private _onActivateObserver;
  15427. /**
  15428. * A function that is added to the onActivateObservable
  15429. */
  15430. onActivate: Nullable<(camera: Camera) => void>;
  15431. /**
  15432. * An event triggered when the postprocess changes its size.
  15433. */
  15434. onSizeChangedObservable: Observable<PostProcess>;
  15435. private _onSizeChangedObserver;
  15436. /**
  15437. * A function that is added to the onSizeChangedObservable
  15438. */
  15439. onSizeChanged: (postProcess: PostProcess) => void;
  15440. /**
  15441. * An event triggered when the postprocess applies its effect.
  15442. */
  15443. onApplyObservable: Observable<Effect>;
  15444. private _onApplyObserver;
  15445. /**
  15446. * A function that is added to the onApplyObservable
  15447. */
  15448. onApply: (effect: Effect) => void;
  15449. /**
  15450. * An event triggered before rendering the postprocess
  15451. */
  15452. onBeforeRenderObservable: Observable<Effect>;
  15453. private _onBeforeRenderObserver;
  15454. /**
  15455. * A function that is added to the onBeforeRenderObservable
  15456. */
  15457. onBeforeRender: (effect: Effect) => void;
  15458. /**
  15459. * An event triggered after rendering the postprocess
  15460. */
  15461. onAfterRenderObservable: Observable<Effect>;
  15462. private _onAfterRenderObserver;
  15463. /**
  15464. * A function that is added to the onAfterRenderObservable
  15465. */
  15466. onAfterRender: (efect: Effect) => void;
  15467. /**
  15468. * 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
  15469. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15470. */
  15471. inputTexture: InternalTexture;
  15472. /**
  15473. * Gets the camera which post process is applied to.
  15474. * @returns The camera the post process is applied to.
  15475. */
  15476. getCamera(): Camera;
  15477. /**
  15478. * Gets the texel size of the postprocess.
  15479. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15480. */
  15481. readonly texelSize: Vector2;
  15482. /**
  15483. * Creates a new instance PostProcess
  15484. * @param name The name of the PostProcess.
  15485. * @param fragmentUrl The url of the fragment shader to be used.
  15486. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15487. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15488. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15489. * @param camera The camera to apply the render pass to.
  15490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15491. * @param engine The engine which the post process will be applied. (default: current engine)
  15492. * @param reusable If the post process can be reused on the same frame. (default: false)
  15493. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15494. * @param textureType Type of textures used when performing the post process. (default: 0)
  15495. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15496. * @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
  15497. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15498. */
  15499. constructor(
  15500. /** Name of the PostProcess. */
  15501. 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);
  15502. /**
  15503. * Gets a string idenfifying the name of the class
  15504. * @returns "PostProcess" string
  15505. */
  15506. getClassName(): string;
  15507. /**
  15508. * Gets the engine which this post process belongs to.
  15509. * @returns The engine the post process was enabled with.
  15510. */
  15511. getEngine(): Engine;
  15512. /**
  15513. * The effect that is created when initializing the post process.
  15514. * @returns The created effect corresponding the the postprocess.
  15515. */
  15516. getEffect(): Effect;
  15517. /**
  15518. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15519. * @param postProcess The post process to share the output with.
  15520. * @returns This post process.
  15521. */
  15522. shareOutputWith(postProcess: PostProcess): PostProcess;
  15523. /**
  15524. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15525. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15526. */
  15527. useOwnOutput(): void;
  15528. /**
  15529. * Updates the effect with the current post process compile time values and recompiles the shader.
  15530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15533. * @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
  15534. * @param onCompiled Called when the shader has been compiled.
  15535. * @param onError Called if there is an error when compiling a shader.
  15536. */
  15537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15538. /**
  15539. * The post process is reusable if it can be used multiple times within one frame.
  15540. * @returns If the post process is reusable
  15541. */
  15542. isReusable(): boolean;
  15543. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15544. markTextureDirty(): void;
  15545. /**
  15546. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15547. * 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.
  15548. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15549. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15550. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15551. * @returns The target texture that was bound to be written to.
  15552. */
  15553. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15554. /**
  15555. * If the post process is supported.
  15556. */
  15557. readonly isSupported: boolean;
  15558. /**
  15559. * The aspect ratio of the output texture.
  15560. */
  15561. readonly aspectRatio: number;
  15562. /**
  15563. * Get a value indicating if the post-process is ready to be used
  15564. * @returns true if the post-process is ready (shader is compiled)
  15565. */
  15566. isReady(): boolean;
  15567. /**
  15568. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15569. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15570. */
  15571. apply(): Nullable<Effect>;
  15572. private _disposeTextures;
  15573. /**
  15574. * Disposes the post process.
  15575. * @param camera The camera to dispose the post process on.
  15576. */
  15577. dispose(camera?: Camera): void;
  15578. }
  15579. }
  15580. declare module BABYLON {
  15581. /** @hidden */
  15582. export var kernelBlurVaryingDeclaration: {
  15583. name: string;
  15584. shader: string;
  15585. };
  15586. }
  15587. declare module BABYLON {
  15588. /** @hidden */
  15589. export var kernelBlurFragment: {
  15590. name: string;
  15591. shader: string;
  15592. };
  15593. }
  15594. declare module BABYLON {
  15595. /** @hidden */
  15596. export var kernelBlurFragment2: {
  15597. name: string;
  15598. shader: string;
  15599. };
  15600. }
  15601. declare module BABYLON {
  15602. /** @hidden */
  15603. export var kernelBlurPixelShader: {
  15604. name: string;
  15605. shader: string;
  15606. };
  15607. }
  15608. declare module BABYLON {
  15609. /** @hidden */
  15610. export var kernelBlurVertex: {
  15611. name: string;
  15612. shader: string;
  15613. };
  15614. }
  15615. declare module BABYLON {
  15616. /** @hidden */
  15617. export var kernelBlurVertexShader: {
  15618. name: string;
  15619. shader: string;
  15620. };
  15621. }
  15622. declare module BABYLON {
  15623. /**
  15624. * The Blur Post Process which blurs an image based on a kernel and direction.
  15625. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15626. */
  15627. export class BlurPostProcess extends PostProcess {
  15628. /** The direction in which to blur the image. */
  15629. direction: Vector2;
  15630. private blockCompilation;
  15631. protected _kernel: number;
  15632. protected _idealKernel: number;
  15633. protected _packedFloat: boolean;
  15634. private _staticDefines;
  15635. /**
  15636. * Sets the length in pixels of the blur sample region
  15637. */
  15638. /**
  15639. * Gets the length in pixels of the blur sample region
  15640. */
  15641. kernel: number;
  15642. /**
  15643. * Sets wether or not the blur needs to unpack/repack floats
  15644. */
  15645. /**
  15646. * Gets wether or not the blur is unpacking/repacking floats
  15647. */
  15648. packedFloat: boolean;
  15649. /**
  15650. * Creates a new instance BlurPostProcess
  15651. * @param name The name of the effect.
  15652. * @param direction The direction in which to blur the image.
  15653. * @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.
  15654. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15655. * @param camera The camera to apply the render pass to.
  15656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15657. * @param engine The engine which the post process will be applied. (default: current engine)
  15658. * @param reusable If the post process can be reused on the same frame. (default: false)
  15659. * @param textureType Type of textures used when performing the post process. (default: 0)
  15660. * @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)
  15661. */
  15662. constructor(name: string,
  15663. /** The direction in which to blur the image. */
  15664. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15665. /**
  15666. * Updates the effect with the current post process compile time values and recompiles the shader.
  15667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15670. * @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
  15671. * @param onCompiled Called when the shader has been compiled.
  15672. * @param onError Called if there is an error when compiling a shader.
  15673. */
  15674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15675. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15676. /**
  15677. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15678. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15679. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15680. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15681. * The gaps between physical kernels are compensated for in the weighting of the samples
  15682. * @param idealKernel Ideal blur kernel.
  15683. * @return Nearest best kernel.
  15684. */
  15685. protected _nearestBestKernel(idealKernel: number): number;
  15686. /**
  15687. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15688. * @param x The point on the Gaussian distribution to sample.
  15689. * @return the value of the Gaussian function at x.
  15690. */
  15691. protected _gaussianWeight(x: number): number;
  15692. /**
  15693. * Generates a string that can be used as a floating point number in GLSL.
  15694. * @param x Value to print.
  15695. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15696. * @return GLSL float string.
  15697. */
  15698. protected _glslFloat(x: number, decimalFigures?: number): string;
  15699. }
  15700. }
  15701. declare module BABYLON {
  15702. /**
  15703. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15704. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15705. * You can then easily use it as a reflectionTexture on a flat surface.
  15706. * In case the surface is not a plane, please consider relying on reflection probes.
  15707. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15708. */
  15709. export class MirrorTexture extends RenderTargetTexture {
  15710. private scene;
  15711. /**
  15712. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15713. * 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.
  15714. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15715. */
  15716. mirrorPlane: Plane;
  15717. /**
  15718. * Define the blur ratio used to blur the reflection if needed.
  15719. */
  15720. blurRatio: number;
  15721. /**
  15722. * Define the adaptive blur kernel used to blur the reflection if needed.
  15723. * This will autocompute the closest best match for the `blurKernel`
  15724. */
  15725. adaptiveBlurKernel: number;
  15726. /**
  15727. * Define the blur kernel used to blur the reflection if needed.
  15728. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15729. */
  15730. blurKernel: number;
  15731. /**
  15732. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15733. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15734. */
  15735. blurKernelX: number;
  15736. /**
  15737. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15738. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15739. */
  15740. blurKernelY: number;
  15741. private _autoComputeBlurKernel;
  15742. protected _onRatioRescale(): void;
  15743. private _updateGammaSpace;
  15744. private _imageProcessingConfigChangeObserver;
  15745. private _transformMatrix;
  15746. private _mirrorMatrix;
  15747. private _savedViewMatrix;
  15748. private _blurX;
  15749. private _blurY;
  15750. private _adaptiveBlurKernel;
  15751. private _blurKernelX;
  15752. private _blurKernelY;
  15753. private _blurRatio;
  15754. /**
  15755. * Instantiates a Mirror Texture.
  15756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15758. * You can then easily use it as a reflectionTexture on a flat surface.
  15759. * In case the surface is not a plane, please consider relying on reflection probes.
  15760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15761. * @param name
  15762. * @param size
  15763. * @param scene
  15764. * @param generateMipMaps
  15765. * @param type
  15766. * @param samplingMode
  15767. * @param generateDepthBuffer
  15768. */
  15769. constructor(name: string, size: number | {
  15770. width: number;
  15771. height: number;
  15772. } | {
  15773. ratio: number;
  15774. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15775. private _preparePostProcesses;
  15776. /**
  15777. * Clone the mirror texture.
  15778. * @returns the cloned texture
  15779. */
  15780. clone(): MirrorTexture;
  15781. /**
  15782. * Serialize the texture to a JSON representation you could use in Parse later on
  15783. * @returns the serialized JSON representation
  15784. */
  15785. serialize(): any;
  15786. /**
  15787. * Dispose the texture and release its associated resources.
  15788. */
  15789. dispose(): void;
  15790. }
  15791. }
  15792. declare module BABYLON {
  15793. /**
  15794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15795. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15796. */
  15797. export class Texture extends BaseTexture {
  15798. /**
  15799. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15800. */
  15801. static SerializeBuffers: boolean;
  15802. /** @hidden */
  15803. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15804. /** @hidden */
  15805. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15806. /** @hidden */
  15807. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15808. /** nearest is mag = nearest and min = nearest and mip = linear */
  15809. static readonly NEAREST_SAMPLINGMODE: number;
  15810. /** nearest is mag = nearest and min = nearest and mip = linear */
  15811. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15813. static readonly BILINEAR_SAMPLINGMODE: number;
  15814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15815. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15816. /** Trilinear is mag = linear and min = linear and mip = linear */
  15817. static readonly TRILINEAR_SAMPLINGMODE: number;
  15818. /** Trilinear is mag = linear and min = linear and mip = linear */
  15819. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15820. /** mag = nearest and min = nearest and mip = nearest */
  15821. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15822. /** mag = nearest and min = linear and mip = nearest */
  15823. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15824. /** mag = nearest and min = linear and mip = linear */
  15825. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15826. /** mag = nearest and min = linear and mip = none */
  15827. static readonly NEAREST_LINEAR: number;
  15828. /** mag = nearest and min = nearest and mip = none */
  15829. static readonly NEAREST_NEAREST: number;
  15830. /** mag = linear and min = nearest and mip = nearest */
  15831. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15832. /** mag = linear and min = nearest and mip = linear */
  15833. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15834. /** mag = linear and min = linear and mip = none */
  15835. static readonly LINEAR_LINEAR: number;
  15836. /** mag = linear and min = nearest and mip = none */
  15837. static readonly LINEAR_NEAREST: number;
  15838. /** Explicit coordinates mode */
  15839. static readonly EXPLICIT_MODE: number;
  15840. /** Spherical coordinates mode */
  15841. static readonly SPHERICAL_MODE: number;
  15842. /** Planar coordinates mode */
  15843. static readonly PLANAR_MODE: number;
  15844. /** Cubic coordinates mode */
  15845. static readonly CUBIC_MODE: number;
  15846. /** Projection coordinates mode */
  15847. static readonly PROJECTION_MODE: number;
  15848. /** Inverse Cubic coordinates mode */
  15849. static readonly SKYBOX_MODE: number;
  15850. /** Inverse Cubic coordinates mode */
  15851. static readonly INVCUBIC_MODE: number;
  15852. /** Equirectangular coordinates mode */
  15853. static readonly EQUIRECTANGULAR_MODE: number;
  15854. /** Equirectangular Fixed coordinates mode */
  15855. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15856. /** Equirectangular Fixed Mirrored coordinates mode */
  15857. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15858. /** Texture is not repeating outside of 0..1 UVs */
  15859. static readonly CLAMP_ADDRESSMODE: number;
  15860. /** Texture is repeating outside of 0..1 UVs */
  15861. static readonly WRAP_ADDRESSMODE: number;
  15862. /** Texture is repeating and mirrored */
  15863. static readonly MIRROR_ADDRESSMODE: number;
  15864. /**
  15865. * 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
  15866. */
  15867. static UseSerializedUrlIfAny: boolean;
  15868. /**
  15869. * Define the url of the texture.
  15870. */
  15871. url: Nullable<string>;
  15872. /**
  15873. * Define an offset on the texture to offset the u coordinates of the UVs
  15874. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15875. */
  15876. uOffset: number;
  15877. /**
  15878. * Define an offset on the texture to offset the v coordinates of the UVs
  15879. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15880. */
  15881. vOffset: number;
  15882. /**
  15883. * Define an offset on the texture to scale the u coordinates of the UVs
  15884. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15885. */
  15886. uScale: number;
  15887. /**
  15888. * Define an offset on the texture to scale the v coordinates of the UVs
  15889. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15890. */
  15891. vScale: number;
  15892. /**
  15893. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15894. * @see http://doc.babylonjs.com/how_to/more_materials
  15895. */
  15896. uAng: number;
  15897. /**
  15898. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15899. * @see http://doc.babylonjs.com/how_to/more_materials
  15900. */
  15901. vAng: number;
  15902. /**
  15903. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15904. * @see http://doc.babylonjs.com/how_to/more_materials
  15905. */
  15906. wAng: number;
  15907. /**
  15908. * Defines the center of rotation (U)
  15909. */
  15910. uRotationCenter: number;
  15911. /**
  15912. * Defines the center of rotation (V)
  15913. */
  15914. vRotationCenter: number;
  15915. /**
  15916. * Defines the center of rotation (W)
  15917. */
  15918. wRotationCenter: number;
  15919. /**
  15920. * Are mip maps generated for this texture or not.
  15921. */
  15922. readonly noMipmap: boolean;
  15923. /**
  15924. * List of inspectable custom properties (used by the Inspector)
  15925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15926. */
  15927. inspectableCustomProperties: Nullable<IInspectable[]>;
  15928. private _noMipmap;
  15929. /** @hidden */
  15930. _invertY: boolean;
  15931. private _rowGenerationMatrix;
  15932. private _cachedTextureMatrix;
  15933. private _projectionModeMatrix;
  15934. private _t0;
  15935. private _t1;
  15936. private _t2;
  15937. private _cachedUOffset;
  15938. private _cachedVOffset;
  15939. private _cachedUScale;
  15940. private _cachedVScale;
  15941. private _cachedUAng;
  15942. private _cachedVAng;
  15943. private _cachedWAng;
  15944. private _cachedProjectionMatrixId;
  15945. private _cachedCoordinatesMode;
  15946. /** @hidden */
  15947. protected _initialSamplingMode: number;
  15948. /** @hidden */
  15949. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15950. private _deleteBuffer;
  15951. protected _format: Nullable<number>;
  15952. private _delayedOnLoad;
  15953. private _delayedOnError;
  15954. private _mimeType?;
  15955. /**
  15956. * Observable triggered once the texture has been loaded.
  15957. */
  15958. onLoadObservable: Observable<Texture>;
  15959. protected _isBlocking: boolean;
  15960. /**
  15961. * Is the texture preventing material to render while loading.
  15962. * If false, a default texture will be used instead of the loading one during the preparation step.
  15963. */
  15964. isBlocking: boolean;
  15965. /**
  15966. * Get the current sampling mode associated with the texture.
  15967. */
  15968. readonly samplingMode: number;
  15969. /**
  15970. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15971. */
  15972. readonly invertY: boolean;
  15973. /**
  15974. * Instantiates a new texture.
  15975. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15976. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15977. * @param url defines the url of the picture to load as a texture
  15978. * @param scene defines the scene or engine the texture will belong to
  15979. * @param noMipmap defines if the texture will require mip maps or not
  15980. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15981. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15982. * @param onLoad defines a callback triggered when the texture has been loaded
  15983. * @param onError defines a callback triggered when an error occurred during the loading session
  15984. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15985. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15986. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15987. * @param mimeType defines an optional mime type information
  15988. */
  15989. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15990. /**
  15991. * Update the url (and optional buffer) of this texture if url was null during construction.
  15992. * @param url the url of the texture
  15993. * @param buffer the buffer of the texture (defaults to null)
  15994. * @param onLoad callback called when the texture is loaded (defaults to null)
  15995. */
  15996. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15997. /**
  15998. * Finish the loading sequence of a texture flagged as delayed load.
  15999. * @hidden
  16000. */
  16001. delayLoad(): void;
  16002. private _prepareRowForTextureGeneration;
  16003. /**
  16004. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16005. * @returns the transform matrix of the texture.
  16006. */
  16007. getTextureMatrix(): Matrix;
  16008. /**
  16009. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16010. * @returns The reflection texture transform
  16011. */
  16012. getReflectionTextureMatrix(): Matrix;
  16013. /**
  16014. * Clones the texture.
  16015. * @returns the cloned texture
  16016. */
  16017. clone(): Texture;
  16018. /**
  16019. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16020. * @returns The JSON representation of the texture
  16021. */
  16022. serialize(): any;
  16023. /**
  16024. * Get the current class name of the texture useful for serialization or dynamic coding.
  16025. * @returns "Texture"
  16026. */
  16027. getClassName(): string;
  16028. /**
  16029. * Dispose the texture and release its associated resources.
  16030. */
  16031. dispose(): void;
  16032. /**
  16033. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16034. * @param parsedTexture Define the JSON representation of the texture
  16035. * @param scene Define the scene the parsed texture should be instantiated in
  16036. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16037. * @returns The parsed texture if successful
  16038. */
  16039. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16040. /**
  16041. * Creates a texture from its base 64 representation.
  16042. * @param data Define the base64 payload without the data: prefix
  16043. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16044. * @param scene Define the scene the texture should belong to
  16045. * @param noMipmap Forces the texture to not create mip map information if true
  16046. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16047. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16048. * @param onLoad define a callback triggered when the texture has been loaded
  16049. * @param onError define a callback triggered when an error occurred during the loading session
  16050. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16051. * @returns the created texture
  16052. */
  16053. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16054. /**
  16055. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16056. * @param data Define the base64 payload without the data: prefix
  16057. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16058. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16059. * @param scene Define the scene the texture should belong to
  16060. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16061. * @param noMipmap Forces the texture to not create mip map information if true
  16062. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16063. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16064. * @param onLoad define a callback triggered when the texture has been loaded
  16065. * @param onError define a callback triggered when an error occurred during the loading session
  16066. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16067. * @returns the created texture
  16068. */
  16069. 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;
  16070. }
  16071. }
  16072. declare module BABYLON {
  16073. /**
  16074. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16075. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16076. */
  16077. export class PostProcessManager {
  16078. private _scene;
  16079. private _indexBuffer;
  16080. private _vertexBuffers;
  16081. /**
  16082. * Creates a new instance PostProcess
  16083. * @param scene The scene that the post process is associated with.
  16084. */
  16085. constructor(scene: Scene);
  16086. private _prepareBuffers;
  16087. private _buildIndexBuffer;
  16088. /**
  16089. * Rebuilds the vertex buffers of the manager.
  16090. * @hidden
  16091. */
  16092. _rebuild(): void;
  16093. /**
  16094. * Prepares a frame to be run through a post process.
  16095. * @param sourceTexture The input texture to the post procesess. (default: null)
  16096. * @param postProcesses An array of post processes to be run. (default: null)
  16097. * @returns True if the post processes were able to be run.
  16098. * @hidden
  16099. */
  16100. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16101. /**
  16102. * Manually render a set of post processes to a texture.
  16103. * @param postProcesses An array of post processes to be run.
  16104. * @param targetTexture The target texture to render to.
  16105. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16106. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16107. * @param lodLevel defines which lod of the texture to render to
  16108. */
  16109. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16110. /**
  16111. * Finalize the result of the output of the postprocesses.
  16112. * @param doNotPresent If true the result will not be displayed to the screen.
  16113. * @param targetTexture The target texture to render to.
  16114. * @param faceIndex The index of the face to bind the target texture to.
  16115. * @param postProcesses The array of post processes to render.
  16116. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16117. * @hidden
  16118. */
  16119. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16120. /**
  16121. * Disposes of the post process manager.
  16122. */
  16123. dispose(): void;
  16124. }
  16125. }
  16126. declare module BABYLON {
  16127. /** Interface used by value gradients (color, factor, ...) */
  16128. export interface IValueGradient {
  16129. /**
  16130. * Gets or sets the gradient value (between 0 and 1)
  16131. */
  16132. gradient: number;
  16133. }
  16134. /** Class used to store color4 gradient */
  16135. export class ColorGradient implements IValueGradient {
  16136. /**
  16137. * Gets or sets the gradient value (between 0 and 1)
  16138. */
  16139. gradient: number;
  16140. /**
  16141. * Gets or sets first associated color
  16142. */
  16143. color1: Color4;
  16144. /**
  16145. * Gets or sets second associated color
  16146. */
  16147. color2?: Color4;
  16148. /**
  16149. * Will get a color picked randomly between color1 and color2.
  16150. * If color2 is undefined then color1 will be used
  16151. * @param result defines the target Color4 to store the result in
  16152. */
  16153. getColorToRef(result: Color4): void;
  16154. }
  16155. /** Class used to store color 3 gradient */
  16156. export class Color3Gradient implements IValueGradient {
  16157. /**
  16158. * Gets or sets the gradient value (between 0 and 1)
  16159. */
  16160. gradient: number;
  16161. /**
  16162. * Gets or sets the associated color
  16163. */
  16164. color: Color3;
  16165. }
  16166. /** Class used to store factor gradient */
  16167. export class FactorGradient implements IValueGradient {
  16168. /**
  16169. * Gets or sets the gradient value (between 0 and 1)
  16170. */
  16171. gradient: number;
  16172. /**
  16173. * Gets or sets first associated factor
  16174. */
  16175. factor1: number;
  16176. /**
  16177. * Gets or sets second associated factor
  16178. */
  16179. factor2?: number;
  16180. /**
  16181. * Will get a number picked randomly between factor1 and factor2.
  16182. * If factor2 is undefined then factor1 will be used
  16183. * @returns the picked number
  16184. */
  16185. getFactor(): number;
  16186. }
  16187. /**
  16188. * Helper used to simplify some generic gradient tasks
  16189. */
  16190. export class GradientHelper {
  16191. /**
  16192. * Gets the current gradient from an array of IValueGradient
  16193. * @param ratio defines the current ratio to get
  16194. * @param gradients defines the array of IValueGradient
  16195. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16196. */
  16197. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16198. }
  16199. }
  16200. declare module BABYLON {
  16201. interface ThinEngine {
  16202. /**
  16203. * Creates a dynamic texture
  16204. * @param width defines the width of the texture
  16205. * @param height defines the height of the texture
  16206. * @param generateMipMaps defines if the engine should generate the mip levels
  16207. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16208. * @returns the dynamic texture inside an InternalTexture
  16209. */
  16210. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16211. /**
  16212. * Update the content of a dynamic texture
  16213. * @param texture defines the texture to update
  16214. * @param canvas defines the canvas containing the source
  16215. * @param invertY defines if data must be stored with Y axis inverted
  16216. * @param premulAlpha defines if alpha is stored as premultiplied
  16217. * @param format defines the format of the data
  16218. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16219. */
  16220. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16221. }
  16222. }
  16223. declare module BABYLON {
  16224. /**
  16225. * Helper class used to generate a canvas to manipulate images
  16226. */
  16227. export class CanvasGenerator {
  16228. /**
  16229. * Create a new canvas (or offscreen canvas depending on the context)
  16230. * @param width defines the expected width
  16231. * @param height defines the expected height
  16232. * @return a new canvas or offscreen canvas
  16233. */
  16234. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16235. }
  16236. }
  16237. declare module BABYLON {
  16238. /**
  16239. * A class extending Texture allowing drawing on a texture
  16240. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16241. */
  16242. export class DynamicTexture extends Texture {
  16243. private _generateMipMaps;
  16244. private _canvas;
  16245. private _context;
  16246. private _engine;
  16247. /**
  16248. * Creates a DynamicTexture
  16249. * @param name defines the name of the texture
  16250. * @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
  16251. * @param scene defines the scene where you want the texture
  16252. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16253. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16254. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16255. */
  16256. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16257. /**
  16258. * Get the current class name of the texture useful for serialization or dynamic coding.
  16259. * @returns "DynamicTexture"
  16260. */
  16261. getClassName(): string;
  16262. /**
  16263. * Gets the current state of canRescale
  16264. */
  16265. readonly canRescale: boolean;
  16266. private _recreate;
  16267. /**
  16268. * Scales the texture
  16269. * @param ratio the scale factor to apply to both width and height
  16270. */
  16271. scale(ratio: number): void;
  16272. /**
  16273. * Resizes the texture
  16274. * @param width the new width
  16275. * @param height the new height
  16276. */
  16277. scaleTo(width: number, height: number): void;
  16278. /**
  16279. * Gets the context of the canvas used by the texture
  16280. * @returns the canvas context of the dynamic texture
  16281. */
  16282. getContext(): CanvasRenderingContext2D;
  16283. /**
  16284. * Clears the texture
  16285. */
  16286. clear(): void;
  16287. /**
  16288. * Updates the texture
  16289. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16290. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16291. */
  16292. update(invertY?: boolean, premulAlpha?: boolean): void;
  16293. /**
  16294. * Draws text onto the texture
  16295. * @param text defines the text to be drawn
  16296. * @param x defines the placement of the text from the left
  16297. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16298. * @param font defines the font to be used with font-style, font-size, font-name
  16299. * @param color defines the color used for the text
  16300. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16301. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16302. * @param update defines whether texture is immediately update (default is true)
  16303. */
  16304. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16305. /**
  16306. * Clones the texture
  16307. * @returns the clone of the texture.
  16308. */
  16309. clone(): DynamicTexture;
  16310. /**
  16311. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16312. * @returns a serialized dynamic texture object
  16313. */
  16314. serialize(): any;
  16315. /** @hidden */
  16316. _rebuild(): void;
  16317. }
  16318. }
  16319. declare module BABYLON {
  16320. interface AbstractScene {
  16321. /**
  16322. * The list of procedural textures added to the scene
  16323. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16324. */
  16325. proceduralTextures: Array<ProceduralTexture>;
  16326. }
  16327. /**
  16328. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16329. * in a given scene.
  16330. */
  16331. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16332. /**
  16333. * The component name helpfull to identify the component in the list of scene components.
  16334. */
  16335. readonly name: string;
  16336. /**
  16337. * The scene the component belongs to.
  16338. */
  16339. scene: Scene;
  16340. /**
  16341. * Creates a new instance of the component for the given scene
  16342. * @param scene Defines the scene to register the component in
  16343. */
  16344. constructor(scene: Scene);
  16345. /**
  16346. * Registers the component in a given scene
  16347. */
  16348. register(): void;
  16349. /**
  16350. * Rebuilds the elements related to this component in case of
  16351. * context lost for instance.
  16352. */
  16353. rebuild(): void;
  16354. /**
  16355. * Disposes the component and the associated ressources.
  16356. */
  16357. dispose(): void;
  16358. private _beforeClear;
  16359. }
  16360. }
  16361. declare module BABYLON {
  16362. interface ThinEngine {
  16363. /**
  16364. * Creates a new render target cube texture
  16365. * @param size defines the size of the texture
  16366. * @param options defines the options used to create the texture
  16367. * @returns a new render target cube texture stored in an InternalTexture
  16368. */
  16369. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16370. }
  16371. }
  16372. declare module BABYLON {
  16373. /** @hidden */
  16374. export var proceduralVertexShader: {
  16375. name: string;
  16376. shader: string;
  16377. };
  16378. }
  16379. declare module BABYLON {
  16380. /**
  16381. * 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.
  16382. * This is the base class of any Procedural texture and contains most of the shareable code.
  16383. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16384. */
  16385. export class ProceduralTexture extends Texture {
  16386. isCube: boolean;
  16387. /**
  16388. * Define if the texture is enabled or not (disabled texture will not render)
  16389. */
  16390. isEnabled: boolean;
  16391. /**
  16392. * Define if the texture must be cleared before rendering (default is true)
  16393. */
  16394. autoClear: boolean;
  16395. /**
  16396. * Callback called when the texture is generated
  16397. */
  16398. onGenerated: () => void;
  16399. /**
  16400. * Event raised when the texture is generated
  16401. */
  16402. onGeneratedObservable: Observable<ProceduralTexture>;
  16403. /** @hidden */
  16404. _generateMipMaps: boolean;
  16405. /** @hidden **/
  16406. _effect: Effect;
  16407. /** @hidden */
  16408. _textures: {
  16409. [key: string]: Texture;
  16410. };
  16411. private _size;
  16412. private _currentRefreshId;
  16413. private _refreshRate;
  16414. private _vertexBuffers;
  16415. private _indexBuffer;
  16416. private _uniforms;
  16417. private _samplers;
  16418. private _fragment;
  16419. private _floats;
  16420. private _ints;
  16421. private _floatsArrays;
  16422. private _colors3;
  16423. private _colors4;
  16424. private _vectors2;
  16425. private _vectors3;
  16426. private _matrices;
  16427. private _fallbackTexture;
  16428. private _fallbackTextureUsed;
  16429. private _engine;
  16430. private _cachedDefines;
  16431. private _contentUpdateId;
  16432. private _contentData;
  16433. /**
  16434. * Instantiates a new procedural texture.
  16435. * 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.
  16436. * This is the base class of any Procedural texture and contains most of the shareable code.
  16437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16438. * @param name Define the name of the texture
  16439. * @param size Define the size of the texture to create
  16440. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16441. * @param scene Define the scene the texture belongs to
  16442. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16443. * @param generateMipMaps Define if the texture should creates mip maps or not
  16444. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16445. */
  16446. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16447. /**
  16448. * The effect that is created when initializing the post process.
  16449. * @returns The created effect corresponding the the postprocess.
  16450. */
  16451. getEffect(): Effect;
  16452. /**
  16453. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16454. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16455. */
  16456. getContent(): Nullable<ArrayBufferView>;
  16457. private _createIndexBuffer;
  16458. /** @hidden */
  16459. _rebuild(): void;
  16460. /**
  16461. * Resets the texture in order to recreate its associated resources.
  16462. * This can be called in case of context loss
  16463. */
  16464. reset(): void;
  16465. protected _getDefines(): string;
  16466. /**
  16467. * Is the texture ready to be used ? (rendered at least once)
  16468. * @returns true if ready, otherwise, false.
  16469. */
  16470. isReady(): boolean;
  16471. /**
  16472. * Resets the refresh counter of the texture and start bak from scratch.
  16473. * Could be useful to regenerate the texture if it is setup to render only once.
  16474. */
  16475. resetRefreshCounter(): void;
  16476. /**
  16477. * Set the fragment shader to use in order to render the texture.
  16478. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16479. */
  16480. setFragment(fragment: any): void;
  16481. /**
  16482. * Define the refresh rate of the texture or the rendering frequency.
  16483. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16484. */
  16485. refreshRate: number;
  16486. /** @hidden */
  16487. _shouldRender(): boolean;
  16488. /**
  16489. * Get the size the texture is rendering at.
  16490. * @returns the size (texture is always squared)
  16491. */
  16492. getRenderSize(): number;
  16493. /**
  16494. * Resize the texture to new value.
  16495. * @param size Define the new size the texture should have
  16496. * @param generateMipMaps Define whether the new texture should create mip maps
  16497. */
  16498. resize(size: number, generateMipMaps: boolean): void;
  16499. private _checkUniform;
  16500. /**
  16501. * Set a texture in the shader program used to render.
  16502. * @param name Define the name of the uniform samplers as defined in the shader
  16503. * @param texture Define the texture to bind to this sampler
  16504. * @return the texture itself allowing "fluent" like uniform updates
  16505. */
  16506. setTexture(name: string, texture: Texture): ProceduralTexture;
  16507. /**
  16508. * Set a float in the shader.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the texture itself allowing "fluent" like uniform updates
  16512. */
  16513. setFloat(name: string, value: number): ProceduralTexture;
  16514. /**
  16515. * Set a int in the shader.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the texture itself allowing "fluent" like uniform updates
  16519. */
  16520. setInt(name: string, value: number): ProceduralTexture;
  16521. /**
  16522. * Set an array of floats in the shader.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the texture itself allowing "fluent" like uniform updates
  16526. */
  16527. setFloats(name: string, value: number[]): ProceduralTexture;
  16528. /**
  16529. * Set a vec3 in the shader from a Color3.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the texture itself allowing "fluent" like uniform updates
  16533. */
  16534. setColor3(name: string, value: Color3): ProceduralTexture;
  16535. /**
  16536. * Set a vec4 in the shader from a Color4.
  16537. * @param name Define the name of the uniform as defined in the shader
  16538. * @param value Define the value to give to the uniform
  16539. * @return the texture itself allowing "fluent" like uniform updates
  16540. */
  16541. setColor4(name: string, value: Color4): ProceduralTexture;
  16542. /**
  16543. * Set a vec2 in the shader from a Vector2.
  16544. * @param name Define the name of the uniform as defined in the shader
  16545. * @param value Define the value to give to the uniform
  16546. * @return the texture itself allowing "fluent" like uniform updates
  16547. */
  16548. setVector2(name: string, value: Vector2): ProceduralTexture;
  16549. /**
  16550. * Set a vec3 in the shader from a Vector3.
  16551. * @param name Define the name of the uniform as defined in the shader
  16552. * @param value Define the value to give to the uniform
  16553. * @return the texture itself allowing "fluent" like uniform updates
  16554. */
  16555. setVector3(name: string, value: Vector3): ProceduralTexture;
  16556. /**
  16557. * Set a mat4 in the shader from a MAtrix.
  16558. * @param name Define the name of the uniform as defined in the shader
  16559. * @param value Define the value to give to the uniform
  16560. * @return the texture itself allowing "fluent" like uniform updates
  16561. */
  16562. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16563. /**
  16564. * Render the texture to its associated render target.
  16565. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16566. */
  16567. render(useCameraPostProcess?: boolean): void;
  16568. /**
  16569. * Clone the texture.
  16570. * @returns the cloned texture
  16571. */
  16572. clone(): ProceduralTexture;
  16573. /**
  16574. * Dispose the texture and release its asoociated resources.
  16575. */
  16576. dispose(): void;
  16577. }
  16578. }
  16579. declare module BABYLON {
  16580. /**
  16581. * This represents the base class for particle system in Babylon.
  16582. * 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.
  16583. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16584. * @example https://doc.babylonjs.com/babylon101/particles
  16585. */
  16586. export class BaseParticleSystem {
  16587. /**
  16588. * Source color is added to the destination color without alpha affecting the result
  16589. */
  16590. static BLENDMODE_ONEONE: number;
  16591. /**
  16592. * Blend current color and particle color using particle’s alpha
  16593. */
  16594. static BLENDMODE_STANDARD: number;
  16595. /**
  16596. * Add current color and particle color multiplied by particle’s alpha
  16597. */
  16598. static BLENDMODE_ADD: number;
  16599. /**
  16600. * Multiply current color with particle color
  16601. */
  16602. static BLENDMODE_MULTIPLY: number;
  16603. /**
  16604. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16605. */
  16606. static BLENDMODE_MULTIPLYADD: number;
  16607. /**
  16608. * List of animations used by the particle system.
  16609. */
  16610. animations: Animation[];
  16611. /**
  16612. * The id of the Particle system.
  16613. */
  16614. id: string;
  16615. /**
  16616. * The friendly name of the Particle system.
  16617. */
  16618. name: string;
  16619. /**
  16620. * The rendering group used by the Particle system to chose when to render.
  16621. */
  16622. renderingGroupId: number;
  16623. /**
  16624. * The emitter represents the Mesh or position we are attaching the particle system to.
  16625. */
  16626. emitter: Nullable<AbstractMesh | Vector3>;
  16627. /**
  16628. * The maximum number of particles to emit per frame
  16629. */
  16630. emitRate: number;
  16631. /**
  16632. * If you want to launch only a few particles at once, that can be done, as well.
  16633. */
  16634. manualEmitCount: number;
  16635. /**
  16636. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16637. */
  16638. updateSpeed: number;
  16639. /**
  16640. * The amount of time the particle system is running (depends of the overall update speed).
  16641. */
  16642. targetStopDuration: number;
  16643. /**
  16644. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16645. */
  16646. disposeOnStop: boolean;
  16647. /**
  16648. * Minimum power of emitting particles.
  16649. */
  16650. minEmitPower: number;
  16651. /**
  16652. * Maximum power of emitting particles.
  16653. */
  16654. maxEmitPower: number;
  16655. /**
  16656. * Minimum life time of emitting particles.
  16657. */
  16658. minLifeTime: number;
  16659. /**
  16660. * Maximum life time of emitting particles.
  16661. */
  16662. maxLifeTime: number;
  16663. /**
  16664. * Minimum Size of emitting particles.
  16665. */
  16666. minSize: number;
  16667. /**
  16668. * Maximum Size of emitting particles.
  16669. */
  16670. maxSize: number;
  16671. /**
  16672. * Minimum scale of emitting particles on X axis.
  16673. */
  16674. minScaleX: number;
  16675. /**
  16676. * Maximum scale of emitting particles on X axis.
  16677. */
  16678. maxScaleX: number;
  16679. /**
  16680. * Minimum scale of emitting particles on Y axis.
  16681. */
  16682. minScaleY: number;
  16683. /**
  16684. * Maximum scale of emitting particles on Y axis.
  16685. */
  16686. maxScaleY: number;
  16687. /**
  16688. * Gets or sets the minimal initial rotation in radians.
  16689. */
  16690. minInitialRotation: number;
  16691. /**
  16692. * Gets or sets the maximal initial rotation in radians.
  16693. */
  16694. maxInitialRotation: number;
  16695. /**
  16696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16697. */
  16698. minAngularSpeed: number;
  16699. /**
  16700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16701. */
  16702. maxAngularSpeed: number;
  16703. /**
  16704. * The texture used to render each particle. (this can be a spritesheet)
  16705. */
  16706. particleTexture: Nullable<Texture>;
  16707. /**
  16708. * The layer mask we are rendering the particles through.
  16709. */
  16710. layerMask: number;
  16711. /**
  16712. * This can help using your own shader to render the particle system.
  16713. * The according effect will be created
  16714. */
  16715. customShader: any;
  16716. /**
  16717. * By default particle system starts as soon as they are created. This prevents the
  16718. * automatic start to happen and let you decide when to start emitting particles.
  16719. */
  16720. preventAutoStart: boolean;
  16721. private _noiseTexture;
  16722. /**
  16723. * Gets or sets a texture used to add random noise to particle positions
  16724. */
  16725. noiseTexture: Nullable<ProceduralTexture>;
  16726. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16727. noiseStrength: Vector3;
  16728. /**
  16729. * Callback triggered when the particle animation is ending.
  16730. */
  16731. onAnimationEnd: Nullable<() => void>;
  16732. /**
  16733. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16734. */
  16735. blendMode: number;
  16736. /**
  16737. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16738. * to override the particles.
  16739. */
  16740. forceDepthWrite: boolean;
  16741. /** 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 */
  16742. preWarmCycles: number;
  16743. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16744. preWarmStepOffset: number;
  16745. /**
  16746. * 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)
  16747. */
  16748. spriteCellChangeSpeed: number;
  16749. /**
  16750. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16751. */
  16752. startSpriteCellID: number;
  16753. /**
  16754. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16755. */
  16756. endSpriteCellID: number;
  16757. /**
  16758. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16759. */
  16760. spriteCellWidth: number;
  16761. /**
  16762. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16763. */
  16764. spriteCellHeight: number;
  16765. /**
  16766. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16767. */
  16768. spriteRandomStartCell: boolean;
  16769. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16770. translationPivot: Vector2;
  16771. /** @hidden */
  16772. protected _isAnimationSheetEnabled: boolean;
  16773. /**
  16774. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16775. */
  16776. beginAnimationOnStart: boolean;
  16777. /**
  16778. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16779. */
  16780. beginAnimationFrom: number;
  16781. /**
  16782. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16783. */
  16784. beginAnimationTo: number;
  16785. /**
  16786. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16787. */
  16788. beginAnimationLoop: boolean;
  16789. /**
  16790. * Gets or sets a world offset applied to all particles
  16791. */
  16792. worldOffset: Vector3;
  16793. /**
  16794. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16795. */
  16796. isAnimationSheetEnabled: boolean;
  16797. /**
  16798. * Get hosting scene
  16799. * @returns the scene
  16800. */
  16801. getScene(): Scene;
  16802. /**
  16803. * You can use gravity if you want to give an orientation to your particles.
  16804. */
  16805. gravity: Vector3;
  16806. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16807. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16808. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16809. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16810. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16811. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16812. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16813. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16814. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16815. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16816. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16817. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16818. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16819. /**
  16820. * Defines the delay in milliseconds before starting the system (0 by default)
  16821. */
  16822. startDelay: number;
  16823. /**
  16824. * Gets the current list of drag gradients.
  16825. * You must use addDragGradient and removeDragGradient to udpate this list
  16826. * @returns the list of drag gradients
  16827. */
  16828. getDragGradients(): Nullable<Array<FactorGradient>>;
  16829. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16830. limitVelocityDamping: number;
  16831. /**
  16832. * Gets the current list of limit velocity gradients.
  16833. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16834. * @returns the list of limit velocity gradients
  16835. */
  16836. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Gets the current list of color gradients.
  16839. * You must use addColorGradient and removeColorGradient to udpate this list
  16840. * @returns the list of color gradients
  16841. */
  16842. getColorGradients(): Nullable<Array<ColorGradient>>;
  16843. /**
  16844. * Gets the current list of size gradients.
  16845. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16846. * @returns the list of size gradients
  16847. */
  16848. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16849. /**
  16850. * Gets the current list of color remap gradients.
  16851. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16852. * @returns the list of color remap gradients
  16853. */
  16854. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16855. /**
  16856. * Gets the current list of alpha remap gradients.
  16857. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16858. * @returns the list of alpha remap gradients
  16859. */
  16860. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16861. /**
  16862. * Gets the current list of life time gradients.
  16863. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16864. * @returns the list of life time gradients
  16865. */
  16866. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16867. /**
  16868. * Gets the current list of angular speed gradients.
  16869. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16870. * @returns the list of angular speed gradients
  16871. */
  16872. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16873. /**
  16874. * Gets the current list of velocity gradients.
  16875. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16876. * @returns the list of velocity gradients
  16877. */
  16878. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Gets the current list of start size gradients.
  16881. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16882. * @returns the list of start size gradients
  16883. */
  16884. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16885. /**
  16886. * Gets the current list of emit rate gradients.
  16887. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16888. * @returns the list of emit rate gradients
  16889. */
  16890. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16893. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16894. */
  16895. direction1: Vector3;
  16896. /**
  16897. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16898. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16899. */
  16900. direction2: Vector3;
  16901. /**
  16902. * 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.
  16903. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16904. */
  16905. minEmitBox: Vector3;
  16906. /**
  16907. * 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.
  16908. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16909. */
  16910. maxEmitBox: Vector3;
  16911. /**
  16912. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16913. */
  16914. color1: Color4;
  16915. /**
  16916. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16917. */
  16918. color2: Color4;
  16919. /**
  16920. * Color the particle will have at the end of its lifetime
  16921. */
  16922. colorDead: Color4;
  16923. /**
  16924. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16925. */
  16926. textureMask: Color4;
  16927. /**
  16928. * The particle emitter type defines the emitter used by the particle system.
  16929. * It can be for example box, sphere, or cone...
  16930. */
  16931. particleEmitterType: IParticleEmitterType;
  16932. /** @hidden */
  16933. _isSubEmitter: boolean;
  16934. /**
  16935. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16936. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16937. */
  16938. billboardMode: number;
  16939. protected _isBillboardBased: boolean;
  16940. /**
  16941. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16942. */
  16943. isBillboardBased: boolean;
  16944. /**
  16945. * The scene the particle system belongs to.
  16946. */
  16947. protected _scene: Scene;
  16948. /**
  16949. * Local cache of defines for image processing.
  16950. */
  16951. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16952. /**
  16953. * Default configuration related to image processing available in the standard Material.
  16954. */
  16955. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16956. /**
  16957. * Gets the image processing configuration used either in this material.
  16958. */
  16959. /**
  16960. * Sets the Default image processing configuration used either in the this material.
  16961. *
  16962. * If sets to null, the scene one is in use.
  16963. */
  16964. imageProcessingConfiguration: ImageProcessingConfiguration;
  16965. /**
  16966. * Attaches a new image processing configuration to the Standard Material.
  16967. * @param configuration
  16968. */
  16969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16970. /** @hidden */
  16971. protected _reset(): void;
  16972. /** @hidden */
  16973. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16974. /**
  16975. * Instantiates a particle system.
  16976. * 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.
  16977. * @param name The name of the particle system
  16978. */
  16979. constructor(name: string);
  16980. /**
  16981. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16984. * @returns the emitter
  16985. */
  16986. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16987. /**
  16988. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16989. * @param radius The radius of the hemisphere to emit from
  16990. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16991. * @returns the emitter
  16992. */
  16993. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16994. /**
  16995. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16996. * @param radius The radius of the sphere to emit from
  16997. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16998. * @returns the emitter
  16999. */
  17000. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17001. /**
  17002. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17003. * @param radius The radius of the sphere to emit from
  17004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17006. * @returns the emitter
  17007. */
  17008. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17009. /**
  17010. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17011. * @param radius The radius of the emission cylinder
  17012. * @param height The height of the emission cylinder
  17013. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17014. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17015. * @returns the emitter
  17016. */
  17017. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17018. /**
  17019. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17020. * @param radius The radius of the cylinder to emit from
  17021. * @param height The height of the emission cylinder
  17022. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17023. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17024. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17025. * @returns the emitter
  17026. */
  17027. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17028. /**
  17029. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17030. * @param radius The radius of the cone to emit from
  17031. * @param angle The base angle of the cone
  17032. * @returns the emitter
  17033. */
  17034. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17035. /**
  17036. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17039. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17040. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17041. * @returns the emitter
  17042. */
  17043. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17044. }
  17045. }
  17046. declare module BABYLON {
  17047. /**
  17048. * Type of sub emitter
  17049. */
  17050. export enum SubEmitterType {
  17051. /**
  17052. * Attached to the particle over it's lifetime
  17053. */
  17054. ATTACHED = 0,
  17055. /**
  17056. * Created when the particle dies
  17057. */
  17058. END = 1
  17059. }
  17060. /**
  17061. * Sub emitter class used to emit particles from an existing particle
  17062. */
  17063. export class SubEmitter {
  17064. /**
  17065. * the particle system to be used by the sub emitter
  17066. */
  17067. particleSystem: ParticleSystem;
  17068. /**
  17069. * Type of the submitter (Default: END)
  17070. */
  17071. type: SubEmitterType;
  17072. /**
  17073. * 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)
  17074. * Note: This only is supported when using an emitter of type Mesh
  17075. */
  17076. inheritDirection: boolean;
  17077. /**
  17078. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17079. */
  17080. inheritedVelocityAmount: number;
  17081. /**
  17082. * Creates a sub emitter
  17083. * @param particleSystem the particle system to be used by the sub emitter
  17084. */
  17085. constructor(
  17086. /**
  17087. * the particle system to be used by the sub emitter
  17088. */
  17089. particleSystem: ParticleSystem);
  17090. /**
  17091. * Clones the sub emitter
  17092. * @returns the cloned sub emitter
  17093. */
  17094. clone(): SubEmitter;
  17095. /**
  17096. * Serialize current object to a JSON object
  17097. * @returns the serialized object
  17098. */
  17099. serialize(): any;
  17100. /** @hidden */
  17101. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17102. /**
  17103. * Creates a new SubEmitter from a serialized JSON version
  17104. * @param serializationObject defines the JSON object to read from
  17105. * @param scene defines the hosting scene
  17106. * @param rootUrl defines the rootUrl for data loading
  17107. * @returns a new SubEmitter
  17108. */
  17109. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17110. /** Release associated resources */
  17111. dispose(): void;
  17112. }
  17113. }
  17114. declare module BABYLON {
  17115. /** @hidden */
  17116. export var clipPlaneFragmentDeclaration: {
  17117. name: string;
  17118. shader: string;
  17119. };
  17120. }
  17121. declare module BABYLON {
  17122. /** @hidden */
  17123. export var imageProcessingDeclaration: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module BABYLON {
  17129. /** @hidden */
  17130. export var imageProcessingFunctions: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module BABYLON {
  17136. /** @hidden */
  17137. export var clipPlaneFragment: {
  17138. name: string;
  17139. shader: string;
  17140. };
  17141. }
  17142. declare module BABYLON {
  17143. /** @hidden */
  17144. export var particlesPixelShader: {
  17145. name: string;
  17146. shader: string;
  17147. };
  17148. }
  17149. declare module BABYLON {
  17150. /** @hidden */
  17151. export var clipPlaneVertexDeclaration: {
  17152. name: string;
  17153. shader: string;
  17154. };
  17155. }
  17156. declare module BABYLON {
  17157. /** @hidden */
  17158. export var clipPlaneVertex: {
  17159. name: string;
  17160. shader: string;
  17161. };
  17162. }
  17163. declare module BABYLON {
  17164. /** @hidden */
  17165. export var particlesVertexShader: {
  17166. name: string;
  17167. shader: string;
  17168. };
  17169. }
  17170. declare module BABYLON {
  17171. /**
  17172. * This represents a particle system in Babylon.
  17173. * 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.
  17174. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17175. * @example https://doc.babylonjs.com/babylon101/particles
  17176. */
  17177. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17178. /**
  17179. * Billboard mode will only apply to Y axis
  17180. */
  17181. static readonly BILLBOARDMODE_Y: number;
  17182. /**
  17183. * Billboard mode will apply to all axes
  17184. */
  17185. static readonly BILLBOARDMODE_ALL: number;
  17186. /**
  17187. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17188. */
  17189. static readonly BILLBOARDMODE_STRETCHED: number;
  17190. /**
  17191. * This function can be defined to provide custom update for active particles.
  17192. * This function will be called instead of regular update (age, position, color, etc.).
  17193. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17194. */
  17195. updateFunction: (particles: Particle[]) => void;
  17196. private _emitterWorldMatrix;
  17197. /**
  17198. * This function can be defined to specify initial direction for every new particle.
  17199. * It by default use the emitterType defined function
  17200. */
  17201. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17202. /**
  17203. * This function can be defined to specify initial position for every new particle.
  17204. * It by default use the emitterType defined function
  17205. */
  17206. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17207. /**
  17208. * @hidden
  17209. */
  17210. _inheritedVelocityOffset: Vector3;
  17211. /**
  17212. * An event triggered when the system is disposed
  17213. */
  17214. onDisposeObservable: Observable<ParticleSystem>;
  17215. private _onDisposeObserver;
  17216. /**
  17217. * Sets a callback that will be triggered when the system is disposed
  17218. */
  17219. onDispose: () => void;
  17220. private _particles;
  17221. private _epsilon;
  17222. private _capacity;
  17223. private _stockParticles;
  17224. private _newPartsExcess;
  17225. private _vertexData;
  17226. private _vertexBuffer;
  17227. private _vertexBuffers;
  17228. private _spriteBuffer;
  17229. private _indexBuffer;
  17230. private _effect;
  17231. private _customEffect;
  17232. private _cachedDefines;
  17233. private _scaledColorStep;
  17234. private _colorDiff;
  17235. private _scaledDirection;
  17236. private _scaledGravity;
  17237. private _currentRenderId;
  17238. private _alive;
  17239. private _useInstancing;
  17240. private _started;
  17241. private _stopped;
  17242. private _actualFrame;
  17243. private _scaledUpdateSpeed;
  17244. private _vertexBufferSize;
  17245. /** @hidden */
  17246. _currentEmitRateGradient: Nullable<FactorGradient>;
  17247. /** @hidden */
  17248. _currentEmitRate1: number;
  17249. /** @hidden */
  17250. _currentEmitRate2: number;
  17251. /** @hidden */
  17252. _currentStartSizeGradient: Nullable<FactorGradient>;
  17253. /** @hidden */
  17254. _currentStartSize1: number;
  17255. /** @hidden */
  17256. _currentStartSize2: number;
  17257. private readonly _rawTextureWidth;
  17258. private _rampGradientsTexture;
  17259. private _useRampGradients;
  17260. /** Gets or sets a boolean indicating that ramp gradients must be used
  17261. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17262. */
  17263. useRampGradients: boolean;
  17264. /**
  17265. * 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.
  17266. * 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: [])
  17267. */
  17268. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17269. private _subEmitters;
  17270. /**
  17271. * @hidden
  17272. * If the particle systems emitter should be disposed when the particle system is disposed
  17273. */
  17274. _disposeEmitterOnDispose: boolean;
  17275. /**
  17276. * The current active Sub-systems, this property is used by the root particle system only.
  17277. */
  17278. activeSubSystems: Array<ParticleSystem>;
  17279. private _rootParticleSystem;
  17280. /**
  17281. * Gets the current list of active particles
  17282. */
  17283. readonly particles: Particle[];
  17284. /**
  17285. * Returns the string "ParticleSystem"
  17286. * @returns a string containing the class name
  17287. */
  17288. getClassName(): string;
  17289. /**
  17290. * Instantiates a particle system.
  17291. * 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.
  17292. * @param name The name of the particle system
  17293. * @param capacity The max number of particles alive at the same time
  17294. * @param scene The scene the particle system belongs to
  17295. * @param customEffect a custom effect used to change the way particles are rendered by default
  17296. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17297. * @param epsilon Offset used to render the particles
  17298. */
  17299. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17300. private _addFactorGradient;
  17301. private _removeFactorGradient;
  17302. /**
  17303. * Adds a new life time gradient
  17304. * @param gradient defines the gradient to use (between 0 and 1)
  17305. * @param factor defines the life time factor to affect to the specified gradient
  17306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17307. * @returns the current particle system
  17308. */
  17309. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17310. /**
  17311. * Remove a specific life time gradient
  17312. * @param gradient defines the gradient to remove
  17313. * @returns the current particle system
  17314. */
  17315. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17316. /**
  17317. * Adds a new size gradient
  17318. * @param gradient defines the gradient to use (between 0 and 1)
  17319. * @param factor defines the size factor to affect to the specified gradient
  17320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17321. * @returns the current particle system
  17322. */
  17323. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17324. /**
  17325. * Remove a specific size gradient
  17326. * @param gradient defines the gradient to remove
  17327. * @returns the current particle system
  17328. */
  17329. removeSizeGradient(gradient: number): IParticleSystem;
  17330. /**
  17331. * Adds a new color remap gradient
  17332. * @param gradient defines the gradient to use (between 0 and 1)
  17333. * @param min defines the color remap minimal range
  17334. * @param max defines the color remap maximal range
  17335. * @returns the current particle system
  17336. */
  17337. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17338. /**
  17339. * Remove a specific color remap gradient
  17340. * @param gradient defines the gradient to remove
  17341. * @returns the current particle system
  17342. */
  17343. removeColorRemapGradient(gradient: number): IParticleSystem;
  17344. /**
  17345. * Adds a new alpha remap gradient
  17346. * @param gradient defines the gradient to use (between 0 and 1)
  17347. * @param min defines the alpha remap minimal range
  17348. * @param max defines the alpha remap maximal range
  17349. * @returns the current particle system
  17350. */
  17351. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17352. /**
  17353. * Remove a specific alpha remap gradient
  17354. * @param gradient defines the gradient to remove
  17355. * @returns the current particle system
  17356. */
  17357. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17358. /**
  17359. * Adds a new angular speed gradient
  17360. * @param gradient defines the gradient to use (between 0 and 1)
  17361. * @param factor defines the angular speed to affect to the specified gradient
  17362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17363. * @returns the current particle system
  17364. */
  17365. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17366. /**
  17367. * Remove a specific angular speed gradient
  17368. * @param gradient defines the gradient to remove
  17369. * @returns the current particle system
  17370. */
  17371. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17372. /**
  17373. * Adds a new velocity gradient
  17374. * @param gradient defines the gradient to use (between 0 and 1)
  17375. * @param factor defines the velocity to affect to the specified gradient
  17376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17377. * @returns the current particle system
  17378. */
  17379. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17380. /**
  17381. * Remove a specific velocity gradient
  17382. * @param gradient defines the gradient to remove
  17383. * @returns the current particle system
  17384. */
  17385. removeVelocityGradient(gradient: number): IParticleSystem;
  17386. /**
  17387. * Adds a new limit velocity gradient
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the limit velocity value to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific limit velocity gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Adds a new drag gradient
  17402. * @param gradient defines the gradient to use (between 0 and 1)
  17403. * @param factor defines the drag value to affect to the specified gradient
  17404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17405. * @returns the current particle system
  17406. */
  17407. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17408. /**
  17409. * Remove a specific drag gradient
  17410. * @param gradient defines the gradient to remove
  17411. * @returns the current particle system
  17412. */
  17413. removeDragGradient(gradient: number): IParticleSystem;
  17414. /**
  17415. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17416. * @param gradient defines the gradient to use (between 0 and 1)
  17417. * @param factor defines the emit rate value to affect to the specified gradient
  17418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17419. * @returns the current particle system
  17420. */
  17421. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17422. /**
  17423. * Remove a specific emit rate gradient
  17424. * @param gradient defines the gradient to remove
  17425. * @returns the current particle system
  17426. */
  17427. removeEmitRateGradient(gradient: number): IParticleSystem;
  17428. /**
  17429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17430. * @param gradient defines the gradient to use (between 0 and 1)
  17431. * @param factor defines the start size value to affect to the specified gradient
  17432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17433. * @returns the current particle system
  17434. */
  17435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17436. /**
  17437. * Remove a specific start size gradient
  17438. * @param gradient defines the gradient to remove
  17439. * @returns the current particle system
  17440. */
  17441. removeStartSizeGradient(gradient: number): IParticleSystem;
  17442. private _createRampGradientTexture;
  17443. /**
  17444. * Gets the current list of ramp gradients.
  17445. * You must use addRampGradient and removeRampGradient to udpate this list
  17446. * @returns the list of ramp gradients
  17447. */
  17448. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17449. /**
  17450. * Adds a new ramp gradient used to remap particle colors
  17451. * @param gradient defines the gradient to use (between 0 and 1)
  17452. * @param color defines the color to affect to the specified gradient
  17453. * @returns the current particle system
  17454. */
  17455. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17456. /**
  17457. * Remove a specific ramp gradient
  17458. * @param gradient defines the gradient to remove
  17459. * @returns the current particle system
  17460. */
  17461. removeRampGradient(gradient: number): ParticleSystem;
  17462. /**
  17463. * Adds a new color gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param color1 defines the color to affect to the specified gradient
  17466. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17467. * @returns this particle system
  17468. */
  17469. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17470. /**
  17471. * Remove a specific color gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns this particle system
  17474. */
  17475. removeColorGradient(gradient: number): IParticleSystem;
  17476. private _fetchR;
  17477. protected _reset(): void;
  17478. private _resetEffect;
  17479. private _createVertexBuffers;
  17480. private _createIndexBuffer;
  17481. /**
  17482. * Gets the maximum number of particles active at the same time.
  17483. * @returns The max number of active particles.
  17484. */
  17485. getCapacity(): number;
  17486. /**
  17487. * Gets whether there are still active particles in the system.
  17488. * @returns True if it is alive, otherwise false.
  17489. */
  17490. isAlive(): boolean;
  17491. /**
  17492. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17493. * @returns True if it has been started, otherwise false.
  17494. */
  17495. isStarted(): boolean;
  17496. private _prepareSubEmitterInternalArray;
  17497. /**
  17498. * Starts the particle system and begins to emit
  17499. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17500. */
  17501. start(delay?: number): void;
  17502. /**
  17503. * Stops the particle system.
  17504. * @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.
  17505. */
  17506. stop(stopSubEmitters?: boolean): void;
  17507. /**
  17508. * Remove all active particles
  17509. */
  17510. reset(): void;
  17511. /**
  17512. * @hidden (for internal use only)
  17513. */
  17514. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17515. /**
  17516. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17517. * Its lifetime will start back at 0.
  17518. */
  17519. recycleParticle: (particle: Particle) => void;
  17520. private _stopSubEmitters;
  17521. private _createParticle;
  17522. private _removeFromRoot;
  17523. private _emitFromParticle;
  17524. private _update;
  17525. /** @hidden */
  17526. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17527. /** @hidden */
  17528. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17529. /** @hidden */
  17530. private _getEffect;
  17531. /**
  17532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17533. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17534. */
  17535. animate(preWarmOnly?: boolean): void;
  17536. private _appendParticleVertices;
  17537. /**
  17538. * Rebuilds the particle system.
  17539. */
  17540. rebuild(): void;
  17541. /**
  17542. * Is this system ready to be used/rendered
  17543. * @return true if the system is ready
  17544. */
  17545. isReady(): boolean;
  17546. private _render;
  17547. /**
  17548. * Renders the particle system in its current state.
  17549. * @returns the current number of particles
  17550. */
  17551. render(): number;
  17552. /**
  17553. * Disposes the particle system and free the associated resources
  17554. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17555. */
  17556. dispose(disposeTexture?: boolean): void;
  17557. /**
  17558. * Clones the particle system.
  17559. * @param name The name of the cloned object
  17560. * @param newEmitter The new emitter to use
  17561. * @returns the cloned particle system
  17562. */
  17563. clone(name: string, newEmitter: any): ParticleSystem;
  17564. /**
  17565. * Serializes the particle system to a JSON object.
  17566. * @returns the JSON object
  17567. */
  17568. serialize(): any;
  17569. /** @hidden */
  17570. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17571. /** @hidden */
  17572. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17573. /**
  17574. * Parses a JSON object to create a particle system.
  17575. * @param parsedParticleSystem The JSON object to parse
  17576. * @param scene The scene to create the particle system in
  17577. * @param rootUrl The root url to use to load external dependencies like texture
  17578. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17579. * @returns the Parsed particle system
  17580. */
  17581. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17582. }
  17583. }
  17584. declare module BABYLON {
  17585. /**
  17586. * A particle represents one of the element emitted by a particle system.
  17587. * This is mainly define by its coordinates, direction, velocity and age.
  17588. */
  17589. export class Particle {
  17590. /**
  17591. * The particle system the particle belongs to.
  17592. */
  17593. particleSystem: ParticleSystem;
  17594. private static _Count;
  17595. /**
  17596. * Unique ID of the particle
  17597. */
  17598. id: number;
  17599. /**
  17600. * The world position of the particle in the scene.
  17601. */
  17602. position: Vector3;
  17603. /**
  17604. * The world direction of the particle in the scene.
  17605. */
  17606. direction: Vector3;
  17607. /**
  17608. * The color of the particle.
  17609. */
  17610. color: Color4;
  17611. /**
  17612. * The color change of the particle per step.
  17613. */
  17614. colorStep: Color4;
  17615. /**
  17616. * Defines how long will the life of the particle be.
  17617. */
  17618. lifeTime: number;
  17619. /**
  17620. * The current age of the particle.
  17621. */
  17622. age: number;
  17623. /**
  17624. * The current size of the particle.
  17625. */
  17626. size: number;
  17627. /**
  17628. * The current scale of the particle.
  17629. */
  17630. scale: Vector2;
  17631. /**
  17632. * The current angle of the particle.
  17633. */
  17634. angle: number;
  17635. /**
  17636. * Defines how fast is the angle changing.
  17637. */
  17638. angularSpeed: number;
  17639. /**
  17640. * Defines the cell index used by the particle to be rendered from a sprite.
  17641. */
  17642. cellIndex: number;
  17643. /**
  17644. * The information required to support color remapping
  17645. */
  17646. remapData: Vector4;
  17647. /** @hidden */
  17648. _randomCellOffset?: number;
  17649. /** @hidden */
  17650. _initialDirection: Nullable<Vector3>;
  17651. /** @hidden */
  17652. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17653. /** @hidden */
  17654. _initialStartSpriteCellID: number;
  17655. /** @hidden */
  17656. _initialEndSpriteCellID: number;
  17657. /** @hidden */
  17658. _currentColorGradient: Nullable<ColorGradient>;
  17659. /** @hidden */
  17660. _currentColor1: Color4;
  17661. /** @hidden */
  17662. _currentColor2: Color4;
  17663. /** @hidden */
  17664. _currentSizeGradient: Nullable<FactorGradient>;
  17665. /** @hidden */
  17666. _currentSize1: number;
  17667. /** @hidden */
  17668. _currentSize2: number;
  17669. /** @hidden */
  17670. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17671. /** @hidden */
  17672. _currentAngularSpeed1: number;
  17673. /** @hidden */
  17674. _currentAngularSpeed2: number;
  17675. /** @hidden */
  17676. _currentVelocityGradient: Nullable<FactorGradient>;
  17677. /** @hidden */
  17678. _currentVelocity1: number;
  17679. /** @hidden */
  17680. _currentVelocity2: number;
  17681. /** @hidden */
  17682. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17683. /** @hidden */
  17684. _currentLimitVelocity1: number;
  17685. /** @hidden */
  17686. _currentLimitVelocity2: number;
  17687. /** @hidden */
  17688. _currentDragGradient: Nullable<FactorGradient>;
  17689. /** @hidden */
  17690. _currentDrag1: number;
  17691. /** @hidden */
  17692. _currentDrag2: number;
  17693. /** @hidden */
  17694. _randomNoiseCoordinates1: Vector3;
  17695. /** @hidden */
  17696. _randomNoiseCoordinates2: Vector3;
  17697. /**
  17698. * Creates a new instance Particle
  17699. * @param particleSystem the particle system the particle belongs to
  17700. */
  17701. constructor(
  17702. /**
  17703. * The particle system the particle belongs to.
  17704. */
  17705. particleSystem: ParticleSystem);
  17706. private updateCellInfoFromSystem;
  17707. /**
  17708. * Defines how the sprite cell index is updated for the particle
  17709. */
  17710. updateCellIndex(): void;
  17711. /** @hidden */
  17712. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17713. /** @hidden */
  17714. _inheritParticleInfoToSubEmitters(): void;
  17715. /** @hidden */
  17716. _reset(): void;
  17717. /**
  17718. * Copy the properties of particle to another one.
  17719. * @param other the particle to copy the information to.
  17720. */
  17721. copyTo(other: Particle): void;
  17722. }
  17723. }
  17724. declare module BABYLON {
  17725. /**
  17726. * Particle emitter represents a volume emitting particles.
  17727. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17728. */
  17729. export interface IParticleEmitterType {
  17730. /**
  17731. * Called by the particle System when the direction is computed for the created particle.
  17732. * @param worldMatrix is the world matrix of the particle system
  17733. * @param directionToUpdate is the direction vector to update with the result
  17734. * @param particle is the particle we are computed the direction for
  17735. */
  17736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17737. /**
  17738. * Called by the particle System when the position is computed for the created particle.
  17739. * @param worldMatrix is the world matrix of the particle system
  17740. * @param positionToUpdate is the position vector to update with the result
  17741. * @param particle is the particle we are computed the position for
  17742. */
  17743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17744. /**
  17745. * Clones the current emitter and returns a copy of it
  17746. * @returns the new emitter
  17747. */
  17748. clone(): IParticleEmitterType;
  17749. /**
  17750. * Called by the GPUParticleSystem to setup the update shader
  17751. * @param effect defines the update shader
  17752. */
  17753. applyToShader(effect: Effect): void;
  17754. /**
  17755. * Returns a string to use to update the GPU particles update shader
  17756. * @returns the effect defines string
  17757. */
  17758. getEffectDefines(): string;
  17759. /**
  17760. * Returns a string representing the class name
  17761. * @returns a string containing the class name
  17762. */
  17763. getClassName(): string;
  17764. /**
  17765. * Serializes the particle system to a JSON object.
  17766. * @returns the JSON object
  17767. */
  17768. serialize(): any;
  17769. /**
  17770. * Parse properties from a JSON object
  17771. * @param serializationObject defines the JSON object
  17772. */
  17773. parse(serializationObject: any): void;
  17774. }
  17775. }
  17776. declare module BABYLON {
  17777. /**
  17778. * Particle emitter emitting particles from the inside of a box.
  17779. * It emits the particles randomly between 2 given directions.
  17780. */
  17781. export class BoxParticleEmitter implements IParticleEmitterType {
  17782. /**
  17783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17784. */
  17785. direction1: Vector3;
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction2: Vector3;
  17790. /**
  17791. * 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.
  17792. */
  17793. minEmitBox: Vector3;
  17794. /**
  17795. * 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.
  17796. */
  17797. maxEmitBox: Vector3;
  17798. /**
  17799. * Creates a new instance BoxParticleEmitter
  17800. */
  17801. constructor();
  17802. /**
  17803. * Called by the particle System when the direction is computed for the created particle.
  17804. * @param worldMatrix is the world matrix of the particle system
  17805. * @param directionToUpdate is the direction vector to update with the result
  17806. * @param particle is the particle we are computed the direction for
  17807. */
  17808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17809. /**
  17810. * Called by the particle System when the position is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param positionToUpdate is the position vector to update with the result
  17813. * @param particle is the particle we are computed the position for
  17814. */
  17815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Clones the current emitter and returns a copy of it
  17818. * @returns the new emitter
  17819. */
  17820. clone(): BoxParticleEmitter;
  17821. /**
  17822. * Called by the GPUParticleSystem to setup the update shader
  17823. * @param effect defines the update shader
  17824. */
  17825. applyToShader(effect: Effect): void;
  17826. /**
  17827. * Returns a string to use to update the GPU particles update shader
  17828. * @returns a string containng the defines string
  17829. */
  17830. getEffectDefines(): string;
  17831. /**
  17832. * Returns the string "BoxParticleEmitter"
  17833. * @returns a string containing the class name
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Serializes the particle system to a JSON object.
  17838. * @returns the JSON object
  17839. */
  17840. serialize(): any;
  17841. /**
  17842. * Parse properties from a JSON object
  17843. * @param serializationObject defines the JSON object
  17844. */
  17845. parse(serializationObject: any): void;
  17846. }
  17847. }
  17848. declare module BABYLON {
  17849. /**
  17850. * Particle emitter emitting particles from the inside of a cone.
  17851. * It emits the particles alongside the cone volume from the base to the particle.
  17852. * The emission direction might be randomized.
  17853. */
  17854. export class ConeParticleEmitter implements IParticleEmitterType {
  17855. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17856. directionRandomizer: number;
  17857. private _radius;
  17858. private _angle;
  17859. private _height;
  17860. /**
  17861. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17862. */
  17863. radiusRange: number;
  17864. /**
  17865. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17866. */
  17867. heightRange: number;
  17868. /**
  17869. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17870. */
  17871. emitFromSpawnPointOnly: boolean;
  17872. /**
  17873. * Gets or sets the radius of the emission cone
  17874. */
  17875. radius: number;
  17876. /**
  17877. * Gets or sets the angle of the emission cone
  17878. */
  17879. angle: number;
  17880. private _buildHeight;
  17881. /**
  17882. * Creates a new instance ConeParticleEmitter
  17883. * @param radius the radius of the emission cone (1 by default)
  17884. * @param angle the cone base angle (PI by default)
  17885. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17886. */
  17887. constructor(radius?: number, angle?: number,
  17888. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17889. directionRandomizer?: number);
  17890. /**
  17891. * Called by the particle System when the direction is computed for the created particle.
  17892. * @param worldMatrix is the world matrix of the particle system
  17893. * @param directionToUpdate is the direction vector to update with the result
  17894. * @param particle is the particle we are computed the direction for
  17895. */
  17896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17897. /**
  17898. * Called by the particle System when the position is computed for the created particle.
  17899. * @param worldMatrix is the world matrix of the particle system
  17900. * @param positionToUpdate is the position vector to update with the result
  17901. * @param particle is the particle we are computed the position for
  17902. */
  17903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17904. /**
  17905. * Clones the current emitter and returns a copy of it
  17906. * @returns the new emitter
  17907. */
  17908. clone(): ConeParticleEmitter;
  17909. /**
  17910. * Called by the GPUParticleSystem to setup the update shader
  17911. * @param effect defines the update shader
  17912. */
  17913. applyToShader(effect: Effect): void;
  17914. /**
  17915. * Returns a string to use to update the GPU particles update shader
  17916. * @returns a string containng the defines string
  17917. */
  17918. getEffectDefines(): string;
  17919. /**
  17920. * Returns the string "ConeParticleEmitter"
  17921. * @returns a string containing the class name
  17922. */
  17923. getClassName(): string;
  17924. /**
  17925. * Serializes the particle system to a JSON object.
  17926. * @returns the JSON object
  17927. */
  17928. serialize(): any;
  17929. /**
  17930. * Parse properties from a JSON object
  17931. * @param serializationObject defines the JSON object
  17932. */
  17933. parse(serializationObject: any): void;
  17934. }
  17935. }
  17936. declare module BABYLON {
  17937. /**
  17938. * Particle emitter emitting particles from the inside of a cylinder.
  17939. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17940. */
  17941. export class CylinderParticleEmitter implements IParticleEmitterType {
  17942. /**
  17943. * The radius of the emission cylinder.
  17944. */
  17945. radius: number;
  17946. /**
  17947. * The height of the emission cylinder.
  17948. */
  17949. height: number;
  17950. /**
  17951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17952. */
  17953. radiusRange: number;
  17954. /**
  17955. * How much to randomize the particle direction [0-1].
  17956. */
  17957. directionRandomizer: number;
  17958. /**
  17959. * Creates a new instance CylinderParticleEmitter
  17960. * @param radius the radius of the emission cylinder (1 by default)
  17961. * @param height the height of the emission cylinder (1 by default)
  17962. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17963. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17964. */
  17965. constructor(
  17966. /**
  17967. * The radius of the emission cylinder.
  17968. */
  17969. radius?: number,
  17970. /**
  17971. * The height of the emission cylinder.
  17972. */
  17973. height?: number,
  17974. /**
  17975. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17976. */
  17977. radiusRange?: number,
  17978. /**
  17979. * How much to randomize the particle direction [0-1].
  17980. */
  17981. directionRandomizer?: number);
  17982. /**
  17983. * Called by the particle System when the direction is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param directionToUpdate is the direction vector to update with the result
  17986. * @param particle is the particle we are computed the direction for
  17987. */
  17988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Called by the particle System when the position is computed for the created particle.
  17991. * @param worldMatrix is the world matrix of the particle system
  17992. * @param positionToUpdate is the position vector to update with the result
  17993. * @param particle is the particle we are computed the position for
  17994. */
  17995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17996. /**
  17997. * Clones the current emitter and returns a copy of it
  17998. * @returns the new emitter
  17999. */
  18000. clone(): CylinderParticleEmitter;
  18001. /**
  18002. * Called by the GPUParticleSystem to setup the update shader
  18003. * @param effect defines the update shader
  18004. */
  18005. applyToShader(effect: Effect): void;
  18006. /**
  18007. * Returns a string to use to update the GPU particles update shader
  18008. * @returns a string containng the defines string
  18009. */
  18010. getEffectDefines(): string;
  18011. /**
  18012. * Returns the string "CylinderParticleEmitter"
  18013. * @returns a string containing the class name
  18014. */
  18015. getClassName(): string;
  18016. /**
  18017. * Serializes the particle system to a JSON object.
  18018. * @returns the JSON object
  18019. */
  18020. serialize(): any;
  18021. /**
  18022. * Parse properties from a JSON object
  18023. * @param serializationObject defines the JSON object
  18024. */
  18025. parse(serializationObject: any): void;
  18026. }
  18027. /**
  18028. * Particle emitter emitting particles from the inside of a cylinder.
  18029. * It emits the particles randomly between two vectors.
  18030. */
  18031. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18032. /**
  18033. * The min limit of the emission direction.
  18034. */
  18035. direction1: Vector3;
  18036. /**
  18037. * The max limit of the emission direction.
  18038. */
  18039. direction2: Vector3;
  18040. /**
  18041. * Creates a new instance CylinderDirectedParticleEmitter
  18042. * @param radius the radius of the emission cylinder (1 by default)
  18043. * @param height the height of the emission cylinder (1 by default)
  18044. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18045. * @param direction1 the min limit of the emission direction (up vector by default)
  18046. * @param direction2 the max limit of the emission direction (up vector by default)
  18047. */
  18048. constructor(radius?: number, height?: number, radiusRange?: number,
  18049. /**
  18050. * The min limit of the emission direction.
  18051. */
  18052. direction1?: Vector3,
  18053. /**
  18054. * The max limit of the emission direction.
  18055. */
  18056. direction2?: Vector3);
  18057. /**
  18058. * Called by the particle System when the direction is computed for the created particle.
  18059. * @param worldMatrix is the world matrix of the particle system
  18060. * @param directionToUpdate is the direction vector to update with the result
  18061. * @param particle is the particle we are computed the direction for
  18062. */
  18063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18064. /**
  18065. * Clones the current emitter and returns a copy of it
  18066. * @returns the new emitter
  18067. */
  18068. clone(): CylinderDirectedParticleEmitter;
  18069. /**
  18070. * Called by the GPUParticleSystem to setup the update shader
  18071. * @param effect defines the update shader
  18072. */
  18073. applyToShader(effect: Effect): void;
  18074. /**
  18075. * Returns a string to use to update the GPU particles update shader
  18076. * @returns a string containng the defines string
  18077. */
  18078. getEffectDefines(): string;
  18079. /**
  18080. * Returns the string "CylinderDirectedParticleEmitter"
  18081. * @returns a string containing the class name
  18082. */
  18083. getClassName(): string;
  18084. /**
  18085. * Serializes the particle system to a JSON object.
  18086. * @returns the JSON object
  18087. */
  18088. serialize(): any;
  18089. /**
  18090. * Parse properties from a JSON object
  18091. * @param serializationObject defines the JSON object
  18092. */
  18093. parse(serializationObject: any): void;
  18094. }
  18095. }
  18096. declare module BABYLON {
  18097. /**
  18098. * Particle emitter emitting particles from the inside of a hemisphere.
  18099. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18100. */
  18101. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18102. /**
  18103. * The radius of the emission hemisphere.
  18104. */
  18105. radius: number;
  18106. /**
  18107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18108. */
  18109. radiusRange: number;
  18110. /**
  18111. * How much to randomize the particle direction [0-1].
  18112. */
  18113. directionRandomizer: number;
  18114. /**
  18115. * Creates a new instance HemisphericParticleEmitter
  18116. * @param radius the radius of the emission hemisphere (1 by default)
  18117. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18118. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18119. */
  18120. constructor(
  18121. /**
  18122. * The radius of the emission hemisphere.
  18123. */
  18124. radius?: number,
  18125. /**
  18126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18127. */
  18128. radiusRange?: number,
  18129. /**
  18130. * How much to randomize the particle direction [0-1].
  18131. */
  18132. directionRandomizer?: number);
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): HemisphericParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "HemisphericParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module BABYLON {
  18180. /**
  18181. * Particle emitter emitting particles from a point.
  18182. * It emits the particles randomly between 2 given directions.
  18183. */
  18184. export class PointParticleEmitter implements IParticleEmitterType {
  18185. /**
  18186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18187. */
  18188. direction1: Vector3;
  18189. /**
  18190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18191. */
  18192. direction2: Vector3;
  18193. /**
  18194. * Creates a new instance PointParticleEmitter
  18195. */
  18196. constructor();
  18197. /**
  18198. * Called by the particle System when the direction is computed for the created particle.
  18199. * @param worldMatrix is the world matrix of the particle system
  18200. * @param directionToUpdate is the direction vector to update with the result
  18201. * @param particle is the particle we are computed the direction for
  18202. */
  18203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18204. /**
  18205. * Called by the particle System when the position is computed for the created particle.
  18206. * @param worldMatrix is the world matrix of the particle system
  18207. * @param positionToUpdate is the position vector to update with the result
  18208. * @param particle is the particle we are computed the position for
  18209. */
  18210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18211. /**
  18212. * Clones the current emitter and returns a copy of it
  18213. * @returns the new emitter
  18214. */
  18215. clone(): PointParticleEmitter;
  18216. /**
  18217. * Called by the GPUParticleSystem to setup the update shader
  18218. * @param effect defines the update shader
  18219. */
  18220. applyToShader(effect: Effect): void;
  18221. /**
  18222. * Returns a string to use to update the GPU particles update shader
  18223. * @returns a string containng the defines string
  18224. */
  18225. getEffectDefines(): string;
  18226. /**
  18227. * Returns the string "PointParticleEmitter"
  18228. * @returns a string containing the class name
  18229. */
  18230. getClassName(): string;
  18231. /**
  18232. * Serializes the particle system to a JSON object.
  18233. * @returns the JSON object
  18234. */
  18235. serialize(): any;
  18236. /**
  18237. * Parse properties from a JSON object
  18238. * @param serializationObject defines the JSON object
  18239. */
  18240. parse(serializationObject: any): void;
  18241. }
  18242. }
  18243. declare module BABYLON {
  18244. /**
  18245. * Particle emitter emitting particles from the inside of a sphere.
  18246. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18247. */
  18248. export class SphereParticleEmitter implements IParticleEmitterType {
  18249. /**
  18250. * The radius of the emission sphere.
  18251. */
  18252. radius: number;
  18253. /**
  18254. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18255. */
  18256. radiusRange: number;
  18257. /**
  18258. * How much to randomize the particle direction [0-1].
  18259. */
  18260. directionRandomizer: number;
  18261. /**
  18262. * Creates a new instance SphereParticleEmitter
  18263. * @param radius the radius of the emission sphere (1 by default)
  18264. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18265. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18266. */
  18267. constructor(
  18268. /**
  18269. * The radius of the emission sphere.
  18270. */
  18271. radius?: number,
  18272. /**
  18273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18274. */
  18275. radiusRange?: number,
  18276. /**
  18277. * How much to randomize the particle direction [0-1].
  18278. */
  18279. directionRandomizer?: number);
  18280. /**
  18281. * Called by the particle System when the direction is computed for the created particle.
  18282. * @param worldMatrix is the world matrix of the particle system
  18283. * @param directionToUpdate is the direction vector to update with the result
  18284. * @param particle is the particle we are computed the direction for
  18285. */
  18286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18287. /**
  18288. * Called by the particle System when the position is computed for the created particle.
  18289. * @param worldMatrix is the world matrix of the particle system
  18290. * @param positionToUpdate is the position vector to update with the result
  18291. * @param particle is the particle we are computed the position for
  18292. */
  18293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18294. /**
  18295. * Clones the current emitter and returns a copy of it
  18296. * @returns the new emitter
  18297. */
  18298. clone(): SphereParticleEmitter;
  18299. /**
  18300. * Called by the GPUParticleSystem to setup the update shader
  18301. * @param effect defines the update shader
  18302. */
  18303. applyToShader(effect: Effect): void;
  18304. /**
  18305. * Returns a string to use to update the GPU particles update shader
  18306. * @returns a string containng the defines string
  18307. */
  18308. getEffectDefines(): string;
  18309. /**
  18310. * Returns the string "SphereParticleEmitter"
  18311. * @returns a string containing the class name
  18312. */
  18313. getClassName(): string;
  18314. /**
  18315. * Serializes the particle system to a JSON object.
  18316. * @returns the JSON object
  18317. */
  18318. serialize(): any;
  18319. /**
  18320. * Parse properties from a JSON object
  18321. * @param serializationObject defines the JSON object
  18322. */
  18323. parse(serializationObject: any): void;
  18324. }
  18325. /**
  18326. * Particle emitter emitting particles from the inside of a sphere.
  18327. * It emits the particles randomly between two vectors.
  18328. */
  18329. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18330. /**
  18331. * The min limit of the emission direction.
  18332. */
  18333. direction1: Vector3;
  18334. /**
  18335. * The max limit of the emission direction.
  18336. */
  18337. direction2: Vector3;
  18338. /**
  18339. * Creates a new instance SphereDirectedParticleEmitter
  18340. * @param radius the radius of the emission sphere (1 by default)
  18341. * @param direction1 the min limit of the emission direction (up vector by default)
  18342. * @param direction2 the max limit of the emission direction (up vector by default)
  18343. */
  18344. constructor(radius?: number,
  18345. /**
  18346. * The min limit of the emission direction.
  18347. */
  18348. direction1?: Vector3,
  18349. /**
  18350. * The max limit of the emission direction.
  18351. */
  18352. direction2?: Vector3);
  18353. /**
  18354. * Called by the particle System when the direction is computed for the created particle.
  18355. * @param worldMatrix is the world matrix of the particle system
  18356. * @param directionToUpdate is the direction vector to update with the result
  18357. * @param particle is the particle we are computed the direction for
  18358. */
  18359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18360. /**
  18361. * Clones the current emitter and returns a copy of it
  18362. * @returns the new emitter
  18363. */
  18364. clone(): SphereDirectedParticleEmitter;
  18365. /**
  18366. * Called by the GPUParticleSystem to setup the update shader
  18367. * @param effect defines the update shader
  18368. */
  18369. applyToShader(effect: Effect): void;
  18370. /**
  18371. * Returns a string to use to update the GPU particles update shader
  18372. * @returns a string containng the defines string
  18373. */
  18374. getEffectDefines(): string;
  18375. /**
  18376. * Returns the string "SphereDirectedParticleEmitter"
  18377. * @returns a string containing the class name
  18378. */
  18379. getClassName(): string;
  18380. /**
  18381. * Serializes the particle system to a JSON object.
  18382. * @returns the JSON object
  18383. */
  18384. serialize(): any;
  18385. /**
  18386. * Parse properties from a JSON object
  18387. * @param serializationObject defines the JSON object
  18388. */
  18389. parse(serializationObject: any): void;
  18390. }
  18391. }
  18392. declare module BABYLON {
  18393. /**
  18394. * Interface representing a particle system in Babylon.js.
  18395. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18396. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18397. */
  18398. export interface IParticleSystem {
  18399. /**
  18400. * List of animations used by the particle system.
  18401. */
  18402. animations: Animation[];
  18403. /**
  18404. * The id of the Particle system.
  18405. */
  18406. id: string;
  18407. /**
  18408. * The name of the Particle system.
  18409. */
  18410. name: string;
  18411. /**
  18412. * The emitter represents the Mesh or position we are attaching the particle system to.
  18413. */
  18414. emitter: Nullable<AbstractMesh | Vector3>;
  18415. /**
  18416. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18417. */
  18418. isBillboardBased: boolean;
  18419. /**
  18420. * The rendering group used by the Particle system to chose when to render.
  18421. */
  18422. renderingGroupId: number;
  18423. /**
  18424. * The layer mask we are rendering the particles through.
  18425. */
  18426. layerMask: number;
  18427. /**
  18428. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18429. */
  18430. updateSpeed: number;
  18431. /**
  18432. * The amount of time the particle system is running (depends of the overall update speed).
  18433. */
  18434. targetStopDuration: number;
  18435. /**
  18436. * The texture used to render each particle. (this can be a spritesheet)
  18437. */
  18438. particleTexture: Nullable<Texture>;
  18439. /**
  18440. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18441. */
  18442. blendMode: number;
  18443. /**
  18444. * Minimum life time of emitting particles.
  18445. */
  18446. minLifeTime: number;
  18447. /**
  18448. * Maximum life time of emitting particles.
  18449. */
  18450. maxLifeTime: number;
  18451. /**
  18452. * Minimum Size of emitting particles.
  18453. */
  18454. minSize: number;
  18455. /**
  18456. * Maximum Size of emitting particles.
  18457. */
  18458. maxSize: number;
  18459. /**
  18460. * Minimum scale of emitting particles on X axis.
  18461. */
  18462. minScaleX: number;
  18463. /**
  18464. * Maximum scale of emitting particles on X axis.
  18465. */
  18466. maxScaleX: number;
  18467. /**
  18468. * Minimum scale of emitting particles on Y axis.
  18469. */
  18470. minScaleY: number;
  18471. /**
  18472. * Maximum scale of emitting particles on Y axis.
  18473. */
  18474. maxScaleY: number;
  18475. /**
  18476. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18477. */
  18478. color1: Color4;
  18479. /**
  18480. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18481. */
  18482. color2: Color4;
  18483. /**
  18484. * Color the particle will have at the end of its lifetime.
  18485. */
  18486. colorDead: Color4;
  18487. /**
  18488. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18489. */
  18490. emitRate: number;
  18491. /**
  18492. * You can use gravity if you want to give an orientation to your particles.
  18493. */
  18494. gravity: Vector3;
  18495. /**
  18496. * Minimum power of emitting particles.
  18497. */
  18498. minEmitPower: number;
  18499. /**
  18500. * Maximum power of emitting particles.
  18501. */
  18502. maxEmitPower: number;
  18503. /**
  18504. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18505. */
  18506. minAngularSpeed: number;
  18507. /**
  18508. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18509. */
  18510. maxAngularSpeed: number;
  18511. /**
  18512. * Gets or sets the minimal initial rotation in radians.
  18513. */
  18514. minInitialRotation: number;
  18515. /**
  18516. * Gets or sets the maximal initial rotation in radians.
  18517. */
  18518. maxInitialRotation: number;
  18519. /**
  18520. * The particle emitter type defines the emitter used by the particle system.
  18521. * It can be for example box, sphere, or cone...
  18522. */
  18523. particleEmitterType: Nullable<IParticleEmitterType>;
  18524. /**
  18525. * Defines the delay in milliseconds before starting the system (0 by default)
  18526. */
  18527. startDelay: number;
  18528. /**
  18529. * 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
  18530. */
  18531. preWarmCycles: number;
  18532. /**
  18533. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18534. */
  18535. preWarmStepOffset: number;
  18536. /**
  18537. * 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)
  18538. */
  18539. spriteCellChangeSpeed: number;
  18540. /**
  18541. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18542. */
  18543. startSpriteCellID: number;
  18544. /**
  18545. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18546. */
  18547. endSpriteCellID: number;
  18548. /**
  18549. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18550. */
  18551. spriteCellWidth: number;
  18552. /**
  18553. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18554. */
  18555. spriteCellHeight: number;
  18556. /**
  18557. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18558. */
  18559. spriteRandomStartCell: boolean;
  18560. /**
  18561. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18562. */
  18563. isAnimationSheetEnabled: boolean;
  18564. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18565. translationPivot: Vector2;
  18566. /**
  18567. * Gets or sets a texture used to add random noise to particle positions
  18568. */
  18569. noiseTexture: Nullable<BaseTexture>;
  18570. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18571. noiseStrength: Vector3;
  18572. /**
  18573. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18574. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18575. */
  18576. billboardMode: number;
  18577. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18578. limitVelocityDamping: number;
  18579. /**
  18580. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18581. */
  18582. beginAnimationOnStart: boolean;
  18583. /**
  18584. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18585. */
  18586. beginAnimationFrom: number;
  18587. /**
  18588. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18589. */
  18590. beginAnimationTo: number;
  18591. /**
  18592. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18593. */
  18594. beginAnimationLoop: boolean;
  18595. /**
  18596. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18597. */
  18598. disposeOnStop: boolean;
  18599. /**
  18600. * Gets the maximum number of particles active at the same time.
  18601. * @returns The max number of active particles.
  18602. */
  18603. getCapacity(): number;
  18604. /**
  18605. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18606. * @returns True if it has been started, otherwise false.
  18607. */
  18608. isStarted(): boolean;
  18609. /**
  18610. * Animates the particle system for this frame.
  18611. */
  18612. animate(): void;
  18613. /**
  18614. * Renders the particle system in its current state.
  18615. * @returns the current number of particles
  18616. */
  18617. render(): number;
  18618. /**
  18619. * Dispose the particle system and frees its associated resources.
  18620. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18621. */
  18622. dispose(disposeTexture?: boolean): void;
  18623. /**
  18624. * Clones the particle system.
  18625. * @param name The name of the cloned object
  18626. * @param newEmitter The new emitter to use
  18627. * @returns the cloned particle system
  18628. */
  18629. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18630. /**
  18631. * Serializes the particle system to a JSON object.
  18632. * @returns the JSON object
  18633. */
  18634. serialize(): any;
  18635. /**
  18636. * Rebuild the particle system
  18637. */
  18638. rebuild(): void;
  18639. /**
  18640. * Starts the particle system and begins to emit
  18641. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18642. */
  18643. start(delay?: number): void;
  18644. /**
  18645. * Stops the particle system.
  18646. */
  18647. stop(): void;
  18648. /**
  18649. * Remove all active particles
  18650. */
  18651. reset(): void;
  18652. /**
  18653. * Is this system ready to be used/rendered
  18654. * @return true if the system is ready
  18655. */
  18656. isReady(): boolean;
  18657. /**
  18658. * Adds a new color gradient
  18659. * @param gradient defines the gradient to use (between 0 and 1)
  18660. * @param color1 defines the color to affect to the specified gradient
  18661. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18662. * @returns the current particle system
  18663. */
  18664. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18665. /**
  18666. * Remove a specific color gradient
  18667. * @param gradient defines the gradient to remove
  18668. * @returns the current particle system
  18669. */
  18670. removeColorGradient(gradient: number): IParticleSystem;
  18671. /**
  18672. * Adds a new size gradient
  18673. * @param gradient defines the gradient to use (between 0 and 1)
  18674. * @param factor defines the size factor to affect to the specified gradient
  18675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18676. * @returns the current particle system
  18677. */
  18678. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18679. /**
  18680. * Remove a specific size gradient
  18681. * @param gradient defines the gradient to remove
  18682. * @returns the current particle system
  18683. */
  18684. removeSizeGradient(gradient: number): IParticleSystem;
  18685. /**
  18686. * Gets the current list of color gradients.
  18687. * You must use addColorGradient and removeColorGradient to udpate this list
  18688. * @returns the list of color gradients
  18689. */
  18690. getColorGradients(): Nullable<Array<ColorGradient>>;
  18691. /**
  18692. * Gets the current list of size gradients.
  18693. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18694. * @returns the list of size gradients
  18695. */
  18696. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18697. /**
  18698. * Gets the current list of angular speed gradients.
  18699. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18700. * @returns the list of angular speed gradients
  18701. */
  18702. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18703. /**
  18704. * Adds a new angular speed gradient
  18705. * @param gradient defines the gradient to use (between 0 and 1)
  18706. * @param factor defines the angular speed to affect to the specified gradient
  18707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18708. * @returns the current particle system
  18709. */
  18710. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18711. /**
  18712. * Remove a specific angular speed gradient
  18713. * @param gradient defines the gradient to remove
  18714. * @returns the current particle system
  18715. */
  18716. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18717. /**
  18718. * Gets the current list of velocity gradients.
  18719. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18720. * @returns the list of velocity gradients
  18721. */
  18722. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18723. /**
  18724. * Adds a new velocity gradient
  18725. * @param gradient defines the gradient to use (between 0 and 1)
  18726. * @param factor defines the velocity to affect to the specified gradient
  18727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18728. * @returns the current particle system
  18729. */
  18730. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18731. /**
  18732. * Remove a specific velocity gradient
  18733. * @param gradient defines the gradient to remove
  18734. * @returns the current particle system
  18735. */
  18736. removeVelocityGradient(gradient: number): IParticleSystem;
  18737. /**
  18738. * Gets the current list of limit velocity gradients.
  18739. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18740. * @returns the list of limit velocity gradients
  18741. */
  18742. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18743. /**
  18744. * Adds a new limit velocity gradient
  18745. * @param gradient defines the gradient to use (between 0 and 1)
  18746. * @param factor defines the limit velocity to affect to the specified gradient
  18747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18748. * @returns the current particle system
  18749. */
  18750. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18751. /**
  18752. * Remove a specific limit velocity gradient
  18753. * @param gradient defines the gradient to remove
  18754. * @returns the current particle system
  18755. */
  18756. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18757. /**
  18758. * Adds a new drag gradient
  18759. * @param gradient defines the gradient to use (between 0 and 1)
  18760. * @param factor defines the drag to affect to the specified gradient
  18761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18762. * @returns the current particle system
  18763. */
  18764. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18765. /**
  18766. * Remove a specific drag gradient
  18767. * @param gradient defines the gradient to remove
  18768. * @returns the current particle system
  18769. */
  18770. removeDragGradient(gradient: number): IParticleSystem;
  18771. /**
  18772. * Gets the current list of drag gradients.
  18773. * You must use addDragGradient and removeDragGradient to udpate this list
  18774. * @returns the list of drag gradients
  18775. */
  18776. getDragGradients(): Nullable<Array<FactorGradient>>;
  18777. /**
  18778. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18779. * @param gradient defines the gradient to use (between 0 and 1)
  18780. * @param factor defines the emit rate to affect to the specified gradient
  18781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18782. * @returns the current particle system
  18783. */
  18784. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18785. /**
  18786. * Remove a specific emit rate gradient
  18787. * @param gradient defines the gradient to remove
  18788. * @returns the current particle system
  18789. */
  18790. removeEmitRateGradient(gradient: number): IParticleSystem;
  18791. /**
  18792. * Gets the current list of emit rate gradients.
  18793. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18794. * @returns the list of emit rate gradients
  18795. */
  18796. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18797. /**
  18798. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18799. * @param gradient defines the gradient to use (between 0 and 1)
  18800. * @param factor defines the start size to affect to the specified gradient
  18801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18802. * @returns the current particle system
  18803. */
  18804. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18805. /**
  18806. * Remove a specific start size gradient
  18807. * @param gradient defines the gradient to remove
  18808. * @returns the current particle system
  18809. */
  18810. removeStartSizeGradient(gradient: number): IParticleSystem;
  18811. /**
  18812. * Gets the current list of start size gradients.
  18813. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18814. * @returns the list of start size gradients
  18815. */
  18816. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18817. /**
  18818. * Adds a new life time gradient
  18819. * @param gradient defines the gradient to use (between 0 and 1)
  18820. * @param factor defines the life time factor to affect to the specified gradient
  18821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18822. * @returns the current particle system
  18823. */
  18824. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18825. /**
  18826. * Remove a specific life time gradient
  18827. * @param gradient defines the gradient to remove
  18828. * @returns the current particle system
  18829. */
  18830. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18831. /**
  18832. * Gets the current list of life time gradients.
  18833. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18834. * @returns the list of life time gradients
  18835. */
  18836. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18837. /**
  18838. * Gets the current list of color gradients.
  18839. * You must use addColorGradient and removeColorGradient to udpate this list
  18840. * @returns the list of color gradients
  18841. */
  18842. getColorGradients(): Nullable<Array<ColorGradient>>;
  18843. /**
  18844. * Adds a new ramp gradient used to remap particle colors
  18845. * @param gradient defines the gradient to use (between 0 and 1)
  18846. * @param color defines the color to affect to the specified gradient
  18847. * @returns the current particle system
  18848. */
  18849. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18850. /**
  18851. * Gets the current list of ramp gradients.
  18852. * You must use addRampGradient and removeRampGradient to udpate this list
  18853. * @returns the list of ramp gradients
  18854. */
  18855. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18856. /** Gets or sets a boolean indicating that ramp gradients must be used
  18857. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18858. */
  18859. useRampGradients: boolean;
  18860. /**
  18861. * Adds a new color remap gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param min defines the color remap minimal range
  18864. * @param max defines the color remap maximal range
  18865. * @returns the current particle system
  18866. */
  18867. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18868. /**
  18869. * Gets the current list of color remap gradients.
  18870. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18871. * @returns the list of color remap gradients
  18872. */
  18873. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18874. /**
  18875. * Adds a new alpha remap gradient
  18876. * @param gradient defines the gradient to use (between 0 and 1)
  18877. * @param min defines the alpha remap minimal range
  18878. * @param max defines the alpha remap maximal range
  18879. * @returns the current particle system
  18880. */
  18881. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18882. /**
  18883. * Gets the current list of alpha remap gradients.
  18884. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18885. * @returns the list of alpha remap gradients
  18886. */
  18887. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18888. /**
  18889. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18890. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18891. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18892. * @returns the emitter
  18893. */
  18894. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18895. /**
  18896. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18897. * @param radius The radius of the hemisphere to emit from
  18898. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18899. * @returns the emitter
  18900. */
  18901. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18902. /**
  18903. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18904. * @param radius The radius of the sphere to emit from
  18905. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18906. * @returns the emitter
  18907. */
  18908. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18909. /**
  18910. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18911. * @param radius The radius of the sphere to emit from
  18912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18914. * @returns the emitter
  18915. */
  18916. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18917. /**
  18918. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18919. * @param radius The radius of the emission cylinder
  18920. * @param height The height of the emission cylinder
  18921. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18922. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18923. * @returns the emitter
  18924. */
  18925. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18926. /**
  18927. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18928. * @param radius The radius of the cylinder to emit from
  18929. * @param height The height of the emission cylinder
  18930. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18931. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18932. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18933. * @returns the emitter
  18934. */
  18935. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18936. /**
  18937. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18938. * @param radius The radius of the cone to emit from
  18939. * @param angle The base angle of the cone
  18940. * @returns the emitter
  18941. */
  18942. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18943. /**
  18944. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18947. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18948. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18949. * @returns the emitter
  18950. */
  18951. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18952. /**
  18953. * Get hosting scene
  18954. * @returns the scene
  18955. */
  18956. getScene(): Scene;
  18957. }
  18958. }
  18959. declare module BABYLON {
  18960. /**
  18961. * Creates an instance based on a source mesh.
  18962. */
  18963. export class InstancedMesh extends AbstractMesh {
  18964. private _sourceMesh;
  18965. private _currentLOD;
  18966. /** @hidden */
  18967. _indexInSourceMeshInstanceArray: number;
  18968. constructor(name: string, source: Mesh);
  18969. /**
  18970. * Returns the string "InstancedMesh".
  18971. */
  18972. getClassName(): string;
  18973. /** Gets the list of lights affecting that mesh */
  18974. readonly lightSources: Light[];
  18975. _resyncLightSources(): void;
  18976. _resyncLighSource(light: Light): void;
  18977. _removeLightSource(light: Light, dispose: boolean): void;
  18978. /**
  18979. * If the source mesh receives shadows
  18980. */
  18981. readonly receiveShadows: boolean;
  18982. /**
  18983. * The material of the source mesh
  18984. */
  18985. readonly material: Nullable<Material>;
  18986. /**
  18987. * Visibility of the source mesh
  18988. */
  18989. readonly visibility: number;
  18990. /**
  18991. * Skeleton of the source mesh
  18992. */
  18993. readonly skeleton: Nullable<Skeleton>;
  18994. /**
  18995. * Rendering ground id of the source mesh
  18996. */
  18997. renderingGroupId: number;
  18998. /**
  18999. * Returns the total number of vertices (integer).
  19000. */
  19001. getTotalVertices(): number;
  19002. /**
  19003. * Returns a positive integer : the total number of indices in this mesh geometry.
  19004. * @returns the numner of indices or zero if the mesh has no geometry.
  19005. */
  19006. getTotalIndices(): number;
  19007. /**
  19008. * The source mesh of the instance
  19009. */
  19010. readonly sourceMesh: Mesh;
  19011. /**
  19012. * Is this node ready to be used/rendered
  19013. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19014. * @return {boolean} is it ready
  19015. */
  19016. isReady(completeCheck?: boolean): boolean;
  19017. /**
  19018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19019. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19020. * @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.
  19021. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19022. */
  19023. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19024. /**
  19025. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19026. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19027. * The `data` are either a numeric array either a Float32Array.
  19028. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19029. * 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).
  19030. * Note that a new underlying VertexBuffer object is created each call.
  19031. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19032. *
  19033. * Possible `kind` values :
  19034. * - VertexBuffer.PositionKind
  19035. * - VertexBuffer.UVKind
  19036. * - VertexBuffer.UV2Kind
  19037. * - VertexBuffer.UV3Kind
  19038. * - VertexBuffer.UV4Kind
  19039. * - VertexBuffer.UV5Kind
  19040. * - VertexBuffer.UV6Kind
  19041. * - VertexBuffer.ColorKind
  19042. * - VertexBuffer.MatricesIndicesKind
  19043. * - VertexBuffer.MatricesIndicesExtraKind
  19044. * - VertexBuffer.MatricesWeightsKind
  19045. * - VertexBuffer.MatricesWeightsExtraKind
  19046. *
  19047. * Returns the Mesh.
  19048. */
  19049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19050. /**
  19051. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19052. * If the mesh has no geometry, it is simply returned as it is.
  19053. * The `data` are either a numeric array either a Float32Array.
  19054. * No new underlying VertexBuffer object is created.
  19055. * 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.
  19056. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19057. *
  19058. * Possible `kind` values :
  19059. * - VertexBuffer.PositionKind
  19060. * - VertexBuffer.UVKind
  19061. * - VertexBuffer.UV2Kind
  19062. * - VertexBuffer.UV3Kind
  19063. * - VertexBuffer.UV4Kind
  19064. * - VertexBuffer.UV5Kind
  19065. * - VertexBuffer.UV6Kind
  19066. * - VertexBuffer.ColorKind
  19067. * - VertexBuffer.MatricesIndicesKind
  19068. * - VertexBuffer.MatricesIndicesExtraKind
  19069. * - VertexBuffer.MatricesWeightsKind
  19070. * - VertexBuffer.MatricesWeightsExtraKind
  19071. *
  19072. * Returns the Mesh.
  19073. */
  19074. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19075. /**
  19076. * Sets the mesh indices.
  19077. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19078. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19079. * This method creates a new index buffer each call.
  19080. * Returns the Mesh.
  19081. */
  19082. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19083. /**
  19084. * Boolean : True if the mesh owns the requested kind of data.
  19085. */
  19086. isVerticesDataPresent(kind: string): boolean;
  19087. /**
  19088. * Returns an array of indices (IndicesArray).
  19089. */
  19090. getIndices(): Nullable<IndicesArray>;
  19091. readonly _positions: Nullable<Vector3[]>;
  19092. /**
  19093. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19094. * This means the mesh underlying bounding box and sphere are recomputed.
  19095. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19096. * @returns the current mesh
  19097. */
  19098. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19099. /** @hidden */
  19100. _preActivate(): InstancedMesh;
  19101. /** @hidden */
  19102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19103. /** @hidden */
  19104. _postActivate(): void;
  19105. getWorldMatrix(): Matrix;
  19106. readonly isAnInstance: boolean;
  19107. /**
  19108. * Returns the current associated LOD AbstractMesh.
  19109. */
  19110. getLOD(camera: Camera): AbstractMesh;
  19111. /** @hidden */
  19112. _syncSubMeshes(): InstancedMesh;
  19113. /** @hidden */
  19114. _generatePointsArray(): boolean;
  19115. /**
  19116. * Creates a new InstancedMesh from the current mesh.
  19117. * - name (string) : the cloned mesh name
  19118. * - newParent (optional Node) : the optional Node to parent the clone to.
  19119. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19120. *
  19121. * Returns the clone.
  19122. */
  19123. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19124. /**
  19125. * Disposes the InstancedMesh.
  19126. * Returns nothing.
  19127. */
  19128. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19129. }
  19130. interface Mesh {
  19131. /**
  19132. * Register a custom buffer that will be instanced
  19133. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19134. * @param kind defines the buffer kind
  19135. * @param stride defines the stride in floats
  19136. */
  19137. registerInstancedBuffer(kind: string, stride: number): void;
  19138. /** @hidden */
  19139. _userInstancedBuffersStorage: {
  19140. data: {
  19141. [key: string]: Float32Array;
  19142. };
  19143. sizes: {
  19144. [key: string]: number;
  19145. };
  19146. vertexBuffers: {
  19147. [key: string]: Nullable<VertexBuffer>;
  19148. };
  19149. strides: {
  19150. [key: string]: number;
  19151. };
  19152. };
  19153. }
  19154. interface AbstractMesh {
  19155. /**
  19156. * Object used to store instanced buffers defined by user
  19157. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19158. */
  19159. instancedBuffers: {
  19160. [key: string]: any;
  19161. };
  19162. }
  19163. }
  19164. declare module BABYLON {
  19165. /**
  19166. * Defines the options associated with the creation of a shader material.
  19167. */
  19168. export interface IShaderMaterialOptions {
  19169. /**
  19170. * Does the material work in alpha blend mode
  19171. */
  19172. needAlphaBlending: boolean;
  19173. /**
  19174. * Does the material work in alpha test mode
  19175. */
  19176. needAlphaTesting: boolean;
  19177. /**
  19178. * The list of attribute names used in the shader
  19179. */
  19180. attributes: string[];
  19181. /**
  19182. * The list of unifrom names used in the shader
  19183. */
  19184. uniforms: string[];
  19185. /**
  19186. * The list of UBO names used in the shader
  19187. */
  19188. uniformBuffers: string[];
  19189. /**
  19190. * The list of sampler names used in the shader
  19191. */
  19192. samplers: string[];
  19193. /**
  19194. * The list of defines used in the shader
  19195. */
  19196. defines: string[];
  19197. }
  19198. /**
  19199. * 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.
  19200. *
  19201. * This returned material effects how the mesh will look based on the code in the shaders.
  19202. *
  19203. * @see http://doc.babylonjs.com/how_to/shader_material
  19204. */
  19205. export class ShaderMaterial extends Material {
  19206. private _shaderPath;
  19207. private _options;
  19208. private _textures;
  19209. private _textureArrays;
  19210. private _floats;
  19211. private _ints;
  19212. private _floatsArrays;
  19213. private _colors3;
  19214. private _colors3Arrays;
  19215. private _colors4;
  19216. private _colors4Arrays;
  19217. private _vectors2;
  19218. private _vectors3;
  19219. private _vectors4;
  19220. private _matrices;
  19221. private _matrixArrays;
  19222. private _matrices3x3;
  19223. private _matrices2x2;
  19224. private _vectors2Arrays;
  19225. private _vectors3Arrays;
  19226. private _vectors4Arrays;
  19227. private _cachedWorldViewMatrix;
  19228. private _cachedWorldViewProjectionMatrix;
  19229. private _renderId;
  19230. private _multiview;
  19231. /**
  19232. * Instantiate a new shader material.
  19233. * 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.
  19234. * This returned material effects how the mesh will look based on the code in the shaders.
  19235. * @see http://doc.babylonjs.com/how_to/shader_material
  19236. * @param name Define the name of the material in the scene
  19237. * @param scene Define the scene the material belongs to
  19238. * @param shaderPath Defines the route to the shader code in one of three ways:
  19239. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19240. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19241. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19242. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19243. * @param options Define the options used to create the shader
  19244. */
  19245. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19246. /**
  19247. * Gets the shader path used to define the shader code
  19248. * It can be modified to trigger a new compilation
  19249. */
  19250. /**
  19251. * Sets the shader path used to define the shader code
  19252. * It can be modified to trigger a new compilation
  19253. */
  19254. shaderPath: any;
  19255. /**
  19256. * Gets the options used to compile the shader.
  19257. * They can be modified to trigger a new compilation
  19258. */
  19259. readonly options: IShaderMaterialOptions;
  19260. /**
  19261. * Gets the current class name of the material e.g. "ShaderMaterial"
  19262. * Mainly use in serialization.
  19263. * @returns the class name
  19264. */
  19265. getClassName(): string;
  19266. /**
  19267. * Specifies if the material will require alpha blending
  19268. * @returns a boolean specifying if alpha blending is needed
  19269. */
  19270. needAlphaBlending(): boolean;
  19271. /**
  19272. * Specifies if this material should be rendered in alpha test mode
  19273. * @returns a boolean specifying if an alpha test is needed.
  19274. */
  19275. needAlphaTesting(): boolean;
  19276. private _checkUniform;
  19277. /**
  19278. * Set a texture in the shader.
  19279. * @param name Define the name of the uniform samplers as defined in the shader
  19280. * @param texture Define the texture to bind to this sampler
  19281. * @return the material itself allowing "fluent" like uniform updates
  19282. */
  19283. setTexture(name: string, texture: Texture): ShaderMaterial;
  19284. /**
  19285. * Set a texture array in the shader.
  19286. * @param name Define the name of the uniform sampler array as defined in the shader
  19287. * @param textures Define the list of textures to bind to this sampler
  19288. * @return the material itself allowing "fluent" like uniform updates
  19289. */
  19290. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19291. /**
  19292. * Set a float in the shader.
  19293. * @param name Define the name of the uniform as defined in the shader
  19294. * @param value Define the value to give to the uniform
  19295. * @return the material itself allowing "fluent" like uniform updates
  19296. */
  19297. setFloat(name: string, value: number): ShaderMaterial;
  19298. /**
  19299. * Set a int in the shader.
  19300. * @param name Define the name of the uniform as defined in the shader
  19301. * @param value Define the value to give to the uniform
  19302. * @return the material itself allowing "fluent" like uniform updates
  19303. */
  19304. setInt(name: string, value: number): ShaderMaterial;
  19305. /**
  19306. * Set an array of floats in the shader.
  19307. * @param name Define the name of the uniform as defined in the shader
  19308. * @param value Define the value to give to the uniform
  19309. * @return the material itself allowing "fluent" like uniform updates
  19310. */
  19311. setFloats(name: string, value: number[]): ShaderMaterial;
  19312. /**
  19313. * Set a vec3 in the shader from a Color3.
  19314. * @param name Define the name of the uniform as defined in the shader
  19315. * @param value Define the value to give to the uniform
  19316. * @return the material itself allowing "fluent" like uniform updates
  19317. */
  19318. setColor3(name: string, value: Color3): ShaderMaterial;
  19319. /**
  19320. * Set a vec3 array in the shader from a Color3 array.
  19321. * @param name Define the name of the uniform as defined in the shader
  19322. * @param value Define the value to give to the uniform
  19323. * @return the material itself allowing "fluent" like uniform updates
  19324. */
  19325. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19326. /**
  19327. * Set a vec4 in the shader from a Color4.
  19328. * @param name Define the name of the uniform as defined in the shader
  19329. * @param value Define the value to give to the uniform
  19330. * @return the material itself allowing "fluent" like uniform updates
  19331. */
  19332. setColor4(name: string, value: Color4): ShaderMaterial;
  19333. /**
  19334. * Set a vec4 array in the shader from a Color4 array.
  19335. * @param name Define the name of the uniform as defined in the shader
  19336. * @param value Define the value to give to the uniform
  19337. * @return the material itself allowing "fluent" like uniform updates
  19338. */
  19339. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19340. /**
  19341. * Set a vec2 in the shader from a Vector2.
  19342. * @param name Define the name of the uniform as defined in the shader
  19343. * @param value Define the value to give to the uniform
  19344. * @return the material itself allowing "fluent" like uniform updates
  19345. */
  19346. setVector2(name: string, value: Vector2): ShaderMaterial;
  19347. /**
  19348. * Set a vec3 in the shader from a Vector3.
  19349. * @param name Define the name of the uniform as defined in the shader
  19350. * @param value Define the value to give to the uniform
  19351. * @return the material itself allowing "fluent" like uniform updates
  19352. */
  19353. setVector3(name: string, value: Vector3): ShaderMaterial;
  19354. /**
  19355. * Set a vec4 in the shader from a Vector4.
  19356. * @param name Define the name of the uniform as defined in the shader
  19357. * @param value Define the value to give to the uniform
  19358. * @return the material itself allowing "fluent" like uniform updates
  19359. */
  19360. setVector4(name: string, value: Vector4): ShaderMaterial;
  19361. /**
  19362. * Set a mat4 in the shader from a Matrix.
  19363. * @param name Define the name of the uniform as defined in the shader
  19364. * @param value Define the value to give to the uniform
  19365. * @return the material itself allowing "fluent" like uniform updates
  19366. */
  19367. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19368. /**
  19369. * Set a float32Array in the shader from a matrix array.
  19370. * @param name Define the name of the uniform as defined in the shader
  19371. * @param value Define the value to give to the uniform
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19375. /**
  19376. * Set a mat3 in the shader from a Float32Array.
  19377. * @param name Define the name of the uniform as defined in the shader
  19378. * @param value Define the value to give to the uniform
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19382. /**
  19383. * Set a mat2 in the shader from a Float32Array.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19389. /**
  19390. * Set a vec2 array in the shader from a number array.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setArray2(name: string, value: number[]): ShaderMaterial;
  19396. /**
  19397. * Set a vec3 array in the shader from a number array.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setArray3(name: string, value: number[]): ShaderMaterial;
  19403. /**
  19404. * Set a vec4 array in the shader from a number array.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setArray4(name: string, value: number[]): ShaderMaterial;
  19410. private _checkCache;
  19411. /**
  19412. * Specifies that the submesh is ready to be used
  19413. * @param mesh defines the mesh to check
  19414. * @param subMesh defines which submesh to check
  19415. * @param useInstances specifies that instances should be used
  19416. * @returns a boolean indicating that the submesh is ready or not
  19417. */
  19418. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19419. /**
  19420. * Checks if the material is ready to render the requested mesh
  19421. * @param mesh Define the mesh to render
  19422. * @param useInstances Define whether or not the material is used with instances
  19423. * @returns true if ready, otherwise false
  19424. */
  19425. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19426. /**
  19427. * Binds the world matrix to the material
  19428. * @param world defines the world transformation matrix
  19429. */
  19430. bindOnlyWorldMatrix(world: Matrix): void;
  19431. /**
  19432. * Binds the material to the mesh
  19433. * @param world defines the world transformation matrix
  19434. * @param mesh defines the mesh to bind the material to
  19435. */
  19436. bind(world: Matrix, mesh?: Mesh): void;
  19437. /**
  19438. * Gets the active textures from the material
  19439. * @returns an array of textures
  19440. */
  19441. getActiveTextures(): BaseTexture[];
  19442. /**
  19443. * Specifies if the material uses a texture
  19444. * @param texture defines the texture to check against the material
  19445. * @returns a boolean specifying if the material uses the texture
  19446. */
  19447. hasTexture(texture: BaseTexture): boolean;
  19448. /**
  19449. * Makes a duplicate of the material, and gives it a new name
  19450. * @param name defines the new name for the duplicated material
  19451. * @returns the cloned material
  19452. */
  19453. clone(name: string): ShaderMaterial;
  19454. /**
  19455. * Disposes the material
  19456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19459. */
  19460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19461. /**
  19462. * Serializes this material in a JSON representation
  19463. * @returns the serialized material object
  19464. */
  19465. serialize(): any;
  19466. /**
  19467. * Creates a shader material from parsed shader material data
  19468. * @param source defines the JSON represnetation of the material
  19469. * @param scene defines the hosting scene
  19470. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19471. * @returns a new material
  19472. */
  19473. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19474. }
  19475. }
  19476. declare module BABYLON {
  19477. /** @hidden */
  19478. export var colorPixelShader: {
  19479. name: string;
  19480. shader: string;
  19481. };
  19482. }
  19483. declare module BABYLON {
  19484. /** @hidden */
  19485. export var colorVertexShader: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module BABYLON {
  19491. /**
  19492. * Line mesh
  19493. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19494. */
  19495. export class LinesMesh extends Mesh {
  19496. /**
  19497. * If vertex color should be applied to the mesh
  19498. */
  19499. readonly useVertexColor?: boolean | undefined;
  19500. /**
  19501. * If vertex alpha should be applied to the mesh
  19502. */
  19503. readonly useVertexAlpha?: boolean | undefined;
  19504. /**
  19505. * Color of the line (Default: White)
  19506. */
  19507. color: Color3;
  19508. /**
  19509. * Alpha of the line (Default: 1)
  19510. */
  19511. alpha: number;
  19512. /**
  19513. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19514. * This margin is expressed in world space coordinates, so its value may vary.
  19515. * Default value is 0.1
  19516. */
  19517. intersectionThreshold: number;
  19518. private _colorShader;
  19519. private color4;
  19520. /**
  19521. * Creates a new LinesMesh
  19522. * @param name defines the name
  19523. * @param scene defines the hosting scene
  19524. * @param parent defines the parent mesh if any
  19525. * @param source defines the optional source LinesMesh used to clone data from
  19526. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19527. * When false, achieved by calling a clone(), also passing False.
  19528. * This will make creation of children, recursive.
  19529. * @param useVertexColor defines if this LinesMesh supports vertex color
  19530. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19531. */
  19532. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19533. /**
  19534. * If vertex color should be applied to the mesh
  19535. */
  19536. useVertexColor?: boolean | undefined,
  19537. /**
  19538. * If vertex alpha should be applied to the mesh
  19539. */
  19540. useVertexAlpha?: boolean | undefined);
  19541. private _addClipPlaneDefine;
  19542. private _removeClipPlaneDefine;
  19543. isReady(): boolean;
  19544. /**
  19545. * Returns the string "LineMesh"
  19546. */
  19547. getClassName(): string;
  19548. /**
  19549. * @hidden
  19550. */
  19551. /**
  19552. * @hidden
  19553. */
  19554. material: Material;
  19555. /**
  19556. * @hidden
  19557. */
  19558. readonly checkCollisions: boolean;
  19559. /** @hidden */
  19560. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19561. /** @hidden */
  19562. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19563. /**
  19564. * Disposes of the line mesh
  19565. * @param doNotRecurse If children should be disposed
  19566. */
  19567. dispose(doNotRecurse?: boolean): void;
  19568. /**
  19569. * Returns a new LineMesh object cloned from the current one.
  19570. */
  19571. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19572. /**
  19573. * Creates a new InstancedLinesMesh object from the mesh model.
  19574. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19575. * @param name defines the name of the new instance
  19576. * @returns a new InstancedLinesMesh
  19577. */
  19578. createInstance(name: string): InstancedLinesMesh;
  19579. }
  19580. /**
  19581. * Creates an instance based on a source LinesMesh
  19582. */
  19583. export class InstancedLinesMesh extends InstancedMesh {
  19584. /**
  19585. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19586. * This margin is expressed in world space coordinates, so its value may vary.
  19587. * Initilized with the intersectionThreshold value of the source LinesMesh
  19588. */
  19589. intersectionThreshold: number;
  19590. constructor(name: string, source: LinesMesh);
  19591. /**
  19592. * Returns the string "InstancedLinesMesh".
  19593. */
  19594. getClassName(): string;
  19595. }
  19596. }
  19597. declare module BABYLON {
  19598. /** @hidden */
  19599. export var linePixelShader: {
  19600. name: string;
  19601. shader: string;
  19602. };
  19603. }
  19604. declare module BABYLON {
  19605. /** @hidden */
  19606. export var lineVertexShader: {
  19607. name: string;
  19608. shader: string;
  19609. };
  19610. }
  19611. declare module BABYLON {
  19612. interface AbstractMesh {
  19613. /**
  19614. * Gets the edgesRenderer associated with the mesh
  19615. */
  19616. edgesRenderer: Nullable<EdgesRenderer>;
  19617. }
  19618. interface LinesMesh {
  19619. /**
  19620. * Enables the edge rendering mode on the mesh.
  19621. * This mode makes the mesh edges visible
  19622. * @param epsilon defines the maximal distance between two angles to detect a face
  19623. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19624. * @returns the currentAbstractMesh
  19625. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19626. */
  19627. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19628. }
  19629. interface InstancedLinesMesh {
  19630. /**
  19631. * Enables the edge rendering mode on the mesh.
  19632. * This mode makes the mesh edges visible
  19633. * @param epsilon defines the maximal distance between two angles to detect a face
  19634. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19635. * @returns the current InstancedLinesMesh
  19636. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19637. */
  19638. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19639. }
  19640. /**
  19641. * Defines the minimum contract an Edges renderer should follow.
  19642. */
  19643. export interface IEdgesRenderer extends IDisposable {
  19644. /**
  19645. * Gets or sets a boolean indicating if the edgesRenderer is active
  19646. */
  19647. isEnabled: boolean;
  19648. /**
  19649. * Renders the edges of the attached mesh,
  19650. */
  19651. render(): void;
  19652. /**
  19653. * Checks wether or not the edges renderer is ready to render.
  19654. * @return true if ready, otherwise false.
  19655. */
  19656. isReady(): boolean;
  19657. }
  19658. /**
  19659. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19660. */
  19661. export class EdgesRenderer implements IEdgesRenderer {
  19662. /**
  19663. * Define the size of the edges with an orthographic camera
  19664. */
  19665. edgesWidthScalerForOrthographic: number;
  19666. /**
  19667. * Define the size of the edges with a perspective camera
  19668. */
  19669. edgesWidthScalerForPerspective: number;
  19670. protected _source: AbstractMesh;
  19671. protected _linesPositions: number[];
  19672. protected _linesNormals: number[];
  19673. protected _linesIndices: number[];
  19674. protected _epsilon: number;
  19675. protected _indicesCount: number;
  19676. protected _lineShader: ShaderMaterial;
  19677. protected _ib: DataBuffer;
  19678. protected _buffers: {
  19679. [key: string]: Nullable<VertexBuffer>;
  19680. };
  19681. protected _checkVerticesInsteadOfIndices: boolean;
  19682. private _meshRebuildObserver;
  19683. private _meshDisposeObserver;
  19684. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19685. isEnabled: boolean;
  19686. /**
  19687. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19688. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19689. * @param source Mesh used to create edges
  19690. * @param epsilon sum of angles in adjacency to check for edge
  19691. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19692. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19693. */
  19694. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19695. protected _prepareRessources(): void;
  19696. /** @hidden */
  19697. _rebuild(): void;
  19698. /**
  19699. * Releases the required resources for the edges renderer
  19700. */
  19701. dispose(): void;
  19702. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19703. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19704. /**
  19705. * Checks if the pair of p0 and p1 is en edge
  19706. * @param faceIndex
  19707. * @param edge
  19708. * @param faceNormals
  19709. * @param p0
  19710. * @param p1
  19711. * @private
  19712. */
  19713. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19714. /**
  19715. * push line into the position, normal and index buffer
  19716. * @protected
  19717. */
  19718. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19719. /**
  19720. * Generates lines edges from adjacencjes
  19721. * @private
  19722. */
  19723. _generateEdgesLines(): void;
  19724. /**
  19725. * Checks wether or not the edges renderer is ready to render.
  19726. * @return true if ready, otherwise false.
  19727. */
  19728. isReady(): boolean;
  19729. /**
  19730. * Renders the edges of the attached mesh,
  19731. */
  19732. render(): void;
  19733. }
  19734. /**
  19735. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19736. */
  19737. export class LineEdgesRenderer extends EdgesRenderer {
  19738. /**
  19739. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19740. * @param source LineMesh used to generate edges
  19741. * @param epsilon not important (specified angle for edge detection)
  19742. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19743. */
  19744. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19745. /**
  19746. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19747. */
  19748. _generateEdgesLines(): void;
  19749. }
  19750. }
  19751. declare module BABYLON {
  19752. /**
  19753. * This represents the object necessary to create a rendering group.
  19754. * This is exclusively used and created by the rendering manager.
  19755. * To modify the behavior, you use the available helpers in your scene or meshes.
  19756. * @hidden
  19757. */
  19758. export class RenderingGroup {
  19759. index: number;
  19760. private static _zeroVector;
  19761. private _scene;
  19762. private _opaqueSubMeshes;
  19763. private _transparentSubMeshes;
  19764. private _alphaTestSubMeshes;
  19765. private _depthOnlySubMeshes;
  19766. private _particleSystems;
  19767. private _spriteManagers;
  19768. private _opaqueSortCompareFn;
  19769. private _alphaTestSortCompareFn;
  19770. private _transparentSortCompareFn;
  19771. private _renderOpaque;
  19772. private _renderAlphaTest;
  19773. private _renderTransparent;
  19774. /** @hidden */
  19775. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19776. onBeforeTransparentRendering: () => void;
  19777. /**
  19778. * Set the opaque sort comparison function.
  19779. * If null the sub meshes will be render in the order they were created
  19780. */
  19781. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19782. /**
  19783. * Set the alpha test sort comparison function.
  19784. * If null the sub meshes will be render in the order they were created
  19785. */
  19786. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19787. /**
  19788. * Set the transparent sort comparison function.
  19789. * If null the sub meshes will be render in the order they were created
  19790. */
  19791. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19792. /**
  19793. * Creates a new rendering group.
  19794. * @param index The rendering group index
  19795. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19796. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19797. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19798. */
  19799. 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>);
  19800. /**
  19801. * Render all the sub meshes contained in the group.
  19802. * @param customRenderFunction Used to override the default render behaviour of the group.
  19803. * @returns true if rendered some submeshes.
  19804. */
  19805. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19806. /**
  19807. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19808. * @param subMeshes The submeshes to render
  19809. */
  19810. private renderOpaqueSorted;
  19811. /**
  19812. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19813. * @param subMeshes The submeshes to render
  19814. */
  19815. private renderAlphaTestSorted;
  19816. /**
  19817. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19818. * @param subMeshes The submeshes to render
  19819. */
  19820. private renderTransparentSorted;
  19821. /**
  19822. * Renders the submeshes in a specified order.
  19823. * @param subMeshes The submeshes to sort before render
  19824. * @param sortCompareFn The comparison function use to sort
  19825. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19826. * @param transparent Specifies to activate blending if true
  19827. */
  19828. private static renderSorted;
  19829. /**
  19830. * Renders the submeshes in the order they were dispatched (no sort applied).
  19831. * @param subMeshes The submeshes to render
  19832. */
  19833. private static renderUnsorted;
  19834. /**
  19835. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19836. * are rendered back to front if in the same alpha index.
  19837. *
  19838. * @param a The first submesh
  19839. * @param b The second submesh
  19840. * @returns The result of the comparison
  19841. */
  19842. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19843. /**
  19844. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19845. * are rendered back to front.
  19846. *
  19847. * @param a The first submesh
  19848. * @param b The second submesh
  19849. * @returns The result of the comparison
  19850. */
  19851. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19852. /**
  19853. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19854. * are rendered front to back (prevent overdraw).
  19855. *
  19856. * @param a The first submesh
  19857. * @param b The second submesh
  19858. * @returns The result of the comparison
  19859. */
  19860. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19861. /**
  19862. * Resets the different lists of submeshes to prepare a new frame.
  19863. */
  19864. prepare(): void;
  19865. dispose(): void;
  19866. /**
  19867. * Inserts the submesh in its correct queue depending on its material.
  19868. * @param subMesh The submesh to dispatch
  19869. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19870. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19871. */
  19872. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19873. dispatchSprites(spriteManager: ISpriteManager): void;
  19874. dispatchParticles(particleSystem: IParticleSystem): void;
  19875. private _renderParticles;
  19876. private _renderSprites;
  19877. }
  19878. }
  19879. declare module BABYLON {
  19880. /**
  19881. * Interface describing the different options available in the rendering manager
  19882. * regarding Auto Clear between groups.
  19883. */
  19884. export interface IRenderingManagerAutoClearSetup {
  19885. /**
  19886. * Defines whether or not autoclear is enable.
  19887. */
  19888. autoClear: boolean;
  19889. /**
  19890. * Defines whether or not to autoclear the depth buffer.
  19891. */
  19892. depth: boolean;
  19893. /**
  19894. * Defines whether or not to autoclear the stencil buffer.
  19895. */
  19896. stencil: boolean;
  19897. }
  19898. /**
  19899. * This class is used by the onRenderingGroupObservable
  19900. */
  19901. export class RenderingGroupInfo {
  19902. /**
  19903. * The Scene that being rendered
  19904. */
  19905. scene: Scene;
  19906. /**
  19907. * The camera currently used for the rendering pass
  19908. */
  19909. camera: Nullable<Camera>;
  19910. /**
  19911. * The ID of the renderingGroup being processed
  19912. */
  19913. renderingGroupId: number;
  19914. }
  19915. /**
  19916. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19917. * It is enable to manage the different groups as well as the different necessary sort functions.
  19918. * This should not be used directly aside of the few static configurations
  19919. */
  19920. export class RenderingManager {
  19921. /**
  19922. * The max id used for rendering groups (not included)
  19923. */
  19924. static MAX_RENDERINGGROUPS: number;
  19925. /**
  19926. * The min id used for rendering groups (included)
  19927. */
  19928. static MIN_RENDERINGGROUPS: number;
  19929. /**
  19930. * Used to globally prevent autoclearing scenes.
  19931. */
  19932. static AUTOCLEAR: boolean;
  19933. /**
  19934. * @hidden
  19935. */
  19936. _useSceneAutoClearSetup: boolean;
  19937. private _scene;
  19938. private _renderingGroups;
  19939. private _depthStencilBufferAlreadyCleaned;
  19940. private _autoClearDepthStencil;
  19941. private _customOpaqueSortCompareFn;
  19942. private _customAlphaTestSortCompareFn;
  19943. private _customTransparentSortCompareFn;
  19944. private _renderingGroupInfo;
  19945. /**
  19946. * Instantiates a new rendering group for a particular scene
  19947. * @param scene Defines the scene the groups belongs to
  19948. */
  19949. constructor(scene: Scene);
  19950. private _clearDepthStencilBuffer;
  19951. /**
  19952. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19953. * @hidden
  19954. */
  19955. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19956. /**
  19957. * Resets the different information of the group to prepare a new frame
  19958. * @hidden
  19959. */
  19960. reset(): void;
  19961. /**
  19962. * Dispose and release the group and its associated resources.
  19963. * @hidden
  19964. */
  19965. dispose(): void;
  19966. /**
  19967. * Clear the info related to rendering groups preventing retention points during dispose.
  19968. */
  19969. freeRenderingGroups(): void;
  19970. private _prepareRenderingGroup;
  19971. /**
  19972. * Add a sprite manager to the rendering manager in order to render it this frame.
  19973. * @param spriteManager Define the sprite manager to render
  19974. */
  19975. dispatchSprites(spriteManager: ISpriteManager): void;
  19976. /**
  19977. * Add a particle system to the rendering manager in order to render it this frame.
  19978. * @param particleSystem Define the particle system to render
  19979. */
  19980. dispatchParticles(particleSystem: IParticleSystem): void;
  19981. /**
  19982. * Add a submesh to the manager in order to render it this frame
  19983. * @param subMesh The submesh to dispatch
  19984. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19985. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19986. */
  19987. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19988. /**
  19989. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19990. * This allowed control for front to back rendering or reversly depending of the special needs.
  19991. *
  19992. * @param renderingGroupId The rendering group id corresponding to its index
  19993. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19994. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19995. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19996. */
  19997. 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;
  19998. /**
  19999. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20000. *
  20001. * @param renderingGroupId The rendering group id corresponding to its index
  20002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20003. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20004. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20005. */
  20006. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20007. /**
  20008. * Gets the current auto clear configuration for one rendering group of the rendering
  20009. * manager.
  20010. * @param index the rendering group index to get the information for
  20011. * @returns The auto clear setup for the requested rendering group
  20012. */
  20013. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20014. }
  20015. }
  20016. declare module BABYLON {
  20017. /**
  20018. * This Helps creating a texture that will be created from a camera in your scene.
  20019. * It is basically a dynamic texture that could be used to create special effects for instance.
  20020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20021. */
  20022. export class RenderTargetTexture extends Texture {
  20023. isCube: boolean;
  20024. /**
  20025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20026. */
  20027. static readonly REFRESHRATE_RENDER_ONCE: number;
  20028. /**
  20029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20030. */
  20031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20032. /**
  20033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20034. * the central point of your effect and can save a lot of performances.
  20035. */
  20036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20037. /**
  20038. * Use this predicate to dynamically define the list of mesh you want to render.
  20039. * If set, the renderList property will be overwritten.
  20040. */
  20041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20042. private _renderList;
  20043. /**
  20044. * Use this list to define the list of mesh you want to render.
  20045. */
  20046. renderList: Nullable<Array<AbstractMesh>>;
  20047. private _hookArray;
  20048. /**
  20049. * Define if particles should be rendered in your texture.
  20050. */
  20051. renderParticles: boolean;
  20052. /**
  20053. * Define if sprites should be rendered in your texture.
  20054. */
  20055. renderSprites: boolean;
  20056. /**
  20057. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20058. */
  20059. coordinatesMode: number;
  20060. /**
  20061. * Define the camera used to render the texture.
  20062. */
  20063. activeCamera: Nullable<Camera>;
  20064. /**
  20065. * Override the render function of the texture with your own one.
  20066. */
  20067. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20068. /**
  20069. * Define if camera post processes should be use while rendering the texture.
  20070. */
  20071. useCameraPostProcesses: boolean;
  20072. /**
  20073. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20074. */
  20075. ignoreCameraViewport: boolean;
  20076. private _postProcessManager;
  20077. private _postProcesses;
  20078. private _resizeObserver;
  20079. /**
  20080. * An event triggered when the texture is unbind.
  20081. */
  20082. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20083. /**
  20084. * An event triggered when the texture is unbind.
  20085. */
  20086. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20087. private _onAfterUnbindObserver;
  20088. /**
  20089. * Set a after unbind callback in the texture.
  20090. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20091. */
  20092. onAfterUnbind: () => void;
  20093. /**
  20094. * An event triggered before rendering the texture
  20095. */
  20096. onBeforeRenderObservable: Observable<number>;
  20097. private _onBeforeRenderObserver;
  20098. /**
  20099. * Set a before render callback in the texture.
  20100. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20101. */
  20102. onBeforeRender: (faceIndex: number) => void;
  20103. /**
  20104. * An event triggered after rendering the texture
  20105. */
  20106. onAfterRenderObservable: Observable<number>;
  20107. private _onAfterRenderObserver;
  20108. /**
  20109. * Set a after render callback in the texture.
  20110. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20111. */
  20112. onAfterRender: (faceIndex: number) => void;
  20113. /**
  20114. * An event triggered after the texture clear
  20115. */
  20116. onClearObservable: Observable<Engine>;
  20117. private _onClearObserver;
  20118. /**
  20119. * Set a clear callback in the texture.
  20120. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20121. */
  20122. onClear: (Engine: Engine) => void;
  20123. /**
  20124. * An event triggered when the texture is resized.
  20125. */
  20126. onResizeObservable: Observable<RenderTargetTexture>;
  20127. /**
  20128. * Define the clear color of the Render Target if it should be different from the scene.
  20129. */
  20130. clearColor: Color4;
  20131. protected _size: number | {
  20132. width: number;
  20133. height: number;
  20134. };
  20135. protected _initialSizeParameter: number | {
  20136. width: number;
  20137. height: number;
  20138. } | {
  20139. ratio: number;
  20140. };
  20141. protected _sizeRatio: Nullable<number>;
  20142. /** @hidden */
  20143. _generateMipMaps: boolean;
  20144. protected _renderingManager: RenderingManager;
  20145. /** @hidden */
  20146. _waitingRenderList: string[];
  20147. protected _doNotChangeAspectRatio: boolean;
  20148. protected _currentRefreshId: number;
  20149. protected _refreshRate: number;
  20150. protected _textureMatrix: Matrix;
  20151. protected _samples: number;
  20152. protected _renderTargetOptions: RenderTargetCreationOptions;
  20153. /**
  20154. * Gets render target creation options that were used.
  20155. */
  20156. readonly renderTargetOptions: RenderTargetCreationOptions;
  20157. protected _engine: Engine;
  20158. protected _onRatioRescale(): void;
  20159. /**
  20160. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20161. * It must define where the camera used to render the texture is set
  20162. */
  20163. boundingBoxPosition: Vector3;
  20164. private _boundingBoxSize;
  20165. /**
  20166. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20167. * When defined, the cubemap will switch to local mode
  20168. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20169. * @example https://www.babylonjs-playground.com/#RNASML
  20170. */
  20171. boundingBoxSize: Vector3;
  20172. /**
  20173. * In case the RTT has been created with a depth texture, get the associated
  20174. * depth texture.
  20175. * Otherwise, return null.
  20176. */
  20177. depthStencilTexture: Nullable<InternalTexture>;
  20178. /**
  20179. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20180. * or used a shadow, depth texture...
  20181. * @param name The friendly name of the texture
  20182. * @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)
  20183. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20184. * @param generateMipMaps True if mip maps need to be generated after render.
  20185. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20186. * @param type The type of the buffer in the RTT (int, half float, float...)
  20187. * @param isCube True if a cube texture needs to be created
  20188. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20189. * @param generateDepthBuffer True to generate a depth buffer
  20190. * @param generateStencilBuffer True to generate a stencil buffer
  20191. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20192. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20193. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20194. */
  20195. constructor(name: string, size: number | {
  20196. width: number;
  20197. height: number;
  20198. } | {
  20199. ratio: number;
  20200. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20201. /**
  20202. * Creates a depth stencil texture.
  20203. * This is only available in WebGL 2 or with the depth texture extension available.
  20204. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20205. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20206. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20207. */
  20208. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20209. private _processSizeParameter;
  20210. /**
  20211. * Define the number of samples to use in case of MSAA.
  20212. * It defaults to one meaning no MSAA has been enabled.
  20213. */
  20214. samples: number;
  20215. /**
  20216. * Resets the refresh counter of the texture and start bak from scratch.
  20217. * Could be useful to regenerate the texture if it is setup to render only once.
  20218. */
  20219. resetRefreshCounter(): void;
  20220. /**
  20221. * Define the refresh rate of the texture or the rendering frequency.
  20222. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20223. */
  20224. refreshRate: number;
  20225. /**
  20226. * Adds a post process to the render target rendering passes.
  20227. * @param postProcess define the post process to add
  20228. */
  20229. addPostProcess(postProcess: PostProcess): void;
  20230. /**
  20231. * Clear all the post processes attached to the render target
  20232. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20233. */
  20234. clearPostProcesses(dispose?: boolean): void;
  20235. /**
  20236. * Remove one of the post process from the list of attached post processes to the texture
  20237. * @param postProcess define the post process to remove from the list
  20238. */
  20239. removePostProcess(postProcess: PostProcess): void;
  20240. /** @hidden */
  20241. _shouldRender(): boolean;
  20242. /**
  20243. * Gets the actual render size of the texture.
  20244. * @returns the width of the render size
  20245. */
  20246. getRenderSize(): number;
  20247. /**
  20248. * Gets the actual render width of the texture.
  20249. * @returns the width of the render size
  20250. */
  20251. getRenderWidth(): number;
  20252. /**
  20253. * Gets the actual render height of the texture.
  20254. * @returns the height of the render size
  20255. */
  20256. getRenderHeight(): number;
  20257. /**
  20258. * Get if the texture can be rescaled or not.
  20259. */
  20260. readonly canRescale: boolean;
  20261. /**
  20262. * Resize the texture using a ratio.
  20263. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20264. */
  20265. scale(ratio: number): void;
  20266. /**
  20267. * Get the texture reflection matrix used to rotate/transform the reflection.
  20268. * @returns the reflection matrix
  20269. */
  20270. getReflectionTextureMatrix(): Matrix;
  20271. /**
  20272. * Resize the texture to a new desired size.
  20273. * Be carrefull as it will recreate all the data in the new texture.
  20274. * @param size Define the new size. It can be:
  20275. * - a number for squared texture,
  20276. * - an object containing { width: number, height: number }
  20277. * - or an object containing a ratio { ratio: number }
  20278. */
  20279. resize(size: number | {
  20280. width: number;
  20281. height: number;
  20282. } | {
  20283. ratio: number;
  20284. }): void;
  20285. /**
  20286. * Renders all the objects from the render list into the texture.
  20287. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20288. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20289. */
  20290. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20291. private _bestReflectionRenderTargetDimension;
  20292. /**
  20293. * @hidden
  20294. * @param faceIndex face index to bind to if this is a cubetexture
  20295. */
  20296. _bindFrameBuffer(faceIndex?: number): void;
  20297. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20298. private renderToTarget;
  20299. /**
  20300. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20301. * This allowed control for front to back rendering or reversly depending of the special needs.
  20302. *
  20303. * @param renderingGroupId The rendering group id corresponding to its index
  20304. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20305. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20306. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20307. */
  20308. 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;
  20309. /**
  20310. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20311. *
  20312. * @param renderingGroupId The rendering group id corresponding to its index
  20313. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20314. */
  20315. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20316. /**
  20317. * Clones the texture.
  20318. * @returns the cloned texture
  20319. */
  20320. clone(): RenderTargetTexture;
  20321. /**
  20322. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20323. * @returns The JSON representation of the texture
  20324. */
  20325. serialize(): any;
  20326. /**
  20327. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20328. */
  20329. disposeFramebufferObjects(): void;
  20330. /**
  20331. * Dispose the texture and release its associated resources.
  20332. */
  20333. dispose(): void;
  20334. /** @hidden */
  20335. _rebuild(): void;
  20336. /**
  20337. * Clear the info related to rendering groups preventing retention point in material dispose.
  20338. */
  20339. freeRenderingGroups(): void;
  20340. /**
  20341. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20342. * @returns the view count
  20343. */
  20344. getViewCount(): number;
  20345. }
  20346. }
  20347. declare module BABYLON {
  20348. /**
  20349. * Options for compiling materials.
  20350. */
  20351. export interface IMaterialCompilationOptions {
  20352. /**
  20353. * Defines whether clip planes are enabled.
  20354. */
  20355. clipPlane: boolean;
  20356. /**
  20357. * Defines whether instances are enabled.
  20358. */
  20359. useInstances: boolean;
  20360. }
  20361. /**
  20362. * Base class for the main features of a material in Babylon.js
  20363. */
  20364. export class Material implements IAnimatable {
  20365. /**
  20366. * Returns the triangle fill mode
  20367. */
  20368. static readonly TriangleFillMode: number;
  20369. /**
  20370. * Returns the wireframe mode
  20371. */
  20372. static readonly WireFrameFillMode: number;
  20373. /**
  20374. * Returns the point fill mode
  20375. */
  20376. static readonly PointFillMode: number;
  20377. /**
  20378. * Returns the point list draw mode
  20379. */
  20380. static readonly PointListDrawMode: number;
  20381. /**
  20382. * Returns the line list draw mode
  20383. */
  20384. static readonly LineListDrawMode: number;
  20385. /**
  20386. * Returns the line loop draw mode
  20387. */
  20388. static readonly LineLoopDrawMode: number;
  20389. /**
  20390. * Returns the line strip draw mode
  20391. */
  20392. static readonly LineStripDrawMode: number;
  20393. /**
  20394. * Returns the triangle strip draw mode
  20395. */
  20396. static readonly TriangleStripDrawMode: number;
  20397. /**
  20398. * Returns the triangle fan draw mode
  20399. */
  20400. static readonly TriangleFanDrawMode: number;
  20401. /**
  20402. * Stores the clock-wise side orientation
  20403. */
  20404. static readonly ClockWiseSideOrientation: number;
  20405. /**
  20406. * Stores the counter clock-wise side orientation
  20407. */
  20408. static readonly CounterClockWiseSideOrientation: number;
  20409. /**
  20410. * The dirty texture flag value
  20411. */
  20412. static readonly TextureDirtyFlag: number;
  20413. /**
  20414. * The dirty light flag value
  20415. */
  20416. static readonly LightDirtyFlag: number;
  20417. /**
  20418. * The dirty fresnel flag value
  20419. */
  20420. static readonly FresnelDirtyFlag: number;
  20421. /**
  20422. * The dirty attribute flag value
  20423. */
  20424. static readonly AttributesDirtyFlag: number;
  20425. /**
  20426. * The dirty misc flag value
  20427. */
  20428. static readonly MiscDirtyFlag: number;
  20429. /**
  20430. * The all dirty flag value
  20431. */
  20432. static readonly AllDirtyFlag: number;
  20433. /**
  20434. * The ID of the material
  20435. */
  20436. id: string;
  20437. /**
  20438. * Gets or sets the unique id of the material
  20439. */
  20440. uniqueId: number;
  20441. /**
  20442. * The name of the material
  20443. */
  20444. name: string;
  20445. /**
  20446. * Gets or sets user defined metadata
  20447. */
  20448. metadata: any;
  20449. /**
  20450. * For internal use only. Please do not use.
  20451. */
  20452. reservedDataStore: any;
  20453. /**
  20454. * Specifies if the ready state should be checked on each call
  20455. */
  20456. checkReadyOnEveryCall: boolean;
  20457. /**
  20458. * Specifies if the ready state should be checked once
  20459. */
  20460. checkReadyOnlyOnce: boolean;
  20461. /**
  20462. * The state of the material
  20463. */
  20464. state: string;
  20465. /**
  20466. * The alpha value of the material
  20467. */
  20468. protected _alpha: number;
  20469. /**
  20470. * List of inspectable custom properties (used by the Inspector)
  20471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20472. */
  20473. inspectableCustomProperties: IInspectable[];
  20474. /**
  20475. * Sets the alpha value of the material
  20476. */
  20477. /**
  20478. * Gets the alpha value of the material
  20479. */
  20480. alpha: number;
  20481. /**
  20482. * Specifies if back face culling is enabled
  20483. */
  20484. protected _backFaceCulling: boolean;
  20485. /**
  20486. * Sets the back-face culling state
  20487. */
  20488. /**
  20489. * Gets the back-face culling state
  20490. */
  20491. backFaceCulling: boolean;
  20492. /**
  20493. * Stores the value for side orientation
  20494. */
  20495. sideOrientation: number;
  20496. /**
  20497. * Callback triggered when the material is compiled
  20498. */
  20499. onCompiled: Nullable<(effect: Effect) => void>;
  20500. /**
  20501. * Callback triggered when an error occurs
  20502. */
  20503. onError: Nullable<(effect: Effect, errors: string) => void>;
  20504. /**
  20505. * Callback triggered to get the render target textures
  20506. */
  20507. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20508. /**
  20509. * Gets a boolean indicating that current material needs to register RTT
  20510. */
  20511. readonly hasRenderTargetTextures: boolean;
  20512. /**
  20513. * Specifies if the material should be serialized
  20514. */
  20515. doNotSerialize: boolean;
  20516. /**
  20517. * @hidden
  20518. */
  20519. _storeEffectOnSubMeshes: boolean;
  20520. /**
  20521. * Stores the animations for the material
  20522. */
  20523. animations: Nullable<Array<Animation>>;
  20524. /**
  20525. * An event triggered when the material is disposed
  20526. */
  20527. onDisposeObservable: Observable<Material>;
  20528. /**
  20529. * An observer which watches for dispose events
  20530. */
  20531. private _onDisposeObserver;
  20532. private _onUnBindObservable;
  20533. /**
  20534. * Called during a dispose event
  20535. */
  20536. onDispose: () => void;
  20537. private _onBindObservable;
  20538. /**
  20539. * An event triggered when the material is bound
  20540. */
  20541. readonly onBindObservable: Observable<AbstractMesh>;
  20542. /**
  20543. * An observer which watches for bind events
  20544. */
  20545. private _onBindObserver;
  20546. /**
  20547. * Called during a bind event
  20548. */
  20549. onBind: (Mesh: AbstractMesh) => void;
  20550. /**
  20551. * An event triggered when the material is unbound
  20552. */
  20553. readonly onUnBindObservable: Observable<Material>;
  20554. /**
  20555. * Stores the value of the alpha mode
  20556. */
  20557. private _alphaMode;
  20558. /**
  20559. * Sets the value of the alpha mode.
  20560. *
  20561. * | Value | Type | Description |
  20562. * | --- | --- | --- |
  20563. * | 0 | ALPHA_DISABLE | |
  20564. * | 1 | ALPHA_ADD | |
  20565. * | 2 | ALPHA_COMBINE | |
  20566. * | 3 | ALPHA_SUBTRACT | |
  20567. * | 4 | ALPHA_MULTIPLY | |
  20568. * | 5 | ALPHA_MAXIMIZED | |
  20569. * | 6 | ALPHA_ONEONE | |
  20570. * | 7 | ALPHA_PREMULTIPLIED | |
  20571. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20572. * | 9 | ALPHA_INTERPOLATE | |
  20573. * | 10 | ALPHA_SCREENMODE | |
  20574. *
  20575. */
  20576. /**
  20577. * Gets the value of the alpha mode
  20578. */
  20579. alphaMode: number;
  20580. /**
  20581. * Stores the state of the need depth pre-pass value
  20582. */
  20583. private _needDepthPrePass;
  20584. /**
  20585. * Sets the need depth pre-pass value
  20586. */
  20587. /**
  20588. * Gets the depth pre-pass value
  20589. */
  20590. needDepthPrePass: boolean;
  20591. /**
  20592. * Specifies if depth writing should be disabled
  20593. */
  20594. disableDepthWrite: boolean;
  20595. /**
  20596. * Specifies if depth writing should be forced
  20597. */
  20598. forceDepthWrite: boolean;
  20599. /**
  20600. * Specifies the depth function that should be used. 0 means the default engine function
  20601. */
  20602. depthFunction: number;
  20603. /**
  20604. * Specifies if there should be a separate pass for culling
  20605. */
  20606. separateCullingPass: boolean;
  20607. /**
  20608. * Stores the state specifing if fog should be enabled
  20609. */
  20610. private _fogEnabled;
  20611. /**
  20612. * Sets the state for enabling fog
  20613. */
  20614. /**
  20615. * Gets the value of the fog enabled state
  20616. */
  20617. fogEnabled: boolean;
  20618. /**
  20619. * Stores the size of points
  20620. */
  20621. pointSize: number;
  20622. /**
  20623. * Stores the z offset value
  20624. */
  20625. zOffset: number;
  20626. /**
  20627. * Gets a value specifying if wireframe mode is enabled
  20628. */
  20629. /**
  20630. * Sets the state of wireframe mode
  20631. */
  20632. wireframe: boolean;
  20633. /**
  20634. * Gets the value specifying if point clouds are enabled
  20635. */
  20636. /**
  20637. * Sets the state of point cloud mode
  20638. */
  20639. pointsCloud: boolean;
  20640. /**
  20641. * Gets the material fill mode
  20642. */
  20643. /**
  20644. * Sets the material fill mode
  20645. */
  20646. fillMode: number;
  20647. /**
  20648. * @hidden
  20649. * Stores the effects for the material
  20650. */
  20651. _effect: Nullable<Effect>;
  20652. /**
  20653. * @hidden
  20654. * Specifies if the material was previously ready
  20655. */
  20656. _wasPreviouslyReady: boolean;
  20657. /**
  20658. * Specifies if uniform buffers should be used
  20659. */
  20660. private _useUBO;
  20661. /**
  20662. * Stores a reference to the scene
  20663. */
  20664. private _scene;
  20665. /**
  20666. * Stores the fill mode state
  20667. */
  20668. private _fillMode;
  20669. /**
  20670. * Specifies if the depth write state should be cached
  20671. */
  20672. private _cachedDepthWriteState;
  20673. /**
  20674. * Specifies if the depth function state should be cached
  20675. */
  20676. private _cachedDepthFunctionState;
  20677. /**
  20678. * Stores the uniform buffer
  20679. */
  20680. protected _uniformBuffer: UniformBuffer;
  20681. /** @hidden */
  20682. _indexInSceneMaterialArray: number;
  20683. /** @hidden */
  20684. meshMap: Nullable<{
  20685. [id: string]: AbstractMesh | undefined;
  20686. }>;
  20687. /**
  20688. * Creates a material instance
  20689. * @param name defines the name of the material
  20690. * @param scene defines the scene to reference
  20691. * @param doNotAdd specifies if the material should be added to the scene
  20692. */
  20693. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20694. /**
  20695. * Returns a string representation of the current material
  20696. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20697. * @returns a string with material information
  20698. */
  20699. toString(fullDetails?: boolean): string;
  20700. /**
  20701. * Gets the class name of the material
  20702. * @returns a string with the class name of the material
  20703. */
  20704. getClassName(): string;
  20705. /**
  20706. * Specifies if updates for the material been locked
  20707. */
  20708. readonly isFrozen: boolean;
  20709. /**
  20710. * Locks updates for the material
  20711. */
  20712. freeze(): void;
  20713. /**
  20714. * Unlocks updates for the material
  20715. */
  20716. unfreeze(): void;
  20717. /**
  20718. * Specifies if the material is ready to be used
  20719. * @param mesh defines the mesh to check
  20720. * @param useInstances specifies if instances should be used
  20721. * @returns a boolean indicating if the material is ready to be used
  20722. */
  20723. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20724. /**
  20725. * Specifies that the submesh is ready to be used
  20726. * @param mesh defines the mesh to check
  20727. * @param subMesh defines which submesh to check
  20728. * @param useInstances specifies that instances should be used
  20729. * @returns a boolean indicating that the submesh is ready or not
  20730. */
  20731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20732. /**
  20733. * Returns the material effect
  20734. * @returns the effect associated with the material
  20735. */
  20736. getEffect(): Nullable<Effect>;
  20737. /**
  20738. * Returns the current scene
  20739. * @returns a Scene
  20740. */
  20741. getScene(): Scene;
  20742. /**
  20743. * Specifies if the material will require alpha blending
  20744. * @returns a boolean specifying if alpha blending is needed
  20745. */
  20746. needAlphaBlending(): boolean;
  20747. /**
  20748. * Specifies if the mesh will require alpha blending
  20749. * @param mesh defines the mesh to check
  20750. * @returns a boolean specifying if alpha blending is needed for the mesh
  20751. */
  20752. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20753. /**
  20754. * Specifies if this material should be rendered in alpha test mode
  20755. * @returns a boolean specifying if an alpha test is needed.
  20756. */
  20757. needAlphaTesting(): boolean;
  20758. /**
  20759. * Gets the texture used for the alpha test
  20760. * @returns the texture to use for alpha testing
  20761. */
  20762. getAlphaTestTexture(): Nullable<BaseTexture>;
  20763. /**
  20764. * Marks the material to indicate that it needs to be re-calculated
  20765. */
  20766. markDirty(): void;
  20767. /** @hidden */
  20768. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20769. /**
  20770. * Binds the material to the mesh
  20771. * @param world defines the world transformation matrix
  20772. * @param mesh defines the mesh to bind the material to
  20773. */
  20774. bind(world: Matrix, mesh?: Mesh): void;
  20775. /**
  20776. * Binds the submesh to the material
  20777. * @param world defines the world transformation matrix
  20778. * @param mesh defines the mesh containing the submesh
  20779. * @param subMesh defines the submesh to bind the material to
  20780. */
  20781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20782. /**
  20783. * Binds the world matrix to the material
  20784. * @param world defines the world transformation matrix
  20785. */
  20786. bindOnlyWorldMatrix(world: Matrix): void;
  20787. /**
  20788. * Binds the scene's uniform buffer to the effect.
  20789. * @param effect defines the effect to bind to the scene uniform buffer
  20790. * @param sceneUbo defines the uniform buffer storing scene data
  20791. */
  20792. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20793. /**
  20794. * Binds the view matrix to the effect
  20795. * @param effect defines the effect to bind the view matrix to
  20796. */
  20797. bindView(effect: Effect): void;
  20798. /**
  20799. * Binds the view projection matrix to the effect
  20800. * @param effect defines the effect to bind the view projection matrix to
  20801. */
  20802. bindViewProjection(effect: Effect): void;
  20803. /**
  20804. * Specifies if material alpha testing should be turned on for the mesh
  20805. * @param mesh defines the mesh to check
  20806. */
  20807. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20808. /**
  20809. * Processes to execute after binding the material to a mesh
  20810. * @param mesh defines the rendered mesh
  20811. */
  20812. protected _afterBind(mesh?: Mesh): void;
  20813. /**
  20814. * Unbinds the material from the mesh
  20815. */
  20816. unbind(): void;
  20817. /**
  20818. * Gets the active textures from the material
  20819. * @returns an array of textures
  20820. */
  20821. getActiveTextures(): BaseTexture[];
  20822. /**
  20823. * Specifies if the material uses a texture
  20824. * @param texture defines the texture to check against the material
  20825. * @returns a boolean specifying if the material uses the texture
  20826. */
  20827. hasTexture(texture: BaseTexture): boolean;
  20828. /**
  20829. * Makes a duplicate of the material, and gives it a new name
  20830. * @param name defines the new name for the duplicated material
  20831. * @returns the cloned material
  20832. */
  20833. clone(name: string): Nullable<Material>;
  20834. /**
  20835. * Gets the meshes bound to the material
  20836. * @returns an array of meshes bound to the material
  20837. */
  20838. getBindedMeshes(): AbstractMesh[];
  20839. /**
  20840. * Force shader compilation
  20841. * @param mesh defines the mesh associated with this material
  20842. * @param onCompiled defines a function to execute once the material is compiled
  20843. * @param options defines the options to configure the compilation
  20844. * @param onError defines a function to execute if the material fails compiling
  20845. */
  20846. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20847. /**
  20848. * Force shader compilation
  20849. * @param mesh defines the mesh that will use this material
  20850. * @param options defines additional options for compiling the shaders
  20851. * @returns a promise that resolves when the compilation completes
  20852. */
  20853. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20854. private static readonly _AllDirtyCallBack;
  20855. private static readonly _ImageProcessingDirtyCallBack;
  20856. private static readonly _TextureDirtyCallBack;
  20857. private static readonly _FresnelDirtyCallBack;
  20858. private static readonly _MiscDirtyCallBack;
  20859. private static readonly _LightsDirtyCallBack;
  20860. private static readonly _AttributeDirtyCallBack;
  20861. private static _FresnelAndMiscDirtyCallBack;
  20862. private static _TextureAndMiscDirtyCallBack;
  20863. private static readonly _DirtyCallbackArray;
  20864. private static readonly _RunDirtyCallBacks;
  20865. /**
  20866. * Marks a define in the material to indicate that it needs to be re-computed
  20867. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20868. */
  20869. markAsDirty(flag: number): void;
  20870. /**
  20871. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20872. * @param func defines a function which checks material defines against the submeshes
  20873. */
  20874. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20875. /**
  20876. * Indicates that we need to re-calculated for all submeshes
  20877. */
  20878. protected _markAllSubMeshesAsAllDirty(): void;
  20879. /**
  20880. * Indicates that image processing needs to be re-calculated for all submeshes
  20881. */
  20882. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20883. /**
  20884. * Indicates that textures need to be re-calculated for all submeshes
  20885. */
  20886. protected _markAllSubMeshesAsTexturesDirty(): void;
  20887. /**
  20888. * Indicates that fresnel needs to be re-calculated for all submeshes
  20889. */
  20890. protected _markAllSubMeshesAsFresnelDirty(): void;
  20891. /**
  20892. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20893. */
  20894. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20895. /**
  20896. * Indicates that lights need to be re-calculated for all submeshes
  20897. */
  20898. protected _markAllSubMeshesAsLightsDirty(): void;
  20899. /**
  20900. * Indicates that attributes need to be re-calculated for all submeshes
  20901. */
  20902. protected _markAllSubMeshesAsAttributesDirty(): void;
  20903. /**
  20904. * Indicates that misc needs to be re-calculated for all submeshes
  20905. */
  20906. protected _markAllSubMeshesAsMiscDirty(): void;
  20907. /**
  20908. * Indicates that textures and misc need to be re-calculated for all submeshes
  20909. */
  20910. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20911. /**
  20912. * Disposes the material
  20913. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20914. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20915. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20916. */
  20917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20918. /** @hidden */
  20919. private releaseVertexArrayObject;
  20920. /**
  20921. * Serializes this material
  20922. * @returns the serialized material object
  20923. */
  20924. serialize(): any;
  20925. /**
  20926. * Creates a material from parsed material data
  20927. * @param parsedMaterial defines parsed material data
  20928. * @param scene defines the hosting scene
  20929. * @param rootUrl defines the root URL to use to load textures
  20930. * @returns a new material
  20931. */
  20932. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20933. }
  20934. }
  20935. declare module BABYLON {
  20936. /**
  20937. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20938. * separate meshes. This can be use to improve performances.
  20939. * @see http://doc.babylonjs.com/how_to/multi_materials
  20940. */
  20941. export class MultiMaterial extends Material {
  20942. private _subMaterials;
  20943. /**
  20944. * Gets or Sets the list of Materials used within the multi material.
  20945. * They need to be ordered according to the submeshes order in the associated mesh
  20946. */
  20947. subMaterials: Nullable<Material>[];
  20948. /**
  20949. * Function used to align with Node.getChildren()
  20950. * @returns the list of Materials used within the multi material
  20951. */
  20952. getChildren(): Nullable<Material>[];
  20953. /**
  20954. * Instantiates a new Multi Material
  20955. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20956. * separate meshes. This can be use to improve performances.
  20957. * @see http://doc.babylonjs.com/how_to/multi_materials
  20958. * @param name Define the name in the scene
  20959. * @param scene Define the scene the material belongs to
  20960. */
  20961. constructor(name: string, scene: Scene);
  20962. private _hookArray;
  20963. /**
  20964. * Get one of the submaterial by its index in the submaterials array
  20965. * @param index The index to look the sub material at
  20966. * @returns The Material if the index has been defined
  20967. */
  20968. getSubMaterial(index: number): Nullable<Material>;
  20969. /**
  20970. * Get the list of active textures for the whole sub materials list.
  20971. * @returns All the textures that will be used during the rendering
  20972. */
  20973. getActiveTextures(): BaseTexture[];
  20974. /**
  20975. * Gets the current class name of the material e.g. "MultiMaterial"
  20976. * Mainly use in serialization.
  20977. * @returns the class name
  20978. */
  20979. getClassName(): string;
  20980. /**
  20981. * Checks if the material is ready to render the requested sub mesh
  20982. * @param mesh Define the mesh the submesh belongs to
  20983. * @param subMesh Define the sub mesh to look readyness for
  20984. * @param useInstances Define whether or not the material is used with instances
  20985. * @returns true if ready, otherwise false
  20986. */
  20987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20988. /**
  20989. * Clones the current material and its related sub materials
  20990. * @param name Define the name of the newly cloned material
  20991. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20992. * @returns the cloned material
  20993. */
  20994. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20995. /**
  20996. * Serializes the materials into a JSON representation.
  20997. * @returns the JSON representation
  20998. */
  20999. serialize(): any;
  21000. /**
  21001. * Dispose the material and release its associated resources
  21002. * @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)
  21003. * @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)
  21004. * @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)
  21005. */
  21006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21007. /**
  21008. * Creates a MultiMaterial from parsed MultiMaterial data.
  21009. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21010. * @param scene defines the hosting scene
  21011. * @returns a new MultiMaterial
  21012. */
  21013. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21014. }
  21015. }
  21016. declare module BABYLON {
  21017. /**
  21018. * Base class for submeshes
  21019. */
  21020. export class BaseSubMesh {
  21021. /** @hidden */
  21022. _materialDefines: Nullable<MaterialDefines>;
  21023. /** @hidden */
  21024. _materialEffect: Nullable<Effect>;
  21025. /**
  21026. * Gets associated effect
  21027. */
  21028. readonly effect: Nullable<Effect>;
  21029. /**
  21030. * Sets associated effect (effect used to render this submesh)
  21031. * @param effect defines the effect to associate with
  21032. * @param defines defines the set of defines used to compile this effect
  21033. */
  21034. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21035. }
  21036. /**
  21037. * Defines a subdivision inside a mesh
  21038. */
  21039. export class SubMesh extends BaseSubMesh implements ICullable {
  21040. /** the material index to use */
  21041. materialIndex: number;
  21042. /** vertex index start */
  21043. verticesStart: number;
  21044. /** vertices count */
  21045. verticesCount: number;
  21046. /** index start */
  21047. indexStart: number;
  21048. /** indices count */
  21049. indexCount: number;
  21050. /** @hidden */
  21051. _linesIndexCount: number;
  21052. private _mesh;
  21053. private _renderingMesh;
  21054. private _boundingInfo;
  21055. private _linesIndexBuffer;
  21056. /** @hidden */
  21057. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21058. /** @hidden */
  21059. _trianglePlanes: Plane[];
  21060. /** @hidden */
  21061. _lastColliderTransformMatrix: Nullable<Matrix>;
  21062. /** @hidden */
  21063. _renderId: number;
  21064. /** @hidden */
  21065. _alphaIndex: number;
  21066. /** @hidden */
  21067. _distanceToCamera: number;
  21068. /** @hidden */
  21069. _id: number;
  21070. private _currentMaterial;
  21071. /**
  21072. * Add a new submesh to a mesh
  21073. * @param materialIndex defines the material index to use
  21074. * @param verticesStart defines vertex index start
  21075. * @param verticesCount defines vertices count
  21076. * @param indexStart defines index start
  21077. * @param indexCount defines indices count
  21078. * @param mesh defines the parent mesh
  21079. * @param renderingMesh defines an optional rendering mesh
  21080. * @param createBoundingBox defines if bounding box should be created for this submesh
  21081. * @returns the new submesh
  21082. */
  21083. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21084. /**
  21085. * Creates a new submesh
  21086. * @param materialIndex defines the material index to use
  21087. * @param verticesStart defines vertex index start
  21088. * @param verticesCount defines vertices count
  21089. * @param indexStart defines index start
  21090. * @param indexCount defines indices count
  21091. * @param mesh defines the parent mesh
  21092. * @param renderingMesh defines an optional rendering mesh
  21093. * @param createBoundingBox defines if bounding box should be created for this submesh
  21094. */
  21095. constructor(
  21096. /** the material index to use */
  21097. materialIndex: number,
  21098. /** vertex index start */
  21099. verticesStart: number,
  21100. /** vertices count */
  21101. verticesCount: number,
  21102. /** index start */
  21103. indexStart: number,
  21104. /** indices count */
  21105. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21106. /**
  21107. * Returns true if this submesh covers the entire parent mesh
  21108. * @ignorenaming
  21109. */
  21110. readonly IsGlobal: boolean;
  21111. /**
  21112. * Returns the submesh BoudingInfo object
  21113. * @returns current bounding info (or mesh's one if the submesh is global)
  21114. */
  21115. getBoundingInfo(): BoundingInfo;
  21116. /**
  21117. * Sets the submesh BoundingInfo
  21118. * @param boundingInfo defines the new bounding info to use
  21119. * @returns the SubMesh
  21120. */
  21121. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21122. /**
  21123. * Returns the mesh of the current submesh
  21124. * @return the parent mesh
  21125. */
  21126. getMesh(): AbstractMesh;
  21127. /**
  21128. * Returns the rendering mesh of the submesh
  21129. * @returns the rendering mesh (could be different from parent mesh)
  21130. */
  21131. getRenderingMesh(): Mesh;
  21132. /**
  21133. * Returns the submesh material
  21134. * @returns null or the current material
  21135. */
  21136. getMaterial(): Nullable<Material>;
  21137. /**
  21138. * Sets a new updated BoundingInfo object to the submesh
  21139. * @param data defines an optional position array to use to determine the bounding info
  21140. * @returns the SubMesh
  21141. */
  21142. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21143. /** @hidden */
  21144. _checkCollision(collider: Collider): boolean;
  21145. /**
  21146. * Updates the submesh BoundingInfo
  21147. * @param world defines the world matrix to use to update the bounding info
  21148. * @returns the submesh
  21149. */
  21150. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21151. /**
  21152. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21153. * @param frustumPlanes defines the frustum planes
  21154. * @returns true if the submesh is intersecting with the frustum
  21155. */
  21156. isInFrustum(frustumPlanes: Plane[]): boolean;
  21157. /**
  21158. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21159. * @param frustumPlanes defines the frustum planes
  21160. * @returns true if the submesh is inside the frustum
  21161. */
  21162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21163. /**
  21164. * Renders the submesh
  21165. * @param enableAlphaMode defines if alpha needs to be used
  21166. * @returns the submesh
  21167. */
  21168. render(enableAlphaMode: boolean): SubMesh;
  21169. /**
  21170. * @hidden
  21171. */
  21172. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21173. /**
  21174. * Checks if the submesh intersects with a ray
  21175. * @param ray defines the ray to test
  21176. * @returns true is the passed ray intersects the submesh bounding box
  21177. */
  21178. canIntersects(ray: Ray): boolean;
  21179. /**
  21180. * Intersects current submesh with a ray
  21181. * @param ray defines the ray to test
  21182. * @param positions defines mesh's positions array
  21183. * @param indices defines mesh's indices array
  21184. * @param fastCheck defines if only bounding info should be used
  21185. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21186. * @returns intersection info or null if no intersection
  21187. */
  21188. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21189. /** @hidden */
  21190. private _intersectLines;
  21191. /** @hidden */
  21192. private _intersectUnIndexedLines;
  21193. /** @hidden */
  21194. private _intersectTriangles;
  21195. /** @hidden */
  21196. private _intersectUnIndexedTriangles;
  21197. /** @hidden */
  21198. _rebuild(): void;
  21199. /**
  21200. * Creates a new submesh from the passed mesh
  21201. * @param newMesh defines the new hosting mesh
  21202. * @param newRenderingMesh defines an optional rendering mesh
  21203. * @returns the new submesh
  21204. */
  21205. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21206. /**
  21207. * Release associated resources
  21208. */
  21209. dispose(): void;
  21210. /**
  21211. * Gets the class name
  21212. * @returns the string "SubMesh".
  21213. */
  21214. getClassName(): string;
  21215. /**
  21216. * Creates a new submesh from indices data
  21217. * @param materialIndex the index of the main mesh material
  21218. * @param startIndex the index where to start the copy in the mesh indices array
  21219. * @param indexCount the number of indices to copy then from the startIndex
  21220. * @param mesh the main mesh to create the submesh from
  21221. * @param renderingMesh the optional rendering mesh
  21222. * @returns a new submesh
  21223. */
  21224. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21225. }
  21226. }
  21227. declare module BABYLON {
  21228. /**
  21229. * Class used to represent data loading progression
  21230. */
  21231. export class SceneLoaderFlags {
  21232. private static _ForceFullSceneLoadingForIncremental;
  21233. private static _ShowLoadingScreen;
  21234. private static _CleanBoneMatrixWeights;
  21235. private static _loggingLevel;
  21236. /**
  21237. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21238. */
  21239. static ForceFullSceneLoadingForIncremental: boolean;
  21240. /**
  21241. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21242. */
  21243. static ShowLoadingScreen: boolean;
  21244. /**
  21245. * Defines the current logging level (while loading the scene)
  21246. * @ignorenaming
  21247. */
  21248. static loggingLevel: number;
  21249. /**
  21250. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21251. */
  21252. static CleanBoneMatrixWeights: boolean;
  21253. }
  21254. }
  21255. declare module BABYLON {
  21256. /**
  21257. * Class used to store geometry data (vertex buffers + index buffer)
  21258. */
  21259. export class Geometry implements IGetSetVerticesData {
  21260. /**
  21261. * Gets or sets the ID of the geometry
  21262. */
  21263. id: string;
  21264. /**
  21265. * Gets or sets the unique ID of the geometry
  21266. */
  21267. uniqueId: number;
  21268. /**
  21269. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21270. */
  21271. delayLoadState: number;
  21272. /**
  21273. * Gets the file containing the data to load when running in delay load state
  21274. */
  21275. delayLoadingFile: Nullable<string>;
  21276. /**
  21277. * Callback called when the geometry is updated
  21278. */
  21279. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21280. private _scene;
  21281. private _engine;
  21282. private _meshes;
  21283. private _totalVertices;
  21284. /** @hidden */
  21285. _indices: IndicesArray;
  21286. /** @hidden */
  21287. _vertexBuffers: {
  21288. [key: string]: VertexBuffer;
  21289. };
  21290. private _isDisposed;
  21291. private _extend;
  21292. private _boundingBias;
  21293. /** @hidden */
  21294. _delayInfo: Array<string>;
  21295. private _indexBuffer;
  21296. private _indexBufferIsUpdatable;
  21297. /** @hidden */
  21298. _boundingInfo: Nullable<BoundingInfo>;
  21299. /** @hidden */
  21300. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21301. /** @hidden */
  21302. _softwareSkinningFrameId: number;
  21303. private _vertexArrayObjects;
  21304. private _updatable;
  21305. /** @hidden */
  21306. _positions: Nullable<Vector3[]>;
  21307. /**
  21308. * 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
  21309. */
  21310. /**
  21311. * 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
  21312. */
  21313. boundingBias: Vector2;
  21314. /**
  21315. * Static function used to attach a new empty geometry to a mesh
  21316. * @param mesh defines the mesh to attach the geometry to
  21317. * @returns the new Geometry
  21318. */
  21319. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21320. /**
  21321. * Creates a new geometry
  21322. * @param id defines the unique ID
  21323. * @param scene defines the hosting scene
  21324. * @param vertexData defines the VertexData used to get geometry data
  21325. * @param updatable defines if geometry must be updatable (false by default)
  21326. * @param mesh defines the mesh that will be associated with the geometry
  21327. */
  21328. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21329. /**
  21330. * Gets the current extend of the geometry
  21331. */
  21332. readonly extend: {
  21333. minimum: Vector3;
  21334. maximum: Vector3;
  21335. };
  21336. /**
  21337. * Gets the hosting scene
  21338. * @returns the hosting Scene
  21339. */
  21340. getScene(): Scene;
  21341. /**
  21342. * Gets the hosting engine
  21343. * @returns the hosting Engine
  21344. */
  21345. getEngine(): Engine;
  21346. /**
  21347. * Defines if the geometry is ready to use
  21348. * @returns true if the geometry is ready to be used
  21349. */
  21350. isReady(): boolean;
  21351. /**
  21352. * Gets a value indicating that the geometry should not be serialized
  21353. */
  21354. readonly doNotSerialize: boolean;
  21355. /** @hidden */
  21356. _rebuild(): void;
  21357. /**
  21358. * Affects all geometry data in one call
  21359. * @param vertexData defines the geometry data
  21360. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21361. */
  21362. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21363. /**
  21364. * Set specific vertex data
  21365. * @param kind defines the data kind (Position, normal, etc...)
  21366. * @param data defines the vertex data to use
  21367. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21368. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21369. */
  21370. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21371. /**
  21372. * Removes a specific vertex data
  21373. * @param kind defines the data kind (Position, normal, etc...)
  21374. */
  21375. removeVerticesData(kind: string): void;
  21376. /**
  21377. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21378. * @param buffer defines the vertex buffer to use
  21379. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21380. */
  21381. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21382. /**
  21383. * Update a specific vertex buffer
  21384. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21385. * It will do nothing if the buffer is not updatable
  21386. * @param kind defines the data kind (Position, normal, etc...)
  21387. * @param data defines the data to use
  21388. * @param offset defines the offset in the target buffer where to store the data
  21389. * @param useBytes set to true if the offset is in bytes
  21390. */
  21391. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21392. /**
  21393. * Update a specific vertex buffer
  21394. * This function will create a new buffer if the current one is not updatable
  21395. * @param kind defines the data kind (Position, normal, etc...)
  21396. * @param data defines the data to use
  21397. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21398. */
  21399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21400. private _updateBoundingInfo;
  21401. /** @hidden */
  21402. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21403. /**
  21404. * Gets total number of vertices
  21405. * @returns the total number of vertices
  21406. */
  21407. getTotalVertices(): number;
  21408. /**
  21409. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21410. * @param kind defines the data kind (Position, normal, etc...)
  21411. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21412. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21413. * @returns a float array containing vertex data
  21414. */
  21415. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21416. /**
  21417. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21418. * @param kind defines the data kind (Position, normal, etc...)
  21419. * @returns true if the vertex buffer with the specified kind is updatable
  21420. */
  21421. isVertexBufferUpdatable(kind: string): boolean;
  21422. /**
  21423. * Gets a specific vertex buffer
  21424. * @param kind defines the data kind (Position, normal, etc...)
  21425. * @returns a VertexBuffer
  21426. */
  21427. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21428. /**
  21429. * Returns all vertex buffers
  21430. * @return an object holding all vertex buffers indexed by kind
  21431. */
  21432. getVertexBuffers(): Nullable<{
  21433. [key: string]: VertexBuffer;
  21434. }>;
  21435. /**
  21436. * Gets a boolean indicating if specific vertex buffer is present
  21437. * @param kind defines the data kind (Position, normal, etc...)
  21438. * @returns true if data is present
  21439. */
  21440. isVerticesDataPresent(kind: string): boolean;
  21441. /**
  21442. * Gets a list of all attached data kinds (Position, normal, etc...)
  21443. * @returns a list of string containing all kinds
  21444. */
  21445. getVerticesDataKinds(): string[];
  21446. /**
  21447. * Update index buffer
  21448. * @param indices defines the indices to store in the index buffer
  21449. * @param offset defines the offset in the target buffer where to store the data
  21450. * @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)
  21451. */
  21452. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21453. /**
  21454. * Creates a new index buffer
  21455. * @param indices defines the indices to store in the index buffer
  21456. * @param totalVertices defines the total number of vertices (could be null)
  21457. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21458. */
  21459. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21460. /**
  21461. * Return the total number of indices
  21462. * @returns the total number of indices
  21463. */
  21464. getTotalIndices(): number;
  21465. /**
  21466. * Gets the index buffer array
  21467. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21469. * @returns the index buffer array
  21470. */
  21471. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21472. /**
  21473. * Gets the index buffer
  21474. * @return the index buffer
  21475. */
  21476. getIndexBuffer(): Nullable<DataBuffer>;
  21477. /** @hidden */
  21478. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21479. /**
  21480. * Release the associated resources for a specific mesh
  21481. * @param mesh defines the source mesh
  21482. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21483. */
  21484. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21485. /**
  21486. * Apply current geometry to a given mesh
  21487. * @param mesh defines the mesh to apply geometry to
  21488. */
  21489. applyToMesh(mesh: Mesh): void;
  21490. private _updateExtend;
  21491. private _applyToMesh;
  21492. private notifyUpdate;
  21493. /**
  21494. * Load the geometry if it was flagged as delay loaded
  21495. * @param scene defines the hosting scene
  21496. * @param onLoaded defines a callback called when the geometry is loaded
  21497. */
  21498. load(scene: Scene, onLoaded?: () => void): void;
  21499. private _queueLoad;
  21500. /**
  21501. * Invert the geometry to move from a right handed system to a left handed one.
  21502. */
  21503. toLeftHanded(): void;
  21504. /** @hidden */
  21505. _resetPointsArrayCache(): void;
  21506. /** @hidden */
  21507. _generatePointsArray(): boolean;
  21508. /**
  21509. * Gets a value indicating if the geometry is disposed
  21510. * @returns true if the geometry was disposed
  21511. */
  21512. isDisposed(): boolean;
  21513. private _disposeVertexArrayObjects;
  21514. /**
  21515. * Free all associated resources
  21516. */
  21517. dispose(): void;
  21518. /**
  21519. * Clone the current geometry into a new geometry
  21520. * @param id defines the unique ID of the new geometry
  21521. * @returns a new geometry object
  21522. */
  21523. copy(id: string): Geometry;
  21524. /**
  21525. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21526. * @return a JSON representation of the current geometry data (without the vertices data)
  21527. */
  21528. serialize(): any;
  21529. private toNumberArray;
  21530. /**
  21531. * Serialize all vertices data into a JSON oject
  21532. * @returns a JSON representation of the current geometry data
  21533. */
  21534. serializeVerticeData(): any;
  21535. /**
  21536. * Extracts a clone of a mesh geometry
  21537. * @param mesh defines the source mesh
  21538. * @param id defines the unique ID of the new geometry object
  21539. * @returns the new geometry object
  21540. */
  21541. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21542. /**
  21543. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21544. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21545. * Be aware Math.random() could cause collisions, but:
  21546. * "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"
  21547. * @returns a string containing a new GUID
  21548. */
  21549. static RandomId(): string;
  21550. /** @hidden */
  21551. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21552. private static _CleanMatricesWeights;
  21553. /**
  21554. * Create a new geometry from persisted data (Using .babylon file format)
  21555. * @param parsedVertexData defines the persisted data
  21556. * @param scene defines the hosting scene
  21557. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21558. * @returns the new geometry object
  21559. */
  21560. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21561. }
  21562. }
  21563. declare module BABYLON {
  21564. /**
  21565. * Define an interface for all classes that will get and set the data on vertices
  21566. */
  21567. export interface IGetSetVerticesData {
  21568. /**
  21569. * Gets a boolean indicating if specific vertex data is present
  21570. * @param kind defines the vertex data kind to use
  21571. * @returns true is data kind is present
  21572. */
  21573. isVerticesDataPresent(kind: string): boolean;
  21574. /**
  21575. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21578. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21579. * @returns a float array containing vertex data
  21580. */
  21581. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21582. /**
  21583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21584. * @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.
  21585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21586. * @returns the indices array or an empty array if the mesh has no geometry
  21587. */
  21588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21589. /**
  21590. * Set specific vertex data
  21591. * @param kind defines the data kind (Position, normal, etc...)
  21592. * @param data defines the vertex data to use
  21593. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21594. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21595. */
  21596. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21597. /**
  21598. * Update a specific associated vertex buffer
  21599. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21600. * - VertexBuffer.PositionKind
  21601. * - VertexBuffer.UVKind
  21602. * - VertexBuffer.UV2Kind
  21603. * - VertexBuffer.UV3Kind
  21604. * - VertexBuffer.UV4Kind
  21605. * - VertexBuffer.UV5Kind
  21606. * - VertexBuffer.UV6Kind
  21607. * - VertexBuffer.ColorKind
  21608. * - VertexBuffer.MatricesIndicesKind
  21609. * - VertexBuffer.MatricesIndicesExtraKind
  21610. * - VertexBuffer.MatricesWeightsKind
  21611. * - VertexBuffer.MatricesWeightsExtraKind
  21612. * @param data defines the data source
  21613. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21614. * @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)
  21615. */
  21616. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21617. /**
  21618. * Creates a new index buffer
  21619. * @param indices defines the indices to store in the index buffer
  21620. * @param totalVertices defines the total number of vertices (could be null)
  21621. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21622. */
  21623. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21624. }
  21625. /**
  21626. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21627. */
  21628. export class VertexData {
  21629. /**
  21630. * Mesh side orientation : usually the external or front surface
  21631. */
  21632. static readonly FRONTSIDE: number;
  21633. /**
  21634. * Mesh side orientation : usually the internal or back surface
  21635. */
  21636. static readonly BACKSIDE: number;
  21637. /**
  21638. * Mesh side orientation : both internal and external or front and back surfaces
  21639. */
  21640. static readonly DOUBLESIDE: number;
  21641. /**
  21642. * Mesh side orientation : by default, `FRONTSIDE`
  21643. */
  21644. static readonly DEFAULTSIDE: number;
  21645. /**
  21646. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21647. */
  21648. positions: Nullable<FloatArray>;
  21649. /**
  21650. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21651. */
  21652. normals: Nullable<FloatArray>;
  21653. /**
  21654. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21655. */
  21656. tangents: Nullable<FloatArray>;
  21657. /**
  21658. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21659. */
  21660. uvs: Nullable<FloatArray>;
  21661. /**
  21662. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21663. */
  21664. uvs2: Nullable<FloatArray>;
  21665. /**
  21666. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21667. */
  21668. uvs3: Nullable<FloatArray>;
  21669. /**
  21670. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21671. */
  21672. uvs4: Nullable<FloatArray>;
  21673. /**
  21674. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21675. */
  21676. uvs5: Nullable<FloatArray>;
  21677. /**
  21678. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21679. */
  21680. uvs6: Nullable<FloatArray>;
  21681. /**
  21682. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21683. */
  21684. colors: Nullable<FloatArray>;
  21685. /**
  21686. * 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).
  21687. */
  21688. matricesIndices: Nullable<FloatArray>;
  21689. /**
  21690. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21691. */
  21692. matricesWeights: Nullable<FloatArray>;
  21693. /**
  21694. * An array extending the number of possible indices
  21695. */
  21696. matricesIndicesExtra: Nullable<FloatArray>;
  21697. /**
  21698. * An array extending the number of possible weights when the number of indices is extended
  21699. */
  21700. matricesWeightsExtra: Nullable<FloatArray>;
  21701. /**
  21702. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21703. */
  21704. indices: Nullable<IndicesArray>;
  21705. /**
  21706. * Uses the passed data array to set the set the values for the specified kind of data
  21707. * @param data a linear array of floating numbers
  21708. * @param kind the type of data that is being set, eg positions, colors etc
  21709. */
  21710. set(data: FloatArray, kind: string): void;
  21711. /**
  21712. * Associates the vertexData to the passed Mesh.
  21713. * Sets it as updatable or not (default `false`)
  21714. * @param mesh the mesh the vertexData is applied to
  21715. * @param updatable when used and having the value true allows new data to update the vertexData
  21716. * @returns the VertexData
  21717. */
  21718. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21719. /**
  21720. * Associates the vertexData to the passed Geometry.
  21721. * Sets it as updatable or not (default `false`)
  21722. * @param geometry the geometry the vertexData is applied to
  21723. * @param updatable when used and having the value true allows new data to update the vertexData
  21724. * @returns VertexData
  21725. */
  21726. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21727. /**
  21728. * Updates the associated mesh
  21729. * @param mesh the mesh to be updated
  21730. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21731. * @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
  21732. * @returns VertexData
  21733. */
  21734. updateMesh(mesh: Mesh): VertexData;
  21735. /**
  21736. * Updates the associated geometry
  21737. * @param geometry the geometry to be updated
  21738. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21739. * @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
  21740. * @returns VertexData.
  21741. */
  21742. updateGeometry(geometry: Geometry): VertexData;
  21743. private _applyTo;
  21744. private _update;
  21745. /**
  21746. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21747. * @param matrix the transforming matrix
  21748. * @returns the VertexData
  21749. */
  21750. transform(matrix: Matrix): VertexData;
  21751. /**
  21752. * Merges the passed VertexData into the current one
  21753. * @param other the VertexData to be merged into the current one
  21754. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21755. * @returns the modified VertexData
  21756. */
  21757. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21758. private _mergeElement;
  21759. private _validate;
  21760. /**
  21761. * Serializes the VertexData
  21762. * @returns a serialized object
  21763. */
  21764. serialize(): any;
  21765. /**
  21766. * Extracts the vertexData from a mesh
  21767. * @param mesh the mesh from which to extract the VertexData
  21768. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21769. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21770. * @returns the object VertexData associated to the passed mesh
  21771. */
  21772. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21773. /**
  21774. * Extracts the vertexData from the geometry
  21775. * @param geometry the geometry from which to extract the VertexData
  21776. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21777. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21778. * @returns the object VertexData associated to the passed mesh
  21779. */
  21780. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21781. private static _ExtractFrom;
  21782. /**
  21783. * Creates the VertexData for a Ribbon
  21784. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21785. * * pathArray array of paths, each of which an array of successive Vector3
  21786. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21787. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21788. * * 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
  21789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21790. * * 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)
  21791. * * 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)
  21792. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21793. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21794. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21795. * @returns the VertexData of the ribbon
  21796. */
  21797. static CreateRibbon(options: {
  21798. pathArray: Vector3[][];
  21799. closeArray?: boolean;
  21800. closePath?: boolean;
  21801. offset?: number;
  21802. sideOrientation?: number;
  21803. frontUVs?: Vector4;
  21804. backUVs?: Vector4;
  21805. invertUV?: boolean;
  21806. uvs?: Vector2[];
  21807. colors?: Color4[];
  21808. }): VertexData;
  21809. /**
  21810. * Creates the VertexData for a box
  21811. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21812. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21813. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21814. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21815. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21816. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21817. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21819. * * 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)
  21820. * * 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)
  21821. * @returns the VertexData of the box
  21822. */
  21823. static CreateBox(options: {
  21824. size?: number;
  21825. width?: number;
  21826. height?: number;
  21827. depth?: number;
  21828. faceUV?: Vector4[];
  21829. faceColors?: Color4[];
  21830. sideOrientation?: number;
  21831. frontUVs?: Vector4;
  21832. backUVs?: Vector4;
  21833. }): VertexData;
  21834. /**
  21835. * Creates the VertexData for a tiled box
  21836. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21837. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21838. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21839. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21841. * @returns the VertexData of the box
  21842. */
  21843. static CreateTiledBox(options: {
  21844. pattern?: number;
  21845. width?: number;
  21846. height?: number;
  21847. depth?: number;
  21848. tileSize?: number;
  21849. tileWidth?: number;
  21850. tileHeight?: number;
  21851. alignHorizontal?: number;
  21852. alignVertical?: number;
  21853. faceUV?: Vector4[];
  21854. faceColors?: Color4[];
  21855. sideOrientation?: number;
  21856. }): VertexData;
  21857. /**
  21858. * Creates the VertexData for a tiled plane
  21859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21860. * * pattern a limited pattern arrangement depending on the number
  21861. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21862. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21863. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21865. * * 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)
  21866. * * 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)
  21867. * @returns the VertexData of the tiled plane
  21868. */
  21869. static CreateTiledPlane(options: {
  21870. pattern?: number;
  21871. tileSize?: number;
  21872. tileWidth?: number;
  21873. tileHeight?: number;
  21874. size?: number;
  21875. width?: number;
  21876. height?: number;
  21877. alignHorizontal?: number;
  21878. alignVertical?: number;
  21879. sideOrientation?: number;
  21880. frontUVs?: Vector4;
  21881. backUVs?: Vector4;
  21882. }): VertexData;
  21883. /**
  21884. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21886. * * segments sets the number of horizontal strips optional, default 32
  21887. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21888. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21889. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21890. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21891. * * 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
  21892. * * 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
  21893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21894. * * 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)
  21895. * * 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)
  21896. * @returns the VertexData of the ellipsoid
  21897. */
  21898. static CreateSphere(options: {
  21899. segments?: number;
  21900. diameter?: number;
  21901. diameterX?: number;
  21902. diameterY?: number;
  21903. diameterZ?: number;
  21904. arc?: number;
  21905. slice?: number;
  21906. sideOrientation?: number;
  21907. frontUVs?: Vector4;
  21908. backUVs?: Vector4;
  21909. }): VertexData;
  21910. /**
  21911. * Creates the VertexData for a cylinder, cone or prism
  21912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21913. * * height sets the height (y direction) of the cylinder, optional, default 2
  21914. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21915. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21916. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21917. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21918. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21919. * * 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
  21920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21922. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21923. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21925. * * 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)
  21926. * * 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)
  21927. * @returns the VertexData of the cylinder, cone or prism
  21928. */
  21929. static CreateCylinder(options: {
  21930. height?: number;
  21931. diameterTop?: number;
  21932. diameterBottom?: number;
  21933. diameter?: number;
  21934. tessellation?: number;
  21935. subdivisions?: number;
  21936. arc?: number;
  21937. faceColors?: Color4[];
  21938. faceUV?: Vector4[];
  21939. hasRings?: boolean;
  21940. enclose?: boolean;
  21941. sideOrientation?: number;
  21942. frontUVs?: Vector4;
  21943. backUVs?: Vector4;
  21944. }): VertexData;
  21945. /**
  21946. * Creates the VertexData for a torus
  21947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21948. * * diameter the diameter of the torus, optional default 1
  21949. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21952. * * 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)
  21953. * * 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)
  21954. * @returns the VertexData of the torus
  21955. */
  21956. static CreateTorus(options: {
  21957. diameter?: number;
  21958. thickness?: number;
  21959. tessellation?: number;
  21960. sideOrientation?: number;
  21961. frontUVs?: Vector4;
  21962. backUVs?: Vector4;
  21963. }): VertexData;
  21964. /**
  21965. * Creates the VertexData of the LineSystem
  21966. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21967. * - lines an array of lines, each line being an array of successive Vector3
  21968. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21969. * @returns the VertexData of the LineSystem
  21970. */
  21971. static CreateLineSystem(options: {
  21972. lines: Vector3[][];
  21973. colors?: Nullable<Color4[][]>;
  21974. }): VertexData;
  21975. /**
  21976. * Create the VertexData for a DashedLines
  21977. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21978. * - points an array successive Vector3
  21979. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21980. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21981. * - dashNb the intended total number of dashes, optional, default 200
  21982. * @returns the VertexData for the DashedLines
  21983. */
  21984. static CreateDashedLines(options: {
  21985. points: Vector3[];
  21986. dashSize?: number;
  21987. gapSize?: number;
  21988. dashNb?: number;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for a Ground
  21992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21993. * - width the width (x direction) of the ground, optional, default 1
  21994. * - height the height (z direction) of the ground, optional, default 1
  21995. * - subdivisions the number of subdivisions per side, optional, default 1
  21996. * @returns the VertexData of the Ground
  21997. */
  21998. static CreateGround(options: {
  21999. width?: number;
  22000. height?: number;
  22001. subdivisions?: number;
  22002. subdivisionsX?: number;
  22003. subdivisionsY?: number;
  22004. }): VertexData;
  22005. /**
  22006. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22007. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22008. * * xmin the ground minimum X coordinate, optional, default -1
  22009. * * zmin the ground minimum Z coordinate, optional, default -1
  22010. * * xmax the ground maximum X coordinate, optional, default 1
  22011. * * zmax the ground maximum Z coordinate, optional, default 1
  22012. * * 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}
  22013. * * 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}
  22014. * @returns the VertexData of the TiledGround
  22015. */
  22016. static CreateTiledGround(options: {
  22017. xmin: number;
  22018. zmin: number;
  22019. xmax: number;
  22020. zmax: number;
  22021. subdivisions?: {
  22022. w: number;
  22023. h: number;
  22024. };
  22025. precision?: {
  22026. w: number;
  22027. h: number;
  22028. };
  22029. }): VertexData;
  22030. /**
  22031. * Creates the VertexData of the Ground designed from a heightmap
  22032. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22033. * * width the width (x direction) of the ground
  22034. * * height the height (z direction) of the ground
  22035. * * subdivisions the number of subdivisions per side
  22036. * * minHeight the minimum altitude on the ground, optional, default 0
  22037. * * maxHeight the maximum altitude on the ground, optional default 1
  22038. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22039. * * buffer the array holding the image color data
  22040. * * bufferWidth the width of image
  22041. * * bufferHeight the height of image
  22042. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22043. * @returns the VertexData of the Ground designed from a heightmap
  22044. */
  22045. static CreateGroundFromHeightMap(options: {
  22046. width: number;
  22047. height: number;
  22048. subdivisions: number;
  22049. minHeight: number;
  22050. maxHeight: number;
  22051. colorFilter: Color3;
  22052. buffer: Uint8Array;
  22053. bufferWidth: number;
  22054. bufferHeight: number;
  22055. alphaFilter: number;
  22056. }): VertexData;
  22057. /**
  22058. * Creates the VertexData for a Plane
  22059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22060. * * size sets the width and height of the plane to the value of size, optional default 1
  22061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22063. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22064. * * 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)
  22065. * * 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)
  22066. * @returns the VertexData of the box
  22067. */
  22068. static CreatePlane(options: {
  22069. size?: number;
  22070. width?: number;
  22071. height?: number;
  22072. sideOrientation?: number;
  22073. frontUVs?: Vector4;
  22074. backUVs?: Vector4;
  22075. }): VertexData;
  22076. /**
  22077. * Creates the VertexData of the Disc or regular Polygon
  22078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22079. * * radius the radius of the disc, optional default 0.5
  22080. * * tessellation the number of polygon sides, optional, default 64
  22081. * * 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
  22082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22083. * * 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)
  22084. * * 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)
  22085. * @returns the VertexData of the box
  22086. */
  22087. static CreateDisc(options: {
  22088. radius?: number;
  22089. tessellation?: number;
  22090. arc?: number;
  22091. sideOrientation?: number;
  22092. frontUVs?: Vector4;
  22093. backUVs?: Vector4;
  22094. }): VertexData;
  22095. /**
  22096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22098. * @param polygon a mesh built from polygonTriangulation.build()
  22099. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22102. * @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)
  22103. * @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)
  22104. * @returns the VertexData of the Polygon
  22105. */
  22106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22107. /**
  22108. * Creates the VertexData of the IcoSphere
  22109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22110. * * radius the radius of the IcoSphere, optional default 1
  22111. * * radiusX allows stretching in the x direction, optional, default radius
  22112. * * radiusY allows stretching in the y direction, optional, default radius
  22113. * * radiusZ allows stretching in the z direction, optional, default radius
  22114. * * flat when true creates a flat shaded mesh, optional, default true
  22115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22117. * * 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)
  22118. * * 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)
  22119. * @returns the VertexData of the IcoSphere
  22120. */
  22121. static CreateIcoSphere(options: {
  22122. radius?: number;
  22123. radiusX?: number;
  22124. radiusY?: number;
  22125. radiusZ?: number;
  22126. flat?: boolean;
  22127. subdivisions?: number;
  22128. sideOrientation?: number;
  22129. frontUVs?: Vector4;
  22130. backUVs?: Vector4;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a Polyhedron
  22134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22135. * * type provided types are:
  22136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22137. * * 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)
  22138. * * size the size of the IcoSphere, optional default 1
  22139. * * sizeX allows stretching in the x direction, optional, default size
  22140. * * sizeY allows stretching in the y direction, optional, default size
  22141. * * sizeZ allows stretching in the z direction, optional, default size
  22142. * * 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
  22143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22145. * * flat when true creates a flat shaded mesh, optional, default true
  22146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22148. * * 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)
  22149. * * 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)
  22150. * @returns the VertexData of the Polyhedron
  22151. */
  22152. static CreatePolyhedron(options: {
  22153. type?: number;
  22154. size?: number;
  22155. sizeX?: number;
  22156. sizeY?: number;
  22157. sizeZ?: number;
  22158. custom?: any;
  22159. faceUV?: Vector4[];
  22160. faceColors?: Color4[];
  22161. flat?: boolean;
  22162. sideOrientation?: number;
  22163. frontUVs?: Vector4;
  22164. backUVs?: Vector4;
  22165. }): VertexData;
  22166. /**
  22167. * Creates the VertexData for a TorusKnot
  22168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22169. * * radius the radius of the torus knot, optional, default 2
  22170. * * tube the thickness of the tube, optional, default 0.5
  22171. * * radialSegments the number of sides on each tube segments, optional, default 32
  22172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22173. * * p the number of windings around the z axis, optional, default 2
  22174. * * q the number of windings around the x axis, optional, default 3
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * 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)
  22177. * * 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)
  22178. * @returns the VertexData of the Torus Knot
  22179. */
  22180. static CreateTorusKnot(options: {
  22181. radius?: number;
  22182. tube?: number;
  22183. radialSegments?: number;
  22184. tubularSegments?: number;
  22185. p?: number;
  22186. q?: number;
  22187. sideOrientation?: number;
  22188. frontUVs?: Vector4;
  22189. backUVs?: Vector4;
  22190. }): VertexData;
  22191. /**
  22192. * Compute normals for given positions and indices
  22193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22197. * * facetNormals : optional array of facet normals (vector3)
  22198. * * facetPositions : optional array of facet positions (vector3)
  22199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22201. * * bInfo : optional bounding info, required for facetPartitioning computation
  22202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22204. * * useRightHandedSystem: optional boolean to for right handed system computation
  22205. * * depthSort : optional boolean to enable the facet depth sort computation
  22206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22208. */
  22209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22210. facetNormals?: any;
  22211. facetPositions?: any;
  22212. facetPartitioning?: any;
  22213. ratio?: number;
  22214. bInfo?: any;
  22215. bbSize?: Vector3;
  22216. subDiv?: any;
  22217. useRightHandedSystem?: boolean;
  22218. depthSort?: boolean;
  22219. distanceTo?: Vector3;
  22220. depthSortedFacets?: any;
  22221. }): void;
  22222. /** @hidden */
  22223. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22224. /**
  22225. * Applies VertexData created from the imported parameters to the geometry
  22226. * @param parsedVertexData the parsed data from an imported file
  22227. * @param geometry the geometry to apply the VertexData to
  22228. */
  22229. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22230. }
  22231. }
  22232. declare module BABYLON {
  22233. /**
  22234. * Defines a target to use with MorphTargetManager
  22235. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22236. */
  22237. export class MorphTarget implements IAnimatable {
  22238. /** defines the name of the target */
  22239. name: string;
  22240. /**
  22241. * Gets or sets the list of animations
  22242. */
  22243. animations: Animation[];
  22244. private _scene;
  22245. private _positions;
  22246. private _normals;
  22247. private _tangents;
  22248. private _uvs;
  22249. private _influence;
  22250. private _uniqueId;
  22251. /**
  22252. * Observable raised when the influence changes
  22253. */
  22254. onInfluenceChanged: Observable<boolean>;
  22255. /** @hidden */
  22256. _onDataLayoutChanged: Observable<void>;
  22257. /**
  22258. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22259. */
  22260. influence: number;
  22261. /**
  22262. * Gets or sets the id of the morph Target
  22263. */
  22264. id: string;
  22265. private _animationPropertiesOverride;
  22266. /**
  22267. * Gets or sets the animation properties override
  22268. */
  22269. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22270. /**
  22271. * Creates a new MorphTarget
  22272. * @param name defines the name of the target
  22273. * @param influence defines the influence to use
  22274. * @param scene defines the scene the morphtarget belongs to
  22275. */
  22276. constructor(
  22277. /** defines the name of the target */
  22278. name: string, influence?: number, scene?: Nullable<Scene>);
  22279. /**
  22280. * Gets the unique ID of this manager
  22281. */
  22282. readonly uniqueId: number;
  22283. /**
  22284. * Gets a boolean defining if the target contains position data
  22285. */
  22286. readonly hasPositions: boolean;
  22287. /**
  22288. * Gets a boolean defining if the target contains normal data
  22289. */
  22290. readonly hasNormals: boolean;
  22291. /**
  22292. * Gets a boolean defining if the target contains tangent data
  22293. */
  22294. readonly hasTangents: boolean;
  22295. /**
  22296. * Gets a boolean defining if the target contains texture coordinates data
  22297. */
  22298. readonly hasUVs: boolean;
  22299. /**
  22300. * Affects position data to this target
  22301. * @param data defines the position data to use
  22302. */
  22303. setPositions(data: Nullable<FloatArray>): void;
  22304. /**
  22305. * Gets the position data stored in this target
  22306. * @returns a FloatArray containing the position data (or null if not present)
  22307. */
  22308. getPositions(): Nullable<FloatArray>;
  22309. /**
  22310. * Affects normal data to this target
  22311. * @param data defines the normal data to use
  22312. */
  22313. setNormals(data: Nullable<FloatArray>): void;
  22314. /**
  22315. * Gets the normal data stored in this target
  22316. * @returns a FloatArray containing the normal data (or null if not present)
  22317. */
  22318. getNormals(): Nullable<FloatArray>;
  22319. /**
  22320. * Affects tangent data to this target
  22321. * @param data defines the tangent data to use
  22322. */
  22323. setTangents(data: Nullable<FloatArray>): void;
  22324. /**
  22325. * Gets the tangent data stored in this target
  22326. * @returns a FloatArray containing the tangent data (or null if not present)
  22327. */
  22328. getTangents(): Nullable<FloatArray>;
  22329. /**
  22330. * Affects texture coordinates data to this target
  22331. * @param data defines the texture coordinates data to use
  22332. */
  22333. setUVs(data: Nullable<FloatArray>): void;
  22334. /**
  22335. * Gets the texture coordinates data stored in this target
  22336. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22337. */
  22338. getUVs(): Nullable<FloatArray>;
  22339. /**
  22340. * Clone the current target
  22341. * @returns a new MorphTarget
  22342. */
  22343. clone(): MorphTarget;
  22344. /**
  22345. * Serializes the current target into a Serialization object
  22346. * @returns the serialized object
  22347. */
  22348. serialize(): any;
  22349. /**
  22350. * Returns the string "MorphTarget"
  22351. * @returns "MorphTarget"
  22352. */
  22353. getClassName(): string;
  22354. /**
  22355. * Creates a new target from serialized data
  22356. * @param serializationObject defines the serialized data to use
  22357. * @returns a new MorphTarget
  22358. */
  22359. static Parse(serializationObject: any): MorphTarget;
  22360. /**
  22361. * Creates a MorphTarget from mesh data
  22362. * @param mesh defines the source mesh
  22363. * @param name defines the name to use for the new target
  22364. * @param influence defines the influence to attach to the target
  22365. * @returns a new MorphTarget
  22366. */
  22367. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22368. }
  22369. }
  22370. declare module BABYLON {
  22371. /**
  22372. * This class is used to deform meshes using morphing between different targets
  22373. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22374. */
  22375. export class MorphTargetManager {
  22376. private _targets;
  22377. private _targetInfluenceChangedObservers;
  22378. private _targetDataLayoutChangedObservers;
  22379. private _activeTargets;
  22380. private _scene;
  22381. private _influences;
  22382. private _supportsNormals;
  22383. private _supportsTangents;
  22384. private _supportsUVs;
  22385. private _vertexCount;
  22386. private _uniqueId;
  22387. private _tempInfluences;
  22388. /**
  22389. * Gets or sets a boolean indicating if normals must be morphed
  22390. */
  22391. enableNormalMorphing: boolean;
  22392. /**
  22393. * Gets or sets a boolean indicating if tangents must be morphed
  22394. */
  22395. enableTangentMorphing: boolean;
  22396. /**
  22397. * Gets or sets a boolean indicating if UV must be morphed
  22398. */
  22399. enableUVMorphing: boolean;
  22400. /**
  22401. * Creates a new MorphTargetManager
  22402. * @param scene defines the current scene
  22403. */
  22404. constructor(scene?: Nullable<Scene>);
  22405. /**
  22406. * Gets the unique ID of this manager
  22407. */
  22408. readonly uniqueId: number;
  22409. /**
  22410. * Gets the number of vertices handled by this manager
  22411. */
  22412. readonly vertexCount: number;
  22413. /**
  22414. * Gets a boolean indicating if this manager supports morphing of normals
  22415. */
  22416. readonly supportsNormals: boolean;
  22417. /**
  22418. * Gets a boolean indicating if this manager supports morphing of tangents
  22419. */
  22420. readonly supportsTangents: boolean;
  22421. /**
  22422. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22423. */
  22424. readonly supportsUVs: boolean;
  22425. /**
  22426. * Gets the number of targets stored in this manager
  22427. */
  22428. readonly numTargets: number;
  22429. /**
  22430. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22431. */
  22432. readonly numInfluencers: number;
  22433. /**
  22434. * Gets the list of influences (one per target)
  22435. */
  22436. readonly influences: Float32Array;
  22437. /**
  22438. * Gets the active target at specified index. An active target is a target with an influence > 0
  22439. * @param index defines the index to check
  22440. * @returns the requested target
  22441. */
  22442. getActiveTarget(index: number): MorphTarget;
  22443. /**
  22444. * Gets the target at specified index
  22445. * @param index defines the index to check
  22446. * @returns the requested target
  22447. */
  22448. getTarget(index: number): MorphTarget;
  22449. /**
  22450. * Add a new target to this manager
  22451. * @param target defines the target to add
  22452. */
  22453. addTarget(target: MorphTarget): void;
  22454. /**
  22455. * Removes a target from the manager
  22456. * @param target defines the target to remove
  22457. */
  22458. removeTarget(target: MorphTarget): void;
  22459. /**
  22460. * Clone the current manager
  22461. * @returns a new MorphTargetManager
  22462. */
  22463. clone(): MorphTargetManager;
  22464. /**
  22465. * Serializes the current manager into a Serialization object
  22466. * @returns the serialized object
  22467. */
  22468. serialize(): any;
  22469. private _syncActiveTargets;
  22470. /**
  22471. * Syncrhonize the targets with all the meshes using this morph target manager
  22472. */
  22473. synchronize(): void;
  22474. /**
  22475. * Creates a new MorphTargetManager from serialized data
  22476. * @param serializationObject defines the serialized data
  22477. * @param scene defines the hosting scene
  22478. * @returns the new MorphTargetManager
  22479. */
  22480. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22481. }
  22482. }
  22483. declare module BABYLON {
  22484. /**
  22485. * Class used to represent a specific level of detail of a mesh
  22486. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22487. */
  22488. export class MeshLODLevel {
  22489. /** Defines the distance where this level should start being displayed */
  22490. distance: number;
  22491. /** Defines the mesh to use to render this level */
  22492. mesh: Nullable<Mesh>;
  22493. /**
  22494. * Creates a new LOD level
  22495. * @param distance defines the distance where this level should star being displayed
  22496. * @param mesh defines the mesh to use to render this level
  22497. */
  22498. constructor(
  22499. /** Defines the distance where this level should start being displayed */
  22500. distance: number,
  22501. /** Defines the mesh to use to render this level */
  22502. mesh: Nullable<Mesh>);
  22503. }
  22504. }
  22505. declare module BABYLON {
  22506. /**
  22507. * Mesh representing the gorund
  22508. */
  22509. export class GroundMesh extends Mesh {
  22510. /** If octree should be generated */
  22511. generateOctree: boolean;
  22512. private _heightQuads;
  22513. /** @hidden */
  22514. _subdivisionsX: number;
  22515. /** @hidden */
  22516. _subdivisionsY: number;
  22517. /** @hidden */
  22518. _width: number;
  22519. /** @hidden */
  22520. _height: number;
  22521. /** @hidden */
  22522. _minX: number;
  22523. /** @hidden */
  22524. _maxX: number;
  22525. /** @hidden */
  22526. _minZ: number;
  22527. /** @hidden */
  22528. _maxZ: number;
  22529. constructor(name: string, scene: Scene);
  22530. /**
  22531. * "GroundMesh"
  22532. * @returns "GroundMesh"
  22533. */
  22534. getClassName(): string;
  22535. /**
  22536. * The minimum of x and y subdivisions
  22537. */
  22538. readonly subdivisions: number;
  22539. /**
  22540. * X subdivisions
  22541. */
  22542. readonly subdivisionsX: number;
  22543. /**
  22544. * Y subdivisions
  22545. */
  22546. readonly subdivisionsY: number;
  22547. /**
  22548. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22549. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22550. * @param chunksCount the number of subdivisions for x and y
  22551. * @param octreeBlocksSize (Default: 32)
  22552. */
  22553. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22554. /**
  22555. * Returns a height (y) value in the Worl system :
  22556. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22557. * @param x x coordinate
  22558. * @param z z coordinate
  22559. * @returns the ground y position if (x, z) are outside the ground surface.
  22560. */
  22561. getHeightAtCoordinates(x: number, z: number): number;
  22562. /**
  22563. * Returns a normalized vector (Vector3) orthogonal to the ground
  22564. * at the ground coordinates (x, z) expressed in the World system.
  22565. * @param x x coordinate
  22566. * @param z z coordinate
  22567. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22568. */
  22569. getNormalAtCoordinates(x: number, z: number): Vector3;
  22570. /**
  22571. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22572. * at the ground coordinates (x, z) expressed in the World system.
  22573. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22574. * @param x x coordinate
  22575. * @param z z coordinate
  22576. * @param ref vector to store the result
  22577. * @returns the GroundMesh.
  22578. */
  22579. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22580. /**
  22581. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22582. * if the ground has been updated.
  22583. * This can be used in the render loop.
  22584. * @returns the GroundMesh.
  22585. */
  22586. updateCoordinateHeights(): GroundMesh;
  22587. private _getFacetAt;
  22588. private _initHeightQuads;
  22589. private _computeHeightQuads;
  22590. /**
  22591. * Serializes this ground mesh
  22592. * @param serializationObject object to write serialization to
  22593. */
  22594. serialize(serializationObject: any): void;
  22595. /**
  22596. * Parses a serialized ground mesh
  22597. * @param parsedMesh the serialized mesh
  22598. * @param scene the scene to create the ground mesh in
  22599. * @returns the created ground mesh
  22600. */
  22601. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22602. }
  22603. }
  22604. declare module BABYLON {
  22605. /**
  22606. * Interface for Physics-Joint data
  22607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22608. */
  22609. export interface PhysicsJointData {
  22610. /**
  22611. * The main pivot of the joint
  22612. */
  22613. mainPivot?: Vector3;
  22614. /**
  22615. * The connected pivot of the joint
  22616. */
  22617. connectedPivot?: Vector3;
  22618. /**
  22619. * The main axis of the joint
  22620. */
  22621. mainAxis?: Vector3;
  22622. /**
  22623. * The connected axis of the joint
  22624. */
  22625. connectedAxis?: Vector3;
  22626. /**
  22627. * The collision of the joint
  22628. */
  22629. collision?: boolean;
  22630. /**
  22631. * Native Oimo/Cannon/Energy data
  22632. */
  22633. nativeParams?: any;
  22634. }
  22635. /**
  22636. * This is a holder class for the physics joint created by the physics plugin
  22637. * It holds a set of functions to control the underlying joint
  22638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22639. */
  22640. export class PhysicsJoint {
  22641. /**
  22642. * The type of the physics joint
  22643. */
  22644. type: number;
  22645. /**
  22646. * The data for the physics joint
  22647. */
  22648. jointData: PhysicsJointData;
  22649. private _physicsJoint;
  22650. protected _physicsPlugin: IPhysicsEnginePlugin;
  22651. /**
  22652. * Initializes the physics joint
  22653. * @param type The type of the physics joint
  22654. * @param jointData The data for the physics joint
  22655. */
  22656. constructor(
  22657. /**
  22658. * The type of the physics joint
  22659. */
  22660. type: number,
  22661. /**
  22662. * The data for the physics joint
  22663. */
  22664. jointData: PhysicsJointData);
  22665. /**
  22666. * Gets the physics joint
  22667. */
  22668. /**
  22669. * Sets the physics joint
  22670. */
  22671. physicsJoint: any;
  22672. /**
  22673. * Sets the physics plugin
  22674. */
  22675. physicsPlugin: IPhysicsEnginePlugin;
  22676. /**
  22677. * Execute a function that is physics-plugin specific.
  22678. * @param {Function} func the function that will be executed.
  22679. * It accepts two parameters: the physics world and the physics joint
  22680. */
  22681. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22682. /**
  22683. * Distance-Joint type
  22684. */
  22685. static DistanceJoint: number;
  22686. /**
  22687. * Hinge-Joint type
  22688. */
  22689. static HingeJoint: number;
  22690. /**
  22691. * Ball-and-Socket joint type
  22692. */
  22693. static BallAndSocketJoint: number;
  22694. /**
  22695. * Wheel-Joint type
  22696. */
  22697. static WheelJoint: number;
  22698. /**
  22699. * Slider-Joint type
  22700. */
  22701. static SliderJoint: number;
  22702. /**
  22703. * Prismatic-Joint type
  22704. */
  22705. static PrismaticJoint: number;
  22706. /**
  22707. * Universal-Joint type
  22708. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22709. */
  22710. static UniversalJoint: number;
  22711. /**
  22712. * Hinge-Joint 2 type
  22713. */
  22714. static Hinge2Joint: number;
  22715. /**
  22716. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22717. */
  22718. static PointToPointJoint: number;
  22719. /**
  22720. * Spring-Joint type
  22721. */
  22722. static SpringJoint: number;
  22723. /**
  22724. * Lock-Joint type
  22725. */
  22726. static LockJoint: number;
  22727. }
  22728. /**
  22729. * A class representing a physics distance joint
  22730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22731. */
  22732. export class DistanceJoint extends PhysicsJoint {
  22733. /**
  22734. *
  22735. * @param jointData The data for the Distance-Joint
  22736. */
  22737. constructor(jointData: DistanceJointData);
  22738. /**
  22739. * Update the predefined distance.
  22740. * @param maxDistance The maximum preferred distance
  22741. * @param minDistance The minimum preferred distance
  22742. */
  22743. updateDistance(maxDistance: number, minDistance?: number): void;
  22744. }
  22745. /**
  22746. * Represents a Motor-Enabled Joint
  22747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22748. */
  22749. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22750. /**
  22751. * Initializes the Motor-Enabled Joint
  22752. * @param type The type of the joint
  22753. * @param jointData The physica joint data for the joint
  22754. */
  22755. constructor(type: number, jointData: PhysicsJointData);
  22756. /**
  22757. * Set the motor values.
  22758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22759. * @param force the force to apply
  22760. * @param maxForce max force for this motor.
  22761. */
  22762. setMotor(force?: number, maxForce?: number): void;
  22763. /**
  22764. * Set the motor's limits.
  22765. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22766. * @param upperLimit The upper limit of the motor
  22767. * @param lowerLimit The lower limit of the motor
  22768. */
  22769. setLimit(upperLimit: number, lowerLimit?: number): void;
  22770. }
  22771. /**
  22772. * This class represents a single physics Hinge-Joint
  22773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22774. */
  22775. export class HingeJoint extends MotorEnabledJoint {
  22776. /**
  22777. * Initializes the Hinge-Joint
  22778. * @param jointData The joint data for the Hinge-Joint
  22779. */
  22780. constructor(jointData: PhysicsJointData);
  22781. /**
  22782. * Set the motor values.
  22783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22784. * @param {number} force the force to apply
  22785. * @param {number} maxForce max force for this motor.
  22786. */
  22787. setMotor(force?: number, maxForce?: number): void;
  22788. /**
  22789. * Set the motor's limits.
  22790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22791. * @param upperLimit The upper limit of the motor
  22792. * @param lowerLimit The lower limit of the motor
  22793. */
  22794. setLimit(upperLimit: number, lowerLimit?: number): void;
  22795. }
  22796. /**
  22797. * This class represents a dual hinge physics joint (same as wheel joint)
  22798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22799. */
  22800. export class Hinge2Joint extends MotorEnabledJoint {
  22801. /**
  22802. * Initializes the Hinge2-Joint
  22803. * @param jointData The joint data for the Hinge2-Joint
  22804. */
  22805. constructor(jointData: PhysicsJointData);
  22806. /**
  22807. * Set the motor values.
  22808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22809. * @param {number} targetSpeed the speed the motor is to reach
  22810. * @param {number} maxForce max force for this motor.
  22811. * @param {motorIndex} the motor's index, 0 or 1.
  22812. */
  22813. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22814. /**
  22815. * Set the motor limits.
  22816. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22817. * @param {number} upperLimit the upper limit
  22818. * @param {number} lowerLimit lower limit
  22819. * @param {motorIndex} the motor's index, 0 or 1.
  22820. */
  22821. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22822. }
  22823. /**
  22824. * Interface for a motor enabled joint
  22825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22826. */
  22827. export interface IMotorEnabledJoint {
  22828. /**
  22829. * Physics joint
  22830. */
  22831. physicsJoint: any;
  22832. /**
  22833. * Sets the motor of the motor-enabled joint
  22834. * @param force The force of the motor
  22835. * @param maxForce The maximum force of the motor
  22836. * @param motorIndex The index of the motor
  22837. */
  22838. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22839. /**
  22840. * Sets the limit of the motor
  22841. * @param upperLimit The upper limit of the motor
  22842. * @param lowerLimit The lower limit of the motor
  22843. * @param motorIndex The index of the motor
  22844. */
  22845. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22846. }
  22847. /**
  22848. * Joint data for a Distance-Joint
  22849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22850. */
  22851. export interface DistanceJointData extends PhysicsJointData {
  22852. /**
  22853. * Max distance the 2 joint objects can be apart
  22854. */
  22855. maxDistance: number;
  22856. }
  22857. /**
  22858. * Joint data from a spring joint
  22859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22860. */
  22861. export interface SpringJointData extends PhysicsJointData {
  22862. /**
  22863. * Length of the spring
  22864. */
  22865. length: number;
  22866. /**
  22867. * Stiffness of the spring
  22868. */
  22869. stiffness: number;
  22870. /**
  22871. * Damping of the spring
  22872. */
  22873. damping: number;
  22874. /** this callback will be called when applying the force to the impostors. */
  22875. forceApplicationCallback: () => void;
  22876. }
  22877. }
  22878. declare module BABYLON {
  22879. /**
  22880. * Holds the data for the raycast result
  22881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22882. */
  22883. export class PhysicsRaycastResult {
  22884. private _hasHit;
  22885. private _hitDistance;
  22886. private _hitNormalWorld;
  22887. private _hitPointWorld;
  22888. private _rayFromWorld;
  22889. private _rayToWorld;
  22890. /**
  22891. * Gets if there was a hit
  22892. */
  22893. readonly hasHit: boolean;
  22894. /**
  22895. * Gets the distance from the hit
  22896. */
  22897. readonly hitDistance: number;
  22898. /**
  22899. * Gets the hit normal/direction in the world
  22900. */
  22901. readonly hitNormalWorld: Vector3;
  22902. /**
  22903. * Gets the hit point in the world
  22904. */
  22905. readonly hitPointWorld: Vector3;
  22906. /**
  22907. * Gets the ray "start point" of the ray in the world
  22908. */
  22909. readonly rayFromWorld: Vector3;
  22910. /**
  22911. * Gets the ray "end point" of the ray in the world
  22912. */
  22913. readonly rayToWorld: Vector3;
  22914. /**
  22915. * Sets the hit data (normal & point in world space)
  22916. * @param hitNormalWorld defines the normal in world space
  22917. * @param hitPointWorld defines the point in world space
  22918. */
  22919. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22920. /**
  22921. * Sets the distance from the start point to the hit point
  22922. * @param distance
  22923. */
  22924. setHitDistance(distance: number): void;
  22925. /**
  22926. * Calculates the distance manually
  22927. */
  22928. calculateHitDistance(): void;
  22929. /**
  22930. * Resets all the values to default
  22931. * @param from The from point on world space
  22932. * @param to The to point on world space
  22933. */
  22934. reset(from?: Vector3, to?: Vector3): void;
  22935. }
  22936. /**
  22937. * Interface for the size containing width and height
  22938. */
  22939. interface IXYZ {
  22940. /**
  22941. * X
  22942. */
  22943. x: number;
  22944. /**
  22945. * Y
  22946. */
  22947. y: number;
  22948. /**
  22949. * Z
  22950. */
  22951. z: number;
  22952. }
  22953. }
  22954. declare module BABYLON {
  22955. /**
  22956. * Interface used to describe a physics joint
  22957. */
  22958. export interface PhysicsImpostorJoint {
  22959. /** Defines the main impostor to which the joint is linked */
  22960. mainImpostor: PhysicsImpostor;
  22961. /** Defines the impostor that is connected to the main impostor using this joint */
  22962. connectedImpostor: PhysicsImpostor;
  22963. /** Defines the joint itself */
  22964. joint: PhysicsJoint;
  22965. }
  22966. /** @hidden */
  22967. export interface IPhysicsEnginePlugin {
  22968. world: any;
  22969. name: string;
  22970. setGravity(gravity: Vector3): void;
  22971. setTimeStep(timeStep: number): void;
  22972. getTimeStep(): number;
  22973. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22974. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22975. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22976. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22977. removePhysicsBody(impostor: PhysicsImpostor): void;
  22978. generateJoint(joint: PhysicsImpostorJoint): void;
  22979. removeJoint(joint: PhysicsImpostorJoint): void;
  22980. isSupported(): boolean;
  22981. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22982. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22983. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22985. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22986. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22987. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22988. getBodyMass(impostor: PhysicsImpostor): number;
  22989. getBodyFriction(impostor: PhysicsImpostor): number;
  22990. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22991. getBodyRestitution(impostor: PhysicsImpostor): number;
  22992. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22993. getBodyPressure?(impostor: PhysicsImpostor): number;
  22994. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22995. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22996. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22997. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22998. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22999. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23000. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23001. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23002. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23003. sleepBody(impostor: PhysicsImpostor): void;
  23004. wakeUpBody(impostor: PhysicsImpostor): void;
  23005. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23007. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23008. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23009. getRadius(impostor: PhysicsImpostor): number;
  23010. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23011. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23012. dispose(): void;
  23013. }
  23014. /**
  23015. * Interface used to define a physics engine
  23016. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23017. */
  23018. export interface IPhysicsEngine {
  23019. /**
  23020. * Gets the gravity vector used by the simulation
  23021. */
  23022. gravity: Vector3;
  23023. /**
  23024. * Sets the gravity vector used by the simulation
  23025. * @param gravity defines the gravity vector to use
  23026. */
  23027. setGravity(gravity: Vector3): void;
  23028. /**
  23029. * Set the time step of the physics engine.
  23030. * Default is 1/60.
  23031. * To slow it down, enter 1/600 for example.
  23032. * To speed it up, 1/30
  23033. * @param newTimeStep the new timestep to apply to this world.
  23034. */
  23035. setTimeStep(newTimeStep: number): void;
  23036. /**
  23037. * Get the time step of the physics engine.
  23038. * @returns the current time step
  23039. */
  23040. getTimeStep(): number;
  23041. /**
  23042. * Release all resources
  23043. */
  23044. dispose(): void;
  23045. /**
  23046. * Gets the name of the current physics plugin
  23047. * @returns the name of the plugin
  23048. */
  23049. getPhysicsPluginName(): string;
  23050. /**
  23051. * Adding a new impostor for the impostor tracking.
  23052. * This will be done by the impostor itself.
  23053. * @param impostor the impostor to add
  23054. */
  23055. addImpostor(impostor: PhysicsImpostor): void;
  23056. /**
  23057. * Remove an impostor from the engine.
  23058. * This impostor and its mesh will not longer be updated by the physics engine.
  23059. * @param impostor the impostor to remove
  23060. */
  23061. removeImpostor(impostor: PhysicsImpostor): void;
  23062. /**
  23063. * Add a joint to the physics engine
  23064. * @param mainImpostor defines the main impostor to which the joint is added.
  23065. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23066. * @param joint defines the joint that will connect both impostors.
  23067. */
  23068. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23069. /**
  23070. * Removes a joint from the simulation
  23071. * @param mainImpostor defines the impostor used with the joint
  23072. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23073. * @param joint defines the joint to remove
  23074. */
  23075. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23076. /**
  23077. * Gets the current plugin used to run the simulation
  23078. * @returns current plugin
  23079. */
  23080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23081. /**
  23082. * Gets the list of physic impostors
  23083. * @returns an array of PhysicsImpostor
  23084. */
  23085. getImpostors(): Array<PhysicsImpostor>;
  23086. /**
  23087. * Gets the impostor for a physics enabled object
  23088. * @param object defines the object impersonated by the impostor
  23089. * @returns the PhysicsImpostor or null if not found
  23090. */
  23091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23092. /**
  23093. * Gets the impostor for a physics body object
  23094. * @param body defines physics body used by the impostor
  23095. * @returns the PhysicsImpostor or null if not found
  23096. */
  23097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23098. /**
  23099. * Does a raycast in the physics world
  23100. * @param from when should the ray start?
  23101. * @param to when should the ray end?
  23102. * @returns PhysicsRaycastResult
  23103. */
  23104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23105. /**
  23106. * Called by the scene. No need to call it.
  23107. * @param delta defines the timespam between frames
  23108. */
  23109. _step(delta: number): void;
  23110. }
  23111. }
  23112. declare module BABYLON {
  23113. /**
  23114. * The interface for the physics imposter parameters
  23115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23116. */
  23117. export interface PhysicsImpostorParameters {
  23118. /**
  23119. * The mass of the physics imposter
  23120. */
  23121. mass: number;
  23122. /**
  23123. * The friction of the physics imposter
  23124. */
  23125. friction?: number;
  23126. /**
  23127. * The coefficient of restitution of the physics imposter
  23128. */
  23129. restitution?: number;
  23130. /**
  23131. * The native options of the physics imposter
  23132. */
  23133. nativeOptions?: any;
  23134. /**
  23135. * Specifies if the parent should be ignored
  23136. */
  23137. ignoreParent?: boolean;
  23138. /**
  23139. * Specifies if bi-directional transformations should be disabled
  23140. */
  23141. disableBidirectionalTransformation?: boolean;
  23142. /**
  23143. * The pressure inside the physics imposter, soft object only
  23144. */
  23145. pressure?: number;
  23146. /**
  23147. * The stiffness the physics imposter, soft object only
  23148. */
  23149. stiffness?: number;
  23150. /**
  23151. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23152. */
  23153. velocityIterations?: number;
  23154. /**
  23155. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23156. */
  23157. positionIterations?: number;
  23158. /**
  23159. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23160. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23161. * Add to fix multiple points
  23162. */
  23163. fixedPoints?: number;
  23164. /**
  23165. * The collision margin around a soft object
  23166. */
  23167. margin?: number;
  23168. /**
  23169. * The collision margin around a soft object
  23170. */
  23171. damping?: number;
  23172. /**
  23173. * The path for a rope based on an extrusion
  23174. */
  23175. path?: any;
  23176. /**
  23177. * The shape of an extrusion used for a rope based on an extrusion
  23178. */
  23179. shape?: any;
  23180. }
  23181. /**
  23182. * Interface for a physics-enabled object
  23183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23184. */
  23185. export interface IPhysicsEnabledObject {
  23186. /**
  23187. * The position of the physics-enabled object
  23188. */
  23189. position: Vector3;
  23190. /**
  23191. * The rotation of the physics-enabled object
  23192. */
  23193. rotationQuaternion: Nullable<Quaternion>;
  23194. /**
  23195. * The scale of the physics-enabled object
  23196. */
  23197. scaling: Vector3;
  23198. /**
  23199. * The rotation of the physics-enabled object
  23200. */
  23201. rotation?: Vector3;
  23202. /**
  23203. * The parent of the physics-enabled object
  23204. */
  23205. parent?: any;
  23206. /**
  23207. * The bounding info of the physics-enabled object
  23208. * @returns The bounding info of the physics-enabled object
  23209. */
  23210. getBoundingInfo(): BoundingInfo;
  23211. /**
  23212. * Computes the world matrix
  23213. * @param force Specifies if the world matrix should be computed by force
  23214. * @returns A world matrix
  23215. */
  23216. computeWorldMatrix(force: boolean): Matrix;
  23217. /**
  23218. * Gets the world matrix
  23219. * @returns A world matrix
  23220. */
  23221. getWorldMatrix?(): Matrix;
  23222. /**
  23223. * Gets the child meshes
  23224. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23225. * @returns An array of abstract meshes
  23226. */
  23227. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23228. /**
  23229. * Gets the vertex data
  23230. * @param kind The type of vertex data
  23231. * @returns A nullable array of numbers, or a float32 array
  23232. */
  23233. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23234. /**
  23235. * Gets the indices from the mesh
  23236. * @returns A nullable array of index arrays
  23237. */
  23238. getIndices?(): Nullable<IndicesArray>;
  23239. /**
  23240. * Gets the scene from the mesh
  23241. * @returns the indices array or null
  23242. */
  23243. getScene?(): Scene;
  23244. /**
  23245. * Gets the absolute position from the mesh
  23246. * @returns the absolute position
  23247. */
  23248. getAbsolutePosition(): Vector3;
  23249. /**
  23250. * Gets the absolute pivot point from the mesh
  23251. * @returns the absolute pivot point
  23252. */
  23253. getAbsolutePivotPoint(): Vector3;
  23254. /**
  23255. * Rotates the mesh
  23256. * @param axis The axis of rotation
  23257. * @param amount The amount of rotation
  23258. * @param space The space of the rotation
  23259. * @returns The rotation transform node
  23260. */
  23261. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23262. /**
  23263. * Translates the mesh
  23264. * @param axis The axis of translation
  23265. * @param distance The distance of translation
  23266. * @param space The space of the translation
  23267. * @returns The transform node
  23268. */
  23269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23270. /**
  23271. * Sets the absolute position of the mesh
  23272. * @param absolutePosition The absolute position of the mesh
  23273. * @returns The transform node
  23274. */
  23275. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23276. /**
  23277. * Gets the class name of the mesh
  23278. * @returns The class name
  23279. */
  23280. getClassName(): string;
  23281. }
  23282. /**
  23283. * Represents a physics imposter
  23284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23285. */
  23286. export class PhysicsImpostor {
  23287. /**
  23288. * The physics-enabled object used as the physics imposter
  23289. */
  23290. object: IPhysicsEnabledObject;
  23291. /**
  23292. * The type of the physics imposter
  23293. */
  23294. type: number;
  23295. private _options;
  23296. private _scene?;
  23297. /**
  23298. * The default object size of the imposter
  23299. */
  23300. static DEFAULT_OBJECT_SIZE: Vector3;
  23301. /**
  23302. * The identity quaternion of the imposter
  23303. */
  23304. static IDENTITY_QUATERNION: Quaternion;
  23305. /** @hidden */
  23306. _pluginData: any;
  23307. private _physicsEngine;
  23308. private _physicsBody;
  23309. private _bodyUpdateRequired;
  23310. private _onBeforePhysicsStepCallbacks;
  23311. private _onAfterPhysicsStepCallbacks;
  23312. /** @hidden */
  23313. _onPhysicsCollideCallbacks: Array<{
  23314. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23315. otherImpostors: Array<PhysicsImpostor>;
  23316. }>;
  23317. private _deltaPosition;
  23318. private _deltaRotation;
  23319. private _deltaRotationConjugated;
  23320. /** @hidden */
  23321. _isFromLine: boolean;
  23322. private _parent;
  23323. private _isDisposed;
  23324. private static _tmpVecs;
  23325. private static _tmpQuat;
  23326. /**
  23327. * Specifies if the physics imposter is disposed
  23328. */
  23329. readonly isDisposed: boolean;
  23330. /**
  23331. * Gets the mass of the physics imposter
  23332. */
  23333. mass: number;
  23334. /**
  23335. * Gets the coefficient of friction
  23336. */
  23337. /**
  23338. * Sets the coefficient of friction
  23339. */
  23340. friction: number;
  23341. /**
  23342. * Gets the coefficient of restitution
  23343. */
  23344. /**
  23345. * Sets the coefficient of restitution
  23346. */
  23347. restitution: number;
  23348. /**
  23349. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23350. */
  23351. /**
  23352. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23353. */
  23354. pressure: number;
  23355. /**
  23356. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23357. */
  23358. /**
  23359. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23360. */
  23361. stiffness: number;
  23362. /**
  23363. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23364. */
  23365. /**
  23366. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23367. */
  23368. velocityIterations: number;
  23369. /**
  23370. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23371. */
  23372. /**
  23373. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23374. */
  23375. positionIterations: number;
  23376. /**
  23377. * The unique id of the physics imposter
  23378. * set by the physics engine when adding this impostor to the array
  23379. */
  23380. uniqueId: number;
  23381. /**
  23382. * @hidden
  23383. */
  23384. soft: boolean;
  23385. /**
  23386. * @hidden
  23387. */
  23388. segments: number;
  23389. private _joints;
  23390. /**
  23391. * Initializes the physics imposter
  23392. * @param object The physics-enabled object used as the physics imposter
  23393. * @param type The type of the physics imposter
  23394. * @param _options The options for the physics imposter
  23395. * @param _scene The Babylon scene
  23396. */
  23397. constructor(
  23398. /**
  23399. * The physics-enabled object used as the physics imposter
  23400. */
  23401. object: IPhysicsEnabledObject,
  23402. /**
  23403. * The type of the physics imposter
  23404. */
  23405. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23406. /**
  23407. * This function will completly initialize this impostor.
  23408. * It will create a new body - but only if this mesh has no parent.
  23409. * If it has, this impostor will not be used other than to define the impostor
  23410. * of the child mesh.
  23411. * @hidden
  23412. */
  23413. _init(): void;
  23414. private _getPhysicsParent;
  23415. /**
  23416. * Should a new body be generated.
  23417. * @returns boolean specifying if body initialization is required
  23418. */
  23419. isBodyInitRequired(): boolean;
  23420. /**
  23421. * Sets the updated scaling
  23422. * @param updated Specifies if the scaling is updated
  23423. */
  23424. setScalingUpdated(): void;
  23425. /**
  23426. * Force a regeneration of this or the parent's impostor's body.
  23427. * Use under cautious - This will remove all joints already implemented.
  23428. */
  23429. forceUpdate(): void;
  23430. /**
  23431. * Gets the body that holds this impostor. Either its own, or its parent.
  23432. */
  23433. /**
  23434. * Set the physics body. Used mainly by the physics engine/plugin
  23435. */
  23436. physicsBody: any;
  23437. /**
  23438. * Get the parent of the physics imposter
  23439. * @returns Physics imposter or null
  23440. */
  23441. /**
  23442. * Sets the parent of the physics imposter
  23443. */
  23444. parent: Nullable<PhysicsImpostor>;
  23445. /**
  23446. * Resets the update flags
  23447. */
  23448. resetUpdateFlags(): void;
  23449. /**
  23450. * Gets the object extend size
  23451. * @returns the object extend size
  23452. */
  23453. getObjectExtendSize(): Vector3;
  23454. /**
  23455. * Gets the object center
  23456. * @returns The object center
  23457. */
  23458. getObjectCenter(): Vector3;
  23459. /**
  23460. * Get a specific parametes from the options parameter
  23461. * @param paramName The object parameter name
  23462. * @returns The object parameter
  23463. */
  23464. getParam(paramName: string): any;
  23465. /**
  23466. * Sets a specific parameter in the options given to the physics plugin
  23467. * @param paramName The parameter name
  23468. * @param value The value of the parameter
  23469. */
  23470. setParam(paramName: string, value: number): void;
  23471. /**
  23472. * Specifically change the body's mass option. Won't recreate the physics body object
  23473. * @param mass The mass of the physics imposter
  23474. */
  23475. setMass(mass: number): void;
  23476. /**
  23477. * Gets the linear velocity
  23478. * @returns linear velocity or null
  23479. */
  23480. getLinearVelocity(): Nullable<Vector3>;
  23481. /**
  23482. * Sets the linear velocity
  23483. * @param velocity linear velocity or null
  23484. */
  23485. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23486. /**
  23487. * Gets the angular velocity
  23488. * @returns angular velocity or null
  23489. */
  23490. getAngularVelocity(): Nullable<Vector3>;
  23491. /**
  23492. * Sets the angular velocity
  23493. * @param velocity The velocity or null
  23494. */
  23495. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23496. /**
  23497. * Execute a function with the physics plugin native code
  23498. * Provide a function the will have two variables - the world object and the physics body object
  23499. * @param func The function to execute with the physics plugin native code
  23500. */
  23501. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23502. /**
  23503. * Register a function that will be executed before the physics world is stepping forward
  23504. * @param func The function to execute before the physics world is stepped forward
  23505. */
  23506. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23507. /**
  23508. * Unregister a function that will be executed before the physics world is stepping forward
  23509. * @param func The function to execute before the physics world is stepped forward
  23510. */
  23511. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23512. /**
  23513. * Register a function that will be executed after the physics step
  23514. * @param func The function to execute after physics step
  23515. */
  23516. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23517. /**
  23518. * Unregisters a function that will be executed after the physics step
  23519. * @param func The function to execute after physics step
  23520. */
  23521. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23522. /**
  23523. * register a function that will be executed when this impostor collides against a different body
  23524. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23525. * @param func Callback that is executed on collision
  23526. */
  23527. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23528. /**
  23529. * Unregisters the physics imposter on contact
  23530. * @param collideAgainst The physics object to collide against
  23531. * @param func Callback to execute on collision
  23532. */
  23533. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23534. private _tmpQuat;
  23535. private _tmpQuat2;
  23536. /**
  23537. * Get the parent rotation
  23538. * @returns The parent rotation
  23539. */
  23540. getParentsRotation(): Quaternion;
  23541. /**
  23542. * this function is executed by the physics engine.
  23543. */
  23544. beforeStep: () => void;
  23545. /**
  23546. * this function is executed by the physics engine
  23547. */
  23548. afterStep: () => void;
  23549. /**
  23550. * Legacy collision detection event support
  23551. */
  23552. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23553. /**
  23554. * event and body object due to cannon's event-based architecture.
  23555. */
  23556. onCollide: (e: {
  23557. body: any;
  23558. }) => void;
  23559. /**
  23560. * Apply a force
  23561. * @param force The force to apply
  23562. * @param contactPoint The contact point for the force
  23563. * @returns The physics imposter
  23564. */
  23565. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23566. /**
  23567. * Apply an impulse
  23568. * @param force The impulse force
  23569. * @param contactPoint The contact point for the impulse force
  23570. * @returns The physics imposter
  23571. */
  23572. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23573. /**
  23574. * A help function to create a joint
  23575. * @param otherImpostor A physics imposter used to create a joint
  23576. * @param jointType The type of joint
  23577. * @param jointData The data for the joint
  23578. * @returns The physics imposter
  23579. */
  23580. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23581. /**
  23582. * Add a joint to this impostor with a different impostor
  23583. * @param otherImpostor A physics imposter used to add a joint
  23584. * @param joint The joint to add
  23585. * @returns The physics imposter
  23586. */
  23587. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23588. /**
  23589. * Add an anchor to a cloth impostor
  23590. * @param otherImpostor rigid impostor to anchor to
  23591. * @param width ratio across width from 0 to 1
  23592. * @param height ratio up height from 0 to 1
  23593. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23594. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23595. * @returns impostor the soft imposter
  23596. */
  23597. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23598. /**
  23599. * Add a hook to a rope impostor
  23600. * @param otherImpostor rigid impostor to anchor to
  23601. * @param length ratio across rope from 0 to 1
  23602. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23603. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23604. * @returns impostor the rope imposter
  23605. */
  23606. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23607. /**
  23608. * Will keep this body still, in a sleep mode.
  23609. * @returns the physics imposter
  23610. */
  23611. sleep(): PhysicsImpostor;
  23612. /**
  23613. * Wake the body up.
  23614. * @returns The physics imposter
  23615. */
  23616. wakeUp(): PhysicsImpostor;
  23617. /**
  23618. * Clones the physics imposter
  23619. * @param newObject The physics imposter clones to this physics-enabled object
  23620. * @returns A nullable physics imposter
  23621. */
  23622. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23623. /**
  23624. * Disposes the physics imposter
  23625. */
  23626. dispose(): void;
  23627. /**
  23628. * Sets the delta position
  23629. * @param position The delta position amount
  23630. */
  23631. setDeltaPosition(position: Vector3): void;
  23632. /**
  23633. * Sets the delta rotation
  23634. * @param rotation The delta rotation amount
  23635. */
  23636. setDeltaRotation(rotation: Quaternion): void;
  23637. /**
  23638. * Gets the box size of the physics imposter and stores the result in the input parameter
  23639. * @param result Stores the box size
  23640. * @returns The physics imposter
  23641. */
  23642. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23643. /**
  23644. * Gets the radius of the physics imposter
  23645. * @returns Radius of the physics imposter
  23646. */
  23647. getRadius(): number;
  23648. /**
  23649. * Sync a bone with this impostor
  23650. * @param bone The bone to sync to the impostor.
  23651. * @param boneMesh The mesh that the bone is influencing.
  23652. * @param jointPivot The pivot of the joint / bone in local space.
  23653. * @param distToJoint Optional distance from the impostor to the joint.
  23654. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23655. */
  23656. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23657. /**
  23658. * Sync impostor to a bone
  23659. * @param bone The bone that the impostor will be synced to.
  23660. * @param boneMesh The mesh that the bone is influencing.
  23661. * @param jointPivot The pivot of the joint / bone in local space.
  23662. * @param distToJoint Optional distance from the impostor to the joint.
  23663. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23664. * @param boneAxis Optional vector3 axis the bone is aligned with
  23665. */
  23666. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23667. /**
  23668. * No-Imposter type
  23669. */
  23670. static NoImpostor: number;
  23671. /**
  23672. * Sphere-Imposter type
  23673. */
  23674. static SphereImpostor: number;
  23675. /**
  23676. * Box-Imposter type
  23677. */
  23678. static BoxImpostor: number;
  23679. /**
  23680. * Plane-Imposter type
  23681. */
  23682. static PlaneImpostor: number;
  23683. /**
  23684. * Mesh-imposter type
  23685. */
  23686. static MeshImpostor: number;
  23687. /**
  23688. * Capsule-Impostor type (Ammo.js plugin only)
  23689. */
  23690. static CapsuleImpostor: number;
  23691. /**
  23692. * Cylinder-Imposter type
  23693. */
  23694. static CylinderImpostor: number;
  23695. /**
  23696. * Particle-Imposter type
  23697. */
  23698. static ParticleImpostor: number;
  23699. /**
  23700. * Heightmap-Imposter type
  23701. */
  23702. static HeightmapImpostor: number;
  23703. /**
  23704. * ConvexHull-Impostor type (Ammo.js plugin only)
  23705. */
  23706. static ConvexHullImpostor: number;
  23707. /**
  23708. * Rope-Imposter type
  23709. */
  23710. static RopeImpostor: number;
  23711. /**
  23712. * Cloth-Imposter type
  23713. */
  23714. static ClothImpostor: number;
  23715. /**
  23716. * Softbody-Imposter type
  23717. */
  23718. static SoftbodyImpostor: number;
  23719. }
  23720. }
  23721. declare module BABYLON {
  23722. /**
  23723. * @hidden
  23724. **/
  23725. export class _CreationDataStorage {
  23726. closePath?: boolean;
  23727. closeArray?: boolean;
  23728. idx: number[];
  23729. dashSize: number;
  23730. gapSize: number;
  23731. path3D: Path3D;
  23732. pathArray: Vector3[][];
  23733. arc: number;
  23734. radius: number;
  23735. cap: number;
  23736. tessellation: number;
  23737. }
  23738. /**
  23739. * @hidden
  23740. **/
  23741. class _InstanceDataStorage {
  23742. visibleInstances: any;
  23743. batchCache: _InstancesBatch;
  23744. instancesBufferSize: number;
  23745. instancesBuffer: Nullable<Buffer>;
  23746. instancesData: Float32Array;
  23747. overridenInstanceCount: number;
  23748. isFrozen: boolean;
  23749. previousBatch: Nullable<_InstancesBatch>;
  23750. hardwareInstancedRendering: boolean;
  23751. sideOrientation: number;
  23752. manualUpdate: boolean;
  23753. }
  23754. /**
  23755. * @hidden
  23756. **/
  23757. export class _InstancesBatch {
  23758. mustReturn: boolean;
  23759. visibleInstances: Nullable<InstancedMesh[]>[];
  23760. renderSelf: boolean[];
  23761. hardwareInstancedRendering: boolean[];
  23762. }
  23763. /**
  23764. * Class used to represent renderable models
  23765. */
  23766. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23767. /**
  23768. * Mesh side orientation : usually the external or front surface
  23769. */
  23770. static readonly FRONTSIDE: number;
  23771. /**
  23772. * Mesh side orientation : usually the internal or back surface
  23773. */
  23774. static readonly BACKSIDE: number;
  23775. /**
  23776. * Mesh side orientation : both internal and external or front and back surfaces
  23777. */
  23778. static readonly DOUBLESIDE: number;
  23779. /**
  23780. * Mesh side orientation : by default, `FRONTSIDE`
  23781. */
  23782. static readonly DEFAULTSIDE: number;
  23783. /**
  23784. * Mesh cap setting : no cap
  23785. */
  23786. static readonly NO_CAP: number;
  23787. /**
  23788. * Mesh cap setting : one cap at the beginning of the mesh
  23789. */
  23790. static readonly CAP_START: number;
  23791. /**
  23792. * Mesh cap setting : one cap at the end of the mesh
  23793. */
  23794. static readonly CAP_END: number;
  23795. /**
  23796. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23797. */
  23798. static readonly CAP_ALL: number;
  23799. /**
  23800. * Mesh pattern setting : no flip or rotate
  23801. */
  23802. static readonly NO_FLIP: number;
  23803. /**
  23804. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23805. */
  23806. static readonly FLIP_TILE: number;
  23807. /**
  23808. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23809. */
  23810. static readonly ROTATE_TILE: number;
  23811. /**
  23812. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23813. */
  23814. static readonly FLIP_ROW: number;
  23815. /**
  23816. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23817. */
  23818. static readonly ROTATE_ROW: number;
  23819. /**
  23820. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23821. */
  23822. static readonly FLIP_N_ROTATE_TILE: number;
  23823. /**
  23824. * Mesh pattern setting : rotate pattern and rotate
  23825. */
  23826. static readonly FLIP_N_ROTATE_ROW: number;
  23827. /**
  23828. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23829. */
  23830. static readonly CENTER: number;
  23831. /**
  23832. * Mesh tile positioning : part tiles on left
  23833. */
  23834. static readonly LEFT: number;
  23835. /**
  23836. * Mesh tile positioning : part tiles on right
  23837. */
  23838. static readonly RIGHT: number;
  23839. /**
  23840. * Mesh tile positioning : part tiles on top
  23841. */
  23842. static readonly TOP: number;
  23843. /**
  23844. * Mesh tile positioning : part tiles on bottom
  23845. */
  23846. static readonly BOTTOM: number;
  23847. /**
  23848. * Gets the default side orientation.
  23849. * @param orientation the orientation to value to attempt to get
  23850. * @returns the default orientation
  23851. * @hidden
  23852. */
  23853. static _GetDefaultSideOrientation(orientation?: number): number;
  23854. private _internalMeshDataInfo;
  23855. /**
  23856. * An event triggered before rendering the mesh
  23857. */
  23858. readonly onBeforeRenderObservable: Observable<Mesh>;
  23859. /**
  23860. * An event triggered before binding the mesh
  23861. */
  23862. readonly onBeforeBindObservable: Observable<Mesh>;
  23863. /**
  23864. * An event triggered after rendering the mesh
  23865. */
  23866. readonly onAfterRenderObservable: Observable<Mesh>;
  23867. /**
  23868. * An event triggered before drawing the mesh
  23869. */
  23870. readonly onBeforeDrawObservable: Observable<Mesh>;
  23871. private _onBeforeDrawObserver;
  23872. /**
  23873. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23874. */
  23875. onBeforeDraw: () => void;
  23876. readonly hasInstances: boolean;
  23877. /**
  23878. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23879. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23880. */
  23881. delayLoadState: number;
  23882. /**
  23883. * Gets the list of instances created from this mesh
  23884. * it is not supposed to be modified manually.
  23885. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23886. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23887. */
  23888. instances: InstancedMesh[];
  23889. /**
  23890. * Gets the file containing delay loading data for this mesh
  23891. */
  23892. delayLoadingFile: string;
  23893. /** @hidden */
  23894. _binaryInfo: any;
  23895. /**
  23896. * User defined function used to change how LOD level selection is done
  23897. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23898. */
  23899. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23900. /**
  23901. * Gets or sets the morph target manager
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23903. */
  23904. morphTargetManager: Nullable<MorphTargetManager>;
  23905. /** @hidden */
  23906. _creationDataStorage: Nullable<_CreationDataStorage>;
  23907. /** @hidden */
  23908. _geometry: Nullable<Geometry>;
  23909. /** @hidden */
  23910. _delayInfo: Array<string>;
  23911. /** @hidden */
  23912. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23913. /** @hidden */
  23914. _instanceDataStorage: _InstanceDataStorage;
  23915. private _effectiveMaterial;
  23916. /** @hidden */
  23917. _shouldGenerateFlatShading: boolean;
  23918. /** @hidden */
  23919. _originalBuilderSideOrientation: number;
  23920. /**
  23921. * Use this property to change the original side orientation defined at construction time
  23922. */
  23923. overrideMaterialSideOrientation: Nullable<number>;
  23924. /**
  23925. * Gets the source mesh (the one used to clone this one from)
  23926. */
  23927. readonly source: Nullable<Mesh>;
  23928. /**
  23929. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23930. */
  23931. isUnIndexed: boolean;
  23932. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23933. readonly worldMatrixInstancedBuffer: Float32Array;
  23934. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  23935. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  23936. /**
  23937. * @constructor
  23938. * @param name The value used by scene.getMeshByName() to do a lookup.
  23939. * @param scene The scene to add this mesh to.
  23940. * @param parent The parent of this mesh, if it has one
  23941. * @param source An optional Mesh from which geometry is shared, cloned.
  23942. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23943. * When false, achieved by calling a clone(), also passing False.
  23944. * This will make creation of children, recursive.
  23945. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23946. */
  23947. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23948. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23949. doNotInstantiate: boolean;
  23950. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23951. /**
  23952. * Gets the class name
  23953. * @returns the string "Mesh".
  23954. */
  23955. getClassName(): string;
  23956. /** @hidden */
  23957. readonly _isMesh: boolean;
  23958. /**
  23959. * Returns a description of this mesh
  23960. * @param fullDetails define if full details about this mesh must be used
  23961. * @returns a descriptive string representing this mesh
  23962. */
  23963. toString(fullDetails?: boolean): string;
  23964. /** @hidden */
  23965. _unBindEffect(): void;
  23966. /**
  23967. * Gets a boolean indicating if this mesh has LOD
  23968. */
  23969. readonly hasLODLevels: boolean;
  23970. /**
  23971. * Gets the list of MeshLODLevel associated with the current mesh
  23972. * @returns an array of MeshLODLevel
  23973. */
  23974. getLODLevels(): MeshLODLevel[];
  23975. private _sortLODLevels;
  23976. /**
  23977. * Add a mesh as LOD level triggered at the given distance.
  23978. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23979. * @param distance The distance from the center of the object to show this level
  23980. * @param mesh The mesh to be added as LOD level (can be null)
  23981. * @return This mesh (for chaining)
  23982. */
  23983. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23984. /**
  23985. * Returns the LOD level mesh at the passed distance or null if not found.
  23986. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23987. * @param distance The distance from the center of the object to show this level
  23988. * @returns a Mesh or `null`
  23989. */
  23990. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23991. /**
  23992. * Remove a mesh from the LOD array
  23993. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23994. * @param mesh defines the mesh to be removed
  23995. * @return This mesh (for chaining)
  23996. */
  23997. removeLODLevel(mesh: Mesh): Mesh;
  23998. /**
  23999. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24000. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24001. * @param camera defines the camera to use to compute distance
  24002. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24003. * @return This mesh (for chaining)
  24004. */
  24005. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24006. /**
  24007. * Gets the mesh internal Geometry object
  24008. */
  24009. readonly geometry: Nullable<Geometry>;
  24010. /**
  24011. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24012. * @returns the total number of vertices
  24013. */
  24014. getTotalVertices(): number;
  24015. /**
  24016. * Returns the content of an associated vertex buffer
  24017. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24018. * - VertexBuffer.PositionKind
  24019. * - VertexBuffer.UVKind
  24020. * - VertexBuffer.UV2Kind
  24021. * - VertexBuffer.UV3Kind
  24022. * - VertexBuffer.UV4Kind
  24023. * - VertexBuffer.UV5Kind
  24024. * - VertexBuffer.UV6Kind
  24025. * - VertexBuffer.ColorKind
  24026. * - VertexBuffer.MatricesIndicesKind
  24027. * - VertexBuffer.MatricesIndicesExtraKind
  24028. * - VertexBuffer.MatricesWeightsKind
  24029. * - VertexBuffer.MatricesWeightsExtraKind
  24030. * @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
  24031. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24032. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24033. */
  24034. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24035. /**
  24036. * Returns the mesh VertexBuffer object from the requested `kind`
  24037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24038. * - VertexBuffer.PositionKind
  24039. * - VertexBuffer.NormalKind
  24040. * - VertexBuffer.UVKind
  24041. * - VertexBuffer.UV2Kind
  24042. * - VertexBuffer.UV3Kind
  24043. * - VertexBuffer.UV4Kind
  24044. * - VertexBuffer.UV5Kind
  24045. * - VertexBuffer.UV6Kind
  24046. * - VertexBuffer.ColorKind
  24047. * - VertexBuffer.MatricesIndicesKind
  24048. * - VertexBuffer.MatricesIndicesExtraKind
  24049. * - VertexBuffer.MatricesWeightsKind
  24050. * - VertexBuffer.MatricesWeightsExtraKind
  24051. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24052. */
  24053. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24054. /**
  24055. * Tests if a specific vertex buffer is associated with this mesh
  24056. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24057. * - VertexBuffer.PositionKind
  24058. * - VertexBuffer.NormalKind
  24059. * - VertexBuffer.UVKind
  24060. * - VertexBuffer.UV2Kind
  24061. * - VertexBuffer.UV3Kind
  24062. * - VertexBuffer.UV4Kind
  24063. * - VertexBuffer.UV5Kind
  24064. * - VertexBuffer.UV6Kind
  24065. * - VertexBuffer.ColorKind
  24066. * - VertexBuffer.MatricesIndicesKind
  24067. * - VertexBuffer.MatricesIndicesExtraKind
  24068. * - VertexBuffer.MatricesWeightsKind
  24069. * - VertexBuffer.MatricesWeightsExtraKind
  24070. * @returns a boolean
  24071. */
  24072. isVerticesDataPresent(kind: string): boolean;
  24073. /**
  24074. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24075. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24076. * - VertexBuffer.PositionKind
  24077. * - VertexBuffer.UVKind
  24078. * - VertexBuffer.UV2Kind
  24079. * - VertexBuffer.UV3Kind
  24080. * - VertexBuffer.UV4Kind
  24081. * - VertexBuffer.UV5Kind
  24082. * - VertexBuffer.UV6Kind
  24083. * - VertexBuffer.ColorKind
  24084. * - VertexBuffer.MatricesIndicesKind
  24085. * - VertexBuffer.MatricesIndicesExtraKind
  24086. * - VertexBuffer.MatricesWeightsKind
  24087. * - VertexBuffer.MatricesWeightsExtraKind
  24088. * @returns a boolean
  24089. */
  24090. isVertexBufferUpdatable(kind: string): boolean;
  24091. /**
  24092. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24094. * - VertexBuffer.PositionKind
  24095. * - VertexBuffer.NormalKind
  24096. * - VertexBuffer.UVKind
  24097. * - VertexBuffer.UV2Kind
  24098. * - VertexBuffer.UV3Kind
  24099. * - VertexBuffer.UV4Kind
  24100. * - VertexBuffer.UV5Kind
  24101. * - VertexBuffer.UV6Kind
  24102. * - VertexBuffer.ColorKind
  24103. * - VertexBuffer.MatricesIndicesKind
  24104. * - VertexBuffer.MatricesIndicesExtraKind
  24105. * - VertexBuffer.MatricesWeightsKind
  24106. * - VertexBuffer.MatricesWeightsExtraKind
  24107. * @returns an array of strings
  24108. */
  24109. getVerticesDataKinds(): string[];
  24110. /**
  24111. * Returns a positive integer : the total number of indices in this mesh geometry.
  24112. * @returns the numner of indices or zero if the mesh has no geometry.
  24113. */
  24114. getTotalIndices(): number;
  24115. /**
  24116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24117. * @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.
  24118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24119. * @returns the indices array or an empty array if the mesh has no geometry
  24120. */
  24121. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24122. readonly isBlocked: boolean;
  24123. /**
  24124. * Determine if the current mesh is ready to be rendered
  24125. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24126. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24127. * @returns true if all associated assets are ready (material, textures, shaders)
  24128. */
  24129. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24130. /**
  24131. * 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.
  24132. */
  24133. readonly areNormalsFrozen: boolean;
  24134. /**
  24135. * 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.
  24136. * @returns the current mesh
  24137. */
  24138. freezeNormals(): Mesh;
  24139. /**
  24140. * 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
  24141. * @returns the current mesh
  24142. */
  24143. unfreezeNormals(): Mesh;
  24144. /**
  24145. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24146. */
  24147. overridenInstanceCount: number;
  24148. /** @hidden */
  24149. _preActivate(): Mesh;
  24150. /** @hidden */
  24151. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24152. /** @hidden */
  24153. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24154. /**
  24155. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24156. * This means the mesh underlying bounding box and sphere are recomputed.
  24157. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24158. * @returns the current mesh
  24159. */
  24160. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24161. /** @hidden */
  24162. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24163. /**
  24164. * This function will subdivide the mesh into multiple submeshes
  24165. * @param count defines the expected number of submeshes
  24166. */
  24167. subdivide(count: number): void;
  24168. /**
  24169. * Copy a FloatArray into a specific associated vertex buffer
  24170. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24171. * - VertexBuffer.PositionKind
  24172. * - VertexBuffer.UVKind
  24173. * - VertexBuffer.UV2Kind
  24174. * - VertexBuffer.UV3Kind
  24175. * - VertexBuffer.UV4Kind
  24176. * - VertexBuffer.UV5Kind
  24177. * - VertexBuffer.UV6Kind
  24178. * - VertexBuffer.ColorKind
  24179. * - VertexBuffer.MatricesIndicesKind
  24180. * - VertexBuffer.MatricesIndicesExtraKind
  24181. * - VertexBuffer.MatricesWeightsKind
  24182. * - VertexBuffer.MatricesWeightsExtraKind
  24183. * @param data defines the data source
  24184. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24185. * @param stride defines the data stride size (can be null)
  24186. * @returns the current mesh
  24187. */
  24188. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24189. /**
  24190. * Delete a vertex buffer associated with this mesh
  24191. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24192. * - VertexBuffer.PositionKind
  24193. * - VertexBuffer.UVKind
  24194. * - VertexBuffer.UV2Kind
  24195. * - VertexBuffer.UV3Kind
  24196. * - VertexBuffer.UV4Kind
  24197. * - VertexBuffer.UV5Kind
  24198. * - VertexBuffer.UV6Kind
  24199. * - VertexBuffer.ColorKind
  24200. * - VertexBuffer.MatricesIndicesKind
  24201. * - VertexBuffer.MatricesIndicesExtraKind
  24202. * - VertexBuffer.MatricesWeightsKind
  24203. * - VertexBuffer.MatricesWeightsExtraKind
  24204. */
  24205. removeVerticesData(kind: string): void;
  24206. /**
  24207. * Flags an associated vertex buffer as updatable
  24208. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24209. * - VertexBuffer.PositionKind
  24210. * - VertexBuffer.UVKind
  24211. * - VertexBuffer.UV2Kind
  24212. * - VertexBuffer.UV3Kind
  24213. * - VertexBuffer.UV4Kind
  24214. * - VertexBuffer.UV5Kind
  24215. * - VertexBuffer.UV6Kind
  24216. * - VertexBuffer.ColorKind
  24217. * - VertexBuffer.MatricesIndicesKind
  24218. * - VertexBuffer.MatricesIndicesExtraKind
  24219. * - VertexBuffer.MatricesWeightsKind
  24220. * - VertexBuffer.MatricesWeightsExtraKind
  24221. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24222. */
  24223. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24224. /**
  24225. * Sets the mesh global Vertex Buffer
  24226. * @param buffer defines the buffer to use
  24227. * @returns the current mesh
  24228. */
  24229. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24230. /**
  24231. * Update a specific associated vertex buffer
  24232. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24233. * - VertexBuffer.PositionKind
  24234. * - VertexBuffer.UVKind
  24235. * - VertexBuffer.UV2Kind
  24236. * - VertexBuffer.UV3Kind
  24237. * - VertexBuffer.UV4Kind
  24238. * - VertexBuffer.UV5Kind
  24239. * - VertexBuffer.UV6Kind
  24240. * - VertexBuffer.ColorKind
  24241. * - VertexBuffer.MatricesIndicesKind
  24242. * - VertexBuffer.MatricesIndicesExtraKind
  24243. * - VertexBuffer.MatricesWeightsKind
  24244. * - VertexBuffer.MatricesWeightsExtraKind
  24245. * @param data defines the data source
  24246. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24247. * @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)
  24248. * @returns the current mesh
  24249. */
  24250. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24251. /**
  24252. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24253. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24254. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24255. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24256. * @returns the current mesh
  24257. */
  24258. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24259. /**
  24260. * Creates a un-shared specific occurence of the geometry for the mesh.
  24261. * @returns the current mesh
  24262. */
  24263. makeGeometryUnique(): Mesh;
  24264. /**
  24265. * Set the index buffer of this mesh
  24266. * @param indices defines the source data
  24267. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24268. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24269. * @returns the current mesh
  24270. */
  24271. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24272. /**
  24273. * Update the current index buffer
  24274. * @param indices defines the source data
  24275. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24276. * @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)
  24277. * @returns the current mesh
  24278. */
  24279. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24280. /**
  24281. * Invert the geometry to move from a right handed system to a left handed one.
  24282. * @returns the current mesh
  24283. */
  24284. toLeftHanded(): Mesh;
  24285. /** @hidden */
  24286. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24287. /** @hidden */
  24288. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24289. /**
  24290. * Registers for this mesh a javascript function called just before the rendering process
  24291. * @param func defines the function to call before rendering this mesh
  24292. * @returns the current mesh
  24293. */
  24294. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24295. /**
  24296. * Disposes a previously registered javascript function called before the rendering
  24297. * @param func defines the function to remove
  24298. * @returns the current mesh
  24299. */
  24300. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24301. /**
  24302. * Registers for this mesh a javascript function called just after the rendering is complete
  24303. * @param func defines the function to call after rendering this mesh
  24304. * @returns the current mesh
  24305. */
  24306. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24307. /**
  24308. * Disposes a previously registered javascript function called after the rendering.
  24309. * @param func defines the function to remove
  24310. * @returns the current mesh
  24311. */
  24312. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24313. /** @hidden */
  24314. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24315. /** @hidden */
  24316. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24317. /** @hidden */
  24318. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24319. /** @hidden */
  24320. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24321. /** @hidden */
  24322. _rebuild(): void;
  24323. /** @hidden */
  24324. _freeze(): void;
  24325. /** @hidden */
  24326. _unFreeze(): void;
  24327. /**
  24328. * 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
  24329. * @param subMesh defines the subMesh to render
  24330. * @param enableAlphaMode defines if alpha mode can be changed
  24331. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24332. * @returns the current mesh
  24333. */
  24334. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24335. private _onBeforeDraw;
  24336. /**
  24337. * Renormalize the mesh and patch it up if there are no weights
  24338. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24339. * However in the case of zero weights then we set just a single influence to 1.
  24340. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24341. */
  24342. cleanMatrixWeights(): void;
  24343. private normalizeSkinFourWeights;
  24344. private normalizeSkinWeightsAndExtra;
  24345. /**
  24346. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24347. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24348. * the user know there was an issue with importing the mesh
  24349. * @returns a validation object with skinned, valid and report string
  24350. */
  24351. validateSkinning(): {
  24352. skinned: boolean;
  24353. valid: boolean;
  24354. report: string;
  24355. };
  24356. /** @hidden */
  24357. _checkDelayState(): Mesh;
  24358. private _queueLoad;
  24359. /**
  24360. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24361. * A mesh is in the frustum if its bounding box intersects the frustum
  24362. * @param frustumPlanes defines the frustum to test
  24363. * @returns true if the mesh is in the frustum planes
  24364. */
  24365. isInFrustum(frustumPlanes: Plane[]): boolean;
  24366. /**
  24367. * Sets the mesh material by the material or multiMaterial `id` property
  24368. * @param id is a string identifying the material or the multiMaterial
  24369. * @returns the current mesh
  24370. */
  24371. setMaterialByID(id: string): Mesh;
  24372. /**
  24373. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24374. * @returns an array of IAnimatable
  24375. */
  24376. getAnimatables(): IAnimatable[];
  24377. /**
  24378. * Modifies the mesh geometry according to the passed transformation matrix.
  24379. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24380. * The mesh normals are modified using the same transformation.
  24381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24382. * @param transform defines the transform matrix to use
  24383. * @see http://doc.babylonjs.com/resources/baking_transformations
  24384. * @returns the current mesh
  24385. */
  24386. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24387. /**
  24388. * Modifies the mesh geometry according to its own current World Matrix.
  24389. * The mesh World Matrix is then reset.
  24390. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24391. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24392. * @see http://doc.babylonjs.com/resources/baking_transformations
  24393. * @returns the current mesh
  24394. */
  24395. bakeCurrentTransformIntoVertices(): Mesh;
  24396. /** @hidden */
  24397. readonly _positions: Nullable<Vector3[]>;
  24398. /** @hidden */
  24399. _resetPointsArrayCache(): Mesh;
  24400. /** @hidden */
  24401. _generatePointsArray(): boolean;
  24402. /**
  24403. * Returns a new Mesh object generated from the current mesh properties.
  24404. * This method must not get confused with createInstance()
  24405. * @param name is a string, the name given to the new mesh
  24406. * @param newParent can be any Node object (default `null`)
  24407. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24408. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24409. * @returns a new mesh
  24410. */
  24411. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24412. /**
  24413. * Releases resources associated with this mesh.
  24414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24416. */
  24417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24418. /** @hidden */
  24419. _disposeInstanceSpecificData(): void;
  24420. /**
  24421. * Modifies the mesh geometry according to a displacement map.
  24422. * 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.
  24423. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24424. * @param url is a string, the URL from the image file is to be downloaded.
  24425. * @param minHeight is the lower limit of the displacement.
  24426. * @param maxHeight is the upper limit of the displacement.
  24427. * @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.
  24428. * @param uvOffset is an optional vector2 used to offset UV.
  24429. * @param uvScale is an optional vector2 used to scale UV.
  24430. * @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.
  24431. * @returns the Mesh.
  24432. */
  24433. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24434. /**
  24435. * Modifies the mesh geometry according to a displacementMap buffer.
  24436. * 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.
  24437. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24438. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24439. * @param heightMapWidth is the width of the buffer image.
  24440. * @param heightMapHeight is the height of the buffer image.
  24441. * @param minHeight is the lower limit of the displacement.
  24442. * @param maxHeight is the upper limit of the displacement.
  24443. * @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.
  24444. * @param uvOffset is an optional vector2 used to offset UV.
  24445. * @param uvScale is an optional vector2 used to scale UV.
  24446. * @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.
  24447. * @returns the Mesh.
  24448. */
  24449. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24450. /**
  24451. * Modify the mesh to get a flat shading rendering.
  24452. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24453. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24454. * @returns current mesh
  24455. */
  24456. convertToFlatShadedMesh(): Mesh;
  24457. /**
  24458. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24459. * In other words, more vertices, no more indices and a single bigger VBO.
  24460. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24461. * @returns current mesh
  24462. */
  24463. convertToUnIndexedMesh(): Mesh;
  24464. /**
  24465. * Inverses facet orientations.
  24466. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24467. * @param flipNormals will also inverts the normals
  24468. * @returns current mesh
  24469. */
  24470. flipFaces(flipNormals?: boolean): Mesh;
  24471. /**
  24472. * Increase the number of facets and hence vertices in a mesh
  24473. * Vertex normals are interpolated from existing vertex normals
  24474. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24475. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24476. */
  24477. increaseVertices(numberPerEdge: number): void;
  24478. /**
  24479. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24480. * This will undo any application of covertToFlatShadedMesh
  24481. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24482. */
  24483. forceSharedVertices(): void;
  24484. /** @hidden */
  24485. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24486. /** @hidden */
  24487. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24488. /**
  24489. * Creates a new InstancedMesh object from the mesh model.
  24490. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24491. * @param name defines the name of the new instance
  24492. * @returns a new InstancedMesh
  24493. */
  24494. createInstance(name: string): InstancedMesh;
  24495. /**
  24496. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24497. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24498. * @returns the current mesh
  24499. */
  24500. synchronizeInstances(): Mesh;
  24501. /**
  24502. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24503. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24504. * This should be used together with the simplification to avoid disappearing triangles.
  24505. * @param successCallback an optional success callback to be called after the optimization finished.
  24506. * @returns the current mesh
  24507. */
  24508. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24509. /**
  24510. * Serialize current mesh
  24511. * @param serializationObject defines the object which will receive the serialization data
  24512. */
  24513. serialize(serializationObject: any): void;
  24514. /** @hidden */
  24515. _syncGeometryWithMorphTargetManager(): void;
  24516. /** @hidden */
  24517. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24518. /**
  24519. * Returns a new Mesh object parsed from the source provided.
  24520. * @param parsedMesh is the source
  24521. * @param scene defines the hosting scene
  24522. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24523. * @returns a new Mesh
  24524. */
  24525. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24526. /**
  24527. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24528. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24529. * @param name defines the name of the mesh to create
  24530. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24531. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24532. * @param closePath creates a seam between the first and the last points of each path of the path array
  24533. * @param offset is taken in account only if the `pathArray` is containing a single path
  24534. * @param scene defines the hosting scene
  24535. * @param updatable defines if the mesh must be flagged as updatable
  24536. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24537. * @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)
  24538. * @returns a new Mesh
  24539. */
  24540. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24541. /**
  24542. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24543. * @param name defines the name of the mesh to create
  24544. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24545. * @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
  24546. * @param scene defines the hosting scene
  24547. * @param updatable defines if the mesh must be flagged as updatable
  24548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24549. * @returns a new Mesh
  24550. */
  24551. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24552. /**
  24553. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24554. * @param name defines the name of the mesh to create
  24555. * @param size sets the size (float) of each box side (default 1)
  24556. * @param scene defines the hosting scene
  24557. * @param updatable defines if the mesh must be flagged as updatable
  24558. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24559. * @returns a new Mesh
  24560. */
  24561. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24562. /**
  24563. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24564. * @param name defines the name of the mesh to create
  24565. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24566. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24567. * @param scene defines the hosting scene
  24568. * @param updatable defines if the mesh must be flagged as updatable
  24569. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24570. * @returns a new Mesh
  24571. */
  24572. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24573. /**
  24574. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24575. * @param name defines the name of the mesh to create
  24576. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24577. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24578. * @param scene defines the hosting scene
  24579. * @returns a new Mesh
  24580. */
  24581. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24582. /**
  24583. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24584. * @param name defines the name of the mesh to create
  24585. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24586. * @param diameterTop set the top cap diameter (floats, default 1)
  24587. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24588. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24589. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24590. * @param scene defines the hosting scene
  24591. * @param updatable defines if the mesh must be flagged as updatable
  24592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24593. * @returns a new Mesh
  24594. */
  24595. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24596. /**
  24597. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24598. * @param name defines the name of the mesh to create
  24599. * @param diameter sets the diameter size (float) of the torus (default 1)
  24600. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24601. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24602. * @param scene defines the hosting scene
  24603. * @param updatable defines if the mesh must be flagged as updatable
  24604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24605. * @returns a new Mesh
  24606. */
  24607. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24608. /**
  24609. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24610. * @param name defines the name of the mesh to create
  24611. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24612. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24613. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24614. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24615. * @param p the number of windings on X axis (positive integers, default 2)
  24616. * @param q the number of windings on Y axis (positive integers, default 3)
  24617. * @param scene defines the hosting scene
  24618. * @param updatable defines if the mesh must be flagged as updatable
  24619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24620. * @returns a new Mesh
  24621. */
  24622. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24623. /**
  24624. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24625. * @param name defines the name of the mesh to create
  24626. * @param points is an array successive Vector3
  24627. * @param scene defines the hosting scene
  24628. * @param updatable defines if the mesh must be flagged as updatable
  24629. * @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).
  24630. * @returns a new Mesh
  24631. */
  24632. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24633. /**
  24634. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24635. * @param name defines the name of the mesh to create
  24636. * @param points is an array successive Vector3
  24637. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24638. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24639. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24640. * @param scene defines the hosting scene
  24641. * @param updatable defines if the mesh must be flagged as updatable
  24642. * @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)
  24643. * @returns a new Mesh
  24644. */
  24645. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24646. /**
  24647. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24648. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24649. * 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.
  24650. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24651. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24652. * Remember you can only change the shape positions, not their number when updating a polygon.
  24653. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24654. * @param name defines the name of the mesh to create
  24655. * @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
  24656. * @param scene defines the hosting scene
  24657. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24658. * @param updatable defines if the mesh must be flagged as updatable
  24659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24660. * @param earcutInjection can be used to inject your own earcut reference
  24661. * @returns a new Mesh
  24662. */
  24663. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24664. /**
  24665. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24666. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24667. * @param name defines the name of the mesh to create
  24668. * @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
  24669. * @param depth defines the height of extrusion
  24670. * @param scene defines the hosting scene
  24671. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24672. * @param updatable defines if the mesh must be flagged as updatable
  24673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24674. * @param earcutInjection can be used to inject your own earcut reference
  24675. * @returns a new Mesh
  24676. */
  24677. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24678. /**
  24679. * Creates an extruded shape mesh.
  24680. * 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
  24681. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24682. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24683. * @param name defines the name of the mesh to create
  24684. * @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
  24685. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24686. * @param scale is the value to scale the shape
  24687. * @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
  24688. * @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
  24689. * @param scene defines the hosting scene
  24690. * @param updatable defines if the mesh must be flagged as updatable
  24691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24692. * @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)
  24693. * @returns a new Mesh
  24694. */
  24695. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24696. /**
  24697. * Creates an custom extruded shape mesh.
  24698. * The custom extrusion is a parametric shape.
  24699. * It has no predefined shape. Its final shape will depend on the input parameters.
  24700. * Please consider using the same method from the MeshBuilder class instead
  24701. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24702. * @param name defines the name of the mesh to create
  24703. * @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
  24704. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24705. * @param scaleFunction is a custom Javascript function called on each path point
  24706. * @param rotationFunction is a custom Javascript function called on each path point
  24707. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24708. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24709. * @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
  24710. * @param scene defines the hosting scene
  24711. * @param updatable defines if the mesh must be flagged as updatable
  24712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24713. * @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)
  24714. * @returns a new Mesh
  24715. */
  24716. 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;
  24717. /**
  24718. * Creates lathe mesh.
  24719. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24720. * Please consider using the same method from the MeshBuilder class instead
  24721. * @param name defines the name of the mesh to create
  24722. * @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
  24723. * @param radius is the radius value of the lathe
  24724. * @param tessellation is the side number of the lathe.
  24725. * @param scene defines the hosting scene
  24726. * @param updatable defines if the mesh must be flagged as updatable
  24727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24728. * @returns a new Mesh
  24729. */
  24730. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24731. /**
  24732. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24733. * @param name defines the name of the mesh to create
  24734. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24735. * @param scene defines the hosting scene
  24736. * @param updatable defines if the mesh must be flagged as updatable
  24737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24738. * @returns a new Mesh
  24739. */
  24740. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24741. /**
  24742. * Creates a ground mesh.
  24743. * Please consider using the same method from the MeshBuilder class instead
  24744. * @param name defines the name of the mesh to create
  24745. * @param width set the width of the ground
  24746. * @param height set the height of the ground
  24747. * @param subdivisions sets the number of subdivisions per side
  24748. * @param scene defines the hosting scene
  24749. * @param updatable defines if the mesh must be flagged as updatable
  24750. * @returns a new Mesh
  24751. */
  24752. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24753. /**
  24754. * Creates a tiled ground mesh.
  24755. * Please consider using the same method from the MeshBuilder class instead
  24756. * @param name defines the name of the mesh to create
  24757. * @param xmin set the ground minimum X coordinate
  24758. * @param zmin set the ground minimum Y coordinate
  24759. * @param xmax set the ground maximum X coordinate
  24760. * @param zmax set the ground maximum Z coordinate
  24761. * @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
  24762. * @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
  24763. * @param scene defines the hosting scene
  24764. * @param updatable defines if the mesh must be flagged as updatable
  24765. * @returns a new Mesh
  24766. */
  24767. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24768. w: number;
  24769. h: number;
  24770. }, precision: {
  24771. w: number;
  24772. h: number;
  24773. }, scene: Scene, updatable?: boolean): Mesh;
  24774. /**
  24775. * Creates a ground mesh from a height map.
  24776. * Please consider using the same method from the MeshBuilder class instead
  24777. * @see http://doc.babylonjs.com/babylon101/height_map
  24778. * @param name defines the name of the mesh to create
  24779. * @param url sets the URL of the height map image resource
  24780. * @param width set the ground width size
  24781. * @param height set the ground height size
  24782. * @param subdivisions sets the number of subdivision per side
  24783. * @param minHeight is the minimum altitude on the ground
  24784. * @param maxHeight is the maximum altitude on the ground
  24785. * @param scene defines the hosting scene
  24786. * @param updatable defines if the mesh must be flagged as updatable
  24787. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24788. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24789. * @returns a new Mesh
  24790. */
  24791. 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;
  24792. /**
  24793. * Creates a tube mesh.
  24794. * The tube is a parametric shape.
  24795. * It has no predefined shape. Its final shape will depend on the input parameters.
  24796. * Please consider using the same method from the MeshBuilder class instead
  24797. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24798. * @param name defines the name of the mesh to create
  24799. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24800. * @param radius sets the tube radius size
  24801. * @param tessellation is the number of sides on the tubular surface
  24802. * @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
  24803. * @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
  24804. * @param scene defines the hosting scene
  24805. * @param updatable defines if the mesh must be flagged as updatable
  24806. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24807. * @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)
  24808. * @returns a new Mesh
  24809. */
  24810. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24811. (i: number, distance: number): number;
  24812. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24813. /**
  24814. * Creates a polyhedron mesh.
  24815. * Please consider using the same method from the MeshBuilder class instead.
  24816. * * 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
  24817. * * The parameter `size` (positive float, default 1) sets the polygon size
  24818. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24819. * * 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`
  24820. * * 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
  24821. * * 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)`)
  24822. * * 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
  24823. * * 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
  24824. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24825. * * 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
  24826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24827. * @param name defines the name of the mesh to create
  24828. * @param options defines the options used to create the mesh
  24829. * @param scene defines the hosting scene
  24830. * @returns a new Mesh
  24831. */
  24832. static CreatePolyhedron(name: string, options: {
  24833. type?: number;
  24834. size?: number;
  24835. sizeX?: number;
  24836. sizeY?: number;
  24837. sizeZ?: number;
  24838. custom?: any;
  24839. faceUV?: Vector4[];
  24840. faceColors?: Color4[];
  24841. updatable?: boolean;
  24842. sideOrientation?: number;
  24843. }, scene: Scene): Mesh;
  24844. /**
  24845. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24846. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24847. * * 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`)
  24848. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24849. * * 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
  24850. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24851. * * 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
  24852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24853. * @param name defines the name of the mesh
  24854. * @param options defines the options used to create the mesh
  24855. * @param scene defines the hosting scene
  24856. * @returns a new Mesh
  24857. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24858. */
  24859. static CreateIcoSphere(name: string, options: {
  24860. radius?: number;
  24861. flat?: boolean;
  24862. subdivisions?: number;
  24863. sideOrientation?: number;
  24864. updatable?: boolean;
  24865. }, scene: Scene): Mesh;
  24866. /**
  24867. * Creates a decal mesh.
  24868. * Please consider using the same method from the MeshBuilder class instead.
  24869. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24870. * @param name defines the name of the mesh
  24871. * @param sourceMesh defines the mesh receiving the decal
  24872. * @param position sets the position of the decal in world coordinates
  24873. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24874. * @param size sets the decal scaling
  24875. * @param angle sets the angle to rotate the decal
  24876. * @returns a new Mesh
  24877. */
  24878. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24879. /**
  24880. * Prepare internal position array for software CPU skinning
  24881. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24882. */
  24883. setPositionsForCPUSkinning(): Float32Array;
  24884. /**
  24885. * Prepare internal normal array for software CPU skinning
  24886. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24887. */
  24888. setNormalsForCPUSkinning(): Float32Array;
  24889. /**
  24890. * Updates the vertex buffer by applying transformation from the bones
  24891. * @param skeleton defines the skeleton to apply to current mesh
  24892. * @returns the current mesh
  24893. */
  24894. applySkeleton(skeleton: Skeleton): Mesh;
  24895. /**
  24896. * 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
  24897. * @param meshes defines the list of meshes to scan
  24898. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24899. */
  24900. static MinMax(meshes: AbstractMesh[]): {
  24901. min: Vector3;
  24902. max: Vector3;
  24903. };
  24904. /**
  24905. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24906. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24907. * @returns a vector3
  24908. */
  24909. static Center(meshesOrMinMaxVector: {
  24910. min: Vector3;
  24911. max: Vector3;
  24912. } | AbstractMesh[]): Vector3;
  24913. /**
  24914. * Merge the array of meshes into a single mesh for performance reasons.
  24915. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24916. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24917. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24918. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24919. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24920. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24921. * @returns a new mesh
  24922. */
  24923. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24924. /** @hidden */
  24925. addInstance(instance: InstancedMesh): void;
  24926. /** @hidden */
  24927. removeInstance(instance: InstancedMesh): void;
  24928. }
  24929. }
  24930. declare module BABYLON {
  24931. /**
  24932. * This is the base class of all the camera used in the application.
  24933. * @see http://doc.babylonjs.com/features/cameras
  24934. */
  24935. export class Camera extends Node {
  24936. /** @hidden */
  24937. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24938. /**
  24939. * This is the default projection mode used by the cameras.
  24940. * It helps recreating a feeling of perspective and better appreciate depth.
  24941. * This is the best way to simulate real life cameras.
  24942. */
  24943. static readonly PERSPECTIVE_CAMERA: number;
  24944. /**
  24945. * This helps creating camera with an orthographic mode.
  24946. * 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.
  24947. */
  24948. static readonly ORTHOGRAPHIC_CAMERA: number;
  24949. /**
  24950. * This is the default FOV mode for perspective cameras.
  24951. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24952. */
  24953. static readonly FOVMODE_VERTICAL_FIXED: number;
  24954. /**
  24955. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24956. */
  24957. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24958. /**
  24959. * This specifies ther is no need for a camera rig.
  24960. * Basically only one eye is rendered corresponding to the camera.
  24961. */
  24962. static readonly RIG_MODE_NONE: number;
  24963. /**
  24964. * Simulates a camera Rig with one blue eye and one red eye.
  24965. * This can be use with 3d blue and red glasses.
  24966. */
  24967. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24968. /**
  24969. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24970. */
  24971. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24972. /**
  24973. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24974. */
  24975. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24976. /**
  24977. * Defines that both eyes of the camera will be rendered over under each other.
  24978. */
  24979. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24980. /**
  24981. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24982. */
  24983. static readonly RIG_MODE_VR: number;
  24984. /**
  24985. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24986. */
  24987. static readonly RIG_MODE_WEBVR: number;
  24988. /**
  24989. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24990. */
  24991. static readonly RIG_MODE_CUSTOM: number;
  24992. /**
  24993. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24994. */
  24995. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24996. /**
  24997. * Define the input manager associated with the camera.
  24998. */
  24999. inputs: CameraInputsManager<Camera>;
  25000. /** @hidden */
  25001. _position: Vector3;
  25002. /**
  25003. * Define the current local position of the camera in the scene
  25004. */
  25005. position: Vector3;
  25006. /**
  25007. * The vector the camera should consider as up.
  25008. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25009. */
  25010. upVector: Vector3;
  25011. /**
  25012. * Define the current limit on the left side for an orthographic camera
  25013. * In scene unit
  25014. */
  25015. orthoLeft: Nullable<number>;
  25016. /**
  25017. * Define the current limit on the right side for an orthographic camera
  25018. * In scene unit
  25019. */
  25020. orthoRight: Nullable<number>;
  25021. /**
  25022. * Define the current limit on the bottom side for an orthographic camera
  25023. * In scene unit
  25024. */
  25025. orthoBottom: Nullable<number>;
  25026. /**
  25027. * Define the current limit on the top side for an orthographic camera
  25028. * In scene unit
  25029. */
  25030. orthoTop: Nullable<number>;
  25031. /**
  25032. * Field Of View is set in Radians. (default is 0.8)
  25033. */
  25034. fov: number;
  25035. /**
  25036. * Define the minimum distance the camera can see from.
  25037. * This is important to note that the depth buffer are not infinite and the closer it starts
  25038. * the more your scene might encounter depth fighting issue.
  25039. */
  25040. minZ: number;
  25041. /**
  25042. * Define the maximum distance the camera can see to.
  25043. * This is important to note that the depth buffer are not infinite and the further it end
  25044. * the more your scene might encounter depth fighting issue.
  25045. */
  25046. maxZ: number;
  25047. /**
  25048. * Define the default inertia of the camera.
  25049. * This helps giving a smooth feeling to the camera movement.
  25050. */
  25051. inertia: number;
  25052. /**
  25053. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25054. */
  25055. mode: number;
  25056. /**
  25057. * Define wether the camera is intermediate.
  25058. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25059. */
  25060. isIntermediate: boolean;
  25061. /**
  25062. * Define the viewport of the camera.
  25063. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25064. */
  25065. viewport: Viewport;
  25066. /**
  25067. * Restricts the camera to viewing objects with the same layerMask.
  25068. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25069. */
  25070. layerMask: number;
  25071. /**
  25072. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25073. */
  25074. fovMode: number;
  25075. /**
  25076. * Rig mode of the camera.
  25077. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25078. * This is normally controlled byt the camera themselves as internal use.
  25079. */
  25080. cameraRigMode: number;
  25081. /**
  25082. * Defines the distance between both "eyes" in case of a RIG
  25083. */
  25084. interaxialDistance: number;
  25085. /**
  25086. * Defines if stereoscopic rendering is done side by side or over under.
  25087. */
  25088. isStereoscopicSideBySide: boolean;
  25089. /**
  25090. * 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
  25091. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25092. * else in the scene. (Eg. security camera)
  25093. *
  25094. * 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)
  25095. */
  25096. customRenderTargets: RenderTargetTexture[];
  25097. /**
  25098. * When set, the camera will render to this render target instead of the default canvas
  25099. *
  25100. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25101. */
  25102. outputRenderTarget: Nullable<RenderTargetTexture>;
  25103. /**
  25104. * Observable triggered when the camera view matrix has changed.
  25105. */
  25106. onViewMatrixChangedObservable: Observable<Camera>;
  25107. /**
  25108. * Observable triggered when the camera Projection matrix has changed.
  25109. */
  25110. onProjectionMatrixChangedObservable: Observable<Camera>;
  25111. /**
  25112. * Observable triggered when the inputs have been processed.
  25113. */
  25114. onAfterCheckInputsObservable: Observable<Camera>;
  25115. /**
  25116. * Observable triggered when reset has been called and applied to the camera.
  25117. */
  25118. onRestoreStateObservable: Observable<Camera>;
  25119. /** @hidden */
  25120. _cameraRigParams: any;
  25121. /** @hidden */
  25122. _rigCameras: Camera[];
  25123. /** @hidden */
  25124. _rigPostProcess: Nullable<PostProcess>;
  25125. protected _webvrViewMatrix: Matrix;
  25126. /** @hidden */
  25127. _skipRendering: boolean;
  25128. /** @hidden */
  25129. _projectionMatrix: Matrix;
  25130. /** @hidden */
  25131. _postProcesses: Nullable<PostProcess>[];
  25132. /** @hidden */
  25133. _activeMeshes: SmartArray<AbstractMesh>;
  25134. protected _globalPosition: Vector3;
  25135. /** @hidden */
  25136. _computedViewMatrix: Matrix;
  25137. private _doNotComputeProjectionMatrix;
  25138. private _transformMatrix;
  25139. private _frustumPlanes;
  25140. private _refreshFrustumPlanes;
  25141. private _storedFov;
  25142. private _stateStored;
  25143. /**
  25144. * Instantiates a new camera object.
  25145. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25146. * @see http://doc.babylonjs.com/features/cameras
  25147. * @param name Defines the name of the camera in the scene
  25148. * @param position Defines the position of the camera
  25149. * @param scene Defines the scene the camera belongs too
  25150. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25151. */
  25152. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25153. /**
  25154. * Store current camera state (fov, position, etc..)
  25155. * @returns the camera
  25156. */
  25157. storeState(): Camera;
  25158. /**
  25159. * Restores the camera state values if it has been stored. You must call storeState() first
  25160. */
  25161. protected _restoreStateValues(): boolean;
  25162. /**
  25163. * Restored camera state. You must call storeState() first.
  25164. * @returns true if restored and false otherwise
  25165. */
  25166. restoreState(): boolean;
  25167. /**
  25168. * Gets the class name of the camera.
  25169. * @returns the class name
  25170. */
  25171. getClassName(): string;
  25172. /** @hidden */
  25173. readonly _isCamera: boolean;
  25174. /**
  25175. * Gets a string representation of the camera useful for debug purpose.
  25176. * @param fullDetails Defines that a more verboe level of logging is required
  25177. * @returns the string representation
  25178. */
  25179. toString(fullDetails?: boolean): string;
  25180. /**
  25181. * Gets the current world space position of the camera.
  25182. */
  25183. readonly globalPosition: Vector3;
  25184. /**
  25185. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25186. * @returns the active meshe list
  25187. */
  25188. getActiveMeshes(): SmartArray<AbstractMesh>;
  25189. /**
  25190. * Check wether a mesh is part of the current active mesh list of the camera
  25191. * @param mesh Defines the mesh to check
  25192. * @returns true if active, false otherwise
  25193. */
  25194. isActiveMesh(mesh: Mesh): boolean;
  25195. /**
  25196. * Is this camera ready to be used/rendered
  25197. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25198. * @return true if the camera is ready
  25199. */
  25200. isReady(completeCheck?: boolean): boolean;
  25201. /** @hidden */
  25202. _initCache(): void;
  25203. /** @hidden */
  25204. _updateCache(ignoreParentClass?: boolean): void;
  25205. /** @hidden */
  25206. _isSynchronized(): boolean;
  25207. /** @hidden */
  25208. _isSynchronizedViewMatrix(): boolean;
  25209. /** @hidden */
  25210. _isSynchronizedProjectionMatrix(): boolean;
  25211. /**
  25212. * Attach the input controls to a specific dom element to get the input from.
  25213. * @param element Defines the element the controls should be listened from
  25214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25215. */
  25216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25217. /**
  25218. * Detach the current controls from the specified dom element.
  25219. * @param element Defines the element to stop listening the inputs from
  25220. */
  25221. detachControl(element: HTMLElement): void;
  25222. /**
  25223. * Update the camera state according to the different inputs gathered during the frame.
  25224. */
  25225. update(): void;
  25226. /** @hidden */
  25227. _checkInputs(): void;
  25228. /** @hidden */
  25229. readonly rigCameras: Camera[];
  25230. /**
  25231. * Gets the post process used by the rig cameras
  25232. */
  25233. readonly rigPostProcess: Nullable<PostProcess>;
  25234. /**
  25235. * Internal, gets the first post proces.
  25236. * @returns the first post process to be run on this camera.
  25237. */
  25238. _getFirstPostProcess(): Nullable<PostProcess>;
  25239. private _cascadePostProcessesToRigCams;
  25240. /**
  25241. * Attach a post process to the camera.
  25242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25243. * @param postProcess The post process to attach to the camera
  25244. * @param insertAt The position of the post process in case several of them are in use in the scene
  25245. * @returns the position the post process has been inserted at
  25246. */
  25247. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25248. /**
  25249. * Detach a post process to the camera.
  25250. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25251. * @param postProcess The post process to detach from the camera
  25252. */
  25253. detachPostProcess(postProcess: PostProcess): void;
  25254. /**
  25255. * Gets the current world matrix of the camera
  25256. */
  25257. getWorldMatrix(): Matrix;
  25258. /** @hidden */
  25259. _getViewMatrix(): Matrix;
  25260. /**
  25261. * Gets the current view matrix of the camera.
  25262. * @param force forces the camera to recompute the matrix without looking at the cached state
  25263. * @returns the view matrix
  25264. */
  25265. getViewMatrix(force?: boolean): Matrix;
  25266. /**
  25267. * Freeze the projection matrix.
  25268. * It will prevent the cache check of the camera projection compute and can speed up perf
  25269. * if no parameter of the camera are meant to change
  25270. * @param projection Defines manually a projection if necessary
  25271. */
  25272. freezeProjectionMatrix(projection?: Matrix): void;
  25273. /**
  25274. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25275. */
  25276. unfreezeProjectionMatrix(): void;
  25277. /**
  25278. * Gets the current projection matrix of the camera.
  25279. * @param force forces the camera to recompute the matrix without looking at the cached state
  25280. * @returns the projection matrix
  25281. */
  25282. getProjectionMatrix(force?: boolean): Matrix;
  25283. /**
  25284. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25285. * @returns a Matrix
  25286. */
  25287. getTransformationMatrix(): Matrix;
  25288. private _updateFrustumPlanes;
  25289. /**
  25290. * Checks if a cullable object (mesh...) is in the camera frustum
  25291. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25292. * @param target The object to check
  25293. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25294. * @returns true if the object is in frustum otherwise false
  25295. */
  25296. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25297. /**
  25298. * Checks if a cullable object (mesh...) is in the camera frustum
  25299. * Unlike isInFrustum this cheks the full bounding box
  25300. * @param target The object to check
  25301. * @returns true if the object is in frustum otherwise false
  25302. */
  25303. isCompletelyInFrustum(target: ICullable): boolean;
  25304. /**
  25305. * Gets a ray in the forward direction from the camera.
  25306. * @param length Defines the length of the ray to create
  25307. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25308. * @param origin Defines the start point of the ray which defaults to the camera position
  25309. * @returns the forward ray
  25310. */
  25311. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25312. /**
  25313. * Releases resources associated with this node.
  25314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25316. */
  25317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25318. /** @hidden */
  25319. _isLeftCamera: boolean;
  25320. /**
  25321. * Gets the left camera of a rig setup in case of Rigged Camera
  25322. */
  25323. readonly isLeftCamera: boolean;
  25324. /** @hidden */
  25325. _isRightCamera: boolean;
  25326. /**
  25327. * Gets the right camera of a rig setup in case of Rigged Camera
  25328. */
  25329. readonly isRightCamera: boolean;
  25330. /**
  25331. * Gets the left camera of a rig setup in case of Rigged Camera
  25332. */
  25333. readonly leftCamera: Nullable<FreeCamera>;
  25334. /**
  25335. * Gets the right camera of a rig setup in case of Rigged Camera
  25336. */
  25337. readonly rightCamera: Nullable<FreeCamera>;
  25338. /**
  25339. * Gets the left camera target of a rig setup in case of Rigged Camera
  25340. * @returns the target position
  25341. */
  25342. getLeftTarget(): Nullable<Vector3>;
  25343. /**
  25344. * Gets the right camera target of a rig setup in case of Rigged Camera
  25345. * @returns the target position
  25346. */
  25347. getRightTarget(): Nullable<Vector3>;
  25348. /**
  25349. * @hidden
  25350. */
  25351. setCameraRigMode(mode: number, rigParams: any): void;
  25352. /** @hidden */
  25353. static _setStereoscopicRigMode(camera: Camera): void;
  25354. /** @hidden */
  25355. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25356. /** @hidden */
  25357. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25358. /** @hidden */
  25359. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25360. /** @hidden */
  25361. _getVRProjectionMatrix(): Matrix;
  25362. protected _updateCameraRotationMatrix(): void;
  25363. protected _updateWebVRCameraRotationMatrix(): void;
  25364. /**
  25365. * This function MUST be overwritten by the different WebVR cameras available.
  25366. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25367. * @hidden
  25368. */
  25369. _getWebVRProjectionMatrix(): Matrix;
  25370. /**
  25371. * This function MUST be overwritten by the different WebVR cameras available.
  25372. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25373. * @hidden
  25374. */
  25375. _getWebVRViewMatrix(): Matrix;
  25376. /** @hidden */
  25377. setCameraRigParameter(name: string, value: any): void;
  25378. /**
  25379. * needs to be overridden by children so sub has required properties to be copied
  25380. * @hidden
  25381. */
  25382. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25383. /**
  25384. * May need to be overridden by children
  25385. * @hidden
  25386. */
  25387. _updateRigCameras(): void;
  25388. /** @hidden */
  25389. _setupInputs(): void;
  25390. /**
  25391. * Serialiaze the camera setup to a json represention
  25392. * @returns the JSON representation
  25393. */
  25394. serialize(): any;
  25395. /**
  25396. * Clones the current camera.
  25397. * @param name The cloned camera name
  25398. * @returns the cloned camera
  25399. */
  25400. clone(name: string): Camera;
  25401. /**
  25402. * Gets the direction of the camera relative to a given local axis.
  25403. * @param localAxis Defines the reference axis to provide a relative direction.
  25404. * @return the direction
  25405. */
  25406. getDirection(localAxis: Vector3): Vector3;
  25407. /**
  25408. * Returns the current camera absolute rotation
  25409. */
  25410. readonly absoluteRotation: Quaternion;
  25411. /**
  25412. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25413. * @param localAxis Defines the reference axis to provide a relative direction.
  25414. * @param result Defines the vector to store the result in
  25415. */
  25416. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25417. /**
  25418. * Gets a camera constructor for a given camera type
  25419. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25420. * @param name The name of the camera the result will be able to instantiate
  25421. * @param scene The scene the result will construct the camera in
  25422. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25423. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25424. * @returns a factory method to construc the camera
  25425. */
  25426. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25427. /**
  25428. * Compute the world matrix of the camera.
  25429. * @returns the camera world matrix
  25430. */
  25431. computeWorldMatrix(): Matrix;
  25432. /**
  25433. * Parse a JSON and creates the camera from the parsed information
  25434. * @param parsedCamera The JSON to parse
  25435. * @param scene The scene to instantiate the camera in
  25436. * @returns the newly constructed camera
  25437. */
  25438. static Parse(parsedCamera: any, scene: Scene): Camera;
  25439. }
  25440. }
  25441. declare module BABYLON {
  25442. /**
  25443. * Class containing static functions to help procedurally build meshes
  25444. */
  25445. export class DiscBuilder {
  25446. /**
  25447. * Creates a plane polygonal mesh. By default, this is a disc
  25448. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25449. * * 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
  25450. * * 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
  25451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25452. * * 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
  25453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25454. * @param name defines the name of the mesh
  25455. * @param options defines the options used to create the mesh
  25456. * @param scene defines the hosting scene
  25457. * @returns the plane polygonal mesh
  25458. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25459. */
  25460. static CreateDisc(name: string, options: {
  25461. radius?: number;
  25462. tessellation?: number;
  25463. arc?: number;
  25464. updatable?: boolean;
  25465. sideOrientation?: number;
  25466. frontUVs?: Vector4;
  25467. backUVs?: Vector4;
  25468. }, scene?: Nullable<Scene>): Mesh;
  25469. }
  25470. }
  25471. declare module BABYLON {
  25472. /**
  25473. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25474. *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.
  25475. * The SPS is also a particle system. It provides some methods to manage the particles.
  25476. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25477. *
  25478. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25479. */
  25480. export class SolidParticleSystem implements IDisposable {
  25481. /**
  25482. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25483. * Example : var p = SPS.particles[i];
  25484. */
  25485. particles: SolidParticle[];
  25486. /**
  25487. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25488. */
  25489. nbParticles: number;
  25490. /**
  25491. * If the particles must ever face the camera (default false). Useful for planar particles.
  25492. */
  25493. billboard: boolean;
  25494. /**
  25495. * Recompute normals when adding a shape
  25496. */
  25497. recomputeNormals: boolean;
  25498. /**
  25499. * This a counter ofr your own usage. It's not set by any SPS functions.
  25500. */
  25501. counter: number;
  25502. /**
  25503. * The SPS name. This name is also given to the underlying mesh.
  25504. */
  25505. name: string;
  25506. /**
  25507. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25508. */
  25509. mesh: Mesh;
  25510. /**
  25511. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25512. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25513. */
  25514. vars: any;
  25515. /**
  25516. * This array is populated when the SPS is set as 'pickable'.
  25517. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25518. * Each element of this array is an object `{idx: int, faceId: int}`.
  25519. * `idx` is the picked particle index in the `SPS.particles` array
  25520. * `faceId` is the picked face index counted within this particle.
  25521. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25522. */
  25523. pickedParticles: {
  25524. idx: number;
  25525. faceId: number;
  25526. }[];
  25527. /**
  25528. * This array is populated when `enableDepthSort` is set to true.
  25529. * Each element of this array is an instance of the class DepthSortedParticle.
  25530. */
  25531. depthSortedParticles: DepthSortedParticle[];
  25532. /**
  25533. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25534. * @hidden
  25535. */
  25536. _bSphereOnly: boolean;
  25537. /**
  25538. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25539. * @hidden
  25540. */
  25541. _bSphereRadiusFactor: number;
  25542. private _scene;
  25543. private _positions;
  25544. private _indices;
  25545. private _normals;
  25546. private _colors;
  25547. private _uvs;
  25548. private _indices32;
  25549. private _positions32;
  25550. private _normals32;
  25551. private _fixedNormal32;
  25552. private _colors32;
  25553. private _uvs32;
  25554. private _index;
  25555. private _updatable;
  25556. private _pickable;
  25557. private _isVisibilityBoxLocked;
  25558. private _alwaysVisible;
  25559. private _depthSort;
  25560. private _expandable;
  25561. private _shapeCounter;
  25562. private _copy;
  25563. private _color;
  25564. private _computeParticleColor;
  25565. private _computeParticleTexture;
  25566. private _computeParticleRotation;
  25567. private _computeParticleVertex;
  25568. private _computeBoundingBox;
  25569. private _depthSortParticles;
  25570. private _camera;
  25571. private _mustUnrotateFixedNormals;
  25572. private _particlesIntersect;
  25573. private _needs32Bits;
  25574. private _isNotBuilt;
  25575. private _lastParticleId;
  25576. private _idxOfId;
  25577. /**
  25578. * Creates a SPS (Solid Particle System) object.
  25579. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25580. * @param scene (Scene) is the scene in which the SPS is added.
  25581. * @param options defines the options of the sps e.g.
  25582. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25583. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25584. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25585. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25586. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25587. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25588. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25589. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25590. */
  25591. constructor(name: string, scene: Scene, options?: {
  25592. updatable?: boolean;
  25593. isPickable?: boolean;
  25594. enableDepthSort?: boolean;
  25595. particleIntersection?: boolean;
  25596. boundingSphereOnly?: boolean;
  25597. bSphereRadiusFactor?: number;
  25598. expandable?: boolean;
  25599. });
  25600. /**
  25601. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25602. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25603. * @returns the created mesh
  25604. */
  25605. buildMesh(): Mesh;
  25606. /**
  25607. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25608. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25609. * Thus the particles generated from `digest()` have their property `position` set yet.
  25610. * @param mesh ( Mesh ) is the mesh to be digested
  25611. * @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
  25612. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25613. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25614. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25615. * @returns the current SPS
  25616. */
  25617. digest(mesh: Mesh, options?: {
  25618. facetNb?: number;
  25619. number?: number;
  25620. delta?: number;
  25621. storage?: [];
  25622. }): SolidParticleSystem;
  25623. /**
  25624. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  25625. * @hidden
  25626. */
  25627. private _unrotateFixedNormals;
  25628. /**
  25629. * Resets the temporary working copy particle
  25630. * @hidden
  25631. */
  25632. private _resetCopy;
  25633. /**
  25634. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  25635. * @param p the current index in the positions array to be updated
  25636. * @param shape a Vector3 array, the shape geometry
  25637. * @param positions the positions array to be updated
  25638. * @param meshInd the shape indices array
  25639. * @param indices the indices array to be updated
  25640. * @param meshUV the shape uv array
  25641. * @param uvs the uv array to be updated
  25642. * @param meshCol the shape color array
  25643. * @param colors the color array to be updated
  25644. * @param meshNor the shape normals array
  25645. * @param normals the normals array to be updated
  25646. * @param idx the particle index
  25647. * @param idxInShape the particle index in its shape
  25648. * @param options the addShape() method passed options
  25649. * @hidden
  25650. */
  25651. private _meshBuilder;
  25652. /**
  25653. * Returns a shape Vector3 array from positions float array
  25654. * @param positions float array
  25655. * @returns a vector3 array
  25656. * @hidden
  25657. */
  25658. private _posToShape;
  25659. /**
  25660. * Returns a shapeUV array from a float uvs (array deep copy)
  25661. * @param uvs as a float array
  25662. * @returns a shapeUV array
  25663. * @hidden
  25664. */
  25665. private _uvsToShapeUV;
  25666. /**
  25667. * Adds a new particle object in the particles array
  25668. * @param idx particle index in particles array
  25669. * @param id particle id
  25670. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  25671. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  25672. * @param model particle ModelShape object
  25673. * @param shapeId model shape identifier
  25674. * @param idxInShape index of the particle in the current model
  25675. * @param bInfo model bounding info object
  25676. * @param storage target storage array, if any
  25677. * @hidden
  25678. */
  25679. private _addParticle;
  25680. /**
  25681. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25682. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25683. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25684. * @param nb (positive integer) the number of particles to be created from this model
  25685. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25686. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25687. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25688. * @returns the number of shapes in the system
  25689. */
  25690. addShape(mesh: Mesh, nb: number, options?: {
  25691. positionFunction?: any;
  25692. vertexFunction?: any;
  25693. storage?: [];
  25694. }): number;
  25695. /**
  25696. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  25697. * @hidden
  25698. */
  25699. private _rebuildParticle;
  25700. /**
  25701. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25702. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25703. * @returns the SPS.
  25704. */
  25705. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25706. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25707. * Returns an array with the removed particles.
  25708. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25709. * The SPS can't be empty so at least one particle needs to remain in place.
  25710. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25711. * @param start index of the first particle to remove
  25712. * @param end index of the last particle to remove (included)
  25713. * @returns an array populated with the removed particles
  25714. */
  25715. removeParticles(start: number, end: number): SolidParticle[];
  25716. /**
  25717. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  25718. * @param solidParticleArray an array populated with Solid Particles objects
  25719. * @returns the SPS
  25720. */
  25721. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  25722. /**
  25723. * Creates a new particle and modifies the SPS mesh geometry :
  25724. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  25725. * - calls _addParticle() to populate the particle array
  25726. * factorized code from addShape() and insertParticlesFromArray()
  25727. * @param idx particle index in the particles array
  25728. * @param i particle index in its shape
  25729. * @param modelShape particle ModelShape object
  25730. * @param shape shape vertex array
  25731. * @param meshInd shape indices array
  25732. * @param meshUV shape uv array
  25733. * @param meshCol shape color array
  25734. * @param meshNor shape normals array
  25735. * @param bbInfo shape bounding info
  25736. * @param storage target particle storage
  25737. * @options addShape() passed options
  25738. * @hidden
  25739. */
  25740. private _insertNewParticle;
  25741. /**
  25742. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25743. * This method calls `updateParticle()` for each particle of the SPS.
  25744. * For an animated SPS, it is usually called within the render loop.
  25745. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25746. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25747. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25748. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25749. * @returns the SPS.
  25750. */
  25751. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25752. /**
  25753. * Disposes the SPS.
  25754. */
  25755. dispose(): void;
  25756. /**
  25757. * Returns a SolidParticle object from its identifier : particle.id
  25758. * @param id (integer) the particle Id
  25759. * @returns the searched particle or null if not found in the SPS.
  25760. */
  25761. getParticleById(id: number): Nullable<SolidParticle>;
  25762. /**
  25763. * Returns a new array populated with the particles having the passed shapeId.
  25764. * @param shapeId (integer) the shape identifier
  25765. * @returns a new solid particle array
  25766. */
  25767. getParticlesByShapeId(shapeId: number): SolidParticle[];
  25768. /**
  25769. * Populates the passed array "ref" with the particles having the passed shapeId.
  25770. * @param shapeId the shape identifier
  25771. * @returns the SPS
  25772. * @param ref
  25773. */
  25774. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  25775. /**
  25776. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25777. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25778. * @returns the SPS.
  25779. */
  25780. refreshVisibleSize(): SolidParticleSystem;
  25781. /**
  25782. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25783. * @param size the size (float) of the visibility box
  25784. * note : this doesn't lock the SPS mesh bounding box.
  25785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25786. */
  25787. setVisibilityBox(size: number): void;
  25788. /**
  25789. * Gets whether the SPS as always visible or not
  25790. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25791. */
  25792. /**
  25793. * Sets the SPS as always visible or not
  25794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25795. */
  25796. isAlwaysVisible: boolean;
  25797. /**
  25798. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25799. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25800. */
  25801. /**
  25802. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25804. */
  25805. isVisibilityBoxLocked: boolean;
  25806. /**
  25807. * Tells to `setParticles()` to compute the particle rotations or not.
  25808. * Default value : true. The SPS is faster when it's set to false.
  25809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25810. */
  25811. /**
  25812. * Gets if `setParticles()` computes the particle rotations or not.
  25813. * Default value : true. The SPS is faster when it's set to false.
  25814. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25815. */
  25816. computeParticleRotation: boolean;
  25817. /**
  25818. * Tells to `setParticles()` to compute the particle colors or not.
  25819. * Default value : true. The SPS is faster when it's set to false.
  25820. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25821. */
  25822. /**
  25823. * Gets if `setParticles()` computes the particle colors or not.
  25824. * Default value : true. The SPS is faster when it's set to false.
  25825. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25826. */
  25827. computeParticleColor: boolean;
  25828. /**
  25829. * Gets if `setParticles()` computes the particle textures or not.
  25830. * Default value : true. The SPS is faster when it's set to false.
  25831. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25832. */
  25833. computeParticleTexture: boolean;
  25834. /**
  25835. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25836. * Default value : false. The SPS is faster when it's set to false.
  25837. * Note : the particle custom vertex positions aren't stored values.
  25838. */
  25839. /**
  25840. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25841. * Default value : false. The SPS is faster when it's set to false.
  25842. * Note : the particle custom vertex positions aren't stored values.
  25843. */
  25844. computeParticleVertex: boolean;
  25845. /**
  25846. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25847. */
  25848. /**
  25849. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25850. */
  25851. computeBoundingBox: boolean;
  25852. /**
  25853. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25854. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25855. * Default : `true`
  25856. */
  25857. /**
  25858. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25859. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25860. * Default : `true`
  25861. */
  25862. depthSortParticles: boolean;
  25863. /**
  25864. * Gets if the SPS is created as expandable at construction time.
  25865. * Default : `false`
  25866. */
  25867. readonly expandable: boolean;
  25868. /**
  25869. * This function does nothing. It may be overwritten to set all the particle first values.
  25870. * The SPS doesn't call this function, you may have to call it by your own.
  25871. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25872. */
  25873. initParticles(): void;
  25874. /**
  25875. * This function does nothing. It may be overwritten to recycle a particle.
  25876. * The SPS doesn't call this function, you may have to call it by your own.
  25877. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25878. * @param particle The particle to recycle
  25879. * @returns the recycled particle
  25880. */
  25881. recycleParticle(particle: SolidParticle): SolidParticle;
  25882. /**
  25883. * Updates a particle : this function should be overwritten by the user.
  25884. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25886. * @example : just set a particle position or velocity and recycle conditions
  25887. * @param particle The particle to update
  25888. * @returns the updated particle
  25889. */
  25890. updateParticle(particle: SolidParticle): SolidParticle;
  25891. /**
  25892. * Updates a vertex of a particle : it can be overwritten by the user.
  25893. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25894. * @param particle the current particle
  25895. * @param vertex the current index of the current particle
  25896. * @param pt the index of the current vertex in the particle shape
  25897. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25898. * @example : just set a vertex particle position
  25899. * @returns the updated vertex
  25900. */
  25901. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25902. /**
  25903. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25904. * This does nothing and may be overwritten by the user.
  25905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25907. * @param update the boolean update value actually passed to setParticles()
  25908. */
  25909. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25910. /**
  25911. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25912. * This will be passed three parameters.
  25913. * This does nothing and may be overwritten by the user.
  25914. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25915. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25916. * @param update the boolean update value actually passed to setParticles()
  25917. */
  25918. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25919. }
  25920. }
  25921. declare module BABYLON {
  25922. /**
  25923. * Represents one particle of a solid particle system.
  25924. */
  25925. export class SolidParticle {
  25926. /**
  25927. * particle global index
  25928. */
  25929. idx: number;
  25930. /**
  25931. * particle identifier
  25932. */
  25933. id: number;
  25934. /**
  25935. * The color of the particle
  25936. */
  25937. color: Nullable<Color4>;
  25938. /**
  25939. * The world space position of the particle.
  25940. */
  25941. position: Vector3;
  25942. /**
  25943. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25944. */
  25945. rotation: Vector3;
  25946. /**
  25947. * The world space rotation quaternion of the particle.
  25948. */
  25949. rotationQuaternion: Nullable<Quaternion>;
  25950. /**
  25951. * The scaling of the particle.
  25952. */
  25953. scaling: Vector3;
  25954. /**
  25955. * The uvs of the particle.
  25956. */
  25957. uvs: Vector4;
  25958. /**
  25959. * The current speed of the particle.
  25960. */
  25961. velocity: Vector3;
  25962. /**
  25963. * The pivot point in the particle local space.
  25964. */
  25965. pivot: Vector3;
  25966. /**
  25967. * Must the particle be translated from its pivot point in its local space ?
  25968. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25969. * Default : false
  25970. */
  25971. translateFromPivot: boolean;
  25972. /**
  25973. * Is the particle active or not ?
  25974. */
  25975. alive: boolean;
  25976. /**
  25977. * Is the particle visible or not ?
  25978. */
  25979. isVisible: boolean;
  25980. /**
  25981. * Index of this particle in the global "positions" array (Internal use)
  25982. * @hidden
  25983. */
  25984. _pos: number;
  25985. /**
  25986. * @hidden Index of this particle in the global "indices" array (Internal use)
  25987. */
  25988. _ind: number;
  25989. /**
  25990. * @hidden ModelShape of this particle (Internal use)
  25991. */
  25992. _model: ModelShape;
  25993. /**
  25994. * ModelShape id of this particle
  25995. */
  25996. shapeId: number;
  25997. /**
  25998. * Index of the particle in its shape id
  25999. */
  26000. idxInShape: number;
  26001. /**
  26002. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26003. */
  26004. _modelBoundingInfo: BoundingInfo;
  26005. /**
  26006. * @hidden Particle BoundingInfo object (Internal use)
  26007. */
  26008. _boundingInfo: BoundingInfo;
  26009. /**
  26010. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26011. */
  26012. _sps: SolidParticleSystem;
  26013. /**
  26014. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26015. */
  26016. _stillInvisible: boolean;
  26017. /**
  26018. * @hidden Last computed particle rotation matrix
  26019. */
  26020. _rotationMatrix: number[];
  26021. /**
  26022. * Parent particle Id, if any.
  26023. * Default null.
  26024. */
  26025. parentId: Nullable<number>;
  26026. /**
  26027. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26028. * The possible values are :
  26029. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26030. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26033. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26034. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26035. * */
  26036. cullingStrategy: number;
  26037. /**
  26038. * @hidden Internal global position in the SPS.
  26039. */
  26040. _globalPosition: Vector3;
  26041. /**
  26042. * Creates a Solid Particle object.
  26043. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26044. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26045. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26046. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26047. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26048. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26049. * @param shapeId (integer) is the model shape identifier in the SPS.
  26050. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26051. * @param sps defines the sps it is associated to
  26052. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26053. */
  26054. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26055. /**
  26056. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26057. * @param target the particle target
  26058. * @returns the current particle
  26059. */
  26060. copyToRef(target: SolidParticle): SolidParticle;
  26061. /**
  26062. * Legacy support, changed scale to scaling
  26063. */
  26064. /**
  26065. * Legacy support, changed scale to scaling
  26066. */
  26067. scale: Vector3;
  26068. /**
  26069. * Legacy support, changed quaternion to rotationQuaternion
  26070. */
  26071. /**
  26072. * Legacy support, changed quaternion to rotationQuaternion
  26073. */
  26074. quaternion: Nullable<Quaternion>;
  26075. /**
  26076. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26077. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26078. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26079. * @returns true if it intersects
  26080. */
  26081. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26082. /**
  26083. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26084. * A particle is in the frustum if its bounding box intersects the frustum
  26085. * @param frustumPlanes defines the frustum to test
  26086. * @returns true if the particle is in the frustum planes
  26087. */
  26088. isInFrustum(frustumPlanes: Plane[]): boolean;
  26089. /**
  26090. * get the rotation matrix of the particle
  26091. * @hidden
  26092. */
  26093. getRotationMatrix(m: Matrix): void;
  26094. }
  26095. /**
  26096. * Represents the shape of the model used by one particle of a solid particle system.
  26097. * SPS internal tool, don't use it manually.
  26098. */
  26099. export class ModelShape {
  26100. /**
  26101. * The shape id
  26102. * @hidden
  26103. */
  26104. shapeID: number;
  26105. /**
  26106. * flat array of model positions (internal use)
  26107. * @hidden
  26108. */
  26109. _shape: Vector3[];
  26110. /**
  26111. * flat array of model UVs (internal use)
  26112. * @hidden
  26113. */
  26114. _shapeUV: number[];
  26115. /**
  26116. * color array of the model
  26117. * @hidden
  26118. */
  26119. _shapeColors: number[];
  26120. /**
  26121. * indices array of the model
  26122. * @hidden
  26123. */
  26124. _indices: number[];
  26125. /**
  26126. * normals array of the model
  26127. * @hidden
  26128. */
  26129. _normals: number[];
  26130. /**
  26131. * length of the shape in the model indices array (internal use)
  26132. * @hidden
  26133. */
  26134. _indicesLength: number;
  26135. /**
  26136. * Custom position function (internal use)
  26137. * @hidden
  26138. */
  26139. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26140. /**
  26141. * Custom vertex function (internal use)
  26142. * @hidden
  26143. */
  26144. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26145. /**
  26146. * 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.
  26147. * SPS internal tool, don't use it manually.
  26148. * @hidden
  26149. */
  26150. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26151. }
  26152. /**
  26153. * Represents a Depth Sorted Particle in the solid particle system.
  26154. */
  26155. export class DepthSortedParticle {
  26156. /**
  26157. * Index of the particle in the "indices" array
  26158. */
  26159. ind: number;
  26160. /**
  26161. * Length of the particle shape in the "indices" array
  26162. */
  26163. indicesLength: number;
  26164. /**
  26165. * Squared distance from the particle to the camera
  26166. */
  26167. sqDistance: number;
  26168. }
  26169. }
  26170. declare module BABYLON {
  26171. /**
  26172. * @hidden
  26173. */
  26174. export class _MeshCollisionData {
  26175. _checkCollisions: boolean;
  26176. _collisionMask: number;
  26177. _collisionGroup: number;
  26178. _collider: Nullable<Collider>;
  26179. _oldPositionForCollisions: Vector3;
  26180. _diffPositionForCollisions: Vector3;
  26181. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26182. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26183. }
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. class _FacetDataStorage {
  26188. facetPositions: Vector3[];
  26189. facetNormals: Vector3[];
  26190. facetPartitioning: number[][];
  26191. facetNb: number;
  26192. partitioningSubdivisions: number;
  26193. partitioningBBoxRatio: number;
  26194. facetDataEnabled: boolean;
  26195. facetParameters: any;
  26196. bbSize: Vector3;
  26197. subDiv: {
  26198. max: number;
  26199. X: number;
  26200. Y: number;
  26201. Z: number;
  26202. };
  26203. facetDepthSort: boolean;
  26204. facetDepthSortEnabled: boolean;
  26205. depthSortedIndices: IndicesArray;
  26206. depthSortedFacets: {
  26207. ind: number;
  26208. sqDistance: number;
  26209. }[];
  26210. facetDepthSortFunction: (f1: {
  26211. ind: number;
  26212. sqDistance: number;
  26213. }, f2: {
  26214. ind: number;
  26215. sqDistance: number;
  26216. }) => number;
  26217. facetDepthSortFrom: Vector3;
  26218. facetDepthSortOrigin: Vector3;
  26219. invertedMatrix: Matrix;
  26220. }
  26221. /**
  26222. * @hidden
  26223. **/
  26224. class _InternalAbstractMeshDataInfo {
  26225. _hasVertexAlpha: boolean;
  26226. _useVertexColors: boolean;
  26227. _numBoneInfluencers: number;
  26228. _applyFog: boolean;
  26229. _receiveShadows: boolean;
  26230. _facetData: _FacetDataStorage;
  26231. _visibility: number;
  26232. _skeleton: Nullable<Skeleton>;
  26233. _layerMask: number;
  26234. _computeBonesUsingShaders: boolean;
  26235. _isActive: boolean;
  26236. _onlyForInstances: boolean;
  26237. _isActiveIntermediate: boolean;
  26238. _onlyForInstancesIntermediate: boolean;
  26239. _actAsRegularMesh: boolean;
  26240. }
  26241. /**
  26242. * Class used to store all common mesh properties
  26243. */
  26244. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26245. /** No occlusion */
  26246. static OCCLUSION_TYPE_NONE: number;
  26247. /** Occlusion set to optimisitic */
  26248. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26249. /** Occlusion set to strict */
  26250. static OCCLUSION_TYPE_STRICT: number;
  26251. /** Use an accurante occlusion algorithm */
  26252. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26253. /** Use a conservative occlusion algorithm */
  26254. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26255. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26256. * Test order :
  26257. * Is the bounding sphere outside the frustum ?
  26258. * If not, are the bounding box vertices outside the frustum ?
  26259. * It not, then the cullable object is in the frustum.
  26260. */
  26261. static readonly CULLINGSTRATEGY_STANDARD: number;
  26262. /** Culling strategy : Bounding Sphere Only.
  26263. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26264. * It's also less accurate than the standard because some not visible objects can still be selected.
  26265. * Test : is the bounding sphere outside the frustum ?
  26266. * If not, then the cullable object is in the frustum.
  26267. */
  26268. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26269. /** Culling strategy : Optimistic Inclusion.
  26270. * This in an inclusion test first, then the standard exclusion test.
  26271. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26272. * 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.
  26273. * Anyway, it's as accurate as the standard strategy.
  26274. * Test :
  26275. * Is the cullable object bounding sphere center in the frustum ?
  26276. * If not, apply the default culling strategy.
  26277. */
  26278. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26279. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26280. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26281. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26282. * 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.
  26283. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26284. * Test :
  26285. * Is the cullable object bounding sphere center in the frustum ?
  26286. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26287. */
  26288. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26289. /**
  26290. * No billboard
  26291. */
  26292. static readonly BILLBOARDMODE_NONE: number;
  26293. /** Billboard on X axis */
  26294. static readonly BILLBOARDMODE_X: number;
  26295. /** Billboard on Y axis */
  26296. static readonly BILLBOARDMODE_Y: number;
  26297. /** Billboard on Z axis */
  26298. static readonly BILLBOARDMODE_Z: number;
  26299. /** Billboard on all axes */
  26300. static readonly BILLBOARDMODE_ALL: number;
  26301. /** Billboard on using position instead of orientation */
  26302. static readonly BILLBOARDMODE_USE_POSITION: number;
  26303. /** @hidden */
  26304. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26305. /**
  26306. * The culling strategy to use to check whether the mesh must be rendered or not.
  26307. * This value can be changed at any time and will be used on the next render mesh selection.
  26308. * The possible values are :
  26309. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26310. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26313. * Please read each static variable documentation to get details about the culling process.
  26314. * */
  26315. cullingStrategy: number;
  26316. /**
  26317. * Gets the number of facets in the mesh
  26318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26319. */
  26320. readonly facetNb: number;
  26321. /**
  26322. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26324. */
  26325. partitioningSubdivisions: number;
  26326. /**
  26327. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26328. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26330. */
  26331. partitioningBBoxRatio: number;
  26332. /**
  26333. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26334. * Works only for updatable meshes.
  26335. * Doesn't work with multi-materials
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26337. */
  26338. mustDepthSortFacets: boolean;
  26339. /**
  26340. * The location (Vector3) where the facet depth sort must be computed from.
  26341. * By default, the active camera position.
  26342. * Used only when facet depth sort is enabled
  26343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26344. */
  26345. facetDepthSortFrom: Vector3;
  26346. /**
  26347. * gets a boolean indicating if facetData is enabled
  26348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26349. */
  26350. readonly isFacetDataEnabled: boolean;
  26351. /** @hidden */
  26352. _updateNonUniformScalingState(value: boolean): boolean;
  26353. /**
  26354. * An event triggered when this mesh collides with another one
  26355. */
  26356. onCollideObservable: Observable<AbstractMesh>;
  26357. /** Set a function to call when this mesh collides with another one */
  26358. onCollide: () => void;
  26359. /**
  26360. * An event triggered when the collision's position changes
  26361. */
  26362. onCollisionPositionChangeObservable: Observable<Vector3>;
  26363. /** Set a function to call when the collision's position changes */
  26364. onCollisionPositionChange: () => void;
  26365. /**
  26366. * An event triggered when material is changed
  26367. */
  26368. onMaterialChangedObservable: Observable<AbstractMesh>;
  26369. /**
  26370. * Gets or sets the orientation for POV movement & rotation
  26371. */
  26372. definedFacingForward: boolean;
  26373. /** @hidden */
  26374. _occlusionQuery: Nullable<WebGLQuery>;
  26375. /** @hidden */
  26376. _renderingGroup: Nullable<RenderingGroup>;
  26377. /**
  26378. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26379. */
  26380. /**
  26381. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26382. */
  26383. visibility: number;
  26384. /** Gets or sets the alpha index used to sort transparent meshes
  26385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26386. */
  26387. alphaIndex: number;
  26388. /**
  26389. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26390. */
  26391. isVisible: boolean;
  26392. /**
  26393. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26394. */
  26395. isPickable: boolean;
  26396. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26397. showSubMeshesBoundingBox: boolean;
  26398. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26399. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26400. */
  26401. isBlocker: boolean;
  26402. /**
  26403. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26404. */
  26405. enablePointerMoveEvents: boolean;
  26406. /**
  26407. * Specifies the rendering group id for this mesh (0 by default)
  26408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26409. */
  26410. renderingGroupId: number;
  26411. private _material;
  26412. /** Gets or sets current material */
  26413. material: Nullable<Material>;
  26414. /**
  26415. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26416. * @see http://doc.babylonjs.com/babylon101/shadows
  26417. */
  26418. receiveShadows: boolean;
  26419. /** Defines color to use when rendering outline */
  26420. outlineColor: Color3;
  26421. /** Define width to use when rendering outline */
  26422. outlineWidth: number;
  26423. /** Defines color to use when rendering overlay */
  26424. overlayColor: Color3;
  26425. /** Defines alpha to use when rendering overlay */
  26426. overlayAlpha: number;
  26427. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26428. hasVertexAlpha: boolean;
  26429. /** 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) */
  26430. useVertexColors: boolean;
  26431. /**
  26432. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26433. */
  26434. computeBonesUsingShaders: boolean;
  26435. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26436. numBoneInfluencers: number;
  26437. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26438. applyFog: boolean;
  26439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26440. useOctreeForRenderingSelection: boolean;
  26441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26442. useOctreeForPicking: boolean;
  26443. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26444. useOctreeForCollisions: boolean;
  26445. /**
  26446. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26447. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26448. */
  26449. layerMask: number;
  26450. /**
  26451. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26452. */
  26453. alwaysSelectAsActiveMesh: boolean;
  26454. /**
  26455. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26456. */
  26457. doNotSyncBoundingInfo: boolean;
  26458. /**
  26459. * Gets or sets the current action manager
  26460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26461. */
  26462. actionManager: Nullable<AbstractActionManager>;
  26463. private _meshCollisionData;
  26464. /**
  26465. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26467. */
  26468. ellipsoid: Vector3;
  26469. /**
  26470. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26472. */
  26473. ellipsoidOffset: Vector3;
  26474. /**
  26475. * Gets or sets a collision mask used to mask collisions (default is -1).
  26476. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26477. */
  26478. collisionMask: number;
  26479. /**
  26480. * Gets or sets the current collision group mask (-1 by default).
  26481. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26482. */
  26483. collisionGroup: number;
  26484. /**
  26485. * Defines edge width used when edgesRenderer is enabled
  26486. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26487. */
  26488. edgesWidth: number;
  26489. /**
  26490. * Defines edge color used when edgesRenderer is enabled
  26491. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26492. */
  26493. edgesColor: Color4;
  26494. /** @hidden */
  26495. _edgesRenderer: Nullable<IEdgesRenderer>;
  26496. /** @hidden */
  26497. _masterMesh: Nullable<AbstractMesh>;
  26498. /** @hidden */
  26499. _boundingInfo: Nullable<BoundingInfo>;
  26500. /** @hidden */
  26501. _renderId: number;
  26502. /**
  26503. * Gets or sets the list of subMeshes
  26504. * @see http://doc.babylonjs.com/how_to/multi_materials
  26505. */
  26506. subMeshes: SubMesh[];
  26507. /** @hidden */
  26508. _intersectionsInProgress: AbstractMesh[];
  26509. /** @hidden */
  26510. _unIndexed: boolean;
  26511. /** @hidden */
  26512. _lightSources: Light[];
  26513. /** Gets the list of lights affecting that mesh */
  26514. readonly lightSources: Light[];
  26515. /** @hidden */
  26516. readonly _positions: Nullable<Vector3[]>;
  26517. /** @hidden */
  26518. _waitingData: {
  26519. lods: Nullable<any>;
  26520. actions: Nullable<any>;
  26521. freezeWorldMatrix: Nullable<boolean>;
  26522. };
  26523. /** @hidden */
  26524. _bonesTransformMatrices: Nullable<Float32Array>;
  26525. /** @hidden */
  26526. _transformMatrixTexture: Nullable<RawTexture>;
  26527. /**
  26528. * Gets or sets a skeleton to apply skining transformations
  26529. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26530. */
  26531. skeleton: Nullable<Skeleton>;
  26532. /**
  26533. * An event triggered when the mesh is rebuilt.
  26534. */
  26535. onRebuildObservable: Observable<AbstractMesh>;
  26536. /**
  26537. * Creates a new AbstractMesh
  26538. * @param name defines the name of the mesh
  26539. * @param scene defines the hosting scene
  26540. */
  26541. constructor(name: string, scene?: Nullable<Scene>);
  26542. /**
  26543. * Returns the string "AbstractMesh"
  26544. * @returns "AbstractMesh"
  26545. */
  26546. getClassName(): string;
  26547. /**
  26548. * Gets a string representation of the current mesh
  26549. * @param fullDetails defines a boolean indicating if full details must be included
  26550. * @returns a string representation of the current mesh
  26551. */
  26552. toString(fullDetails?: boolean): string;
  26553. /**
  26554. * @hidden
  26555. */
  26556. protected _getEffectiveParent(): Nullable<Node>;
  26557. /** @hidden */
  26558. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26559. /** @hidden */
  26560. _rebuild(): void;
  26561. /** @hidden */
  26562. _resyncLightSources(): void;
  26563. /** @hidden */
  26564. _resyncLighSource(light: Light): void;
  26565. /** @hidden */
  26566. _unBindEffect(): void;
  26567. /** @hidden */
  26568. _removeLightSource(light: Light, dispose: boolean): void;
  26569. private _markSubMeshesAsDirty;
  26570. /** @hidden */
  26571. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26572. /** @hidden */
  26573. _markSubMeshesAsAttributesDirty(): void;
  26574. /** @hidden */
  26575. _markSubMeshesAsMiscDirty(): void;
  26576. /**
  26577. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26578. */
  26579. scaling: Vector3;
  26580. /**
  26581. * Returns true if the mesh is blocked. Implemented by child classes
  26582. */
  26583. readonly isBlocked: boolean;
  26584. /**
  26585. * Returns the mesh itself by default. Implemented by child classes
  26586. * @param camera defines the camera to use to pick the right LOD level
  26587. * @returns the currentAbstractMesh
  26588. */
  26589. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26590. /**
  26591. * Returns 0 by default. Implemented by child classes
  26592. * @returns an integer
  26593. */
  26594. getTotalVertices(): number;
  26595. /**
  26596. * Returns a positive integer : the total number of indices in this mesh geometry.
  26597. * @returns the numner of indices or zero if the mesh has no geometry.
  26598. */
  26599. getTotalIndices(): number;
  26600. /**
  26601. * Returns null by default. Implemented by child classes
  26602. * @returns null
  26603. */
  26604. getIndices(): Nullable<IndicesArray>;
  26605. /**
  26606. * Returns the array of the requested vertex data kind. Implemented by child classes
  26607. * @param kind defines the vertex data kind to use
  26608. * @returns null
  26609. */
  26610. getVerticesData(kind: string): Nullable<FloatArray>;
  26611. /**
  26612. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26613. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26614. * Note that a new underlying VertexBuffer object is created each call.
  26615. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26616. * @param kind defines vertex data kind:
  26617. * * VertexBuffer.PositionKind
  26618. * * VertexBuffer.UVKind
  26619. * * VertexBuffer.UV2Kind
  26620. * * VertexBuffer.UV3Kind
  26621. * * VertexBuffer.UV4Kind
  26622. * * VertexBuffer.UV5Kind
  26623. * * VertexBuffer.UV6Kind
  26624. * * VertexBuffer.ColorKind
  26625. * * VertexBuffer.MatricesIndicesKind
  26626. * * VertexBuffer.MatricesIndicesExtraKind
  26627. * * VertexBuffer.MatricesWeightsKind
  26628. * * VertexBuffer.MatricesWeightsExtraKind
  26629. * @param data defines the data source
  26630. * @param updatable defines if the data must be flagged as updatable (or static)
  26631. * @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
  26632. * @returns the current mesh
  26633. */
  26634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26635. /**
  26636. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26637. * If the mesh has no geometry, it is simply returned as it is.
  26638. * @param kind defines vertex data kind:
  26639. * * VertexBuffer.PositionKind
  26640. * * VertexBuffer.UVKind
  26641. * * VertexBuffer.UV2Kind
  26642. * * VertexBuffer.UV3Kind
  26643. * * VertexBuffer.UV4Kind
  26644. * * VertexBuffer.UV5Kind
  26645. * * VertexBuffer.UV6Kind
  26646. * * VertexBuffer.ColorKind
  26647. * * VertexBuffer.MatricesIndicesKind
  26648. * * VertexBuffer.MatricesIndicesExtraKind
  26649. * * VertexBuffer.MatricesWeightsKind
  26650. * * VertexBuffer.MatricesWeightsExtraKind
  26651. * @param data defines the data source
  26652. * @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
  26653. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26654. * @returns the current mesh
  26655. */
  26656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26657. /**
  26658. * Sets the mesh indices,
  26659. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26660. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26661. * @param totalVertices Defines the total number of vertices
  26662. * @returns the current mesh
  26663. */
  26664. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26665. /**
  26666. * Gets a boolean indicating if specific vertex data is present
  26667. * @param kind defines the vertex data kind to use
  26668. * @returns true is data kind is present
  26669. */
  26670. isVerticesDataPresent(kind: string): boolean;
  26671. /**
  26672. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26673. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26674. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26675. * @returns a BoundingInfo
  26676. */
  26677. getBoundingInfo(): BoundingInfo;
  26678. /**
  26679. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26680. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26681. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26682. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26683. * @returns the current mesh
  26684. */
  26685. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26686. /**
  26687. * Overwrite the current bounding info
  26688. * @param boundingInfo defines the new bounding info
  26689. * @returns the current mesh
  26690. */
  26691. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26692. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26693. readonly useBones: boolean;
  26694. /** @hidden */
  26695. _preActivate(): void;
  26696. /** @hidden */
  26697. _preActivateForIntermediateRendering(renderId: number): void;
  26698. /** @hidden */
  26699. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26700. /** @hidden */
  26701. _postActivate(): void;
  26702. /** @hidden */
  26703. _freeze(): void;
  26704. /** @hidden */
  26705. _unFreeze(): void;
  26706. /**
  26707. * Gets the current world matrix
  26708. * @returns a Matrix
  26709. */
  26710. getWorldMatrix(): Matrix;
  26711. /** @hidden */
  26712. _getWorldMatrixDeterminant(): number;
  26713. /**
  26714. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26715. */
  26716. readonly isAnInstance: boolean;
  26717. /**
  26718. * Gets a boolean indicating if this mesh has instances
  26719. */
  26720. readonly hasInstances: boolean;
  26721. /**
  26722. * Perform relative position change from the point of view of behind the front of the mesh.
  26723. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26724. * Supports definition of mesh facing forward or backward
  26725. * @param amountRight defines the distance on the right axis
  26726. * @param amountUp defines the distance on the up axis
  26727. * @param amountForward defines the distance on the forward axis
  26728. * @returns the current mesh
  26729. */
  26730. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26731. /**
  26732. * Calculate relative position change from the point of view of behind the front of the mesh.
  26733. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26734. * Supports definition of mesh facing forward or backward
  26735. * @param amountRight defines the distance on the right axis
  26736. * @param amountUp defines the distance on the up axis
  26737. * @param amountForward defines the distance on the forward axis
  26738. * @returns the new displacement vector
  26739. */
  26740. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26741. /**
  26742. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26743. * Supports definition of mesh facing forward or backward
  26744. * @param flipBack defines the flip
  26745. * @param twirlClockwise defines the twirl
  26746. * @param tiltRight defines the tilt
  26747. * @returns the current mesh
  26748. */
  26749. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26750. /**
  26751. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26752. * Supports definition of mesh facing forward or backward.
  26753. * @param flipBack defines the flip
  26754. * @param twirlClockwise defines the twirl
  26755. * @param tiltRight defines the tilt
  26756. * @returns the new rotation vector
  26757. */
  26758. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26759. /**
  26760. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26761. * This means the mesh underlying bounding box and sphere are recomputed.
  26762. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26763. * @returns the current mesh
  26764. */
  26765. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26766. /** @hidden */
  26767. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26768. /** @hidden */
  26769. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26770. /** @hidden */
  26771. _updateBoundingInfo(): AbstractMesh;
  26772. /** @hidden */
  26773. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26774. /** @hidden */
  26775. protected _afterComputeWorldMatrix(): void;
  26776. /** @hidden */
  26777. readonly _effectiveMesh: AbstractMesh;
  26778. /**
  26779. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26780. * A mesh is in the frustum if its bounding box intersects the frustum
  26781. * @param frustumPlanes defines the frustum to test
  26782. * @returns true if the mesh is in the frustum planes
  26783. */
  26784. isInFrustum(frustumPlanes: Plane[]): boolean;
  26785. /**
  26786. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26787. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26788. * @param frustumPlanes defines the frustum to test
  26789. * @returns true if the mesh is completely in the frustum planes
  26790. */
  26791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26792. /**
  26793. * True if the mesh intersects another mesh or a SolidParticle object
  26794. * @param mesh defines a target mesh or SolidParticle to test
  26795. * @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)
  26796. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26797. * @returns true if there is an intersection
  26798. */
  26799. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26800. /**
  26801. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26802. * @param point defines the point to test
  26803. * @returns true if there is an intersection
  26804. */
  26805. intersectsPoint(point: Vector3): boolean;
  26806. /**
  26807. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26809. */
  26810. checkCollisions: boolean;
  26811. /**
  26812. * Gets Collider object used to compute collisions (not physics)
  26813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26814. */
  26815. readonly collider: Nullable<Collider>;
  26816. /**
  26817. * Move the mesh using collision engine
  26818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26819. * @param displacement defines the requested displacement vector
  26820. * @returns the current mesh
  26821. */
  26822. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26823. private _onCollisionPositionChange;
  26824. /** @hidden */
  26825. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26826. /** @hidden */
  26827. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26828. /** @hidden */
  26829. _checkCollision(collider: Collider): AbstractMesh;
  26830. /** @hidden */
  26831. _generatePointsArray(): boolean;
  26832. /**
  26833. * Checks if the passed Ray intersects with the mesh
  26834. * @param ray defines the ray to use
  26835. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26836. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26837. * @returns the picking info
  26838. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26839. */
  26840. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26841. /**
  26842. * Clones the current mesh
  26843. * @param name defines the mesh name
  26844. * @param newParent defines the new mesh parent
  26845. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26846. * @returns the new mesh
  26847. */
  26848. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26849. /**
  26850. * Disposes all the submeshes of the current meshnp
  26851. * @returns the current mesh
  26852. */
  26853. releaseSubMeshes(): AbstractMesh;
  26854. /**
  26855. * Releases resources associated with this abstract mesh.
  26856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26858. */
  26859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26860. /**
  26861. * Adds the passed mesh as a child to the current mesh
  26862. * @param mesh defines the child mesh
  26863. * @returns the current mesh
  26864. */
  26865. addChild(mesh: AbstractMesh): AbstractMesh;
  26866. /**
  26867. * Removes the passed mesh from the current mesh children list
  26868. * @param mesh defines the child mesh
  26869. * @returns the current mesh
  26870. */
  26871. removeChild(mesh: AbstractMesh): AbstractMesh;
  26872. /** @hidden */
  26873. private _initFacetData;
  26874. /**
  26875. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26876. * This method can be called within the render loop.
  26877. * 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
  26878. * @returns the current mesh
  26879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26880. */
  26881. updateFacetData(): AbstractMesh;
  26882. /**
  26883. * Returns the facetLocalNormals array.
  26884. * The normals are expressed in the mesh local spac
  26885. * @returns an array of Vector3
  26886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26887. */
  26888. getFacetLocalNormals(): Vector3[];
  26889. /**
  26890. * Returns the facetLocalPositions array.
  26891. * The facet positions are expressed in the mesh local space
  26892. * @returns an array of Vector3
  26893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26894. */
  26895. getFacetLocalPositions(): Vector3[];
  26896. /**
  26897. * Returns the facetLocalPartioning array
  26898. * @returns an array of array of numbers
  26899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26900. */
  26901. getFacetLocalPartitioning(): number[][];
  26902. /**
  26903. * Returns the i-th facet position in the world system.
  26904. * This method allocates a new Vector3 per call
  26905. * @param i defines the facet index
  26906. * @returns a new Vector3
  26907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26908. */
  26909. getFacetPosition(i: number): Vector3;
  26910. /**
  26911. * Sets the reference Vector3 with the i-th facet position in the world system
  26912. * @param i defines the facet index
  26913. * @param ref defines the target vector
  26914. * @returns the current mesh
  26915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26916. */
  26917. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26918. /**
  26919. * Returns the i-th facet normal in the world system.
  26920. * This method allocates a new Vector3 per call
  26921. * @param i defines the facet index
  26922. * @returns a new Vector3
  26923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26924. */
  26925. getFacetNormal(i: number): Vector3;
  26926. /**
  26927. * Sets the reference Vector3 with the i-th facet normal in the world system
  26928. * @param i defines the facet index
  26929. * @param ref defines the target vector
  26930. * @returns the current mesh
  26931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26932. */
  26933. getFacetNormalToRef(i: number, ref: Vector3): this;
  26934. /**
  26935. * 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)
  26936. * @param x defines x coordinate
  26937. * @param y defines y coordinate
  26938. * @param z defines z coordinate
  26939. * @returns the array of facet indexes
  26940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26941. */
  26942. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26943. /**
  26944. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26945. * @param projected sets as the (x,y,z) world projection on the facet
  26946. * @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
  26947. * @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
  26948. * @param x defines x coordinate
  26949. * @param y defines y coordinate
  26950. * @param z defines z coordinate
  26951. * @returns the face index if found (or null instead)
  26952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26953. */
  26954. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26955. /**
  26956. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26957. * @param projected sets as the (x,y,z) local projection on the facet
  26958. * @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
  26959. * @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
  26960. * @param x defines x coordinate
  26961. * @param y defines y coordinate
  26962. * @param z defines z coordinate
  26963. * @returns the face index if found (or null instead)
  26964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26965. */
  26966. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26967. /**
  26968. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26969. * @returns the parameters
  26970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26971. */
  26972. getFacetDataParameters(): any;
  26973. /**
  26974. * Disables the feature FacetData and frees the related memory
  26975. * @returns the current mesh
  26976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26977. */
  26978. disableFacetData(): AbstractMesh;
  26979. /**
  26980. * Updates the AbstractMesh indices array
  26981. * @param indices defines the data source
  26982. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26983. * @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)
  26984. * @returns the current mesh
  26985. */
  26986. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26987. /**
  26988. * Creates new normals data for the mesh
  26989. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26990. * @returns the current mesh
  26991. */
  26992. createNormals(updatable: boolean): AbstractMesh;
  26993. /**
  26994. * Align the mesh with a normal
  26995. * @param normal defines the normal to use
  26996. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26997. * @returns the current mesh
  26998. */
  26999. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27000. /** @hidden */
  27001. _checkOcclusionQuery(): boolean;
  27002. /**
  27003. * Disables the mesh edge rendering mode
  27004. * @returns the currentAbstractMesh
  27005. */
  27006. disableEdgesRendering(): AbstractMesh;
  27007. /**
  27008. * Enables the edge rendering mode on the mesh.
  27009. * This mode makes the mesh edges visible
  27010. * @param epsilon defines the maximal distance between two angles to detect a face
  27011. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27012. * @returns the currentAbstractMesh
  27013. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27014. */
  27015. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27016. }
  27017. }
  27018. declare module BABYLON {
  27019. /**
  27020. * Interface used to define ActionEvent
  27021. */
  27022. export interface IActionEvent {
  27023. /** The mesh or sprite that triggered the action */
  27024. source: any;
  27025. /** The X mouse cursor position at the time of the event */
  27026. pointerX: number;
  27027. /** The Y mouse cursor position at the time of the event */
  27028. pointerY: number;
  27029. /** The mesh that is currently pointed at (can be null) */
  27030. meshUnderPointer: Nullable<AbstractMesh>;
  27031. /** the original (browser) event that triggered the ActionEvent */
  27032. sourceEvent?: any;
  27033. /** additional data for the event */
  27034. additionalData?: any;
  27035. }
  27036. /**
  27037. * ActionEvent is the event being sent when an action is triggered.
  27038. */
  27039. export class ActionEvent implements IActionEvent {
  27040. /** The mesh or sprite that triggered the action */
  27041. source: any;
  27042. /** The X mouse cursor position at the time of the event */
  27043. pointerX: number;
  27044. /** The Y mouse cursor position at the time of the event */
  27045. pointerY: number;
  27046. /** The mesh that is currently pointed at (can be null) */
  27047. meshUnderPointer: Nullable<AbstractMesh>;
  27048. /** the original (browser) event that triggered the ActionEvent */
  27049. sourceEvent?: any;
  27050. /** additional data for the event */
  27051. additionalData?: any;
  27052. /**
  27053. * Creates a new ActionEvent
  27054. * @param source The mesh or sprite that triggered the action
  27055. * @param pointerX The X mouse cursor position at the time of the event
  27056. * @param pointerY The Y mouse cursor position at the time of the event
  27057. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27058. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27059. * @param additionalData additional data for the event
  27060. */
  27061. constructor(
  27062. /** The mesh or sprite that triggered the action */
  27063. source: any,
  27064. /** The X mouse cursor position at the time of the event */
  27065. pointerX: number,
  27066. /** The Y mouse cursor position at the time of the event */
  27067. pointerY: number,
  27068. /** The mesh that is currently pointed at (can be null) */
  27069. meshUnderPointer: Nullable<AbstractMesh>,
  27070. /** the original (browser) event that triggered the ActionEvent */
  27071. sourceEvent?: any,
  27072. /** additional data for the event */
  27073. additionalData?: any);
  27074. /**
  27075. * Helper function to auto-create an ActionEvent from a source mesh.
  27076. * @param source The source mesh that triggered the event
  27077. * @param evt The original (browser) event
  27078. * @param additionalData additional data for the event
  27079. * @returns the new ActionEvent
  27080. */
  27081. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27082. /**
  27083. * Helper function to auto-create an ActionEvent from a source sprite
  27084. * @param source The source sprite that triggered the event
  27085. * @param scene Scene associated with the sprite
  27086. * @param evt The original (browser) event
  27087. * @param additionalData additional data for the event
  27088. * @returns the new ActionEvent
  27089. */
  27090. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27091. /**
  27092. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27093. * @param scene the scene where the event occurred
  27094. * @param evt The original (browser) event
  27095. * @returns the new ActionEvent
  27096. */
  27097. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27098. /**
  27099. * Helper function to auto-create an ActionEvent from a primitive
  27100. * @param prim defines the target primitive
  27101. * @param pointerPos defines the pointer position
  27102. * @param evt The original (browser) event
  27103. * @param additionalData additional data for the event
  27104. * @returns the new ActionEvent
  27105. */
  27106. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27107. }
  27108. }
  27109. declare module BABYLON {
  27110. /**
  27111. * Abstract class used to decouple action Manager from scene and meshes.
  27112. * Do not instantiate.
  27113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27114. */
  27115. export abstract class AbstractActionManager implements IDisposable {
  27116. /** Gets the list of active triggers */
  27117. static Triggers: {
  27118. [key: string]: number;
  27119. };
  27120. /** Gets the cursor to use when hovering items */
  27121. hoverCursor: string;
  27122. /** Gets the list of actions */
  27123. actions: IAction[];
  27124. /**
  27125. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27126. */
  27127. isRecursive: boolean;
  27128. /**
  27129. * Releases all associated resources
  27130. */
  27131. abstract dispose(): void;
  27132. /**
  27133. * Does this action manager has pointer triggers
  27134. */
  27135. abstract readonly hasPointerTriggers: boolean;
  27136. /**
  27137. * Does this action manager has pick triggers
  27138. */
  27139. abstract readonly hasPickTriggers: boolean;
  27140. /**
  27141. * Process a specific trigger
  27142. * @param trigger defines the trigger to process
  27143. * @param evt defines the event details to be processed
  27144. */
  27145. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27146. /**
  27147. * Does this action manager handles actions of any of the given triggers
  27148. * @param triggers defines the triggers to be tested
  27149. * @return a boolean indicating whether one (or more) of the triggers is handled
  27150. */
  27151. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27152. /**
  27153. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27154. * speed.
  27155. * @param triggerA defines the trigger to be tested
  27156. * @param triggerB defines the trigger to be tested
  27157. * @return a boolean indicating whether one (or more) of the triggers is handled
  27158. */
  27159. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27160. /**
  27161. * Does this action manager handles actions of a given trigger
  27162. * @param trigger defines the trigger to be tested
  27163. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27164. * @return whether the trigger is handled
  27165. */
  27166. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27167. /**
  27168. * Serialize this manager to a JSON object
  27169. * @param name defines the property name to store this manager
  27170. * @returns a JSON representation of this manager
  27171. */
  27172. abstract serialize(name: string): any;
  27173. /**
  27174. * Registers an action to this action manager
  27175. * @param action defines the action to be registered
  27176. * @return the action amended (prepared) after registration
  27177. */
  27178. abstract registerAction(action: IAction): Nullable<IAction>;
  27179. /**
  27180. * Unregisters an action to this action manager
  27181. * @param action defines the action to be unregistered
  27182. * @return a boolean indicating whether the action has been unregistered
  27183. */
  27184. abstract unregisterAction(action: IAction): Boolean;
  27185. /**
  27186. * Does exist one action manager with at least one trigger
  27187. **/
  27188. static readonly HasTriggers: boolean;
  27189. /**
  27190. * Does exist one action manager with at least one pick trigger
  27191. **/
  27192. static readonly HasPickTriggers: boolean;
  27193. /**
  27194. * Does exist one action manager that handles actions of a given trigger
  27195. * @param trigger defines the trigger to be tested
  27196. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27197. **/
  27198. static HasSpecificTrigger(trigger: number): boolean;
  27199. }
  27200. }
  27201. declare module BABYLON {
  27202. /**
  27203. * Defines how a node can be built from a string name.
  27204. */
  27205. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27206. /**
  27207. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27208. */
  27209. export class Node implements IBehaviorAware<Node> {
  27210. /** @hidden */
  27211. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  27212. private static _NodeConstructors;
  27213. /**
  27214. * Add a new node constructor
  27215. * @param type defines the type name of the node to construct
  27216. * @param constructorFunc defines the constructor function
  27217. */
  27218. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27219. /**
  27220. * Returns a node constructor based on type name
  27221. * @param type defines the type name
  27222. * @param name defines the new node name
  27223. * @param scene defines the hosting scene
  27224. * @param options defines optional options to transmit to constructors
  27225. * @returns the new constructor or null
  27226. */
  27227. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27228. /**
  27229. * Gets or sets the name of the node
  27230. */
  27231. name: string;
  27232. /**
  27233. * Gets or sets the id of the node
  27234. */
  27235. id: string;
  27236. /**
  27237. * Gets or sets the unique id of the node
  27238. */
  27239. uniqueId: number;
  27240. /**
  27241. * Gets or sets a string used to store user defined state for the node
  27242. */
  27243. state: string;
  27244. /**
  27245. * Gets or sets an object used to store user defined information for the node
  27246. */
  27247. metadata: any;
  27248. /**
  27249. * For internal use only. Please do not use.
  27250. */
  27251. reservedDataStore: any;
  27252. /**
  27253. * List of inspectable custom properties (used by the Inspector)
  27254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27255. */
  27256. inspectableCustomProperties: IInspectable[];
  27257. private _doNotSerialize;
  27258. /**
  27259. * Gets or sets a boolean used to define if the node must be serialized
  27260. */
  27261. doNotSerialize: boolean;
  27262. /** @hidden */
  27263. _isDisposed: boolean;
  27264. /**
  27265. * Gets a list of Animations associated with the node
  27266. */
  27267. animations: Animation[];
  27268. protected _ranges: {
  27269. [name: string]: Nullable<AnimationRange>;
  27270. };
  27271. /**
  27272. * Callback raised when the node is ready to be used
  27273. */
  27274. onReady: Nullable<(node: Node) => void>;
  27275. private _isEnabled;
  27276. private _isParentEnabled;
  27277. private _isReady;
  27278. /** @hidden */
  27279. _currentRenderId: number;
  27280. private _parentUpdateId;
  27281. /** @hidden */
  27282. _childUpdateId: number;
  27283. /** @hidden */
  27284. _waitingParentId: Nullable<string>;
  27285. /** @hidden */
  27286. _scene: Scene;
  27287. /** @hidden */
  27288. _cache: any;
  27289. private _parentNode;
  27290. private _children;
  27291. /** @hidden */
  27292. _worldMatrix: Matrix;
  27293. /** @hidden */
  27294. _worldMatrixDeterminant: number;
  27295. /** @hidden */
  27296. _worldMatrixDeterminantIsDirty: boolean;
  27297. /** @hidden */
  27298. private _sceneRootNodesIndex;
  27299. /**
  27300. * Gets a boolean indicating if the node has been disposed
  27301. * @returns true if the node was disposed
  27302. */
  27303. isDisposed(): boolean;
  27304. /**
  27305. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27306. * @see https://doc.babylonjs.com/how_to/parenting
  27307. */
  27308. parent: Nullable<Node>;
  27309. /** @hidden */
  27310. _addToSceneRootNodes(): void;
  27311. /** @hidden */
  27312. _removeFromSceneRootNodes(): void;
  27313. private _animationPropertiesOverride;
  27314. /**
  27315. * Gets or sets the animation properties override
  27316. */
  27317. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27318. /**
  27319. * Gets a string idenfifying the name of the class
  27320. * @returns "Node" string
  27321. */
  27322. getClassName(): string;
  27323. /** @hidden */
  27324. readonly _isNode: boolean;
  27325. /**
  27326. * An event triggered when the mesh is disposed
  27327. */
  27328. onDisposeObservable: Observable<Node>;
  27329. private _onDisposeObserver;
  27330. /**
  27331. * Sets a callback that will be raised when the node will be disposed
  27332. */
  27333. onDispose: () => void;
  27334. /**
  27335. * Creates a new Node
  27336. * @param name the name and id to be given to this node
  27337. * @param scene the scene this node will be added to
  27338. */
  27339. constructor(name: string, scene?: Nullable<Scene>);
  27340. /**
  27341. * Gets the scene of the node
  27342. * @returns a scene
  27343. */
  27344. getScene(): Scene;
  27345. /**
  27346. * Gets the engine of the node
  27347. * @returns a Engine
  27348. */
  27349. getEngine(): Engine;
  27350. private _behaviors;
  27351. /**
  27352. * Attach a behavior to the node
  27353. * @see http://doc.babylonjs.com/features/behaviour
  27354. * @param behavior defines the behavior to attach
  27355. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27356. * @returns the current Node
  27357. */
  27358. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27359. /**
  27360. * Remove an attached behavior
  27361. * @see http://doc.babylonjs.com/features/behaviour
  27362. * @param behavior defines the behavior to attach
  27363. * @returns the current Node
  27364. */
  27365. removeBehavior(behavior: Behavior<Node>): Node;
  27366. /**
  27367. * Gets the list of attached behaviors
  27368. * @see http://doc.babylonjs.com/features/behaviour
  27369. */
  27370. readonly behaviors: Behavior<Node>[];
  27371. /**
  27372. * Gets an attached behavior by name
  27373. * @param name defines the name of the behavior to look for
  27374. * @see http://doc.babylonjs.com/features/behaviour
  27375. * @returns null if behavior was not found else the requested behavior
  27376. */
  27377. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27378. /**
  27379. * Returns the latest update of the World matrix
  27380. * @returns a Matrix
  27381. */
  27382. getWorldMatrix(): Matrix;
  27383. /** @hidden */
  27384. _getWorldMatrixDeterminant(): number;
  27385. /**
  27386. * Returns directly the latest state of the mesh World matrix.
  27387. * A Matrix is returned.
  27388. */
  27389. readonly worldMatrixFromCache: Matrix;
  27390. /** @hidden */
  27391. _initCache(): void;
  27392. /** @hidden */
  27393. updateCache(force?: boolean): void;
  27394. /** @hidden */
  27395. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27396. /** @hidden */
  27397. _updateCache(ignoreParentClass?: boolean): void;
  27398. /** @hidden */
  27399. _isSynchronized(): boolean;
  27400. /** @hidden */
  27401. _markSyncedWithParent(): void;
  27402. /** @hidden */
  27403. isSynchronizedWithParent(): boolean;
  27404. /** @hidden */
  27405. isSynchronized(): boolean;
  27406. /**
  27407. * Is this node ready to be used/rendered
  27408. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27409. * @return true if the node is ready
  27410. */
  27411. isReady(completeCheck?: boolean): boolean;
  27412. /**
  27413. * Is this node enabled?
  27414. * 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
  27415. * @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
  27416. * @return whether this node (and its parent) is enabled
  27417. */
  27418. isEnabled(checkAncestors?: boolean): boolean;
  27419. /** @hidden */
  27420. protected _syncParentEnabledState(): void;
  27421. /**
  27422. * Set the enabled state of this node
  27423. * @param value defines the new enabled state
  27424. */
  27425. setEnabled(value: boolean): void;
  27426. /**
  27427. * Is this node a descendant of the given node?
  27428. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27429. * @param ancestor defines the parent node to inspect
  27430. * @returns a boolean indicating if this node is a descendant of the given node
  27431. */
  27432. isDescendantOf(ancestor: Node): boolean;
  27433. /** @hidden */
  27434. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27435. /**
  27436. * Will return all nodes that have this node as ascendant
  27437. * @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
  27438. * @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
  27439. * @return all children nodes of all types
  27440. */
  27441. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27442. /**
  27443. * Get all child-meshes of this node
  27444. * @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)
  27445. * @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
  27446. * @returns an array of AbstractMesh
  27447. */
  27448. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27449. /**
  27450. * Get all direct children of this node
  27451. * @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
  27452. * @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)
  27453. * @returns an array of Node
  27454. */
  27455. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27456. /** @hidden */
  27457. _setReady(state: boolean): void;
  27458. /**
  27459. * Get an animation by name
  27460. * @param name defines the name of the animation to look for
  27461. * @returns null if not found else the requested animation
  27462. */
  27463. getAnimationByName(name: string): Nullable<Animation>;
  27464. /**
  27465. * Creates an animation range for this node
  27466. * @param name defines the name of the range
  27467. * @param from defines the starting key
  27468. * @param to defines the end key
  27469. */
  27470. createAnimationRange(name: string, from: number, to: number): void;
  27471. /**
  27472. * Delete a specific animation range
  27473. * @param name defines the name of the range to delete
  27474. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27475. */
  27476. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27477. /**
  27478. * Get an animation range by name
  27479. * @param name defines the name of the animation range to look for
  27480. * @returns null if not found else the requested animation range
  27481. */
  27482. getAnimationRange(name: string): Nullable<AnimationRange>;
  27483. /**
  27484. * Gets the list of all animation ranges defined on this node
  27485. * @returns an array
  27486. */
  27487. getAnimationRanges(): Nullable<AnimationRange>[];
  27488. /**
  27489. * Will start the animation sequence
  27490. * @param name defines the range frames for animation sequence
  27491. * @param loop defines if the animation should loop (false by default)
  27492. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27493. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27494. * @returns the object created for this animation. If range does not exist, it will return null
  27495. */
  27496. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27497. /**
  27498. * Serialize animation ranges into a JSON compatible object
  27499. * @returns serialization object
  27500. */
  27501. serializeAnimationRanges(): any;
  27502. /**
  27503. * Computes the world matrix of the node
  27504. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27505. * @returns the world matrix
  27506. */
  27507. computeWorldMatrix(force?: boolean): Matrix;
  27508. /**
  27509. * Releases resources associated with this node.
  27510. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27511. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27512. */
  27513. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27514. /**
  27515. * Parse animation range data from a serialization object and store them into a given node
  27516. * @param node defines where to store the animation ranges
  27517. * @param parsedNode defines the serialization object to read data from
  27518. * @param scene defines the hosting scene
  27519. */
  27520. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27521. /**
  27522. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27523. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27524. * @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
  27525. * @returns the new bounding vectors
  27526. */
  27527. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27528. min: Vector3;
  27529. max: Vector3;
  27530. };
  27531. }
  27532. }
  27533. declare module BABYLON {
  27534. /**
  27535. * @hidden
  27536. */
  27537. export class _IAnimationState {
  27538. key: number;
  27539. repeatCount: number;
  27540. workValue?: any;
  27541. loopMode?: number;
  27542. offsetValue?: any;
  27543. highLimitValue?: any;
  27544. }
  27545. /**
  27546. * Class used to store any kind of animation
  27547. */
  27548. export class Animation {
  27549. /**Name of the animation */
  27550. name: string;
  27551. /**Property to animate */
  27552. targetProperty: string;
  27553. /**The frames per second of the animation */
  27554. framePerSecond: number;
  27555. /**The data type of the animation */
  27556. dataType: number;
  27557. /**The loop mode of the animation */
  27558. loopMode?: number | undefined;
  27559. /**Specifies if blending should be enabled */
  27560. enableBlending?: boolean | undefined;
  27561. /**
  27562. * Use matrix interpolation instead of using direct key value when animating matrices
  27563. */
  27564. static AllowMatricesInterpolation: boolean;
  27565. /**
  27566. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27567. */
  27568. static AllowMatrixDecomposeForInterpolation: boolean;
  27569. /**
  27570. * Stores the key frames of the animation
  27571. */
  27572. private _keys;
  27573. /**
  27574. * Stores the easing function of the animation
  27575. */
  27576. private _easingFunction;
  27577. /**
  27578. * @hidden Internal use only
  27579. */
  27580. _runtimeAnimations: RuntimeAnimation[];
  27581. /**
  27582. * The set of event that will be linked to this animation
  27583. */
  27584. private _events;
  27585. /**
  27586. * Stores an array of target property paths
  27587. */
  27588. targetPropertyPath: string[];
  27589. /**
  27590. * Stores the blending speed of the animation
  27591. */
  27592. blendingSpeed: number;
  27593. /**
  27594. * Stores the animation ranges for the animation
  27595. */
  27596. private _ranges;
  27597. /**
  27598. * @hidden Internal use
  27599. */
  27600. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27601. /**
  27602. * Sets up an animation
  27603. * @param property The property to animate
  27604. * @param animationType The animation type to apply
  27605. * @param framePerSecond The frames per second of the animation
  27606. * @param easingFunction The easing function used in the animation
  27607. * @returns The created animation
  27608. */
  27609. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27610. /**
  27611. * Create and start an animation on a node
  27612. * @param name defines the name of the global animation that will be run on all nodes
  27613. * @param node defines the root node where the animation will take place
  27614. * @param targetProperty defines property to animate
  27615. * @param framePerSecond defines the number of frame per second yo use
  27616. * @param totalFrame defines the number of frames in total
  27617. * @param from defines the initial value
  27618. * @param to defines the final value
  27619. * @param loopMode defines which loop mode you want to use (off by default)
  27620. * @param easingFunction defines the easing function to use (linear by default)
  27621. * @param onAnimationEnd defines the callback to call when animation end
  27622. * @returns the animatable created for this animation
  27623. */
  27624. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27625. /**
  27626. * Create and start an animation on a node and its descendants
  27627. * @param name defines the name of the global animation that will be run on all nodes
  27628. * @param node defines the root node where the animation will take place
  27629. * @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
  27630. * @param targetProperty defines property to animate
  27631. * @param framePerSecond defines the number of frame per second to use
  27632. * @param totalFrame defines the number of frames in total
  27633. * @param from defines the initial value
  27634. * @param to defines the final value
  27635. * @param loopMode defines which loop mode you want to use (off by default)
  27636. * @param easingFunction defines the easing function to use (linear by default)
  27637. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27638. * @returns the list of animatables created for all nodes
  27639. * @example https://www.babylonjs-playground.com/#MH0VLI
  27640. */
  27641. 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[]>;
  27642. /**
  27643. * Creates a new animation, merges it with the existing animations and starts it
  27644. * @param name Name of the animation
  27645. * @param node Node which contains the scene that begins the animations
  27646. * @param targetProperty Specifies which property to animate
  27647. * @param framePerSecond The frames per second of the animation
  27648. * @param totalFrame The total number of frames
  27649. * @param from The frame at the beginning of the animation
  27650. * @param to The frame at the end of the animation
  27651. * @param loopMode Specifies the loop mode of the animation
  27652. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27653. * @param onAnimationEnd Callback to run once the animation is complete
  27654. * @returns Nullable animation
  27655. */
  27656. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27657. /**
  27658. * Transition property of an host to the target Value
  27659. * @param property The property to transition
  27660. * @param targetValue The target Value of the property
  27661. * @param host The object where the property to animate belongs
  27662. * @param scene Scene used to run the animation
  27663. * @param frameRate Framerate (in frame/s) to use
  27664. * @param transition The transition type we want to use
  27665. * @param duration The duration of the animation, in milliseconds
  27666. * @param onAnimationEnd Callback trigger at the end of the animation
  27667. * @returns Nullable animation
  27668. */
  27669. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27670. /**
  27671. * Return the array of runtime animations currently using this animation
  27672. */
  27673. readonly runtimeAnimations: RuntimeAnimation[];
  27674. /**
  27675. * Specifies if any of the runtime animations are currently running
  27676. */
  27677. readonly hasRunningRuntimeAnimations: boolean;
  27678. /**
  27679. * Initializes the animation
  27680. * @param name Name of the animation
  27681. * @param targetProperty Property to animate
  27682. * @param framePerSecond The frames per second of the animation
  27683. * @param dataType The data type of the animation
  27684. * @param loopMode The loop mode of the animation
  27685. * @param enableBlending Specifies if blending should be enabled
  27686. */
  27687. constructor(
  27688. /**Name of the animation */
  27689. name: string,
  27690. /**Property to animate */
  27691. targetProperty: string,
  27692. /**The frames per second of the animation */
  27693. framePerSecond: number,
  27694. /**The data type of the animation */
  27695. dataType: number,
  27696. /**The loop mode of the animation */
  27697. loopMode?: number | undefined,
  27698. /**Specifies if blending should be enabled */
  27699. enableBlending?: boolean | undefined);
  27700. /**
  27701. * Converts the animation to a string
  27702. * @param fullDetails support for multiple levels of logging within scene loading
  27703. * @returns String form of the animation
  27704. */
  27705. toString(fullDetails?: boolean): string;
  27706. /**
  27707. * Add an event to this animation
  27708. * @param event Event to add
  27709. */
  27710. addEvent(event: AnimationEvent): void;
  27711. /**
  27712. * Remove all events found at the given frame
  27713. * @param frame The frame to remove events from
  27714. */
  27715. removeEvents(frame: number): void;
  27716. /**
  27717. * Retrieves all the events from the animation
  27718. * @returns Events from the animation
  27719. */
  27720. getEvents(): AnimationEvent[];
  27721. /**
  27722. * Creates an animation range
  27723. * @param name Name of the animation range
  27724. * @param from Starting frame of the animation range
  27725. * @param to Ending frame of the animation
  27726. */
  27727. createRange(name: string, from: number, to: number): void;
  27728. /**
  27729. * Deletes an animation range by name
  27730. * @param name Name of the animation range to delete
  27731. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27732. */
  27733. deleteRange(name: string, deleteFrames?: boolean): void;
  27734. /**
  27735. * Gets the animation range by name, or null if not defined
  27736. * @param name Name of the animation range
  27737. * @returns Nullable animation range
  27738. */
  27739. getRange(name: string): Nullable<AnimationRange>;
  27740. /**
  27741. * Gets the key frames from the animation
  27742. * @returns The key frames of the animation
  27743. */
  27744. getKeys(): Array<IAnimationKey>;
  27745. /**
  27746. * Gets the highest frame rate of the animation
  27747. * @returns Highest frame rate of the animation
  27748. */
  27749. getHighestFrame(): number;
  27750. /**
  27751. * Gets the easing function of the animation
  27752. * @returns Easing function of the animation
  27753. */
  27754. getEasingFunction(): IEasingFunction;
  27755. /**
  27756. * Sets the easing function of the animation
  27757. * @param easingFunction A custom mathematical formula for animation
  27758. */
  27759. setEasingFunction(easingFunction: EasingFunction): void;
  27760. /**
  27761. * Interpolates a scalar linearly
  27762. * @param startValue Start value of the animation curve
  27763. * @param endValue End value of the animation curve
  27764. * @param gradient Scalar amount to interpolate
  27765. * @returns Interpolated scalar value
  27766. */
  27767. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27768. /**
  27769. * Interpolates a scalar cubically
  27770. * @param startValue Start value of the animation curve
  27771. * @param outTangent End tangent of the animation
  27772. * @param endValue End value of the animation curve
  27773. * @param inTangent Start tangent of the animation curve
  27774. * @param gradient Scalar amount to interpolate
  27775. * @returns Interpolated scalar value
  27776. */
  27777. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27778. /**
  27779. * Interpolates a quaternion using a spherical linear interpolation
  27780. * @param startValue Start value of the animation curve
  27781. * @param endValue End value of the animation curve
  27782. * @param gradient Scalar amount to interpolate
  27783. * @returns Interpolated quaternion value
  27784. */
  27785. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27786. /**
  27787. * Interpolates a quaternion cubically
  27788. * @param startValue Start value of the animation curve
  27789. * @param outTangent End tangent of the animation curve
  27790. * @param endValue End value of the animation curve
  27791. * @param inTangent Start tangent of the animation curve
  27792. * @param gradient Scalar amount to interpolate
  27793. * @returns Interpolated quaternion value
  27794. */
  27795. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27796. /**
  27797. * Interpolates a Vector3 linearl
  27798. * @param startValue Start value of the animation curve
  27799. * @param endValue End value of the animation curve
  27800. * @param gradient Scalar amount to interpolate
  27801. * @returns Interpolated scalar value
  27802. */
  27803. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27804. /**
  27805. * Interpolates a Vector3 cubically
  27806. * @param startValue Start value of the animation curve
  27807. * @param outTangent End tangent of the animation
  27808. * @param endValue End value of the animation curve
  27809. * @param inTangent Start tangent of the animation curve
  27810. * @param gradient Scalar amount to interpolate
  27811. * @returns InterpolatedVector3 value
  27812. */
  27813. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27814. /**
  27815. * Interpolates a Vector2 linearly
  27816. * @param startValue Start value of the animation curve
  27817. * @param endValue End value of the animation curve
  27818. * @param gradient Scalar amount to interpolate
  27819. * @returns Interpolated Vector2 value
  27820. */
  27821. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27822. /**
  27823. * Interpolates a Vector2 cubically
  27824. * @param startValue Start value of the animation curve
  27825. * @param outTangent End tangent of the animation
  27826. * @param endValue End value of the animation curve
  27827. * @param inTangent Start tangent of the animation curve
  27828. * @param gradient Scalar amount to interpolate
  27829. * @returns Interpolated Vector2 value
  27830. */
  27831. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27832. /**
  27833. * Interpolates a size linearly
  27834. * @param startValue Start value of the animation curve
  27835. * @param endValue End value of the animation curve
  27836. * @param gradient Scalar amount to interpolate
  27837. * @returns Interpolated Size value
  27838. */
  27839. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27840. /**
  27841. * Interpolates a Color3 linearly
  27842. * @param startValue Start value of the animation curve
  27843. * @param endValue End value of the animation curve
  27844. * @param gradient Scalar amount to interpolate
  27845. * @returns Interpolated Color3 value
  27846. */
  27847. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27848. /**
  27849. * Interpolates a Color4 linearly
  27850. * @param startValue Start value of the animation curve
  27851. * @param endValue End value of the animation curve
  27852. * @param gradient Scalar amount to interpolate
  27853. * @returns Interpolated Color3 value
  27854. */
  27855. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27856. /**
  27857. * @hidden Internal use only
  27858. */
  27859. _getKeyValue(value: any): any;
  27860. /**
  27861. * @hidden Internal use only
  27862. */
  27863. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27864. /**
  27865. * Defines the function to use to interpolate matrices
  27866. * @param startValue defines the start matrix
  27867. * @param endValue defines the end matrix
  27868. * @param gradient defines the gradient between both matrices
  27869. * @param result defines an optional target matrix where to store the interpolation
  27870. * @returns the interpolated matrix
  27871. */
  27872. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27873. /**
  27874. * Makes a copy of the animation
  27875. * @returns Cloned animation
  27876. */
  27877. clone(): Animation;
  27878. /**
  27879. * Sets the key frames of the animation
  27880. * @param values The animation key frames to set
  27881. */
  27882. setKeys(values: Array<IAnimationKey>): void;
  27883. /**
  27884. * Serializes the animation to an object
  27885. * @returns Serialized object
  27886. */
  27887. serialize(): any;
  27888. /**
  27889. * Float animation type
  27890. */
  27891. static readonly ANIMATIONTYPE_FLOAT: number;
  27892. /**
  27893. * Vector3 animation type
  27894. */
  27895. static readonly ANIMATIONTYPE_VECTOR3: number;
  27896. /**
  27897. * Quaternion animation type
  27898. */
  27899. static readonly ANIMATIONTYPE_QUATERNION: number;
  27900. /**
  27901. * Matrix animation type
  27902. */
  27903. static readonly ANIMATIONTYPE_MATRIX: number;
  27904. /**
  27905. * Color3 animation type
  27906. */
  27907. static readonly ANIMATIONTYPE_COLOR3: number;
  27908. /**
  27909. * Color3 animation type
  27910. */
  27911. static readonly ANIMATIONTYPE_COLOR4: number;
  27912. /**
  27913. * Vector2 animation type
  27914. */
  27915. static readonly ANIMATIONTYPE_VECTOR2: number;
  27916. /**
  27917. * Size animation type
  27918. */
  27919. static readonly ANIMATIONTYPE_SIZE: number;
  27920. /**
  27921. * Relative Loop Mode
  27922. */
  27923. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27924. /**
  27925. * Cycle Loop Mode
  27926. */
  27927. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27928. /**
  27929. * Constant Loop Mode
  27930. */
  27931. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27932. /** @hidden */
  27933. static _UniversalLerp(left: any, right: any, amount: number): any;
  27934. /**
  27935. * Parses an animation object and creates an animation
  27936. * @param parsedAnimation Parsed animation object
  27937. * @returns Animation object
  27938. */
  27939. static Parse(parsedAnimation: any): Animation;
  27940. /**
  27941. * Appends the serialized animations from the source animations
  27942. * @param source Source containing the animations
  27943. * @param destination Target to store the animations
  27944. */
  27945. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27946. }
  27947. }
  27948. declare module BABYLON {
  27949. /**
  27950. * Interface containing an array of animations
  27951. */
  27952. export interface IAnimatable {
  27953. /**
  27954. * Array of animations
  27955. */
  27956. animations: Nullable<Array<Animation>>;
  27957. }
  27958. }
  27959. declare module BABYLON {
  27960. /**
  27961. * This represents all the required information to add a fresnel effect on a material:
  27962. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27963. */
  27964. export class FresnelParameters {
  27965. private _isEnabled;
  27966. /**
  27967. * Define if the fresnel effect is enable or not.
  27968. */
  27969. isEnabled: boolean;
  27970. /**
  27971. * Define the color used on edges (grazing angle)
  27972. */
  27973. leftColor: Color3;
  27974. /**
  27975. * Define the color used on center
  27976. */
  27977. rightColor: Color3;
  27978. /**
  27979. * Define bias applied to computed fresnel term
  27980. */
  27981. bias: number;
  27982. /**
  27983. * Defined the power exponent applied to fresnel term
  27984. */
  27985. power: number;
  27986. /**
  27987. * Clones the current fresnel and its valuues
  27988. * @returns a clone fresnel configuration
  27989. */
  27990. clone(): FresnelParameters;
  27991. /**
  27992. * Serializes the current fresnel parameters to a JSON representation.
  27993. * @return the JSON serialization
  27994. */
  27995. serialize(): any;
  27996. /**
  27997. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27998. * @param parsedFresnelParameters Define the JSON representation
  27999. * @returns the parsed parameters
  28000. */
  28001. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28002. }
  28003. }
  28004. declare module BABYLON {
  28005. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28006. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28007. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28008. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28009. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28010. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28011. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28012. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28013. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28014. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28015. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28016. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28017. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28018. /**
  28019. * Decorator used to define property that can be serialized as reference to a camera
  28020. * @param sourceName defines the name of the property to decorate
  28021. */
  28022. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28023. /**
  28024. * Class used to help serialization objects
  28025. */
  28026. export class SerializationHelper {
  28027. /** @hidden */
  28028. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  28029. /** @hidden */
  28030. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  28031. /** @hidden */
  28032. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  28033. /** @hidden */
  28034. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  28035. /**
  28036. * Appends the serialized animations from the source animations
  28037. * @param source Source containing the animations
  28038. * @param destination Target to store the animations
  28039. */
  28040. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28041. /**
  28042. * Static function used to serialized a specific entity
  28043. * @param entity defines the entity to serialize
  28044. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28045. * @returns a JSON compatible object representing the serialization of the entity
  28046. */
  28047. static Serialize<T>(entity: T, serializationObject?: any): any;
  28048. /**
  28049. * Creates a new entity from a serialization data object
  28050. * @param creationFunction defines a function used to instanciated the new entity
  28051. * @param source defines the source serialization data
  28052. * @param scene defines the hosting scene
  28053. * @param rootUrl defines the root url for resources
  28054. * @returns a new entity
  28055. */
  28056. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28057. /**
  28058. * Clones an object
  28059. * @param creationFunction defines the function used to instanciate the new object
  28060. * @param source defines the source object
  28061. * @returns the cloned object
  28062. */
  28063. static Clone<T>(creationFunction: () => T, source: T): T;
  28064. /**
  28065. * Instanciates a new object based on a source one (some data will be shared between both object)
  28066. * @param creationFunction defines the function used to instanciate the new object
  28067. * @param source defines the source object
  28068. * @returns the new object
  28069. */
  28070. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28071. }
  28072. }
  28073. declare module BABYLON {
  28074. /**
  28075. * Class used to manipulate GUIDs
  28076. */
  28077. export class GUID {
  28078. /**
  28079. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28080. * Be aware Math.random() could cause collisions, but:
  28081. * "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"
  28082. * @returns a pseudo random id
  28083. */
  28084. static RandomId(): string;
  28085. }
  28086. }
  28087. declare module BABYLON {
  28088. /**
  28089. * Base class of all the textures in babylon.
  28090. * It groups all the common properties the materials, post process, lights... might need
  28091. * in order to make a correct use of the texture.
  28092. */
  28093. export class BaseTexture implements IAnimatable {
  28094. /**
  28095. * Default anisotropic filtering level for the application.
  28096. * It is set to 4 as a good tradeoff between perf and quality.
  28097. */
  28098. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28099. /**
  28100. * Gets or sets the unique id of the texture
  28101. */
  28102. uniqueId: number;
  28103. /**
  28104. * Define the name of the texture.
  28105. */
  28106. name: string;
  28107. /**
  28108. * Gets or sets an object used to store user defined information.
  28109. */
  28110. metadata: any;
  28111. /**
  28112. * For internal use only. Please do not use.
  28113. */
  28114. reservedDataStore: any;
  28115. private _hasAlpha;
  28116. /**
  28117. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28118. */
  28119. hasAlpha: boolean;
  28120. /**
  28121. * Defines if the alpha value should be determined via the rgb values.
  28122. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28123. */
  28124. getAlphaFromRGB: boolean;
  28125. /**
  28126. * Intensity or strength of the texture.
  28127. * It is commonly used by materials to fine tune the intensity of the texture
  28128. */
  28129. level: number;
  28130. /**
  28131. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28132. * This is part of the texture as textures usually maps to one uv set.
  28133. */
  28134. coordinatesIndex: number;
  28135. private _coordinatesMode;
  28136. /**
  28137. * How a texture is mapped.
  28138. *
  28139. * | Value | Type | Description |
  28140. * | ----- | ----------------------------------- | ----------- |
  28141. * | 0 | EXPLICIT_MODE | |
  28142. * | 1 | SPHERICAL_MODE | |
  28143. * | 2 | PLANAR_MODE | |
  28144. * | 3 | CUBIC_MODE | |
  28145. * | 4 | PROJECTION_MODE | |
  28146. * | 5 | SKYBOX_MODE | |
  28147. * | 6 | INVCUBIC_MODE | |
  28148. * | 7 | EQUIRECTANGULAR_MODE | |
  28149. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28150. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28151. */
  28152. coordinatesMode: number;
  28153. /**
  28154. * | Value | Type | Description |
  28155. * | ----- | ------------------ | ----------- |
  28156. * | 0 | CLAMP_ADDRESSMODE | |
  28157. * | 1 | WRAP_ADDRESSMODE | |
  28158. * | 2 | MIRROR_ADDRESSMODE | |
  28159. */
  28160. wrapU: number;
  28161. /**
  28162. * | Value | Type | Description |
  28163. * | ----- | ------------------ | ----------- |
  28164. * | 0 | CLAMP_ADDRESSMODE | |
  28165. * | 1 | WRAP_ADDRESSMODE | |
  28166. * | 2 | MIRROR_ADDRESSMODE | |
  28167. */
  28168. wrapV: number;
  28169. /**
  28170. * | Value | Type | Description |
  28171. * | ----- | ------------------ | ----------- |
  28172. * | 0 | CLAMP_ADDRESSMODE | |
  28173. * | 1 | WRAP_ADDRESSMODE | |
  28174. * | 2 | MIRROR_ADDRESSMODE | |
  28175. */
  28176. wrapR: number;
  28177. /**
  28178. * With compliant hardware and browser (supporting anisotropic filtering)
  28179. * this defines the level of anisotropic filtering in the texture.
  28180. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28181. */
  28182. anisotropicFilteringLevel: number;
  28183. /**
  28184. * Define if the texture is a cube texture or if false a 2d texture.
  28185. */
  28186. isCube: boolean;
  28187. /**
  28188. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28189. */
  28190. is3D: boolean;
  28191. /**
  28192. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28193. */
  28194. is2DArray: boolean;
  28195. /**
  28196. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28197. * HDR texture are usually stored in linear space.
  28198. * This only impacts the PBR and Background materials
  28199. */
  28200. gammaSpace: boolean;
  28201. /**
  28202. * Gets or sets whether or not the texture contains RGBD data.
  28203. */
  28204. isRGBD: boolean;
  28205. /**
  28206. * Is Z inverted in the texture (useful in a cube texture).
  28207. */
  28208. invertZ: boolean;
  28209. /**
  28210. * Are mip maps generated for this texture or not.
  28211. */
  28212. readonly noMipmap: boolean;
  28213. /**
  28214. * @hidden
  28215. */
  28216. lodLevelInAlpha: boolean;
  28217. /**
  28218. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28219. */
  28220. lodGenerationOffset: number;
  28221. /**
  28222. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28223. */
  28224. lodGenerationScale: number;
  28225. /**
  28226. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28227. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28228. * average roughness values.
  28229. */
  28230. linearSpecularLOD: boolean;
  28231. /**
  28232. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28233. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28234. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28235. */
  28236. irradianceTexture: Nullable<BaseTexture>;
  28237. /**
  28238. * Define if the texture is a render target.
  28239. */
  28240. isRenderTarget: boolean;
  28241. /**
  28242. * Define the unique id of the texture in the scene.
  28243. */
  28244. readonly uid: string;
  28245. /**
  28246. * Return a string representation of the texture.
  28247. * @returns the texture as a string
  28248. */
  28249. toString(): string;
  28250. /**
  28251. * Get the class name of the texture.
  28252. * @returns "BaseTexture"
  28253. */
  28254. getClassName(): string;
  28255. /**
  28256. * Define the list of animation attached to the texture.
  28257. */
  28258. animations: Animation[];
  28259. /**
  28260. * An event triggered when the texture is disposed.
  28261. */
  28262. onDisposeObservable: Observable<BaseTexture>;
  28263. private _onDisposeObserver;
  28264. /**
  28265. * Callback triggered when the texture has been disposed.
  28266. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28267. */
  28268. onDispose: () => void;
  28269. /**
  28270. * Define the current state of the loading sequence when in delayed load mode.
  28271. */
  28272. delayLoadState: number;
  28273. private _scene;
  28274. /** @hidden */
  28275. _texture: Nullable<InternalTexture>;
  28276. private _uid;
  28277. /**
  28278. * Define if the texture is preventinga material to render or not.
  28279. * If not and the texture is not ready, the engine will use a default black texture instead.
  28280. */
  28281. readonly isBlocking: boolean;
  28282. /**
  28283. * Instantiates a new BaseTexture.
  28284. * Base class of all the textures in babylon.
  28285. * It groups all the common properties the materials, post process, lights... might need
  28286. * in order to make a correct use of the texture.
  28287. * @param scene Define the scene the texture blongs to
  28288. */
  28289. constructor(scene: Nullable<Scene>);
  28290. /**
  28291. * Get the scene the texture belongs to.
  28292. * @returns the scene or null if undefined
  28293. */
  28294. getScene(): Nullable<Scene>;
  28295. /**
  28296. * Get the texture transform matrix used to offset tile the texture for istance.
  28297. * @returns the transformation matrix
  28298. */
  28299. getTextureMatrix(): Matrix;
  28300. /**
  28301. * Get the texture reflection matrix used to rotate/transform the reflection.
  28302. * @returns the reflection matrix
  28303. */
  28304. getReflectionTextureMatrix(): Matrix;
  28305. /**
  28306. * Get the underlying lower level texture from Babylon.
  28307. * @returns the insternal texture
  28308. */
  28309. getInternalTexture(): Nullable<InternalTexture>;
  28310. /**
  28311. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28312. * @returns true if ready or not blocking
  28313. */
  28314. isReadyOrNotBlocking(): boolean;
  28315. /**
  28316. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28317. * @returns true if fully ready
  28318. */
  28319. isReady(): boolean;
  28320. private _cachedSize;
  28321. /**
  28322. * Get the size of the texture.
  28323. * @returns the texture size.
  28324. */
  28325. getSize(): ISize;
  28326. /**
  28327. * Get the base size of the texture.
  28328. * It can be different from the size if the texture has been resized for POT for instance
  28329. * @returns the base size
  28330. */
  28331. getBaseSize(): ISize;
  28332. /**
  28333. * Update the sampling mode of the texture.
  28334. * Default is Trilinear mode.
  28335. *
  28336. * | Value | Type | Description |
  28337. * | ----- | ------------------ | ----------- |
  28338. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28339. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28340. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28341. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28342. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28343. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28344. * | 7 | NEAREST_LINEAR | |
  28345. * | 8 | NEAREST_NEAREST | |
  28346. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28347. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28348. * | 11 | LINEAR_LINEAR | |
  28349. * | 12 | LINEAR_NEAREST | |
  28350. *
  28351. * > _mag_: magnification filter (close to the viewer)
  28352. * > _min_: minification filter (far from the viewer)
  28353. * > _mip_: filter used between mip map levels
  28354. *@param samplingMode Define the new sampling mode of the texture
  28355. */
  28356. updateSamplingMode(samplingMode: number): void;
  28357. /**
  28358. * Scales the texture if is `canRescale()`
  28359. * @param ratio the resize factor we want to use to rescale
  28360. */
  28361. scale(ratio: number): void;
  28362. /**
  28363. * Get if the texture can rescale.
  28364. */
  28365. readonly canRescale: boolean;
  28366. /** @hidden */
  28367. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28368. /** @hidden */
  28369. _rebuild(): void;
  28370. /**
  28371. * Triggers the load sequence in delayed load mode.
  28372. */
  28373. delayLoad(): void;
  28374. /**
  28375. * Clones the texture.
  28376. * @returns the cloned texture
  28377. */
  28378. clone(): Nullable<BaseTexture>;
  28379. /**
  28380. * Get the texture underlying type (INT, FLOAT...)
  28381. */
  28382. readonly textureType: number;
  28383. /**
  28384. * Get the texture underlying format (RGB, RGBA...)
  28385. */
  28386. readonly textureFormat: number;
  28387. /**
  28388. * Indicates that textures need to be re-calculated for all materials
  28389. */
  28390. protected _markAllSubMeshesAsTexturesDirty(): void;
  28391. /**
  28392. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28393. * This will returns an RGBA array buffer containing either in values (0-255) or
  28394. * float values (0-1) depending of the underlying buffer type.
  28395. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28396. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28397. * @param buffer defines a user defined buffer to fill with data (can be null)
  28398. * @returns The Array buffer containing the pixels data.
  28399. */
  28400. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28401. /**
  28402. * Release and destroy the underlying lower level texture aka internalTexture.
  28403. */
  28404. releaseInternalTexture(): void;
  28405. /** @hidden */
  28406. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28407. /** @hidden */
  28408. readonly _lodTextureMid: Nullable<BaseTexture>;
  28409. /** @hidden */
  28410. readonly _lodTextureLow: Nullable<BaseTexture>;
  28411. /**
  28412. * Dispose the texture and release its associated resources.
  28413. */
  28414. dispose(): void;
  28415. /**
  28416. * Serialize the texture into a JSON representation that can be parsed later on.
  28417. * @returns the JSON representation of the texture
  28418. */
  28419. serialize(): any;
  28420. /**
  28421. * Helper function to be called back once a list of texture contains only ready textures.
  28422. * @param textures Define the list of textures to wait for
  28423. * @param callback Define the callback triggered once the entire list will be ready
  28424. */
  28425. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28426. }
  28427. }
  28428. declare module BABYLON {
  28429. /**
  28430. * Options to be used when creating an effect.
  28431. */
  28432. export interface IEffectCreationOptions {
  28433. /**
  28434. * Atrributes that will be used in the shader.
  28435. */
  28436. attributes: string[];
  28437. /**
  28438. * Uniform varible names that will be set in the shader.
  28439. */
  28440. uniformsNames: string[];
  28441. /**
  28442. * Uniform buffer variable names that will be set in the shader.
  28443. */
  28444. uniformBuffersNames: string[];
  28445. /**
  28446. * Sampler texture variable names that will be set in the shader.
  28447. */
  28448. samplers: string[];
  28449. /**
  28450. * Define statements that will be set in the shader.
  28451. */
  28452. defines: any;
  28453. /**
  28454. * Possible fallbacks for this effect to improve performance when needed.
  28455. */
  28456. fallbacks: Nullable<IEffectFallbacks>;
  28457. /**
  28458. * Callback that will be called when the shader is compiled.
  28459. */
  28460. onCompiled: Nullable<(effect: Effect) => void>;
  28461. /**
  28462. * Callback that will be called if an error occurs during shader compilation.
  28463. */
  28464. onError: Nullable<(effect: Effect, errors: string) => void>;
  28465. /**
  28466. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28467. */
  28468. indexParameters?: any;
  28469. /**
  28470. * Max number of lights that can be used in the shader.
  28471. */
  28472. maxSimultaneousLights?: number;
  28473. /**
  28474. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28475. */
  28476. transformFeedbackVaryings?: Nullable<string[]>;
  28477. }
  28478. /**
  28479. * Effect containing vertex and fragment shader that can be executed on an object.
  28480. */
  28481. export class Effect implements IDisposable {
  28482. /**
  28483. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28484. */
  28485. static ShadersRepository: string;
  28486. /**
  28487. * Name of the effect.
  28488. */
  28489. name: any;
  28490. /**
  28491. * String container all the define statements that should be set on the shader.
  28492. */
  28493. defines: string;
  28494. /**
  28495. * Callback that will be called when the shader is compiled.
  28496. */
  28497. onCompiled: Nullable<(effect: Effect) => void>;
  28498. /**
  28499. * Callback that will be called if an error occurs during shader compilation.
  28500. */
  28501. onError: Nullable<(effect: Effect, errors: string) => void>;
  28502. /**
  28503. * Callback that will be called when effect is bound.
  28504. */
  28505. onBind: Nullable<(effect: Effect) => void>;
  28506. /**
  28507. * Unique ID of the effect.
  28508. */
  28509. uniqueId: number;
  28510. /**
  28511. * Observable that will be called when the shader is compiled.
  28512. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28513. */
  28514. onCompileObservable: Observable<Effect>;
  28515. /**
  28516. * Observable that will be called if an error occurs during shader compilation.
  28517. */
  28518. onErrorObservable: Observable<Effect>;
  28519. /** @hidden */
  28520. _onBindObservable: Nullable<Observable<Effect>>;
  28521. /**
  28522. * Observable that will be called when effect is bound.
  28523. */
  28524. readonly onBindObservable: Observable<Effect>;
  28525. /** @hidden */
  28526. _bonesComputationForcedToCPU: boolean;
  28527. private static _uniqueIdSeed;
  28528. private _engine;
  28529. private _uniformBuffersNames;
  28530. private _uniformsNames;
  28531. private _samplerList;
  28532. private _samplers;
  28533. private _isReady;
  28534. private _compilationError;
  28535. private _allFallbacksProcessed;
  28536. private _attributesNames;
  28537. private _attributes;
  28538. private _uniforms;
  28539. /**
  28540. * Key for the effect.
  28541. * @hidden
  28542. */
  28543. _key: string;
  28544. private _indexParameters;
  28545. private _fallbacks;
  28546. private _vertexSourceCode;
  28547. private _fragmentSourceCode;
  28548. private _vertexSourceCodeOverride;
  28549. private _fragmentSourceCodeOverride;
  28550. private _transformFeedbackVaryings;
  28551. /**
  28552. * Compiled shader to webGL program.
  28553. * @hidden
  28554. */
  28555. _pipelineContext: Nullable<IPipelineContext>;
  28556. private _valueCache;
  28557. private static _baseCache;
  28558. /**
  28559. * Instantiates an effect.
  28560. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28561. * @param baseName Name of the effect.
  28562. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28563. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28564. * @param samplers List of sampler variables that will be passed to the shader.
  28565. * @param engine Engine to be used to render the effect
  28566. * @param defines Define statements to be added to the shader.
  28567. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28568. * @param onCompiled Callback that will be called when the shader is compiled.
  28569. * @param onError Callback that will be called if an error occurs during shader compilation.
  28570. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28571. */
  28572. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28573. private _useFinalCode;
  28574. /**
  28575. * Unique key for this effect
  28576. */
  28577. readonly key: string;
  28578. /**
  28579. * If the effect has been compiled and prepared.
  28580. * @returns if the effect is compiled and prepared.
  28581. */
  28582. isReady(): boolean;
  28583. private _isReadyInternal;
  28584. /**
  28585. * The engine the effect was initialized with.
  28586. * @returns the engine.
  28587. */
  28588. getEngine(): Engine;
  28589. /**
  28590. * The pipeline context for this effect
  28591. * @returns the associated pipeline context
  28592. */
  28593. getPipelineContext(): Nullable<IPipelineContext>;
  28594. /**
  28595. * The set of names of attribute variables for the shader.
  28596. * @returns An array of attribute names.
  28597. */
  28598. getAttributesNames(): string[];
  28599. /**
  28600. * Returns the attribute at the given index.
  28601. * @param index The index of the attribute.
  28602. * @returns The location of the attribute.
  28603. */
  28604. getAttributeLocation(index: number): number;
  28605. /**
  28606. * Returns the attribute based on the name of the variable.
  28607. * @param name of the attribute to look up.
  28608. * @returns the attribute location.
  28609. */
  28610. getAttributeLocationByName(name: string): number;
  28611. /**
  28612. * The number of attributes.
  28613. * @returns the numnber of attributes.
  28614. */
  28615. getAttributesCount(): number;
  28616. /**
  28617. * Gets the index of a uniform variable.
  28618. * @param uniformName of the uniform to look up.
  28619. * @returns the index.
  28620. */
  28621. getUniformIndex(uniformName: string): number;
  28622. /**
  28623. * Returns the attribute based on the name of the variable.
  28624. * @param uniformName of the uniform to look up.
  28625. * @returns the location of the uniform.
  28626. */
  28627. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28628. /**
  28629. * Returns an array of sampler variable names
  28630. * @returns The array of sampler variable neames.
  28631. */
  28632. getSamplers(): string[];
  28633. /**
  28634. * The error from the last compilation.
  28635. * @returns the error string.
  28636. */
  28637. getCompilationError(): string;
  28638. /**
  28639. * Gets a boolean indicating that all fallbacks were used during compilation
  28640. * @returns true if all fallbacks were used
  28641. */
  28642. allFallbacksProcessed(): boolean;
  28643. /**
  28644. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28645. * @param func The callback to be used.
  28646. */
  28647. executeWhenCompiled(func: (effect: Effect) => void): void;
  28648. private _checkIsReady;
  28649. private _loadShader;
  28650. /**
  28651. * Recompiles the webGL program
  28652. * @param vertexSourceCode The source code for the vertex shader.
  28653. * @param fragmentSourceCode The source code for the fragment shader.
  28654. * @param onCompiled Callback called when completed.
  28655. * @param onError Callback called on error.
  28656. * @hidden
  28657. */
  28658. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28659. /**
  28660. * Prepares the effect
  28661. * @hidden
  28662. */
  28663. _prepareEffect(): void;
  28664. private _processCompilationErrors;
  28665. /**
  28666. * Checks if the effect is supported. (Must be called after compilation)
  28667. */
  28668. readonly isSupported: boolean;
  28669. /**
  28670. * Binds a texture to the engine to be used as output of the shader.
  28671. * @param channel Name of the output variable.
  28672. * @param texture Texture to bind.
  28673. * @hidden
  28674. */
  28675. _bindTexture(channel: string, texture: InternalTexture): void;
  28676. /**
  28677. * Sets a texture on the engine to be used in the shader.
  28678. * @param channel Name of the sampler variable.
  28679. * @param texture Texture to set.
  28680. */
  28681. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28682. /**
  28683. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28684. * @param channel Name of the sampler variable.
  28685. * @param texture Texture to set.
  28686. */
  28687. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28688. /**
  28689. * Sets an array of textures on the engine to be used in the shader.
  28690. * @param channel Name of the variable.
  28691. * @param textures Textures to set.
  28692. */
  28693. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28694. /**
  28695. * 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)
  28696. * @param channel Name of the sampler variable.
  28697. * @param postProcess Post process to get the input texture from.
  28698. */
  28699. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28700. /**
  28701. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28702. * 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)
  28703. * @param channel Name of the sampler variable.
  28704. * @param postProcess Post process to get the output texture from.
  28705. */
  28706. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28707. /** @hidden */
  28708. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28709. /** @hidden */
  28710. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28711. /** @hidden */
  28712. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28713. /** @hidden */
  28714. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28715. /**
  28716. * Binds a buffer to a uniform.
  28717. * @param buffer Buffer to bind.
  28718. * @param name Name of the uniform variable to bind to.
  28719. */
  28720. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28721. /**
  28722. * Binds block to a uniform.
  28723. * @param blockName Name of the block to bind.
  28724. * @param index Index to bind.
  28725. */
  28726. bindUniformBlock(blockName: string, index: number): void;
  28727. /**
  28728. * Sets an interger value on a uniform variable.
  28729. * @param uniformName Name of the variable.
  28730. * @param value Value to be set.
  28731. * @returns this effect.
  28732. */
  28733. setInt(uniformName: string, value: number): Effect;
  28734. /**
  28735. * Sets an int array on a uniform variable.
  28736. * @param uniformName Name of the variable.
  28737. * @param array array to be set.
  28738. * @returns this effect.
  28739. */
  28740. setIntArray(uniformName: string, array: Int32Array): Effect;
  28741. /**
  28742. * 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)
  28743. * @param uniformName Name of the variable.
  28744. * @param array array to be set.
  28745. * @returns this effect.
  28746. */
  28747. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28748. /**
  28749. * 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)
  28750. * @param uniformName Name of the variable.
  28751. * @param array array to be set.
  28752. * @returns this effect.
  28753. */
  28754. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28755. /**
  28756. * 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)
  28757. * @param uniformName Name of the variable.
  28758. * @param array array to be set.
  28759. * @returns this effect.
  28760. */
  28761. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28762. /**
  28763. * Sets an float array on a uniform variable.
  28764. * @param uniformName Name of the variable.
  28765. * @param array array to be set.
  28766. * @returns this effect.
  28767. */
  28768. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28769. /**
  28770. * 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)
  28771. * @param uniformName Name of the variable.
  28772. * @param array array to be set.
  28773. * @returns this effect.
  28774. */
  28775. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28776. /**
  28777. * 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)
  28778. * @param uniformName Name of the variable.
  28779. * @param array array to be set.
  28780. * @returns this effect.
  28781. */
  28782. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28783. /**
  28784. * 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)
  28785. * @param uniformName Name of the variable.
  28786. * @param array array to be set.
  28787. * @returns this effect.
  28788. */
  28789. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28790. /**
  28791. * Sets an array on a uniform variable.
  28792. * @param uniformName Name of the variable.
  28793. * @param array array to be set.
  28794. * @returns this effect.
  28795. */
  28796. setArray(uniformName: string, array: number[]): Effect;
  28797. /**
  28798. * 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)
  28799. * @param uniformName Name of the variable.
  28800. * @param array array to be set.
  28801. * @returns this effect.
  28802. */
  28803. setArray2(uniformName: string, array: number[]): Effect;
  28804. /**
  28805. * 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)
  28806. * @param uniformName Name of the variable.
  28807. * @param array array to be set.
  28808. * @returns this effect.
  28809. */
  28810. setArray3(uniformName: string, array: number[]): Effect;
  28811. /**
  28812. * 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)
  28813. * @param uniformName Name of the variable.
  28814. * @param array array to be set.
  28815. * @returns this effect.
  28816. */
  28817. setArray4(uniformName: string, array: number[]): Effect;
  28818. /**
  28819. * Sets matrices on a uniform variable.
  28820. * @param uniformName Name of the variable.
  28821. * @param matrices matrices to be set.
  28822. * @returns this effect.
  28823. */
  28824. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28825. /**
  28826. * Sets matrix on a uniform variable.
  28827. * @param uniformName Name of the variable.
  28828. * @param matrix matrix to be set.
  28829. * @returns this effect.
  28830. */
  28831. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28832. /**
  28833. * 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)
  28834. * @param uniformName Name of the variable.
  28835. * @param matrix matrix to be set.
  28836. * @returns this effect.
  28837. */
  28838. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28839. /**
  28840. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28841. * @param uniformName Name of the variable.
  28842. * @param matrix matrix to be set.
  28843. * @returns this effect.
  28844. */
  28845. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28846. /**
  28847. * Sets a float on a uniform variable.
  28848. * @param uniformName Name of the variable.
  28849. * @param value value to be set.
  28850. * @returns this effect.
  28851. */
  28852. setFloat(uniformName: string, value: number): Effect;
  28853. /**
  28854. * Sets a boolean on a uniform variable.
  28855. * @param uniformName Name of the variable.
  28856. * @param bool value to be set.
  28857. * @returns this effect.
  28858. */
  28859. setBool(uniformName: string, bool: boolean): Effect;
  28860. /**
  28861. * Sets a Vector2 on a uniform variable.
  28862. * @param uniformName Name of the variable.
  28863. * @param vector2 vector2 to be set.
  28864. * @returns this effect.
  28865. */
  28866. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28867. /**
  28868. * Sets a float2 on a uniform variable.
  28869. * @param uniformName Name of the variable.
  28870. * @param x First float in float2.
  28871. * @param y Second float in float2.
  28872. * @returns this effect.
  28873. */
  28874. setFloat2(uniformName: string, x: number, y: number): Effect;
  28875. /**
  28876. * Sets a Vector3 on a uniform variable.
  28877. * @param uniformName Name of the variable.
  28878. * @param vector3 Value to be set.
  28879. * @returns this effect.
  28880. */
  28881. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28882. /**
  28883. * Sets a float3 on a uniform variable.
  28884. * @param uniformName Name of the variable.
  28885. * @param x First float in float3.
  28886. * @param y Second float in float3.
  28887. * @param z Third float in float3.
  28888. * @returns this effect.
  28889. */
  28890. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28891. /**
  28892. * Sets a Vector4 on a uniform variable.
  28893. * @param uniformName Name of the variable.
  28894. * @param vector4 Value to be set.
  28895. * @returns this effect.
  28896. */
  28897. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28898. /**
  28899. * Sets a float4 on a uniform variable.
  28900. * @param uniformName Name of the variable.
  28901. * @param x First float in float4.
  28902. * @param y Second float in float4.
  28903. * @param z Third float in float4.
  28904. * @param w Fourth float in float4.
  28905. * @returns this effect.
  28906. */
  28907. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28908. /**
  28909. * Sets a Color3 on a uniform variable.
  28910. * @param uniformName Name of the variable.
  28911. * @param color3 Value to be set.
  28912. * @returns this effect.
  28913. */
  28914. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28915. /**
  28916. * Sets a Color4 on a uniform variable.
  28917. * @param uniformName Name of the variable.
  28918. * @param color3 Value to be set.
  28919. * @param alpha Alpha value to be set.
  28920. * @returns this effect.
  28921. */
  28922. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28923. /**
  28924. * Sets a Color4 on a uniform variable
  28925. * @param uniformName defines the name of the variable
  28926. * @param color4 defines the value to be set
  28927. * @returns this effect.
  28928. */
  28929. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28930. /** Release all associated resources */
  28931. dispose(): void;
  28932. /**
  28933. * This function will add a new shader to the shader store
  28934. * @param name the name of the shader
  28935. * @param pixelShader optional pixel shader content
  28936. * @param vertexShader optional vertex shader content
  28937. */
  28938. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28939. /**
  28940. * Store of each shader (The can be looked up using effect.key)
  28941. */
  28942. static ShadersStore: {
  28943. [key: string]: string;
  28944. };
  28945. /**
  28946. * Store of each included file for a shader (The can be looked up using effect.key)
  28947. */
  28948. static IncludesShadersStore: {
  28949. [key: string]: string;
  28950. };
  28951. /**
  28952. * Resets the cache of effects.
  28953. */
  28954. static ResetCache(): void;
  28955. }
  28956. }
  28957. declare module BABYLON {
  28958. /**
  28959. * Interface used to describe the capabilities of the engine relatively to the current browser
  28960. */
  28961. export interface EngineCapabilities {
  28962. /** Maximum textures units per fragment shader */
  28963. maxTexturesImageUnits: number;
  28964. /** Maximum texture units per vertex shader */
  28965. maxVertexTextureImageUnits: number;
  28966. /** Maximum textures units in the entire pipeline */
  28967. maxCombinedTexturesImageUnits: number;
  28968. /** Maximum texture size */
  28969. maxTextureSize: number;
  28970. /** Maximum cube texture size */
  28971. maxCubemapTextureSize: number;
  28972. /** Maximum render texture size */
  28973. maxRenderTextureSize: number;
  28974. /** Maximum number of vertex attributes */
  28975. maxVertexAttribs: number;
  28976. /** Maximum number of varyings */
  28977. maxVaryingVectors: number;
  28978. /** Maximum number of uniforms per vertex shader */
  28979. maxVertexUniformVectors: number;
  28980. /** Maximum number of uniforms per fragment shader */
  28981. maxFragmentUniformVectors: number;
  28982. /** Defines if standard derivates (dx/dy) are supported */
  28983. standardDerivatives: boolean;
  28984. /** Defines if s3tc texture compression is supported */
  28985. s3tc?: WEBGL_compressed_texture_s3tc;
  28986. /** Defines if pvrtc texture compression is supported */
  28987. pvrtc: any;
  28988. /** Defines if etc1 texture compression is supported */
  28989. etc1: any;
  28990. /** Defines if etc2 texture compression is supported */
  28991. etc2: any;
  28992. /** Defines if astc texture compression is supported */
  28993. astc: any;
  28994. /** Defines if float textures are supported */
  28995. textureFloat: boolean;
  28996. /** Defines if vertex array objects are supported */
  28997. vertexArrayObject: boolean;
  28998. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28999. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29000. /** Gets the maximum level of anisotropy supported */
  29001. maxAnisotropy: number;
  29002. /** Defines if instancing is supported */
  29003. instancedArrays: boolean;
  29004. /** Defines if 32 bits indices are supported */
  29005. uintIndices: boolean;
  29006. /** Defines if high precision shaders are supported */
  29007. highPrecisionShaderSupported: boolean;
  29008. /** Defines if depth reading in the fragment shader is supported */
  29009. fragmentDepthSupported: boolean;
  29010. /** Defines if float texture linear filtering is supported*/
  29011. textureFloatLinearFiltering: boolean;
  29012. /** Defines if rendering to float textures is supported */
  29013. textureFloatRender: boolean;
  29014. /** Defines if half float textures are supported*/
  29015. textureHalfFloat: boolean;
  29016. /** Defines if half float texture linear filtering is supported*/
  29017. textureHalfFloatLinearFiltering: boolean;
  29018. /** Defines if rendering to half float textures is supported */
  29019. textureHalfFloatRender: boolean;
  29020. /** Defines if textureLOD shader command is supported */
  29021. textureLOD: boolean;
  29022. /** Defines if draw buffers extension is supported */
  29023. drawBuffersExtension: boolean;
  29024. /** Defines if depth textures are supported */
  29025. depthTextureExtension: boolean;
  29026. /** Defines if float color buffer are supported */
  29027. colorBufferFloat: boolean;
  29028. /** Gets disjoint timer query extension (null if not supported) */
  29029. timerQuery?: EXT_disjoint_timer_query;
  29030. /** Defines if timestamp can be used with timer query */
  29031. canUseTimestampForTimerQuery: boolean;
  29032. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29033. multiview?: any;
  29034. /** Function used to let the system compiles shaders in background */
  29035. parallelShaderCompile?: {
  29036. COMPLETION_STATUS_KHR: number;
  29037. };
  29038. /** Max number of texture samples for MSAA */
  29039. maxMSAASamples: number;
  29040. /** Defines if the blend min max extension is supported */
  29041. blendMinMax: boolean;
  29042. }
  29043. }
  29044. declare module BABYLON {
  29045. /**
  29046. * @hidden
  29047. **/
  29048. export class DepthCullingState {
  29049. private _isDepthTestDirty;
  29050. private _isDepthMaskDirty;
  29051. private _isDepthFuncDirty;
  29052. private _isCullFaceDirty;
  29053. private _isCullDirty;
  29054. private _isZOffsetDirty;
  29055. private _isFrontFaceDirty;
  29056. private _depthTest;
  29057. private _depthMask;
  29058. private _depthFunc;
  29059. private _cull;
  29060. private _cullFace;
  29061. private _zOffset;
  29062. private _frontFace;
  29063. /**
  29064. * Initializes the state.
  29065. */
  29066. constructor();
  29067. readonly isDirty: boolean;
  29068. zOffset: number;
  29069. cullFace: Nullable<number>;
  29070. cull: Nullable<boolean>;
  29071. depthFunc: Nullable<number>;
  29072. depthMask: boolean;
  29073. depthTest: boolean;
  29074. frontFace: Nullable<number>;
  29075. reset(): void;
  29076. apply(gl: WebGLRenderingContext): void;
  29077. }
  29078. }
  29079. declare module BABYLON {
  29080. /**
  29081. * @hidden
  29082. **/
  29083. export class StencilState {
  29084. /** 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 */
  29085. static readonly ALWAYS: number;
  29086. /** Passed to stencilOperation to specify that stencil value must be kept */
  29087. static readonly KEEP: number;
  29088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29089. static readonly REPLACE: number;
  29090. private _isStencilTestDirty;
  29091. private _isStencilMaskDirty;
  29092. private _isStencilFuncDirty;
  29093. private _isStencilOpDirty;
  29094. private _stencilTest;
  29095. private _stencilMask;
  29096. private _stencilFunc;
  29097. private _stencilFuncRef;
  29098. private _stencilFuncMask;
  29099. private _stencilOpStencilFail;
  29100. private _stencilOpDepthFail;
  29101. private _stencilOpStencilDepthPass;
  29102. readonly isDirty: boolean;
  29103. stencilFunc: number;
  29104. stencilFuncRef: number;
  29105. stencilFuncMask: number;
  29106. stencilOpStencilFail: number;
  29107. stencilOpDepthFail: number;
  29108. stencilOpStencilDepthPass: number;
  29109. stencilMask: number;
  29110. stencilTest: boolean;
  29111. constructor();
  29112. reset(): void;
  29113. apply(gl: WebGLRenderingContext): void;
  29114. }
  29115. }
  29116. declare module BABYLON {
  29117. /**
  29118. * @hidden
  29119. **/
  29120. export class AlphaState {
  29121. private _isAlphaBlendDirty;
  29122. private _isBlendFunctionParametersDirty;
  29123. private _isBlendEquationParametersDirty;
  29124. private _isBlendConstantsDirty;
  29125. private _alphaBlend;
  29126. private _blendFunctionParameters;
  29127. private _blendEquationParameters;
  29128. private _blendConstants;
  29129. /**
  29130. * Initializes the state.
  29131. */
  29132. constructor();
  29133. readonly isDirty: boolean;
  29134. alphaBlend: boolean;
  29135. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29136. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29137. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29138. reset(): void;
  29139. apply(gl: WebGLRenderingContext): void;
  29140. }
  29141. }
  29142. declare module BABYLON {
  29143. /** @hidden */
  29144. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29145. attributeProcessor(attribute: string): string;
  29146. varyingProcessor(varying: string, isFragment: boolean): string;
  29147. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29148. }
  29149. }
  29150. declare module BABYLON {
  29151. /**
  29152. * Interface for attribute information associated with buffer instanciation
  29153. */
  29154. export interface InstancingAttributeInfo {
  29155. /**
  29156. * Index/offset of the attribute in the vertex shader
  29157. */
  29158. index: number;
  29159. /**
  29160. * size of the attribute, 1, 2, 3 or 4
  29161. */
  29162. attributeSize: number;
  29163. /**
  29164. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29165. * default is FLOAT
  29166. */
  29167. attributeType: number;
  29168. /**
  29169. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29170. */
  29171. normalized: boolean;
  29172. /**
  29173. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29174. */
  29175. offset: number;
  29176. /**
  29177. * Name of the GLSL attribute, for debugging purpose only
  29178. */
  29179. attributeName: string;
  29180. }
  29181. }
  29182. declare module BABYLON {
  29183. interface ThinEngine {
  29184. /**
  29185. * Update a video texture
  29186. * @param texture defines the texture to update
  29187. * @param video defines the video element to use
  29188. * @param invertY defines if data must be stored with Y axis inverted
  29189. */
  29190. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29191. }
  29192. }
  29193. declare module BABYLON {
  29194. /**
  29195. * Settings for finer control over video usage
  29196. */
  29197. export interface VideoTextureSettings {
  29198. /**
  29199. * Applies `autoplay` to video, if specified
  29200. */
  29201. autoPlay?: boolean;
  29202. /**
  29203. * Applies `loop` to video, if specified
  29204. */
  29205. loop?: boolean;
  29206. /**
  29207. * Automatically updates internal texture from video at every frame in the render loop
  29208. */
  29209. autoUpdateTexture: boolean;
  29210. /**
  29211. * Image src displayed during the video loading or until the user interacts with the video.
  29212. */
  29213. poster?: string;
  29214. }
  29215. /**
  29216. * If you want to display a video in your scene, this is the special texture for that.
  29217. * This special texture works similar to other textures, with the exception of a few parameters.
  29218. * @see https://doc.babylonjs.com/how_to/video_texture
  29219. */
  29220. export class VideoTexture extends Texture {
  29221. /**
  29222. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29223. */
  29224. readonly autoUpdateTexture: boolean;
  29225. /**
  29226. * The video instance used by the texture internally
  29227. */
  29228. readonly video: HTMLVideoElement;
  29229. private _onUserActionRequestedObservable;
  29230. /**
  29231. * Event triggerd when a dom action is required by the user to play the video.
  29232. * This happens due to recent changes in browser policies preventing video to auto start.
  29233. */
  29234. readonly onUserActionRequestedObservable: Observable<Texture>;
  29235. private _generateMipMaps;
  29236. private _engine;
  29237. private _stillImageCaptured;
  29238. private _displayingPosterTexture;
  29239. private _settings;
  29240. private _createInternalTextureOnEvent;
  29241. private _frameId;
  29242. /**
  29243. * Creates a video texture.
  29244. * If you want to display a video in your scene, this is the special texture for that.
  29245. * This special texture works similar to other textures, with the exception of a few parameters.
  29246. * @see https://doc.babylonjs.com/how_to/video_texture
  29247. * @param name optional name, will detect from video source, if not defined
  29248. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29249. * @param scene is obviously the current scene.
  29250. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29251. * @param invertY is false by default but can be used to invert video on Y axis
  29252. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29253. * @param settings allows finer control over video usage
  29254. */
  29255. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29256. private _getName;
  29257. private _getVideo;
  29258. private _createInternalTexture;
  29259. private reset;
  29260. /**
  29261. * @hidden Internal method to initiate `update`.
  29262. */
  29263. _rebuild(): void;
  29264. /**
  29265. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29266. */
  29267. update(): void;
  29268. /**
  29269. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29270. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29271. */
  29272. updateTexture(isVisible: boolean): void;
  29273. protected _updateInternalTexture: () => void;
  29274. /**
  29275. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29276. * @param url New url.
  29277. */
  29278. updateURL(url: string): void;
  29279. /**
  29280. * Dispose the texture and release its associated resources.
  29281. */
  29282. dispose(): void;
  29283. /**
  29284. * Creates a video texture straight from a stream.
  29285. * @param scene Define the scene the texture should be created in
  29286. * @param stream Define the stream the texture should be created from
  29287. * @returns The created video texture as a promise
  29288. */
  29289. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29290. /**
  29291. * Creates a video texture straight from your WebCam video feed.
  29292. * @param scene Define the scene the texture should be created in
  29293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29295. * @returns The created video texture as a promise
  29296. */
  29297. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29298. minWidth: number;
  29299. maxWidth: number;
  29300. minHeight: number;
  29301. maxHeight: number;
  29302. deviceId: string;
  29303. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29304. /**
  29305. * Creates a video texture straight from your WebCam video feed.
  29306. * @param scene Define the scene the texture should be created in
  29307. * @param onReady Define a callback to triggered once the texture will be ready
  29308. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29309. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29310. */
  29311. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29312. minWidth: number;
  29313. maxWidth: number;
  29314. minHeight: number;
  29315. maxHeight: number;
  29316. deviceId: string;
  29317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29318. }
  29319. }
  29320. declare module BABYLON {
  29321. /**
  29322. * Defines the interface used by objects working like Scene
  29323. * @hidden
  29324. */
  29325. interface ISceneLike {
  29326. _addPendingData(data: any): void;
  29327. _removePendingData(data: any): void;
  29328. offlineProvider: IOfflineProvider;
  29329. }
  29330. /** Interface defining initialization parameters for Engine class */
  29331. export interface EngineOptions extends WebGLContextAttributes {
  29332. /**
  29333. * Defines if the engine should no exceed a specified device ratio
  29334. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29335. */
  29336. limitDeviceRatio?: number;
  29337. /**
  29338. * Defines if webvr should be enabled automatically
  29339. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29340. */
  29341. autoEnableWebVR?: boolean;
  29342. /**
  29343. * Defines if webgl2 should be turned off even if supported
  29344. * @see http://doc.babylonjs.com/features/webgl2
  29345. */
  29346. disableWebGL2Support?: boolean;
  29347. /**
  29348. * Defines if webaudio should be initialized as well
  29349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29350. */
  29351. audioEngine?: boolean;
  29352. /**
  29353. * Defines if animations should run using a deterministic lock step
  29354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29355. */
  29356. deterministicLockstep?: boolean;
  29357. /** Defines the maximum steps to use with deterministic lock step mode */
  29358. lockstepMaxSteps?: number;
  29359. /**
  29360. * Defines that engine should ignore context lost events
  29361. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29362. */
  29363. doNotHandleContextLost?: boolean;
  29364. /**
  29365. * Defines that engine should ignore modifying touch action attribute and style
  29366. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29367. */
  29368. doNotHandleTouchAction?: boolean;
  29369. /**
  29370. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29371. */
  29372. useHighPrecisionFloats?: boolean;
  29373. }
  29374. /**
  29375. * The base engine class (root of all engines)
  29376. */
  29377. export class ThinEngine {
  29378. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29379. static ExceptionList: ({
  29380. key: string;
  29381. capture: string;
  29382. captureConstraint: number;
  29383. targets: string[];
  29384. } | {
  29385. key: string;
  29386. capture: null;
  29387. captureConstraint: null;
  29388. targets: string[];
  29389. })[];
  29390. /** @hidden */
  29391. static _TextureLoaders: IInternalTextureLoader[];
  29392. /**
  29393. * Returns the current npm package of the sdk
  29394. */
  29395. static readonly NpmPackage: string;
  29396. /**
  29397. * Returns the current version of the framework
  29398. */
  29399. static readonly Version: string;
  29400. /**
  29401. * Returns a string describing the current engine
  29402. */
  29403. readonly description: string;
  29404. /**
  29405. * Gets or sets the epsilon value used by collision engine
  29406. */
  29407. static CollisionsEpsilon: number;
  29408. /**
  29409. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29410. */
  29411. static ShadersRepository: string;
  29412. /** @hidden */
  29413. _shaderProcessor: IShaderProcessor;
  29414. /**
  29415. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29416. */
  29417. forcePOTTextures: boolean;
  29418. /**
  29419. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29420. */
  29421. isFullscreen: boolean;
  29422. /**
  29423. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29424. */
  29425. cullBackFaces: boolean;
  29426. /**
  29427. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29428. */
  29429. renderEvenInBackground: boolean;
  29430. /**
  29431. * Gets or sets a boolean indicating that cache can be kept between frames
  29432. */
  29433. preventCacheWipeBetweenFrames: boolean;
  29434. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29435. validateShaderPrograms: boolean;
  29436. /**
  29437. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29438. */
  29439. disableUniformBuffers: boolean;
  29440. /** @hidden */
  29441. _uniformBuffers: UniformBuffer[];
  29442. /**
  29443. * Gets a boolean indicating that the engine supports uniform buffers
  29444. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29445. */
  29446. readonly supportsUniformBuffers: boolean;
  29447. /** @hidden */
  29448. _gl: WebGLRenderingContext;
  29449. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29450. protected _windowIsBackground: boolean;
  29451. protected _webGLVersion: number;
  29452. protected _creationOptions: EngineOptions;
  29453. protected _highPrecisionShadersAllowed: boolean;
  29454. /** @hidden */
  29455. readonly _shouldUseHighPrecisionShader: boolean;
  29456. /**
  29457. * Gets a boolean indicating that only power of 2 textures are supported
  29458. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29459. */
  29460. readonly needPOTTextures: boolean;
  29461. /** @hidden */
  29462. _badOS: boolean;
  29463. /** @hidden */
  29464. _badDesktopOS: boolean;
  29465. private _hardwareScalingLevel;
  29466. /** @hidden */
  29467. _caps: EngineCapabilities;
  29468. private _isStencilEnable;
  29469. protected _colorWrite: boolean;
  29470. private _glVersion;
  29471. private _glRenderer;
  29472. private _glVendor;
  29473. /** @hidden */
  29474. _videoTextureSupported: boolean;
  29475. protected _renderingQueueLaunched: boolean;
  29476. protected _activeRenderLoops: (() => void)[];
  29477. /**
  29478. * Observable signaled when a context lost event is raised
  29479. */
  29480. onContextLostObservable: Observable<ThinEngine>;
  29481. /**
  29482. * Observable signaled when a context restored event is raised
  29483. */
  29484. onContextRestoredObservable: Observable<ThinEngine>;
  29485. private _onContextLost;
  29486. private _onContextRestored;
  29487. protected _contextWasLost: boolean;
  29488. /** @hidden */
  29489. _doNotHandleContextLost: boolean;
  29490. /**
  29491. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29493. */
  29494. doNotHandleContextLost: boolean;
  29495. /**
  29496. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29497. */
  29498. disableVertexArrayObjects: boolean;
  29499. /** @hidden */
  29500. protected _depthCullingState: DepthCullingState;
  29501. /** @hidden */
  29502. protected _stencilState: StencilState;
  29503. /** @hidden */
  29504. protected _alphaState: AlphaState;
  29505. /** @hidden */
  29506. _internalTexturesCache: InternalTexture[];
  29507. /** @hidden */
  29508. protected _activeChannel: number;
  29509. private _currentTextureChannel;
  29510. /** @hidden */
  29511. protected _boundTexturesCache: {
  29512. [key: string]: Nullable<InternalTexture>;
  29513. };
  29514. /** @hidden */
  29515. protected _currentEffect: Nullable<Effect>;
  29516. /** @hidden */
  29517. protected _currentProgram: Nullable<WebGLProgram>;
  29518. private _compiledEffects;
  29519. private _vertexAttribArraysEnabled;
  29520. /** @hidden */
  29521. protected _cachedViewport: Nullable<IViewportLike>;
  29522. private _cachedVertexArrayObject;
  29523. /** @hidden */
  29524. protected _cachedVertexBuffers: any;
  29525. /** @hidden */
  29526. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29527. /** @hidden */
  29528. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29529. /** @hidden */
  29530. _currentRenderTarget: Nullable<InternalTexture>;
  29531. private _uintIndicesCurrentlySet;
  29532. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29533. /** @hidden */
  29534. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29535. private _currentBufferPointers;
  29536. private _currentInstanceLocations;
  29537. private _currentInstanceBuffers;
  29538. private _textureUnits;
  29539. /** @hidden */
  29540. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29541. /** @hidden */
  29542. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29543. /** @hidden */
  29544. _boundRenderFunction: any;
  29545. private _vaoRecordInProgress;
  29546. private _mustWipeVertexAttributes;
  29547. private _emptyTexture;
  29548. private _emptyCubeTexture;
  29549. private _emptyTexture3D;
  29550. private _emptyTexture2DArray;
  29551. /** @hidden */
  29552. _frameHandler: number;
  29553. private _nextFreeTextureSlots;
  29554. private _maxSimultaneousTextures;
  29555. private _activeRequests;
  29556. protected _texturesSupported: string[];
  29557. /** @hidden */
  29558. _textureFormatInUse: Nullable<string>;
  29559. protected readonly _supportsHardwareTextureRescaling: boolean;
  29560. /**
  29561. * Gets the list of texture formats supported
  29562. */
  29563. readonly texturesSupported: Array<string>;
  29564. /**
  29565. * Gets the list of texture formats in use
  29566. */
  29567. readonly textureFormatInUse: Nullable<string>;
  29568. /**
  29569. * Gets the current viewport
  29570. */
  29571. readonly currentViewport: Nullable<IViewportLike>;
  29572. /**
  29573. * Gets the default empty texture
  29574. */
  29575. readonly emptyTexture: InternalTexture;
  29576. /**
  29577. * Gets the default empty 3D texture
  29578. */
  29579. readonly emptyTexture3D: InternalTexture;
  29580. /**
  29581. * Gets the default empty 2D array texture
  29582. */
  29583. readonly emptyTexture2DArray: InternalTexture;
  29584. /**
  29585. * Gets the default empty cube texture
  29586. */
  29587. readonly emptyCubeTexture: InternalTexture;
  29588. /**
  29589. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29590. */
  29591. readonly premultipliedAlpha: boolean;
  29592. /**
  29593. * Observable event triggered before each texture is initialized
  29594. */
  29595. onBeforeTextureInitObservable: Observable<Texture>;
  29596. /**
  29597. * Creates a new engine
  29598. * @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
  29599. * @param antialias defines enable antialiasing (default: false)
  29600. * @param options defines further options to be sent to the getContext() function
  29601. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29602. */
  29603. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29604. private _rebuildInternalTextures;
  29605. private _rebuildEffects;
  29606. /**
  29607. * Gets a boolean indicating if all created effects are ready
  29608. * @returns true if all effects are ready
  29609. */
  29610. areAllEffectsReady(): boolean;
  29611. protected _rebuildBuffers(): void;
  29612. private _initGLContext;
  29613. /**
  29614. * Gets version of the current webGL context
  29615. */
  29616. readonly webGLVersion: number;
  29617. /**
  29618. * Gets a string idenfifying the name of the class
  29619. * @returns "Engine" string
  29620. */
  29621. getClassName(): string;
  29622. /**
  29623. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29624. */
  29625. readonly isStencilEnable: boolean;
  29626. /** @hidden */
  29627. _prepareWorkingCanvas(): void;
  29628. /**
  29629. * Reset the texture cache to empty state
  29630. */
  29631. resetTextureCache(): void;
  29632. /**
  29633. * Gets an object containing information about the current webGL context
  29634. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29635. */
  29636. getGlInfo(): {
  29637. vendor: string;
  29638. renderer: string;
  29639. version: string;
  29640. };
  29641. /**
  29642. * Defines the hardware scaling level.
  29643. * By default the hardware scaling level is computed from the window device ratio.
  29644. * 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.
  29645. * @param level defines the level to use
  29646. */
  29647. setHardwareScalingLevel(level: number): void;
  29648. /**
  29649. * Gets the current hardware scaling level.
  29650. * By default the hardware scaling level is computed from the window device ratio.
  29651. * 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.
  29652. * @returns a number indicating the current hardware scaling level
  29653. */
  29654. getHardwareScalingLevel(): number;
  29655. /**
  29656. * Gets the list of loaded textures
  29657. * @returns an array containing all loaded textures
  29658. */
  29659. getLoadedTexturesCache(): InternalTexture[];
  29660. /**
  29661. * Gets the object containing all engine capabilities
  29662. * @returns the EngineCapabilities object
  29663. */
  29664. getCaps(): EngineCapabilities;
  29665. /**
  29666. * stop executing a render loop function and remove it from the execution array
  29667. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29668. */
  29669. stopRenderLoop(renderFunction?: () => void): void;
  29670. /** @hidden */
  29671. _renderLoop(): void;
  29672. /**
  29673. * Gets the HTML canvas attached with the current webGL context
  29674. * @returns a HTML canvas
  29675. */
  29676. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29677. /**
  29678. * Gets host window
  29679. * @returns the host window object
  29680. */
  29681. getHostWindow(): Nullable<Window>;
  29682. /**
  29683. * Gets the current render width
  29684. * @param useScreen defines if screen size must be used (or the current render target if any)
  29685. * @returns a number defining the current render width
  29686. */
  29687. getRenderWidth(useScreen?: boolean): number;
  29688. /**
  29689. * Gets the current render height
  29690. * @param useScreen defines if screen size must be used (or the current render target if any)
  29691. * @returns a number defining the current render height
  29692. */
  29693. getRenderHeight(useScreen?: boolean): number;
  29694. /**
  29695. * Can be used to override the current requestAnimationFrame requester.
  29696. * @hidden
  29697. */
  29698. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29699. /**
  29700. * Register and execute a render loop. The engine can have more than one render function
  29701. * @param renderFunction defines the function to continuously execute
  29702. */
  29703. runRenderLoop(renderFunction: () => void): void;
  29704. /**
  29705. * Clear the current render buffer or the current render target (if any is set up)
  29706. * @param color defines the color to use
  29707. * @param backBuffer defines if the back buffer must be cleared
  29708. * @param depth defines if the depth buffer must be cleared
  29709. * @param stencil defines if the stencil buffer must be cleared
  29710. */
  29711. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29712. private _viewportCached;
  29713. /** @hidden */
  29714. _viewport(x: number, y: number, width: number, height: number): void;
  29715. /**
  29716. * Set the WebGL's viewport
  29717. * @param viewport defines the viewport element to be used
  29718. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29719. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29720. */
  29721. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29722. /**
  29723. * Begin a new frame
  29724. */
  29725. beginFrame(): void;
  29726. /**
  29727. * Enf the current frame
  29728. */
  29729. endFrame(): void;
  29730. /**
  29731. * Resize the view according to the canvas' size
  29732. */
  29733. resize(): void;
  29734. /**
  29735. * Force a specific size of the canvas
  29736. * @param width defines the new canvas' width
  29737. * @param height defines the new canvas' height
  29738. */
  29739. setSize(width: number, height: number): void;
  29740. /**
  29741. * Binds the frame buffer to the specified texture.
  29742. * @param texture The texture to render to or null for the default canvas
  29743. * @param faceIndex The face of the texture to render to in case of cube texture
  29744. * @param requiredWidth The width of the target to render to
  29745. * @param requiredHeight The height of the target to render to
  29746. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29747. * @param depthStencilTexture The depth stencil texture to use to render
  29748. * @param lodLevel defines le lod level to bind to the frame buffer
  29749. */
  29750. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29751. /** @hidden */
  29752. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29753. /**
  29754. * Unbind the current render target texture from the webGL context
  29755. * @param texture defines the render target texture to unbind
  29756. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29757. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29758. */
  29759. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29760. /**
  29761. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29762. */
  29763. flushFramebuffer(): void;
  29764. /**
  29765. * Unbind the current render target and bind the default framebuffer
  29766. */
  29767. restoreDefaultFramebuffer(): void;
  29768. /** @hidden */
  29769. protected _resetVertexBufferBinding(): void;
  29770. /**
  29771. * Creates a vertex buffer
  29772. * @param data the data for the vertex buffer
  29773. * @returns the new WebGL static buffer
  29774. */
  29775. createVertexBuffer(data: DataArray): DataBuffer;
  29776. private _createVertexBuffer;
  29777. /**
  29778. * Creates a dynamic vertex buffer
  29779. * @param data the data for the dynamic vertex buffer
  29780. * @returns the new WebGL dynamic buffer
  29781. */
  29782. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29783. protected _resetIndexBufferBinding(): void;
  29784. /**
  29785. * Creates a new index buffer
  29786. * @param indices defines the content of the index buffer
  29787. * @param updatable defines if the index buffer must be updatable
  29788. * @returns a new webGL buffer
  29789. */
  29790. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29791. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29792. /**
  29793. * Bind a webGL buffer to the webGL context
  29794. * @param buffer defines the buffer to bind
  29795. */
  29796. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29797. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29798. private bindBuffer;
  29799. /**
  29800. * update the bound buffer with the given data
  29801. * @param data defines the data to update
  29802. */
  29803. updateArrayBuffer(data: Float32Array): void;
  29804. private _vertexAttribPointer;
  29805. private _bindIndexBufferWithCache;
  29806. private _bindVertexBuffersAttributes;
  29807. /**
  29808. * Records a vertex array object
  29809. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29810. * @param vertexBuffers defines the list of vertex buffers to store
  29811. * @param indexBuffer defines the index buffer to store
  29812. * @param effect defines the effect to store
  29813. * @returns the new vertex array object
  29814. */
  29815. recordVertexArrayObject(vertexBuffers: {
  29816. [key: string]: VertexBuffer;
  29817. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29818. /**
  29819. * Bind a specific vertex array object
  29820. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29821. * @param vertexArrayObject defines the vertex array object to bind
  29822. * @param indexBuffer defines the index buffer to bind
  29823. */
  29824. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29825. /**
  29826. * Bind webGl buffers directly to the webGL context
  29827. * @param vertexBuffer defines the vertex buffer to bind
  29828. * @param indexBuffer defines the index buffer to bind
  29829. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29830. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29831. * @param effect defines the effect associated with the vertex buffer
  29832. */
  29833. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29834. private _unbindVertexArrayObject;
  29835. /**
  29836. * Bind a list of vertex buffers to the webGL context
  29837. * @param vertexBuffers defines the list of vertex buffers to bind
  29838. * @param indexBuffer defines the index buffer to bind
  29839. * @param effect defines the effect associated with the vertex buffers
  29840. */
  29841. bindBuffers(vertexBuffers: {
  29842. [key: string]: Nullable<VertexBuffer>;
  29843. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29844. /**
  29845. * Unbind all instance attributes
  29846. */
  29847. unbindInstanceAttributes(): void;
  29848. /**
  29849. * Release and free the memory of a vertex array object
  29850. * @param vao defines the vertex array object to delete
  29851. */
  29852. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29853. /** @hidden */
  29854. _releaseBuffer(buffer: DataBuffer): boolean;
  29855. protected _deleteBuffer(buffer: DataBuffer): void;
  29856. /**
  29857. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29858. * @param instancesBuffer defines the webGL buffer to update and bind
  29859. * @param data defines the data to store in the buffer
  29860. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29861. */
  29862. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29863. /**
  29864. * Apply all cached states (depth, culling, stencil and alpha)
  29865. */
  29866. applyStates(): void;
  29867. /**
  29868. * Send a draw order
  29869. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29870. * @param indexStart defines the starting index
  29871. * @param indexCount defines the number of index to draw
  29872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29873. */
  29874. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29875. /**
  29876. * Draw a list of points
  29877. * @param verticesStart defines the index of first vertex to draw
  29878. * @param verticesCount defines the count of vertices to draw
  29879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29880. */
  29881. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29882. /**
  29883. * Draw a list of unindexed primitives
  29884. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29885. * @param verticesStart defines the index of first vertex to draw
  29886. * @param verticesCount defines the count of vertices to draw
  29887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29888. */
  29889. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29890. /**
  29891. * Draw a list of indexed primitives
  29892. * @param fillMode defines the primitive to use
  29893. * @param indexStart defines the starting index
  29894. * @param indexCount defines the number of index to draw
  29895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29896. */
  29897. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29898. /**
  29899. * Draw a list of unindexed primitives
  29900. * @param fillMode defines the primitive to use
  29901. * @param verticesStart defines the index of first vertex to draw
  29902. * @param verticesCount defines the count of vertices to draw
  29903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29904. */
  29905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29906. private _drawMode;
  29907. /** @hidden */
  29908. protected _reportDrawCall(): void;
  29909. /** @hidden */
  29910. _releaseEffect(effect: Effect): void;
  29911. /** @hidden */
  29912. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29913. /**
  29914. * Create a new effect (used to store vertex/fragment shaders)
  29915. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29916. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29917. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29918. * @param samplers defines an array of string used to represent textures
  29919. * @param defines defines the string containing the defines to use to compile the shaders
  29920. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29921. * @param onCompiled defines a function to call when the effect creation is successful
  29922. * @param onError defines a function to call when the effect creation has failed
  29923. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29924. * @returns the new Effect
  29925. */
  29926. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29927. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29928. private _compileShader;
  29929. private _compileRawShader;
  29930. /**
  29931. * Directly creates a webGL program
  29932. * @param pipelineContext defines the pipeline context to attach to
  29933. * @param vertexCode defines the vertex shader code to use
  29934. * @param fragmentCode defines the fragment shader code to use
  29935. * @param context defines the webGL context to use (if not set, the current one will be used)
  29936. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29937. * @returns the new webGL program
  29938. */
  29939. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29940. /**
  29941. * Creates a webGL program
  29942. * @param pipelineContext defines the pipeline context to attach to
  29943. * @param vertexCode defines the vertex shader code to use
  29944. * @param fragmentCode defines the fragment shader code to use
  29945. * @param defines defines the string containing the defines to use to compile the shaders
  29946. * @param context defines the webGL context to use (if not set, the current one will be used)
  29947. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29948. * @returns the new webGL program
  29949. */
  29950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29951. /**
  29952. * Creates a new pipeline context
  29953. * @returns the new pipeline
  29954. */
  29955. createPipelineContext(): IPipelineContext;
  29956. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29957. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29958. /** @hidden */
  29959. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29960. /** @hidden */
  29961. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29962. /** @hidden */
  29963. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29964. /**
  29965. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29966. * @param pipelineContext defines the pipeline context to use
  29967. * @param uniformsNames defines the list of uniform names
  29968. * @returns an array of webGL uniform locations
  29969. */
  29970. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29971. /**
  29972. * Gets the lsit of active attributes for a given webGL program
  29973. * @param pipelineContext defines the pipeline context to use
  29974. * @param attributesNames defines the list of attribute names to get
  29975. * @returns an array of indices indicating the offset of each attribute
  29976. */
  29977. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29978. /**
  29979. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29980. * @param effect defines the effect to activate
  29981. */
  29982. enableEffect(effect: Nullable<Effect>): void;
  29983. /**
  29984. * Set the value of an uniform to a number (int)
  29985. * @param uniform defines the webGL uniform location where to store the value
  29986. * @param value defines the int number to store
  29987. */
  29988. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29989. /**
  29990. * Set the value of an uniform to an array of int32
  29991. * @param uniform defines the webGL uniform location where to store the value
  29992. * @param array defines the array of int32 to store
  29993. */
  29994. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29995. /**
  29996. * Set the value of an uniform to an array of int32 (stored as vec2)
  29997. * @param uniform defines the webGL uniform location where to store the value
  29998. * @param array defines the array of int32 to store
  29999. */
  30000. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30001. /**
  30002. * Set the value of an uniform to an array of int32 (stored as vec3)
  30003. * @param uniform defines the webGL uniform location where to store the value
  30004. * @param array defines the array of int32 to store
  30005. */
  30006. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30007. /**
  30008. * Set the value of an uniform to an array of int32 (stored as vec4)
  30009. * @param uniform defines the webGL uniform location where to store the value
  30010. * @param array defines the array of int32 to store
  30011. */
  30012. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30013. /**
  30014. * Set the value of an uniform to an array of number
  30015. * @param uniform defines the webGL uniform location where to store the value
  30016. * @param array defines the array of number to store
  30017. */
  30018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30019. /**
  30020. * Set the value of an uniform to an array of number (stored as vec2)
  30021. * @param uniform defines the webGL uniform location where to store the value
  30022. * @param array defines the array of number to store
  30023. */
  30024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30025. /**
  30026. * Set the value of an uniform to an array of number (stored as vec3)
  30027. * @param uniform defines the webGL uniform location where to store the value
  30028. * @param array defines the array of number to store
  30029. */
  30030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30031. /**
  30032. * Set the value of an uniform to an array of number (stored as vec4)
  30033. * @param uniform defines the webGL uniform location where to store the value
  30034. * @param array defines the array of number to store
  30035. */
  30036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30037. /**
  30038. * Set the value of an uniform to an array of float32 (stored as matrices)
  30039. * @param uniform defines the webGL uniform location where to store the value
  30040. * @param matrices defines the array of float32 to store
  30041. */
  30042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30043. /**
  30044. * Set the value of an uniform to a matrix (3x3)
  30045. * @param uniform defines the webGL uniform location where to store the value
  30046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30047. */
  30048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30049. /**
  30050. * Set the value of an uniform to a matrix (2x2)
  30051. * @param uniform defines the webGL uniform location where to store the value
  30052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30053. */
  30054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30055. /**
  30056. * Set the value of an uniform to a number (float)
  30057. * @param uniform defines the webGL uniform location where to store the value
  30058. * @param value defines the float number to store
  30059. */
  30060. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30061. /**
  30062. * Set the value of an uniform to a vec2
  30063. * @param uniform defines the webGL uniform location where to store the value
  30064. * @param x defines the 1st component of the value
  30065. * @param y defines the 2nd component of the value
  30066. */
  30067. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30068. /**
  30069. * Set the value of an uniform to a vec3
  30070. * @param uniform defines the webGL uniform location where to store the value
  30071. * @param x defines the 1st component of the value
  30072. * @param y defines the 2nd component of the value
  30073. * @param z defines the 3rd component of the value
  30074. */
  30075. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30076. /**
  30077. * Set the value of an uniform to a vec4
  30078. * @param uniform defines the webGL uniform location where to store the value
  30079. * @param x defines the 1st component of the value
  30080. * @param y defines the 2nd component of the value
  30081. * @param z defines the 3rd component of the value
  30082. * @param w defines the 4th component of the value
  30083. */
  30084. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30085. /**
  30086. * Gets the depth culling state manager
  30087. */
  30088. readonly depthCullingState: DepthCullingState;
  30089. /**
  30090. * Gets the alpha state manager
  30091. */
  30092. readonly alphaState: AlphaState;
  30093. /**
  30094. * Gets the stencil state manager
  30095. */
  30096. readonly stencilState: StencilState;
  30097. /**
  30098. * Clears the list of texture accessible through engine.
  30099. * This can help preventing texture load conflict due to name collision.
  30100. */
  30101. clearInternalTexturesCache(): void;
  30102. /**
  30103. * Force the entire cache to be cleared
  30104. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30105. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30106. */
  30107. wipeCaches(bruteForce?: boolean): void;
  30108. /** @hidden */
  30109. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30110. min: number;
  30111. mag: number;
  30112. };
  30113. /** @hidden */
  30114. _createTexture(): WebGLTexture;
  30115. /**
  30116. * Usually called from Texture.ts.
  30117. * Passed information to create a WebGLTexture
  30118. * @param urlArg defines a value which contains one of the following:
  30119. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30120. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30121. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30122. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30123. * @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)
  30124. * @param scene needed for loading to the correct scene
  30125. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30126. * @param onLoad optional callback to be called upon successful completion
  30127. * @param onError optional callback to be called upon failure
  30128. * @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
  30129. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30130. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30131. * @param forcedExtension defines the extension to use to pick the right loader
  30132. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30133. * @param mimeType defines an optional mime type
  30134. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30135. */
  30136. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30137. /**
  30138. * @hidden
  30139. */
  30140. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30141. /**
  30142. * Creates a raw texture
  30143. * @param data defines the data to store in the texture
  30144. * @param width defines the width of the texture
  30145. * @param height defines the height of the texture
  30146. * @param format defines the format of the data
  30147. * @param generateMipMaps defines if the engine should generate the mip levels
  30148. * @param invertY defines if data must be stored with Y axis inverted
  30149. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30150. * @param compression defines the compression used (null by default)
  30151. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30152. * @returns the raw texture inside an InternalTexture
  30153. */
  30154. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30155. /**
  30156. * Creates a new raw cube texture
  30157. * @param data defines the array of data to use to create each face
  30158. * @param size defines the size of the textures
  30159. * @param format defines the format of the data
  30160. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30161. * @param generateMipMaps defines if the engine should generate the mip levels
  30162. * @param invertY defines if data must be stored with Y axis inverted
  30163. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30164. * @param compression defines the compression used (null by default)
  30165. * @returns the cube texture as an InternalTexture
  30166. */
  30167. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30168. /**
  30169. * Creates a new raw 3D texture
  30170. * @param data defines the data used to create the texture
  30171. * @param width defines the width of the texture
  30172. * @param height defines the height of the texture
  30173. * @param depth defines the depth of the texture
  30174. * @param format defines the format of the texture
  30175. * @param generateMipMaps defines if the engine must generate mip levels
  30176. * @param invertY defines if data must be stored with Y axis inverted
  30177. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30178. * @param compression defines the compressed used (can be null)
  30179. * @param textureType defines the compressed used (can be null)
  30180. * @returns a new raw 3D texture (stored in an InternalTexture)
  30181. */
  30182. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30183. /**
  30184. * Creates a new raw 2D array texture
  30185. * @param data defines the data used to create the texture
  30186. * @param width defines the width of the texture
  30187. * @param height defines the height of the texture
  30188. * @param depth defines the number of layers of the texture
  30189. * @param format defines the format of the texture
  30190. * @param generateMipMaps defines if the engine must generate mip levels
  30191. * @param invertY defines if data must be stored with Y axis inverted
  30192. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30193. * @param compression defines the compressed used (can be null)
  30194. * @param textureType defines the compressed used (can be null)
  30195. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30196. */
  30197. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30198. private _unpackFlipYCached;
  30199. /**
  30200. * In case you are sharing the context with other applications, it might
  30201. * be interested to not cache the unpack flip y state to ensure a consistent
  30202. * value would be set.
  30203. */
  30204. enableUnpackFlipYCached: boolean;
  30205. /** @hidden */
  30206. _unpackFlipY(value: boolean): void;
  30207. /** @hidden */
  30208. _getUnpackAlignement(): number;
  30209. /**
  30210. * Update the sampling mode of a given texture
  30211. * @param samplingMode defines the required sampling mode
  30212. * @param texture defines the texture to update
  30213. */
  30214. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30215. /** @hidden */
  30216. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30217. width: number;
  30218. height: number;
  30219. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30220. /** @hidden */
  30221. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30222. /** @hidden */
  30223. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30224. /** @hidden */
  30225. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30226. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30227. private _prepareWebGLTexture;
  30228. /** @hidden */
  30229. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30230. /** @hidden */
  30231. _releaseFramebufferObjects(texture: InternalTexture): void;
  30232. /** @hidden */
  30233. _releaseTexture(texture: InternalTexture): void;
  30234. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30235. protected _setProgram(program: WebGLProgram): void;
  30236. protected _boundUniforms: {
  30237. [key: number]: WebGLUniformLocation;
  30238. };
  30239. /**
  30240. * Binds an effect to the webGL context
  30241. * @param effect defines the effect to bind
  30242. */
  30243. bindSamplers(effect: Effect): void;
  30244. private _activateCurrentTexture;
  30245. /** @hidden */
  30246. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30247. /** @hidden */
  30248. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30249. /**
  30250. * Unbind all textures from the webGL context
  30251. */
  30252. unbindAllTextures(): void;
  30253. /**
  30254. * Sets a texture to the according uniform.
  30255. * @param channel The texture channel
  30256. * @param uniform The uniform to set
  30257. * @param texture The texture to apply
  30258. */
  30259. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30260. private _bindSamplerUniformToChannel;
  30261. private _getTextureWrapMode;
  30262. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30263. /**
  30264. * Sets an array of texture to the webGL context
  30265. * @param channel defines the channel where the texture array must be set
  30266. * @param uniform defines the associated uniform location
  30267. * @param textures defines the array of textures to bind
  30268. */
  30269. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30270. /** @hidden */
  30271. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30272. private _setTextureParameterFloat;
  30273. private _setTextureParameterInteger;
  30274. /**
  30275. * Unbind all vertex attributes from the webGL context
  30276. */
  30277. unbindAllAttributes(): void;
  30278. /**
  30279. * 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
  30280. */
  30281. releaseEffects(): void;
  30282. /**
  30283. * Dispose and release all associated resources
  30284. */
  30285. dispose(): void;
  30286. /**
  30287. * Attach a new callback raised when context lost event is fired
  30288. * @param callback defines the callback to call
  30289. */
  30290. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30291. /**
  30292. * Attach a new callback raised when context restored event is fired
  30293. * @param callback defines the callback to call
  30294. */
  30295. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30296. /**
  30297. * Get the current error code of the webGL context
  30298. * @returns the error code
  30299. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30300. */
  30301. getError(): number;
  30302. private _canRenderToFloatFramebuffer;
  30303. private _canRenderToHalfFloatFramebuffer;
  30304. private _canRenderToFramebuffer;
  30305. /** @hidden */
  30306. _getWebGLTextureType(type: number): number;
  30307. /** @hidden */
  30308. _getInternalFormat(format: number): number;
  30309. /** @hidden */
  30310. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30311. /** @hidden */
  30312. _getRGBAMultiSampleBufferFormat(type: number): number;
  30313. /** @hidden */
  30314. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30315. /**
  30316. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30317. * @returns true if the engine can be created
  30318. * @ignorenaming
  30319. */
  30320. static isSupported(): boolean;
  30321. /**
  30322. * Find the next highest power of two.
  30323. * @param x Number to start search from.
  30324. * @return Next highest power of two.
  30325. */
  30326. static CeilingPOT(x: number): number;
  30327. /**
  30328. * Find the next lowest power of two.
  30329. * @param x Number to start search from.
  30330. * @return Next lowest power of two.
  30331. */
  30332. static FloorPOT(x: number): number;
  30333. /**
  30334. * Find the nearest power of two.
  30335. * @param x Number to start search from.
  30336. * @return Next nearest power of two.
  30337. */
  30338. static NearestPOT(x: number): number;
  30339. /**
  30340. * Get the closest exponent of two
  30341. * @param value defines the value to approximate
  30342. * @param max defines the maximum value to return
  30343. * @param mode defines how to define the closest value
  30344. * @returns closest exponent of two of the given value
  30345. */
  30346. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30347. /**
  30348. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30349. * @param func - the function to be called
  30350. * @param requester - the object that will request the next frame. Falls back to window.
  30351. * @returns frame number
  30352. */
  30353. static QueueNewFrame(func: () => void, requester?: any): number;
  30354. }
  30355. }
  30356. declare module BABYLON {
  30357. /**
  30358. * Class representing spherical harmonics coefficients to the 3rd degree
  30359. */
  30360. export class SphericalHarmonics {
  30361. /**
  30362. * Defines whether or not the harmonics have been prescaled for rendering.
  30363. */
  30364. preScaled: boolean;
  30365. /**
  30366. * The l0,0 coefficients of the spherical harmonics
  30367. */
  30368. l00: Vector3;
  30369. /**
  30370. * The l1,-1 coefficients of the spherical harmonics
  30371. */
  30372. l1_1: Vector3;
  30373. /**
  30374. * The l1,0 coefficients of the spherical harmonics
  30375. */
  30376. l10: Vector3;
  30377. /**
  30378. * The l1,1 coefficients of the spherical harmonics
  30379. */
  30380. l11: Vector3;
  30381. /**
  30382. * The l2,-2 coefficients of the spherical harmonics
  30383. */
  30384. l2_2: Vector3;
  30385. /**
  30386. * The l2,-1 coefficients of the spherical harmonics
  30387. */
  30388. l2_1: Vector3;
  30389. /**
  30390. * The l2,0 coefficients of the spherical harmonics
  30391. */
  30392. l20: Vector3;
  30393. /**
  30394. * The l2,1 coefficients of the spherical harmonics
  30395. */
  30396. l21: Vector3;
  30397. /**
  30398. * The l2,2 coefficients of the spherical harmonics
  30399. */
  30400. l22: Vector3;
  30401. /**
  30402. * Adds a light to the spherical harmonics
  30403. * @param direction the direction of the light
  30404. * @param color the color of the light
  30405. * @param deltaSolidAngle the delta solid angle of the light
  30406. */
  30407. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30408. /**
  30409. * Scales the spherical harmonics by the given amount
  30410. * @param scale the amount to scale
  30411. */
  30412. scaleInPlace(scale: number): void;
  30413. /**
  30414. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30415. *
  30416. * ```
  30417. * E_lm = A_l * L_lm
  30418. * ```
  30419. *
  30420. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30421. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30422. * the scaling factors are given in equation 9.
  30423. */
  30424. convertIncidentRadianceToIrradiance(): void;
  30425. /**
  30426. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30427. *
  30428. * ```
  30429. * L = (1/pi) * E * rho
  30430. * ```
  30431. *
  30432. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30433. */
  30434. convertIrradianceToLambertianRadiance(): void;
  30435. /**
  30436. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30437. * required operations at run time.
  30438. *
  30439. * This is simply done by scaling back the SH with Ylm constants parameter.
  30440. * The trigonometric part being applied by the shader at run time.
  30441. */
  30442. preScaleForRendering(): void;
  30443. /**
  30444. * Constructs a spherical harmonics from an array.
  30445. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30446. * @returns the spherical harmonics
  30447. */
  30448. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30449. /**
  30450. * Gets the spherical harmonics from polynomial
  30451. * @param polynomial the spherical polynomial
  30452. * @returns the spherical harmonics
  30453. */
  30454. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30455. }
  30456. /**
  30457. * Class representing spherical polynomial coefficients to the 3rd degree
  30458. */
  30459. export class SphericalPolynomial {
  30460. private _harmonics;
  30461. /**
  30462. * The spherical harmonics used to create the polynomials.
  30463. */
  30464. readonly preScaledHarmonics: SphericalHarmonics;
  30465. /**
  30466. * The x coefficients of the spherical polynomial
  30467. */
  30468. x: Vector3;
  30469. /**
  30470. * The y coefficients of the spherical polynomial
  30471. */
  30472. y: Vector3;
  30473. /**
  30474. * The z coefficients of the spherical polynomial
  30475. */
  30476. z: Vector3;
  30477. /**
  30478. * The xx coefficients of the spherical polynomial
  30479. */
  30480. xx: Vector3;
  30481. /**
  30482. * The yy coefficients of the spherical polynomial
  30483. */
  30484. yy: Vector3;
  30485. /**
  30486. * The zz coefficients of the spherical polynomial
  30487. */
  30488. zz: Vector3;
  30489. /**
  30490. * The xy coefficients of the spherical polynomial
  30491. */
  30492. xy: Vector3;
  30493. /**
  30494. * The yz coefficients of the spherical polynomial
  30495. */
  30496. yz: Vector3;
  30497. /**
  30498. * The zx coefficients of the spherical polynomial
  30499. */
  30500. zx: Vector3;
  30501. /**
  30502. * Adds an ambient color to the spherical polynomial
  30503. * @param color the color to add
  30504. */
  30505. addAmbient(color: Color3): void;
  30506. /**
  30507. * Scales the spherical polynomial by the given amount
  30508. * @param scale the amount to scale
  30509. */
  30510. scaleInPlace(scale: number): void;
  30511. /**
  30512. * Gets the spherical polynomial from harmonics
  30513. * @param harmonics the spherical harmonics
  30514. * @returns the spherical polynomial
  30515. */
  30516. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30517. /**
  30518. * Constructs a spherical polynomial from an array.
  30519. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30520. * @returns the spherical polynomial
  30521. */
  30522. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30523. }
  30524. }
  30525. declare module BABYLON {
  30526. /**
  30527. * Defines the source of the internal texture
  30528. */
  30529. export enum InternalTextureSource {
  30530. /**
  30531. * The source of the texture data is unknown
  30532. */
  30533. Unknown = 0,
  30534. /**
  30535. * Texture data comes from an URL
  30536. */
  30537. Url = 1,
  30538. /**
  30539. * Texture data is only used for temporary storage
  30540. */
  30541. Temp = 2,
  30542. /**
  30543. * Texture data comes from raw data (ArrayBuffer)
  30544. */
  30545. Raw = 3,
  30546. /**
  30547. * Texture content is dynamic (video or dynamic texture)
  30548. */
  30549. Dynamic = 4,
  30550. /**
  30551. * Texture content is generated by rendering to it
  30552. */
  30553. RenderTarget = 5,
  30554. /**
  30555. * Texture content is part of a multi render target process
  30556. */
  30557. MultiRenderTarget = 6,
  30558. /**
  30559. * Texture data comes from a cube data file
  30560. */
  30561. Cube = 7,
  30562. /**
  30563. * Texture data comes from a raw cube data
  30564. */
  30565. CubeRaw = 8,
  30566. /**
  30567. * Texture data come from a prefiltered cube data file
  30568. */
  30569. CubePrefiltered = 9,
  30570. /**
  30571. * Texture content is raw 3D data
  30572. */
  30573. Raw3D = 10,
  30574. /**
  30575. * Texture content is raw 2D array data
  30576. */
  30577. Raw2DArray = 11,
  30578. /**
  30579. * Texture content is a depth texture
  30580. */
  30581. Depth = 12,
  30582. /**
  30583. * Texture data comes from a raw cube data encoded with RGBD
  30584. */
  30585. CubeRawRGBD = 13
  30586. }
  30587. /**
  30588. * Class used to store data associated with WebGL texture data for the engine
  30589. * This class should not be used directly
  30590. */
  30591. export class InternalTexture {
  30592. /** @hidden */
  30593. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30594. /**
  30595. * Defines if the texture is ready
  30596. */
  30597. isReady: boolean;
  30598. /**
  30599. * Defines if the texture is a cube texture
  30600. */
  30601. isCube: boolean;
  30602. /**
  30603. * Defines if the texture contains 3D data
  30604. */
  30605. is3D: boolean;
  30606. /**
  30607. * Defines if the texture contains 2D array data
  30608. */
  30609. is2DArray: boolean;
  30610. /**
  30611. * Defines if the texture contains multiview data
  30612. */
  30613. isMultiview: boolean;
  30614. /**
  30615. * Gets the URL used to load this texture
  30616. */
  30617. url: string;
  30618. /**
  30619. * Gets the sampling mode of the texture
  30620. */
  30621. samplingMode: number;
  30622. /**
  30623. * Gets a boolean indicating if the texture needs mipmaps generation
  30624. */
  30625. generateMipMaps: boolean;
  30626. /**
  30627. * Gets the number of samples used by the texture (WebGL2+ only)
  30628. */
  30629. samples: number;
  30630. /**
  30631. * Gets the type of the texture (int, float...)
  30632. */
  30633. type: number;
  30634. /**
  30635. * Gets the format of the texture (RGB, RGBA...)
  30636. */
  30637. format: number;
  30638. /**
  30639. * Observable called when the texture is loaded
  30640. */
  30641. onLoadedObservable: Observable<InternalTexture>;
  30642. /**
  30643. * Gets the width of the texture
  30644. */
  30645. width: number;
  30646. /**
  30647. * Gets the height of the texture
  30648. */
  30649. height: number;
  30650. /**
  30651. * Gets the depth of the texture
  30652. */
  30653. depth: number;
  30654. /**
  30655. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30656. */
  30657. baseWidth: number;
  30658. /**
  30659. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30660. */
  30661. baseHeight: number;
  30662. /**
  30663. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30664. */
  30665. baseDepth: number;
  30666. /**
  30667. * Gets a boolean indicating if the texture is inverted on Y axis
  30668. */
  30669. invertY: boolean;
  30670. /** @hidden */
  30671. _invertVScale: boolean;
  30672. /** @hidden */
  30673. _associatedChannel: number;
  30674. /** @hidden */
  30675. _source: InternalTextureSource;
  30676. /** @hidden */
  30677. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30678. /** @hidden */
  30679. _bufferView: Nullable<ArrayBufferView>;
  30680. /** @hidden */
  30681. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30682. /** @hidden */
  30683. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30684. /** @hidden */
  30685. _size: number;
  30686. /** @hidden */
  30687. _extension: string;
  30688. /** @hidden */
  30689. _files: Nullable<string[]>;
  30690. /** @hidden */
  30691. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30692. /** @hidden */
  30693. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30694. /** @hidden */
  30695. _framebuffer: Nullable<WebGLFramebuffer>;
  30696. /** @hidden */
  30697. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30698. /** @hidden */
  30699. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30700. /** @hidden */
  30701. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30702. /** @hidden */
  30703. _attachments: Nullable<number[]>;
  30704. /** @hidden */
  30705. _cachedCoordinatesMode: Nullable<number>;
  30706. /** @hidden */
  30707. _cachedWrapU: Nullable<number>;
  30708. /** @hidden */
  30709. _cachedWrapV: Nullable<number>;
  30710. /** @hidden */
  30711. _cachedWrapR: Nullable<number>;
  30712. /** @hidden */
  30713. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30714. /** @hidden */
  30715. _isDisabled: boolean;
  30716. /** @hidden */
  30717. _compression: Nullable<string>;
  30718. /** @hidden */
  30719. _generateStencilBuffer: boolean;
  30720. /** @hidden */
  30721. _generateDepthBuffer: boolean;
  30722. /** @hidden */
  30723. _comparisonFunction: number;
  30724. /** @hidden */
  30725. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30726. /** @hidden */
  30727. _lodGenerationScale: number;
  30728. /** @hidden */
  30729. _lodGenerationOffset: number;
  30730. /** @hidden */
  30731. _colorTextureArray: Nullable<WebGLTexture>;
  30732. /** @hidden */
  30733. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30734. /** @hidden */
  30735. _lodTextureHigh: Nullable<BaseTexture>;
  30736. /** @hidden */
  30737. _lodTextureMid: Nullable<BaseTexture>;
  30738. /** @hidden */
  30739. _lodTextureLow: Nullable<BaseTexture>;
  30740. /** @hidden */
  30741. _isRGBD: boolean;
  30742. /** @hidden */
  30743. _linearSpecularLOD: boolean;
  30744. /** @hidden */
  30745. _irradianceTexture: Nullable<BaseTexture>;
  30746. /** @hidden */
  30747. _webGLTexture: Nullable<WebGLTexture>;
  30748. /** @hidden */
  30749. _references: number;
  30750. private _engine;
  30751. /**
  30752. * Gets the Engine the texture belongs to.
  30753. * @returns The babylon engine
  30754. */
  30755. getEngine(): ThinEngine;
  30756. /**
  30757. * Gets the data source type of the texture
  30758. */
  30759. readonly source: InternalTextureSource;
  30760. /**
  30761. * Creates a new InternalTexture
  30762. * @param engine defines the engine to use
  30763. * @param source defines the type of data that will be used
  30764. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30765. */
  30766. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30767. /**
  30768. * Increments the number of references (ie. the number of Texture that point to it)
  30769. */
  30770. incrementReferences(): void;
  30771. /**
  30772. * Change the size of the texture (not the size of the content)
  30773. * @param width defines the new width
  30774. * @param height defines the new height
  30775. * @param depth defines the new depth (1 by default)
  30776. */
  30777. updateSize(width: int, height: int, depth?: int): void;
  30778. /** @hidden */
  30779. _rebuild(): void;
  30780. /** @hidden */
  30781. _swapAndDie(target: InternalTexture): void;
  30782. /**
  30783. * Dispose the current allocated resources
  30784. */
  30785. dispose(): void;
  30786. }
  30787. }
  30788. declare module BABYLON {
  30789. /**
  30790. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30792. */
  30793. export class Analyser {
  30794. /**
  30795. * Gets or sets the smoothing
  30796. * @ignorenaming
  30797. */
  30798. SMOOTHING: number;
  30799. /**
  30800. * Gets or sets the FFT table size
  30801. * @ignorenaming
  30802. */
  30803. FFT_SIZE: number;
  30804. /**
  30805. * Gets or sets the bar graph amplitude
  30806. * @ignorenaming
  30807. */
  30808. BARGRAPHAMPLITUDE: number;
  30809. /**
  30810. * Gets or sets the position of the debug canvas
  30811. * @ignorenaming
  30812. */
  30813. DEBUGCANVASPOS: {
  30814. x: number;
  30815. y: number;
  30816. };
  30817. /**
  30818. * Gets or sets the debug canvas size
  30819. * @ignorenaming
  30820. */
  30821. DEBUGCANVASSIZE: {
  30822. width: number;
  30823. height: number;
  30824. };
  30825. private _byteFreqs;
  30826. private _byteTime;
  30827. private _floatFreqs;
  30828. private _webAudioAnalyser;
  30829. private _debugCanvas;
  30830. private _debugCanvasContext;
  30831. private _scene;
  30832. private _registerFunc;
  30833. private _audioEngine;
  30834. /**
  30835. * Creates a new analyser
  30836. * @param scene defines hosting scene
  30837. */
  30838. constructor(scene: Scene);
  30839. /**
  30840. * Get the number of data values you will have to play with for the visualization
  30841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30842. * @returns a number
  30843. */
  30844. getFrequencyBinCount(): number;
  30845. /**
  30846. * Gets the current frequency data as a byte array
  30847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30848. * @returns a Uint8Array
  30849. */
  30850. getByteFrequencyData(): Uint8Array;
  30851. /**
  30852. * Gets the current waveform as a byte array
  30853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30854. * @returns a Uint8Array
  30855. */
  30856. getByteTimeDomainData(): Uint8Array;
  30857. /**
  30858. * Gets the current frequency data as a float array
  30859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30860. * @returns a Float32Array
  30861. */
  30862. getFloatFrequencyData(): Float32Array;
  30863. /**
  30864. * Renders the debug canvas
  30865. */
  30866. drawDebugCanvas(): void;
  30867. /**
  30868. * Stops rendering the debug canvas and removes it
  30869. */
  30870. stopDebugCanvas(): void;
  30871. /**
  30872. * Connects two audio nodes
  30873. * @param inputAudioNode defines first node to connect
  30874. * @param outputAudioNode defines second node to connect
  30875. */
  30876. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30877. /**
  30878. * Releases all associated resources
  30879. */
  30880. dispose(): void;
  30881. }
  30882. }
  30883. declare module BABYLON {
  30884. /**
  30885. * This represents an audio engine and it is responsible
  30886. * to play, synchronize and analyse sounds throughout the application.
  30887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30888. */
  30889. export interface IAudioEngine extends IDisposable {
  30890. /**
  30891. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30892. */
  30893. readonly canUseWebAudio: boolean;
  30894. /**
  30895. * Gets the current AudioContext if available.
  30896. */
  30897. readonly audioContext: Nullable<AudioContext>;
  30898. /**
  30899. * The master gain node defines the global audio volume of your audio engine.
  30900. */
  30901. readonly masterGain: GainNode;
  30902. /**
  30903. * Gets whether or not mp3 are supported by your browser.
  30904. */
  30905. readonly isMP3supported: boolean;
  30906. /**
  30907. * Gets whether or not ogg are supported by your browser.
  30908. */
  30909. readonly isOGGsupported: boolean;
  30910. /**
  30911. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30912. * @ignoreNaming
  30913. */
  30914. WarnedWebAudioUnsupported: boolean;
  30915. /**
  30916. * Defines if the audio engine relies on a custom unlocked button.
  30917. * In this case, the embedded button will not be displayed.
  30918. */
  30919. useCustomUnlockedButton: boolean;
  30920. /**
  30921. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30922. */
  30923. readonly unlocked: boolean;
  30924. /**
  30925. * Event raised when audio has been unlocked on the browser.
  30926. */
  30927. onAudioUnlockedObservable: Observable<AudioEngine>;
  30928. /**
  30929. * Event raised when audio has been locked on the browser.
  30930. */
  30931. onAudioLockedObservable: Observable<AudioEngine>;
  30932. /**
  30933. * Flags the audio engine in Locked state.
  30934. * This happens due to new browser policies preventing audio to autoplay.
  30935. */
  30936. lock(): void;
  30937. /**
  30938. * Unlocks the audio engine once a user action has been done on the dom.
  30939. * This is helpful to resume play once browser policies have been satisfied.
  30940. */
  30941. unlock(): void;
  30942. }
  30943. /**
  30944. * This represents the default audio engine used in babylon.
  30945. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30947. */
  30948. export class AudioEngine implements IAudioEngine {
  30949. private _audioContext;
  30950. private _audioContextInitialized;
  30951. private _muteButton;
  30952. private _hostElement;
  30953. /**
  30954. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30955. */
  30956. canUseWebAudio: boolean;
  30957. /**
  30958. * The master gain node defines the global audio volume of your audio engine.
  30959. */
  30960. masterGain: GainNode;
  30961. /**
  30962. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30963. * @ignoreNaming
  30964. */
  30965. WarnedWebAudioUnsupported: boolean;
  30966. /**
  30967. * Gets whether or not mp3 are supported by your browser.
  30968. */
  30969. isMP3supported: boolean;
  30970. /**
  30971. * Gets whether or not ogg are supported by your browser.
  30972. */
  30973. isOGGsupported: boolean;
  30974. /**
  30975. * Gets whether audio has been unlocked on the device.
  30976. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30977. * a user interaction has happened.
  30978. */
  30979. unlocked: boolean;
  30980. /**
  30981. * Defines if the audio engine relies on a custom unlocked button.
  30982. * In this case, the embedded button will not be displayed.
  30983. */
  30984. useCustomUnlockedButton: boolean;
  30985. /**
  30986. * Event raised when audio has been unlocked on the browser.
  30987. */
  30988. onAudioUnlockedObservable: Observable<AudioEngine>;
  30989. /**
  30990. * Event raised when audio has been locked on the browser.
  30991. */
  30992. onAudioLockedObservable: Observable<AudioEngine>;
  30993. /**
  30994. * Gets the current AudioContext if available.
  30995. */
  30996. readonly audioContext: Nullable<AudioContext>;
  30997. private _connectedAnalyser;
  30998. /**
  30999. * Instantiates a new audio engine.
  31000. *
  31001. * There should be only one per page as some browsers restrict the number
  31002. * of audio contexts you can create.
  31003. * @param hostElement defines the host element where to display the mute icon if necessary
  31004. */
  31005. constructor(hostElement?: Nullable<HTMLElement>);
  31006. /**
  31007. * Flags the audio engine in Locked state.
  31008. * This happens due to new browser policies preventing audio to autoplay.
  31009. */
  31010. lock(): void;
  31011. /**
  31012. * Unlocks the audio engine once a user action has been done on the dom.
  31013. * This is helpful to resume play once browser policies have been satisfied.
  31014. */
  31015. unlock(): void;
  31016. private _resumeAudioContext;
  31017. private _initializeAudioContext;
  31018. private _tryToRun;
  31019. private _triggerRunningState;
  31020. private _triggerSuspendedState;
  31021. private _displayMuteButton;
  31022. private _moveButtonToTopLeft;
  31023. private _onResize;
  31024. private _hideMuteButton;
  31025. /**
  31026. * Destroy and release the resources associated with the audio ccontext.
  31027. */
  31028. dispose(): void;
  31029. /**
  31030. * Gets the global volume sets on the master gain.
  31031. * @returns the global volume if set or -1 otherwise
  31032. */
  31033. getGlobalVolume(): number;
  31034. /**
  31035. * Sets the global volume of your experience (sets on the master gain).
  31036. * @param newVolume Defines the new global volume of the application
  31037. */
  31038. setGlobalVolume(newVolume: number): void;
  31039. /**
  31040. * Connect the audio engine to an audio analyser allowing some amazing
  31041. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31043. * @param analyser The analyser to connect to the engine
  31044. */
  31045. connectToAnalyser(analyser: Analyser): void;
  31046. }
  31047. }
  31048. declare module BABYLON {
  31049. /**
  31050. * Interface used to present a loading screen while loading a scene
  31051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31052. */
  31053. export interface ILoadingScreen {
  31054. /**
  31055. * Function called to display the loading screen
  31056. */
  31057. displayLoadingUI: () => void;
  31058. /**
  31059. * Function called to hide the loading screen
  31060. */
  31061. hideLoadingUI: () => void;
  31062. /**
  31063. * Gets or sets the color to use for the background
  31064. */
  31065. loadingUIBackgroundColor: string;
  31066. /**
  31067. * Gets or sets the text to display while loading
  31068. */
  31069. loadingUIText: string;
  31070. }
  31071. /**
  31072. * Class used for the default loading screen
  31073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31074. */
  31075. export class DefaultLoadingScreen implements ILoadingScreen {
  31076. private _renderingCanvas;
  31077. private _loadingText;
  31078. private _loadingDivBackgroundColor;
  31079. private _loadingDiv;
  31080. private _loadingTextDiv;
  31081. /** Gets or sets the logo url to use for the default loading screen */
  31082. static DefaultLogoUrl: string;
  31083. /** Gets or sets the spinner url to use for the default loading screen */
  31084. static DefaultSpinnerUrl: string;
  31085. /**
  31086. * Creates a new default loading screen
  31087. * @param _renderingCanvas defines the canvas used to render the scene
  31088. * @param _loadingText defines the default text to display
  31089. * @param _loadingDivBackgroundColor defines the default background color
  31090. */
  31091. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31092. /**
  31093. * Function called to display the loading screen
  31094. */
  31095. displayLoadingUI(): void;
  31096. /**
  31097. * Function called to hide the loading screen
  31098. */
  31099. hideLoadingUI(): void;
  31100. /**
  31101. * Gets or sets the text to display while loading
  31102. */
  31103. loadingUIText: string;
  31104. /**
  31105. * Gets or sets the color to use for the background
  31106. */
  31107. loadingUIBackgroundColor: string;
  31108. private _resizeLoadingUI;
  31109. }
  31110. }
  31111. declare module BABYLON {
  31112. /**
  31113. * Interface for any object that can request an animation frame
  31114. */
  31115. export interface ICustomAnimationFrameRequester {
  31116. /**
  31117. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31118. */
  31119. renderFunction?: Function;
  31120. /**
  31121. * Called to request the next frame to render to
  31122. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31123. */
  31124. requestAnimationFrame: Function;
  31125. /**
  31126. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31127. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31128. */
  31129. requestID?: number;
  31130. }
  31131. }
  31132. declare module BABYLON {
  31133. /**
  31134. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31135. */
  31136. export class PerformanceMonitor {
  31137. private _enabled;
  31138. private _rollingFrameTime;
  31139. private _lastFrameTimeMs;
  31140. /**
  31141. * constructor
  31142. * @param frameSampleSize The number of samples required to saturate the sliding window
  31143. */
  31144. constructor(frameSampleSize?: number);
  31145. /**
  31146. * Samples current frame
  31147. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31148. */
  31149. sampleFrame(timeMs?: number): void;
  31150. /**
  31151. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31152. */
  31153. readonly averageFrameTime: number;
  31154. /**
  31155. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31156. */
  31157. readonly averageFrameTimeVariance: number;
  31158. /**
  31159. * Returns the frame time of the most recent frame
  31160. */
  31161. readonly instantaneousFrameTime: number;
  31162. /**
  31163. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31164. */
  31165. readonly averageFPS: number;
  31166. /**
  31167. * Returns the average framerate in frames per second using the most recent frame time
  31168. */
  31169. readonly instantaneousFPS: number;
  31170. /**
  31171. * Returns true if enough samples have been taken to completely fill the sliding window
  31172. */
  31173. readonly isSaturated: boolean;
  31174. /**
  31175. * Enables contributions to the sliding window sample set
  31176. */
  31177. enable(): void;
  31178. /**
  31179. * Disables contributions to the sliding window sample set
  31180. * Samples will not be interpolated over the disabled period
  31181. */
  31182. disable(): void;
  31183. /**
  31184. * Returns true if sampling is enabled
  31185. */
  31186. readonly isEnabled: boolean;
  31187. /**
  31188. * Resets performance monitor
  31189. */
  31190. reset(): void;
  31191. }
  31192. /**
  31193. * RollingAverage
  31194. *
  31195. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31196. */
  31197. export class RollingAverage {
  31198. /**
  31199. * Current average
  31200. */
  31201. average: number;
  31202. /**
  31203. * Current variance
  31204. */
  31205. variance: number;
  31206. protected _samples: Array<number>;
  31207. protected _sampleCount: number;
  31208. protected _pos: number;
  31209. protected _m2: number;
  31210. /**
  31211. * constructor
  31212. * @param length The number of samples required to saturate the sliding window
  31213. */
  31214. constructor(length: number);
  31215. /**
  31216. * Adds a sample to the sample set
  31217. * @param v The sample value
  31218. */
  31219. add(v: number): void;
  31220. /**
  31221. * Returns previously added values or null if outside of history or outside the sliding window domain
  31222. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31223. * @return Value previously recorded with add() or null if outside of range
  31224. */
  31225. history(i: number): number;
  31226. /**
  31227. * Returns true if enough samples have been taken to completely fill the sliding window
  31228. * @return true if sample-set saturated
  31229. */
  31230. isSaturated(): boolean;
  31231. /**
  31232. * Resets the rolling average (equivalent to 0 samples taken so far)
  31233. */
  31234. reset(): void;
  31235. /**
  31236. * Wraps a value around the sample range boundaries
  31237. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31238. * @return Wrapped position in sample range
  31239. */
  31240. protected _wrapPosition(i: number): number;
  31241. }
  31242. }
  31243. declare module BABYLON {
  31244. /**
  31245. * This class is used to track a performance counter which is number based.
  31246. * The user has access to many properties which give statistics of different nature.
  31247. *
  31248. * The implementer can track two kinds of Performance Counter: time and count.
  31249. * 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.
  31250. * 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.
  31251. */
  31252. export class PerfCounter {
  31253. /**
  31254. * Gets or sets a global boolean to turn on and off all the counters
  31255. */
  31256. static Enabled: boolean;
  31257. /**
  31258. * Returns the smallest value ever
  31259. */
  31260. readonly min: number;
  31261. /**
  31262. * Returns the biggest value ever
  31263. */
  31264. readonly max: number;
  31265. /**
  31266. * Returns the average value since the performance counter is running
  31267. */
  31268. readonly average: number;
  31269. /**
  31270. * Returns the average value of the last second the counter was monitored
  31271. */
  31272. readonly lastSecAverage: number;
  31273. /**
  31274. * Returns the current value
  31275. */
  31276. readonly current: number;
  31277. /**
  31278. * Gets the accumulated total
  31279. */
  31280. readonly total: number;
  31281. /**
  31282. * Gets the total value count
  31283. */
  31284. readonly count: number;
  31285. /**
  31286. * Creates a new counter
  31287. */
  31288. constructor();
  31289. /**
  31290. * Call this method to start monitoring a new frame.
  31291. * 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.
  31292. */
  31293. fetchNewFrame(): void;
  31294. /**
  31295. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31296. * @param newCount the count value to add to the monitored count
  31297. * @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.
  31298. */
  31299. addCount(newCount: number, fetchResult: boolean): void;
  31300. /**
  31301. * Start monitoring this performance counter
  31302. */
  31303. beginMonitoring(): void;
  31304. /**
  31305. * Compute the time lapsed since the previous beginMonitoring() call.
  31306. * @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
  31307. */
  31308. endMonitoring(newFrame?: boolean): void;
  31309. private _fetchResult;
  31310. private _startMonitoringTime;
  31311. private _min;
  31312. private _max;
  31313. private _average;
  31314. private _current;
  31315. private _totalValueCount;
  31316. private _totalAccumulated;
  31317. private _lastSecAverage;
  31318. private _lastSecAccumulated;
  31319. private _lastSecTime;
  31320. private _lastSecValueCount;
  31321. }
  31322. }
  31323. declare module BABYLON {
  31324. /**
  31325. * Defines the interface used by display changed events
  31326. */
  31327. export interface IDisplayChangedEventArgs {
  31328. /** Gets the vrDisplay object (if any) */
  31329. vrDisplay: Nullable<any>;
  31330. /** Gets a boolean indicating if webVR is supported */
  31331. vrSupported: boolean;
  31332. }
  31333. /**
  31334. * Defines the interface used by objects containing a viewport (like a camera)
  31335. */
  31336. interface IViewportOwnerLike {
  31337. /**
  31338. * Gets or sets the viewport
  31339. */
  31340. viewport: IViewportLike;
  31341. }
  31342. /**
  31343. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31344. */
  31345. export class Engine extends ThinEngine {
  31346. /** Defines that alpha blending is disabled */
  31347. static readonly ALPHA_DISABLE: number;
  31348. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31349. static readonly ALPHA_ADD: number;
  31350. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31351. static readonly ALPHA_COMBINE: number;
  31352. /** Defines that alpha blending to DEST - SRC * DEST */
  31353. static readonly ALPHA_SUBTRACT: number;
  31354. /** Defines that alpha blending to SRC * DEST */
  31355. static readonly ALPHA_MULTIPLY: number;
  31356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31357. static readonly ALPHA_MAXIMIZED: number;
  31358. /** Defines that alpha blending to SRC + DEST */
  31359. static readonly ALPHA_ONEONE: number;
  31360. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31361. static readonly ALPHA_PREMULTIPLIED: number;
  31362. /**
  31363. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31364. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31365. */
  31366. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31367. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31368. static readonly ALPHA_INTERPOLATE: number;
  31369. /**
  31370. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31371. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31372. */
  31373. static readonly ALPHA_SCREENMODE: number;
  31374. /** Defines that the ressource is not delayed*/
  31375. static readonly DELAYLOADSTATE_NONE: number;
  31376. /** Defines that the ressource was successfully delay loaded */
  31377. static readonly DELAYLOADSTATE_LOADED: number;
  31378. /** Defines that the ressource is currently delay loading */
  31379. static readonly DELAYLOADSTATE_LOADING: number;
  31380. /** Defines that the ressource is delayed and has not started loading */
  31381. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31382. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31383. static readonly NEVER: number;
  31384. /** 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 */
  31385. static readonly ALWAYS: number;
  31386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31387. static readonly LESS: number;
  31388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31389. static readonly EQUAL: number;
  31390. /** 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 */
  31391. static readonly LEQUAL: number;
  31392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31393. static readonly GREATER: number;
  31394. /** 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 */
  31395. static readonly GEQUAL: number;
  31396. /** 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 */
  31397. static readonly NOTEQUAL: number;
  31398. /** Passed to stencilOperation to specify that stencil value must be kept */
  31399. static readonly KEEP: number;
  31400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31401. static readonly REPLACE: number;
  31402. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31403. static readonly INCR: number;
  31404. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31405. static readonly DECR: number;
  31406. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31407. static readonly INVERT: number;
  31408. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31409. static readonly INCR_WRAP: number;
  31410. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31411. static readonly DECR_WRAP: number;
  31412. /** Texture is not repeating outside of 0..1 UVs */
  31413. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31414. /** Texture is repeating outside of 0..1 UVs */
  31415. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31416. /** Texture is repeating and mirrored */
  31417. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31418. /** ALPHA */
  31419. static readonly TEXTUREFORMAT_ALPHA: number;
  31420. /** LUMINANCE */
  31421. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31422. /** LUMINANCE_ALPHA */
  31423. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31424. /** RGB */
  31425. static readonly TEXTUREFORMAT_RGB: number;
  31426. /** RGBA */
  31427. static readonly TEXTUREFORMAT_RGBA: number;
  31428. /** RED */
  31429. static readonly TEXTUREFORMAT_RED: number;
  31430. /** RED (2nd reference) */
  31431. static readonly TEXTUREFORMAT_R: number;
  31432. /** RG */
  31433. static readonly TEXTUREFORMAT_RG: number;
  31434. /** RED_INTEGER */
  31435. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31436. /** RED_INTEGER (2nd reference) */
  31437. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31438. /** RG_INTEGER */
  31439. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31440. /** RGB_INTEGER */
  31441. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31442. /** RGBA_INTEGER */
  31443. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31444. /** UNSIGNED_BYTE */
  31445. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31446. /** UNSIGNED_BYTE (2nd reference) */
  31447. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31448. /** FLOAT */
  31449. static readonly TEXTURETYPE_FLOAT: number;
  31450. /** HALF_FLOAT */
  31451. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31452. /** BYTE */
  31453. static readonly TEXTURETYPE_BYTE: number;
  31454. /** SHORT */
  31455. static readonly TEXTURETYPE_SHORT: number;
  31456. /** UNSIGNED_SHORT */
  31457. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31458. /** INT */
  31459. static readonly TEXTURETYPE_INT: number;
  31460. /** UNSIGNED_INT */
  31461. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31462. /** UNSIGNED_SHORT_4_4_4_4 */
  31463. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31464. /** UNSIGNED_SHORT_5_5_5_1 */
  31465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31466. /** UNSIGNED_SHORT_5_6_5 */
  31467. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31468. /** UNSIGNED_INT_2_10_10_10_REV */
  31469. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31470. /** UNSIGNED_INT_24_8 */
  31471. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31472. /** UNSIGNED_INT_10F_11F_11F_REV */
  31473. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31474. /** UNSIGNED_INT_5_9_9_9_REV */
  31475. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31476. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31477. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31478. /** nearest is mag = nearest and min = nearest and mip = linear */
  31479. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31481. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31482. /** Trilinear is mag = linear and min = linear and mip = linear */
  31483. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31484. /** nearest is mag = nearest and min = nearest and mip = linear */
  31485. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31487. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31488. /** Trilinear is mag = linear and min = linear and mip = linear */
  31489. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31490. /** mag = nearest and min = nearest and mip = nearest */
  31491. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31492. /** mag = nearest and min = linear and mip = nearest */
  31493. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31494. /** mag = nearest and min = linear and mip = linear */
  31495. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31496. /** mag = nearest and min = linear and mip = none */
  31497. static readonly TEXTURE_NEAREST_LINEAR: number;
  31498. /** mag = nearest and min = nearest and mip = none */
  31499. static readonly TEXTURE_NEAREST_NEAREST: number;
  31500. /** mag = linear and min = nearest and mip = nearest */
  31501. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31502. /** mag = linear and min = nearest and mip = linear */
  31503. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31504. /** mag = linear and min = linear and mip = none */
  31505. static readonly TEXTURE_LINEAR_LINEAR: number;
  31506. /** mag = linear and min = nearest and mip = none */
  31507. static readonly TEXTURE_LINEAR_NEAREST: number;
  31508. /** Explicit coordinates mode */
  31509. static readonly TEXTURE_EXPLICIT_MODE: number;
  31510. /** Spherical coordinates mode */
  31511. static readonly TEXTURE_SPHERICAL_MODE: number;
  31512. /** Planar coordinates mode */
  31513. static readonly TEXTURE_PLANAR_MODE: number;
  31514. /** Cubic coordinates mode */
  31515. static readonly TEXTURE_CUBIC_MODE: number;
  31516. /** Projection coordinates mode */
  31517. static readonly TEXTURE_PROJECTION_MODE: number;
  31518. /** Skybox coordinates mode */
  31519. static readonly TEXTURE_SKYBOX_MODE: number;
  31520. /** Inverse Cubic coordinates mode */
  31521. static readonly TEXTURE_INVCUBIC_MODE: number;
  31522. /** Equirectangular coordinates mode */
  31523. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31524. /** Equirectangular Fixed coordinates mode */
  31525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31526. /** Equirectangular Fixed Mirrored coordinates mode */
  31527. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31528. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31529. static readonly SCALEMODE_FLOOR: number;
  31530. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31531. static readonly SCALEMODE_NEAREST: number;
  31532. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31533. static readonly SCALEMODE_CEILING: number;
  31534. /**
  31535. * Returns the current npm package of the sdk
  31536. */
  31537. static readonly NpmPackage: string;
  31538. /**
  31539. * Returns the current version of the framework
  31540. */
  31541. static readonly Version: string;
  31542. /** Gets the list of created engines */
  31543. static readonly Instances: Engine[];
  31544. /**
  31545. * Gets the latest created engine
  31546. */
  31547. static readonly LastCreatedEngine: Nullable<Engine>;
  31548. /**
  31549. * Gets the latest created scene
  31550. */
  31551. static readonly LastCreatedScene: Nullable<Scene>;
  31552. /**
  31553. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31554. * @param flag defines which part of the materials must be marked as dirty
  31555. * @param predicate defines a predicate used to filter which materials should be affected
  31556. */
  31557. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31558. /**
  31559. * Method called to create the default loading screen.
  31560. * This can be overriden in your own app.
  31561. * @param canvas The rendering canvas element
  31562. * @returns The loading screen
  31563. */
  31564. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31565. /**
  31566. * Method called to create the default rescale post process on each engine.
  31567. */
  31568. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31569. /**
  31570. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31571. **/
  31572. enableOfflineSupport: boolean;
  31573. /**
  31574. * 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)
  31575. **/
  31576. disableManifestCheck: boolean;
  31577. /**
  31578. * Gets the list of created scenes
  31579. */
  31580. scenes: Scene[];
  31581. /**
  31582. * Event raised when a new scene is created
  31583. */
  31584. onNewSceneAddedObservable: Observable<Scene>;
  31585. /**
  31586. * Gets the list of created postprocesses
  31587. */
  31588. postProcesses: PostProcess[];
  31589. /**
  31590. * Gets a boolean indicating if the pointer is currently locked
  31591. */
  31592. isPointerLock: boolean;
  31593. /**
  31594. * Observable event triggered each time the rendering canvas is resized
  31595. */
  31596. onResizeObservable: Observable<Engine>;
  31597. /**
  31598. * Observable event triggered each time the canvas loses focus
  31599. */
  31600. onCanvasBlurObservable: Observable<Engine>;
  31601. /**
  31602. * Observable event triggered each time the canvas gains focus
  31603. */
  31604. onCanvasFocusObservable: Observable<Engine>;
  31605. /**
  31606. * Observable event triggered each time the canvas receives pointerout event
  31607. */
  31608. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31609. /**
  31610. * Observable raised when the engine begins a new frame
  31611. */
  31612. onBeginFrameObservable: Observable<Engine>;
  31613. /**
  31614. * If set, will be used to request the next animation frame for the render loop
  31615. */
  31616. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31617. /**
  31618. * Observable raised when the engine ends the current frame
  31619. */
  31620. onEndFrameObservable: Observable<Engine>;
  31621. /**
  31622. * Observable raised when the engine is about to compile a shader
  31623. */
  31624. onBeforeShaderCompilationObservable: Observable<Engine>;
  31625. /**
  31626. * Observable raised when the engine has jsut compiled a shader
  31627. */
  31628. onAfterShaderCompilationObservable: Observable<Engine>;
  31629. /**
  31630. * Gets the audio engine
  31631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31632. * @ignorenaming
  31633. */
  31634. static audioEngine: IAudioEngine;
  31635. /**
  31636. * Default AudioEngine factory responsible of creating the Audio Engine.
  31637. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31638. */
  31639. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31640. /**
  31641. * Default offline support factory responsible of creating a tool used to store data locally.
  31642. * By default, this will create a Database object if the workload has been embedded.
  31643. */
  31644. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31645. private _loadingScreen;
  31646. private _pointerLockRequested;
  31647. private _dummyFramebuffer;
  31648. private _rescalePostProcess;
  31649. /** @hidden */
  31650. protected _alphaMode: number;
  31651. /** @hidden */
  31652. protected _alphaEquation: number;
  31653. private _deterministicLockstep;
  31654. private _lockstepMaxSteps;
  31655. protected readonly _supportsHardwareTextureRescaling: boolean;
  31656. private _fps;
  31657. private _deltaTime;
  31658. /** @hidden */
  31659. _drawCalls: PerfCounter;
  31660. /**
  31661. * Turn this value on if you want to pause FPS computation when in background
  31662. */
  31663. disablePerformanceMonitorInBackground: boolean;
  31664. private _performanceMonitor;
  31665. /**
  31666. * Gets the performance monitor attached to this engine
  31667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31668. */
  31669. readonly performanceMonitor: PerformanceMonitor;
  31670. private _onFocus;
  31671. private _onBlur;
  31672. private _onCanvasPointerOut;
  31673. private _onCanvasBlur;
  31674. private _onCanvasFocus;
  31675. private _onFullscreenChange;
  31676. private _onPointerLockChange;
  31677. /**
  31678. * Gets the HTML element used to attach event listeners
  31679. * @returns a HTML element
  31680. */
  31681. getInputElement(): Nullable<HTMLElement>;
  31682. /**
  31683. * Creates a new engine
  31684. * @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
  31685. * @param antialias defines enable antialiasing (default: false)
  31686. * @param options defines further options to be sent to the getContext() function
  31687. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31688. */
  31689. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31690. /**
  31691. * Gets current aspect ratio
  31692. * @param viewportOwner defines the camera to use to get the aspect ratio
  31693. * @param useScreen defines if screen size must be used (or the current render target if any)
  31694. * @returns a number defining the aspect ratio
  31695. */
  31696. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31697. /**
  31698. * Gets current screen aspect ratio
  31699. * @returns a number defining the aspect ratio
  31700. */
  31701. getScreenAspectRatio(): number;
  31702. /**
  31703. * Gets host document
  31704. * @returns the host document object
  31705. */
  31706. getHostDocument(): Document;
  31707. /**
  31708. * Gets the client rect of the HTML canvas attached with the current webGL context
  31709. * @returns a client rectanglee
  31710. */
  31711. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31712. /**
  31713. * Gets the client rect of the HTML element used for events
  31714. * @returns a client rectanglee
  31715. */
  31716. getInputElementClientRect(): Nullable<ClientRect>;
  31717. /**
  31718. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31720. * @returns true if engine is in deterministic lock step mode
  31721. */
  31722. isDeterministicLockStep(): boolean;
  31723. /**
  31724. * Gets the max steps when engine is running in deterministic lock step
  31725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31726. * @returns the max steps
  31727. */
  31728. getLockstepMaxSteps(): number;
  31729. /**
  31730. * Force the mipmap generation for the given render target texture
  31731. * @param texture defines the render target texture to use
  31732. */
  31733. generateMipMapsForCubemap(texture: InternalTexture): void;
  31734. /** States */
  31735. /**
  31736. * Set various states to the webGL context
  31737. * @param culling defines backface culling state
  31738. * @param zOffset defines the value to apply to zOffset (0 by default)
  31739. * @param force defines if states must be applied even if cache is up to date
  31740. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31741. */
  31742. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31743. /**
  31744. * Set the z offset to apply to current rendering
  31745. * @param value defines the offset to apply
  31746. */
  31747. setZOffset(value: number): void;
  31748. /**
  31749. * Gets the current value of the zOffset
  31750. * @returns the current zOffset state
  31751. */
  31752. getZOffset(): number;
  31753. /**
  31754. * Enable or disable depth buffering
  31755. * @param enable defines the state to set
  31756. */
  31757. setDepthBuffer(enable: boolean): void;
  31758. /**
  31759. * Gets a boolean indicating if depth writing is enabled
  31760. * @returns the current depth writing state
  31761. */
  31762. getDepthWrite(): boolean;
  31763. /**
  31764. * Enable or disable depth writing
  31765. * @param enable defines the state to set
  31766. */
  31767. setDepthWrite(enable: boolean): void;
  31768. /**
  31769. * Enable or disable color writing
  31770. * @param enable defines the state to set
  31771. */
  31772. setColorWrite(enable: boolean): void;
  31773. /**
  31774. * Gets a boolean indicating if color writing is enabled
  31775. * @returns the current color writing state
  31776. */
  31777. getColorWrite(): boolean;
  31778. /**
  31779. * Sets alpha constants used by some alpha blending modes
  31780. * @param r defines the red component
  31781. * @param g defines the green component
  31782. * @param b defines the blue component
  31783. * @param a defines the alpha component
  31784. */
  31785. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31786. /**
  31787. * Sets the current alpha mode
  31788. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31789. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31791. */
  31792. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31793. /**
  31794. * Gets the current alpha mode
  31795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31796. * @returns the current alpha mode
  31797. */
  31798. getAlphaMode(): number;
  31799. /**
  31800. * Sets the current alpha equation
  31801. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31802. */
  31803. setAlphaEquation(equation: number): void;
  31804. /**
  31805. * Gets the current alpha equation.
  31806. * @returns the current alpha equation
  31807. */
  31808. getAlphaEquation(): number;
  31809. /**
  31810. * Gets a boolean indicating if stencil buffer is enabled
  31811. * @returns the current stencil buffer state
  31812. */
  31813. getStencilBuffer(): boolean;
  31814. /**
  31815. * Enable or disable the stencil buffer
  31816. * @param enable defines if the stencil buffer must be enabled or disabled
  31817. */
  31818. setStencilBuffer(enable: boolean): void;
  31819. /**
  31820. * Gets the current stencil mask
  31821. * @returns a number defining the new stencil mask to use
  31822. */
  31823. getStencilMask(): number;
  31824. /**
  31825. * Sets the current stencil mask
  31826. * @param mask defines the new stencil mask to use
  31827. */
  31828. setStencilMask(mask: number): void;
  31829. /**
  31830. * Gets the current stencil function
  31831. * @returns a number defining the stencil function to use
  31832. */
  31833. getStencilFunction(): number;
  31834. /**
  31835. * Gets the current stencil reference value
  31836. * @returns a number defining the stencil reference value to use
  31837. */
  31838. getStencilFunctionReference(): number;
  31839. /**
  31840. * Gets the current stencil mask
  31841. * @returns a number defining the stencil mask to use
  31842. */
  31843. getStencilFunctionMask(): number;
  31844. /**
  31845. * Sets the current stencil function
  31846. * @param stencilFunc defines the new stencil function to use
  31847. */
  31848. setStencilFunction(stencilFunc: number): void;
  31849. /**
  31850. * Sets the current stencil reference
  31851. * @param reference defines the new stencil reference to use
  31852. */
  31853. setStencilFunctionReference(reference: number): void;
  31854. /**
  31855. * Sets the current stencil mask
  31856. * @param mask defines the new stencil mask to use
  31857. */
  31858. setStencilFunctionMask(mask: number): void;
  31859. /**
  31860. * Gets the current stencil operation when stencil fails
  31861. * @returns a number defining stencil operation to use when stencil fails
  31862. */
  31863. getStencilOperationFail(): number;
  31864. /**
  31865. * Gets the current stencil operation when depth fails
  31866. * @returns a number defining stencil operation to use when depth fails
  31867. */
  31868. getStencilOperationDepthFail(): number;
  31869. /**
  31870. * Gets the current stencil operation when stencil passes
  31871. * @returns a number defining stencil operation to use when stencil passes
  31872. */
  31873. getStencilOperationPass(): number;
  31874. /**
  31875. * Sets the stencil operation to use when stencil fails
  31876. * @param operation defines the stencil operation to use when stencil fails
  31877. */
  31878. setStencilOperationFail(operation: number): void;
  31879. /**
  31880. * Sets the stencil operation to use when depth fails
  31881. * @param operation defines the stencil operation to use when depth fails
  31882. */
  31883. setStencilOperationDepthFail(operation: number): void;
  31884. /**
  31885. * Sets the stencil operation to use when stencil passes
  31886. * @param operation defines the stencil operation to use when stencil passes
  31887. */
  31888. setStencilOperationPass(operation: number): void;
  31889. /**
  31890. * Sets a boolean indicating if the dithering state is enabled or disabled
  31891. * @param value defines the dithering state
  31892. */
  31893. setDitheringState(value: boolean): void;
  31894. /**
  31895. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31896. * @param value defines the rasterizer state
  31897. */
  31898. setRasterizerState(value: boolean): void;
  31899. /**
  31900. * Gets the current depth function
  31901. * @returns a number defining the depth function
  31902. */
  31903. getDepthFunction(): Nullable<number>;
  31904. /**
  31905. * Sets the current depth function
  31906. * @param depthFunc defines the function to use
  31907. */
  31908. setDepthFunction(depthFunc: number): void;
  31909. /**
  31910. * Sets the current depth function to GREATER
  31911. */
  31912. setDepthFunctionToGreater(): void;
  31913. /**
  31914. * Sets the current depth function to GEQUAL
  31915. */
  31916. setDepthFunctionToGreaterOrEqual(): void;
  31917. /**
  31918. * Sets the current depth function to LESS
  31919. */
  31920. setDepthFunctionToLess(): void;
  31921. /**
  31922. * Sets the current depth function to LEQUAL
  31923. */
  31924. setDepthFunctionToLessOrEqual(): void;
  31925. private _cachedStencilBuffer;
  31926. private _cachedStencilFunction;
  31927. private _cachedStencilMask;
  31928. private _cachedStencilOperationPass;
  31929. private _cachedStencilOperationFail;
  31930. private _cachedStencilOperationDepthFail;
  31931. private _cachedStencilReference;
  31932. /**
  31933. * Caches the the state of the stencil buffer
  31934. */
  31935. cacheStencilState(): void;
  31936. /**
  31937. * Restores the state of the stencil buffer
  31938. */
  31939. restoreStencilState(): void;
  31940. /**
  31941. * Directly set the WebGL Viewport
  31942. * @param x defines the x coordinate of the viewport (in screen space)
  31943. * @param y defines the y coordinate of the viewport (in screen space)
  31944. * @param width defines the width of the viewport (in screen space)
  31945. * @param height defines the height of the viewport (in screen space)
  31946. * @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
  31947. */
  31948. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31949. /**
  31950. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31951. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31952. * @param y defines the y-coordinate of the corner of the clear rectangle
  31953. * @param width defines the width of the clear rectangle
  31954. * @param height defines the height of the clear rectangle
  31955. * @param clearColor defines the clear color
  31956. */
  31957. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31958. /**
  31959. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31960. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31961. * @param y defines the y-coordinate of the corner of the clear rectangle
  31962. * @param width defines the width of the clear rectangle
  31963. * @param height defines the height of the clear rectangle
  31964. */
  31965. enableScissor(x: number, y: number, width: number, height: number): void;
  31966. /**
  31967. * Disable previously set scissor test rectangle
  31968. */
  31969. disableScissor(): void;
  31970. protected _reportDrawCall(): void;
  31971. /**
  31972. * Initializes a webVR display and starts listening to display change events
  31973. * The onVRDisplayChangedObservable will be notified upon these changes
  31974. * @returns The onVRDisplayChangedObservable
  31975. */
  31976. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31977. /** @hidden */
  31978. _prepareVRComponent(): void;
  31979. /** @hidden */
  31980. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31981. /** @hidden */
  31982. _submitVRFrame(): void;
  31983. /**
  31984. * Call this function to leave webVR mode
  31985. * Will do nothing if webVR is not supported or if there is no webVR device
  31986. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31987. */
  31988. disableVR(): void;
  31989. /**
  31990. * Gets a boolean indicating that the system is in VR mode and is presenting
  31991. * @returns true if VR mode is engaged
  31992. */
  31993. isVRPresenting(): boolean;
  31994. /** @hidden */
  31995. _requestVRFrame(): void;
  31996. /** @hidden */
  31997. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31998. /**
  31999. * Gets the source code of the vertex shader associated with a specific webGL program
  32000. * @param program defines the program to use
  32001. * @returns a string containing the source code of the vertex shader associated with the program
  32002. */
  32003. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32004. /**
  32005. * Gets the source code of the fragment shader associated with a specific webGL program
  32006. * @param program defines the program to use
  32007. * @returns a string containing the source code of the fragment shader associated with the program
  32008. */
  32009. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32010. /**
  32011. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32012. * @param x defines the x coordinate of the rectangle where pixels must be read
  32013. * @param y defines the y coordinate of the rectangle where pixels must be read
  32014. * @param width defines the width of the rectangle where pixels must be read
  32015. * @param height defines the height of the rectangle where pixels must be read
  32016. * @returns a Uint8Array containing RGBA colors
  32017. */
  32018. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32019. /**
  32020. * Sets a depth stencil texture from a render target to the according uniform.
  32021. * @param channel The texture channel
  32022. * @param uniform The uniform to set
  32023. * @param texture The render target texture containing the depth stencil texture to apply
  32024. */
  32025. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32026. /**
  32027. * Sets a texture to the webGL context from a postprocess
  32028. * @param channel defines the channel to use
  32029. * @param postProcess defines the source postprocess
  32030. */
  32031. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32032. /**
  32033. * Binds the output of the passed in post process to the texture channel specified
  32034. * @param channel The channel the texture should be bound to
  32035. * @param postProcess The post process which's output should be bound
  32036. */
  32037. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32038. /** @hidden */
  32039. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32040. protected _rebuildBuffers(): void;
  32041. /** @hidden */
  32042. _renderFrame(): void;
  32043. _renderLoop(): void;
  32044. /** @hidden */
  32045. _renderViews(): boolean;
  32046. /**
  32047. * Toggle full screen mode
  32048. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32049. */
  32050. switchFullscreen(requestPointerLock: boolean): void;
  32051. /**
  32052. * Enters full screen mode
  32053. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32054. */
  32055. enterFullscreen(requestPointerLock: boolean): void;
  32056. /**
  32057. * Exits full screen mode
  32058. */
  32059. exitFullscreen(): void;
  32060. /**
  32061. * Enters Pointerlock mode
  32062. */
  32063. enterPointerlock(): void;
  32064. /**
  32065. * Exits Pointerlock mode
  32066. */
  32067. exitPointerlock(): void;
  32068. /**
  32069. * Begin a new frame
  32070. */
  32071. beginFrame(): void;
  32072. /**
  32073. * Enf the current frame
  32074. */
  32075. endFrame(): void;
  32076. resize(): void;
  32077. /**
  32078. * Set the compressed texture format to use, based on the formats you have, and the formats
  32079. * supported by the hardware / browser.
  32080. *
  32081. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32082. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32083. * to API arguments needed to compressed textures. This puts the burden on the container
  32084. * generator to house the arcane code for determining these for current & future formats.
  32085. *
  32086. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32087. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32088. *
  32089. * Note: The result of this call is not taken into account when a texture is base64.
  32090. *
  32091. * @param formatsAvailable defines the list of those format families you have created
  32092. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32093. *
  32094. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32095. * @returns The extension selected.
  32096. */
  32097. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32098. /**
  32099. * Force a specific size of the canvas
  32100. * @param width defines the new canvas' width
  32101. * @param height defines the new canvas' height
  32102. */
  32103. setSize(width: number, height: number): void;
  32104. /**
  32105. * Updates a dynamic vertex buffer.
  32106. * @param vertexBuffer the vertex buffer to update
  32107. * @param data the data used to update the vertex buffer
  32108. * @param byteOffset the byte offset of the data
  32109. * @param byteLength the byte length of the data
  32110. */
  32111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32112. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32115. _releaseTexture(texture: InternalTexture): void;
  32116. /**
  32117. * @hidden
  32118. * Rescales a texture
  32119. * @param source input texutre
  32120. * @param destination destination texture
  32121. * @param scene scene to use to render the resize
  32122. * @param internalFormat format to use when resizing
  32123. * @param onComplete callback to be called when resize has completed
  32124. */
  32125. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32126. /**
  32127. * Gets the current framerate
  32128. * @returns a number representing the framerate
  32129. */
  32130. getFps(): number;
  32131. /**
  32132. * Gets the time spent between current and previous frame
  32133. * @returns a number representing the delta time in ms
  32134. */
  32135. getDeltaTime(): number;
  32136. private _measureFps;
  32137. /** @hidden */
  32138. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32139. /**
  32140. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32141. * @param renderTarget The render target to set the frame buffer for
  32142. */
  32143. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32144. /**
  32145. * Update a dynamic index buffer
  32146. * @param indexBuffer defines the target index buffer
  32147. * @param indices defines the data to update
  32148. * @param offset defines the offset in the target index buffer where update should start
  32149. */
  32150. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32151. /**
  32152. * Updates the sample count of a render target texture
  32153. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32154. * @param texture defines the texture to update
  32155. * @param samples defines the sample count to set
  32156. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32157. */
  32158. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32159. /**
  32160. * Updates a depth texture Comparison Mode and Function.
  32161. * If the comparison Function is equal to 0, the mode will be set to none.
  32162. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32163. * @param texture The texture to set the comparison function for
  32164. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32165. */
  32166. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32167. /**
  32168. * Creates a webGL buffer to use with instanciation
  32169. * @param capacity defines the size of the buffer
  32170. * @returns the webGL buffer
  32171. */
  32172. createInstancesBuffer(capacity: number): DataBuffer;
  32173. /**
  32174. * Delete a webGL buffer used with instanciation
  32175. * @param buffer defines the webGL buffer to delete
  32176. */
  32177. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32178. /** @hidden */
  32179. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32180. dispose(): void;
  32181. private _disableTouchAction;
  32182. /**
  32183. * Display the loading screen
  32184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32185. */
  32186. displayLoadingUI(): void;
  32187. /**
  32188. * Hide the loading screen
  32189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32190. */
  32191. hideLoadingUI(): void;
  32192. /**
  32193. * Gets the current loading screen object
  32194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32195. */
  32196. /**
  32197. * Sets the current loading screen object
  32198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32199. */
  32200. loadingScreen: ILoadingScreen;
  32201. /**
  32202. * Sets the current loading screen text
  32203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32204. */
  32205. loadingUIText: string;
  32206. /**
  32207. * Sets the current loading screen background color
  32208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32209. */
  32210. loadingUIBackgroundColor: string;
  32211. /** Pointerlock and fullscreen */
  32212. /**
  32213. * Ask the browser to promote the current element to pointerlock mode
  32214. * @param element defines the DOM element to promote
  32215. */
  32216. static _RequestPointerlock(element: HTMLElement): void;
  32217. /**
  32218. * Asks the browser to exit pointerlock mode
  32219. */
  32220. static _ExitPointerlock(): void;
  32221. /**
  32222. * Ask the browser to promote the current element to fullscreen rendering mode
  32223. * @param element defines the DOM element to promote
  32224. */
  32225. static _RequestFullscreen(element: HTMLElement): void;
  32226. /**
  32227. * Asks the browser to exit fullscreen mode
  32228. */
  32229. static _ExitFullscreen(): void;
  32230. }
  32231. }
  32232. declare module BABYLON {
  32233. /**
  32234. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32235. * during the life time of the application.
  32236. */
  32237. export class EngineStore {
  32238. /** Gets the list of created engines */
  32239. static Instances: Engine[];
  32240. /** @hidden */
  32241. static _LastCreatedScene: Nullable<Scene>;
  32242. /**
  32243. * Gets the latest created engine
  32244. */
  32245. static readonly LastCreatedEngine: Nullable<Engine>;
  32246. /**
  32247. * Gets the latest created scene
  32248. */
  32249. static readonly LastCreatedScene: Nullable<Scene>;
  32250. /**
  32251. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32252. * @ignorenaming
  32253. */
  32254. static UseFallbackTexture: boolean;
  32255. /**
  32256. * Texture content used if a texture cannot loaded
  32257. * @ignorenaming
  32258. */
  32259. static FallbackTexture: string;
  32260. }
  32261. }
  32262. declare module BABYLON {
  32263. /**
  32264. * Helper class that provides a small promise polyfill
  32265. */
  32266. export class PromisePolyfill {
  32267. /**
  32268. * Static function used to check if the polyfill is required
  32269. * If this is the case then the function will inject the polyfill to window.Promise
  32270. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32271. */
  32272. static Apply(force?: boolean): void;
  32273. }
  32274. }
  32275. declare module BABYLON {
  32276. /**
  32277. * Interface for screenshot methods with describe argument called `size` as object with options
  32278. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32279. */
  32280. export interface IScreenshotSize {
  32281. /**
  32282. * number in pixels for canvas height
  32283. */
  32284. height?: number;
  32285. /**
  32286. * multiplier allowing render at a higher or lower resolution
  32287. * If value is defined then height and width will be ignored and taken from camera
  32288. */
  32289. precision?: number;
  32290. /**
  32291. * number in pixels for canvas width
  32292. */
  32293. width?: number;
  32294. }
  32295. }
  32296. declare module BABYLON {
  32297. interface IColor4Like {
  32298. r: float;
  32299. g: float;
  32300. b: float;
  32301. a: float;
  32302. }
  32303. /**
  32304. * Class containing a set of static utilities functions
  32305. */
  32306. export class Tools {
  32307. /**
  32308. * Gets or sets the base URL to use to load assets
  32309. */
  32310. static BaseUrl: string;
  32311. /**
  32312. * Enable/Disable Custom HTTP Request Headers globally.
  32313. * default = false
  32314. * @see CustomRequestHeaders
  32315. */
  32316. static UseCustomRequestHeaders: boolean;
  32317. /**
  32318. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32319. * i.e. when loading files, where the server/service expects an Authorization header
  32320. */
  32321. static CustomRequestHeaders: {
  32322. [key: string]: string;
  32323. };
  32324. /**
  32325. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32326. */
  32327. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32328. /**
  32329. * Default behaviour for cors in the application.
  32330. * It can be a string if the expected behavior is identical in the entire app.
  32331. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32332. */
  32333. static CorsBehavior: string | ((url: string | string[]) => string);
  32334. /**
  32335. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32336. * @ignorenaming
  32337. */
  32338. static UseFallbackTexture: boolean;
  32339. /**
  32340. * Use this object to register external classes like custom textures or material
  32341. * to allow the laoders to instantiate them
  32342. */
  32343. static RegisteredExternalClasses: {
  32344. [key: string]: Object;
  32345. };
  32346. /**
  32347. * Texture content used if a texture cannot loaded
  32348. * @ignorenaming
  32349. */
  32350. static fallbackTexture: string;
  32351. /**
  32352. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32353. * @param u defines the coordinate on X axis
  32354. * @param v defines the coordinate on Y axis
  32355. * @param width defines the width of the source data
  32356. * @param height defines the height of the source data
  32357. * @param pixels defines the source byte array
  32358. * @param color defines the output color
  32359. */
  32360. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32361. /**
  32362. * Interpolates between a and b via alpha
  32363. * @param a The lower value (returned when alpha = 0)
  32364. * @param b The upper value (returned when alpha = 1)
  32365. * @param alpha The interpolation-factor
  32366. * @return The mixed value
  32367. */
  32368. static Mix(a: number, b: number, alpha: number): number;
  32369. /**
  32370. * Tries to instantiate a new object from a given class name
  32371. * @param className defines the class name to instantiate
  32372. * @returns the new object or null if the system was not able to do the instantiation
  32373. */
  32374. static Instantiate(className: string): any;
  32375. /**
  32376. * Provides a slice function that will work even on IE
  32377. * @param data defines the array to slice
  32378. * @param start defines the start of the data (optional)
  32379. * @param end defines the end of the data (optional)
  32380. * @returns the new sliced array
  32381. */
  32382. static Slice<T>(data: T, start?: number, end?: number): T;
  32383. /**
  32384. * Polyfill for setImmediate
  32385. * @param action defines the action to execute after the current execution block
  32386. */
  32387. static SetImmediate(action: () => void): void;
  32388. /**
  32389. * Function indicating if a number is an exponent of 2
  32390. * @param value defines the value to test
  32391. * @returns true if the value is an exponent of 2
  32392. */
  32393. static IsExponentOfTwo(value: number): boolean;
  32394. private static _tmpFloatArray;
  32395. /**
  32396. * Returns the nearest 32-bit single precision float representation of a Number
  32397. * @param value A Number. If the parameter is of a different type, it will get converted
  32398. * to a number or to NaN if it cannot be converted
  32399. * @returns number
  32400. */
  32401. static FloatRound(value: number): number;
  32402. /**
  32403. * Extracts the filename from a path
  32404. * @param path defines the path to use
  32405. * @returns the filename
  32406. */
  32407. static GetFilename(path: string): string;
  32408. /**
  32409. * Extracts the "folder" part of a path (everything before the filename).
  32410. * @param uri The URI to extract the info from
  32411. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32412. * @returns The "folder" part of the path
  32413. */
  32414. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32415. /**
  32416. * Extracts text content from a DOM element hierarchy
  32417. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32418. */
  32419. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32420. /**
  32421. * Convert an angle in radians to degrees
  32422. * @param angle defines the angle to convert
  32423. * @returns the angle in degrees
  32424. */
  32425. static ToDegrees(angle: number): number;
  32426. /**
  32427. * Convert an angle in degrees to radians
  32428. * @param angle defines the angle to convert
  32429. * @returns the angle in radians
  32430. */
  32431. static ToRadians(angle: number): number;
  32432. /**
  32433. * Returns an array if obj is not an array
  32434. * @param obj defines the object to evaluate as an array
  32435. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32436. * @returns either obj directly if obj is an array or a new array containing obj
  32437. */
  32438. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32439. /**
  32440. * Gets the pointer prefix to use
  32441. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32442. */
  32443. static GetPointerPrefix(): string;
  32444. /**
  32445. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32446. * @param url define the url we are trying
  32447. * @param element define the dom element where to configure the cors policy
  32448. */
  32449. static SetCorsBehavior(url: string | string[], element: {
  32450. crossOrigin: string | null;
  32451. }): void;
  32452. /**
  32453. * Removes unwanted characters from an url
  32454. * @param url defines the url to clean
  32455. * @returns the cleaned url
  32456. */
  32457. static CleanUrl(url: string): string;
  32458. /**
  32459. * Gets or sets a function used to pre-process url before using them to load assets
  32460. */
  32461. static PreprocessUrl: (url: string) => string;
  32462. /**
  32463. * Loads an image as an HTMLImageElement.
  32464. * @param input url string, ArrayBuffer, or Blob to load
  32465. * @param onLoad callback called when the image successfully loads
  32466. * @param onError callback called when the image fails to load
  32467. * @param offlineProvider offline provider for caching
  32468. * @param mimeType optional mime type
  32469. * @returns the HTMLImageElement of the loaded image
  32470. */
  32471. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32472. /**
  32473. * Loads a file from a url
  32474. * @param url url string, ArrayBuffer, or Blob to load
  32475. * @param onSuccess callback called when the file successfully loads
  32476. * @param onProgress callback called while file is loading (if the server supports this mode)
  32477. * @param offlineProvider defines the offline provider for caching
  32478. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32479. * @param onError callback called when the file fails to load
  32480. * @returns a file request object
  32481. */
  32482. 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;
  32483. /**
  32484. * Loads a file from a url
  32485. * @param url the file url to load
  32486. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32487. */
  32488. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32489. /**
  32490. * Load a script (identified by an url). When the url returns, the
  32491. * content of this file is added into a new script element, attached to the DOM (body element)
  32492. * @param scriptUrl defines the url of the script to laod
  32493. * @param onSuccess defines the callback called when the script is loaded
  32494. * @param onError defines the callback to call if an error occurs
  32495. * @param scriptId defines the id of the script element
  32496. */
  32497. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32498. /**
  32499. * Load an asynchronous script (identified by an url). When the url returns, the
  32500. * content of this file is added into a new script element, attached to the DOM (body element)
  32501. * @param scriptUrl defines the url of the script to laod
  32502. * @param scriptId defines the id of the script element
  32503. * @returns a promise request object
  32504. */
  32505. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32506. /**
  32507. * Loads a file from a blob
  32508. * @param fileToLoad defines the blob to use
  32509. * @param callback defines the callback to call when data is loaded
  32510. * @param progressCallback defines the callback to call during loading process
  32511. * @returns a file request object
  32512. */
  32513. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32514. /**
  32515. * Reads a file from a File object
  32516. * @param file defines the file to load
  32517. * @param onSuccess defines the callback to call when data is loaded
  32518. * @param onProgress defines the callback to call during loading process
  32519. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32520. * @param onError defines the callback to call when an error occurs
  32521. * @returns a file request object
  32522. */
  32523. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32524. /**
  32525. * Creates a data url from a given string content
  32526. * @param content defines the content to convert
  32527. * @returns the new data url link
  32528. */
  32529. static FileAsURL(content: string): string;
  32530. /**
  32531. * Format the given number to a specific decimal format
  32532. * @param value defines the number to format
  32533. * @param decimals defines the number of decimals to use
  32534. * @returns the formatted string
  32535. */
  32536. static Format(value: number, decimals?: number): string;
  32537. /**
  32538. * Tries to copy an object by duplicating every property
  32539. * @param source defines the source object
  32540. * @param destination defines the target object
  32541. * @param doNotCopyList defines a list of properties to avoid
  32542. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32543. */
  32544. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32545. /**
  32546. * Gets a boolean indicating if the given object has no own property
  32547. * @param obj defines the object to test
  32548. * @returns true if object has no own property
  32549. */
  32550. static IsEmpty(obj: any): boolean;
  32551. /**
  32552. * Function used to register events at window level
  32553. * @param windowElement defines the Window object to use
  32554. * @param events defines the events to register
  32555. */
  32556. static RegisterTopRootEvents(windowElement: Window, events: {
  32557. name: string;
  32558. handler: Nullable<(e: FocusEvent) => any>;
  32559. }[]): void;
  32560. /**
  32561. * Function used to unregister events from window level
  32562. * @param windowElement defines the Window object to use
  32563. * @param events defines the events to unregister
  32564. */
  32565. static UnregisterTopRootEvents(windowElement: Window, events: {
  32566. name: string;
  32567. handler: Nullable<(e: FocusEvent) => any>;
  32568. }[]): void;
  32569. /**
  32570. * @ignore
  32571. */
  32572. static _ScreenshotCanvas: HTMLCanvasElement;
  32573. /**
  32574. * Dumps the current bound framebuffer
  32575. * @param width defines the rendering width
  32576. * @param height defines the rendering height
  32577. * @param engine defines the hosting engine
  32578. * @param successCallback defines the callback triggered once the data are available
  32579. * @param mimeType defines the mime type of the result
  32580. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32581. */
  32582. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32583. /**
  32584. * Converts the canvas data to blob.
  32585. * This acts as a polyfill for browsers not supporting the to blob function.
  32586. * @param canvas Defines the canvas to extract the data from
  32587. * @param successCallback Defines the callback triggered once the data are available
  32588. * @param mimeType Defines the mime type of the result
  32589. */
  32590. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32591. /**
  32592. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32593. * @param successCallback defines the callback triggered once the data are available
  32594. * @param mimeType defines the mime type of the result
  32595. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32596. */
  32597. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32598. /**
  32599. * Downloads a blob in the browser
  32600. * @param blob defines the blob to download
  32601. * @param fileName defines the name of the downloaded file
  32602. */
  32603. static Download(blob: Blob, fileName: string): void;
  32604. /**
  32605. * Captures a screenshot of the current rendering
  32606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32607. * @param engine defines the rendering engine
  32608. * @param camera defines the source camera
  32609. * @param size This parameter can be set to a single number or to an object with the
  32610. * following (optional) properties: precision, width, height. If a single number is passed,
  32611. * it will be used for both width and height. If an object is passed, the screenshot size
  32612. * will be derived from the parameters. The precision property is a multiplier allowing
  32613. * rendering at a higher or lower resolution
  32614. * @param successCallback defines the callback receives a single parameter which contains the
  32615. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32616. * src parameter of an <img> to display it
  32617. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32618. * Check your browser for supported MIME types
  32619. */
  32620. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32621. /**
  32622. * Captures a screenshot of the current rendering
  32623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32624. * @param engine defines the rendering engine
  32625. * @param camera defines the source camera
  32626. * @param size This parameter can be set to a single number or to an object with the
  32627. * following (optional) properties: precision, width, height. If a single number is passed,
  32628. * it will be used for both width and height. If an object is passed, the screenshot size
  32629. * will be derived from the parameters. The precision property is a multiplier allowing
  32630. * rendering at a higher or lower resolution
  32631. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32632. * Check your browser for supported MIME types
  32633. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32634. * to the src parameter of an <img> to display it
  32635. */
  32636. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32637. /**
  32638. * Generates an image screenshot from the specified camera.
  32639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32640. * @param engine The engine to use for rendering
  32641. * @param camera The camera to use for rendering
  32642. * @param size This parameter can be set to a single number or to an object with the
  32643. * following (optional) properties: precision, width, height. If a single number is passed,
  32644. * it will be used for both width and height. If an object is passed, the screenshot size
  32645. * will be derived from the parameters. The precision property is a multiplier allowing
  32646. * rendering at a higher or lower resolution
  32647. * @param successCallback The callback receives a single parameter which contains the
  32648. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32649. * src parameter of an <img> to display it
  32650. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32651. * Check your browser for supported MIME types
  32652. * @param samples Texture samples (default: 1)
  32653. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32654. * @param fileName A name for for the downloaded file.
  32655. */
  32656. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32657. /**
  32658. * Generates an image screenshot from the specified camera.
  32659. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32660. * @param engine The engine to use for rendering
  32661. * @param camera The camera to use for rendering
  32662. * @param size This parameter can be set to a single number or to an object with the
  32663. * following (optional) properties: precision, width, height. If a single number is passed,
  32664. * it will be used for both width and height. If an object is passed, the screenshot size
  32665. * will be derived from the parameters. The precision property is a multiplier allowing
  32666. * rendering at a higher or lower resolution
  32667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32668. * Check your browser for supported MIME types
  32669. * @param samples Texture samples (default: 1)
  32670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32671. * @param fileName A name for for the downloaded file.
  32672. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32673. * to the src parameter of an <img> to display it
  32674. */
  32675. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32676. /**
  32677. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32678. * Be aware Math.random() could cause collisions, but:
  32679. * "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"
  32680. * @returns a pseudo random id
  32681. */
  32682. static RandomId(): string;
  32683. /**
  32684. * Test if the given uri is a base64 string
  32685. * @param uri The uri to test
  32686. * @return True if the uri is a base64 string or false otherwise
  32687. */
  32688. static IsBase64(uri: string): boolean;
  32689. /**
  32690. * Decode the given base64 uri.
  32691. * @param uri The uri to decode
  32692. * @return The decoded base64 data.
  32693. */
  32694. static DecodeBase64(uri: string): ArrayBuffer;
  32695. /**
  32696. * Gets the absolute url.
  32697. * @param url the input url
  32698. * @return the absolute url
  32699. */
  32700. static GetAbsoluteUrl(url: string): string;
  32701. /**
  32702. * No log
  32703. */
  32704. static readonly NoneLogLevel: number;
  32705. /**
  32706. * Only message logs
  32707. */
  32708. static readonly MessageLogLevel: number;
  32709. /**
  32710. * Only warning logs
  32711. */
  32712. static readonly WarningLogLevel: number;
  32713. /**
  32714. * Only error logs
  32715. */
  32716. static readonly ErrorLogLevel: number;
  32717. /**
  32718. * All logs
  32719. */
  32720. static readonly AllLogLevel: number;
  32721. /**
  32722. * Gets a value indicating the number of loading errors
  32723. * @ignorenaming
  32724. */
  32725. static readonly errorsCount: number;
  32726. /**
  32727. * Callback called when a new log is added
  32728. */
  32729. static OnNewCacheEntry: (entry: string) => void;
  32730. /**
  32731. * Log a message to the console
  32732. * @param message defines the message to log
  32733. */
  32734. static Log(message: string): void;
  32735. /**
  32736. * Write a warning message to the console
  32737. * @param message defines the message to log
  32738. */
  32739. static Warn(message: string): void;
  32740. /**
  32741. * Write an error message to the console
  32742. * @param message defines the message to log
  32743. */
  32744. static Error(message: string): void;
  32745. /**
  32746. * Gets current log cache (list of logs)
  32747. */
  32748. static readonly LogCache: string;
  32749. /**
  32750. * Clears the log cache
  32751. */
  32752. static ClearLogCache(): void;
  32753. /**
  32754. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32755. */
  32756. static LogLevels: number;
  32757. /**
  32758. * Checks if the window object exists
  32759. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32760. */
  32761. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32762. /**
  32763. * No performance log
  32764. */
  32765. static readonly PerformanceNoneLogLevel: number;
  32766. /**
  32767. * Use user marks to log performance
  32768. */
  32769. static readonly PerformanceUserMarkLogLevel: number;
  32770. /**
  32771. * Log performance to the console
  32772. */
  32773. static readonly PerformanceConsoleLogLevel: number;
  32774. private static _performance;
  32775. /**
  32776. * Sets the current performance log level
  32777. */
  32778. static PerformanceLogLevel: number;
  32779. private static _StartPerformanceCounterDisabled;
  32780. private static _EndPerformanceCounterDisabled;
  32781. private static _StartUserMark;
  32782. private static _EndUserMark;
  32783. private static _StartPerformanceConsole;
  32784. private static _EndPerformanceConsole;
  32785. /**
  32786. * Starts a performance counter
  32787. */
  32788. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32789. /**
  32790. * Ends a specific performance coutner
  32791. */
  32792. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32793. /**
  32794. * Gets either window.performance.now() if supported or Date.now() else
  32795. */
  32796. static readonly Now: number;
  32797. /**
  32798. * This method will return the name of the class used to create the instance of the given object.
  32799. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32800. * @param object the object to get the class name from
  32801. * @param isType defines if the object is actually a type
  32802. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32803. */
  32804. static GetClassName(object: any, isType?: boolean): string;
  32805. /**
  32806. * Gets the first element of an array satisfying a given predicate
  32807. * @param array defines the array to browse
  32808. * @param predicate defines the predicate to use
  32809. * @returns null if not found or the element
  32810. */
  32811. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32812. /**
  32813. * This method will return the name of the full name of the class, including its owning module (if any).
  32814. * 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).
  32815. * @param object the object to get the class name from
  32816. * @param isType defines if the object is actually a type
  32817. * @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.
  32818. * @ignorenaming
  32819. */
  32820. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32821. /**
  32822. * Returns a promise that resolves after the given amount of time.
  32823. * @param delay Number of milliseconds to delay
  32824. * @returns Promise that resolves after the given amount of time
  32825. */
  32826. static DelayAsync(delay: number): Promise<void>;
  32827. }
  32828. /**
  32829. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32830. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32831. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32832. * @param name The name of the class, case should be preserved
  32833. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32834. */
  32835. export function className(name: string, module?: string): (target: Object) => void;
  32836. /**
  32837. * An implementation of a loop for asynchronous functions.
  32838. */
  32839. export class AsyncLoop {
  32840. /**
  32841. * Defines the number of iterations for the loop
  32842. */
  32843. iterations: number;
  32844. /**
  32845. * Defines the current index of the loop.
  32846. */
  32847. index: number;
  32848. private _done;
  32849. private _fn;
  32850. private _successCallback;
  32851. /**
  32852. * Constructor.
  32853. * @param iterations the number of iterations.
  32854. * @param func the function to run each iteration
  32855. * @param successCallback the callback that will be called upon succesful execution
  32856. * @param offset starting offset.
  32857. */
  32858. constructor(
  32859. /**
  32860. * Defines the number of iterations for the loop
  32861. */
  32862. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32863. /**
  32864. * Execute the next iteration. Must be called after the last iteration was finished.
  32865. */
  32866. executeNext(): void;
  32867. /**
  32868. * Break the loop and run the success callback.
  32869. */
  32870. breakLoop(): void;
  32871. /**
  32872. * Create and run an async loop.
  32873. * @param iterations the number of iterations.
  32874. * @param fn the function to run each iteration
  32875. * @param successCallback the callback that will be called upon succesful execution
  32876. * @param offset starting offset.
  32877. * @returns the created async loop object
  32878. */
  32879. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32880. /**
  32881. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32882. * @param iterations total number of iterations
  32883. * @param syncedIterations number of synchronous iterations in each async iteration.
  32884. * @param fn the function to call each iteration.
  32885. * @param callback a success call back that will be called when iterating stops.
  32886. * @param breakFunction a break condition (optional)
  32887. * @param timeout timeout settings for the setTimeout function. default - 0.
  32888. * @returns the created async loop object
  32889. */
  32890. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32891. }
  32892. }
  32893. declare module BABYLON {
  32894. /**
  32895. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32896. * The underlying implementation relies on an associative array to ensure the best performances.
  32897. * The value can be anything including 'null' but except 'undefined'
  32898. */
  32899. export class StringDictionary<T> {
  32900. /**
  32901. * This will clear this dictionary and copy the content from the 'source' one.
  32902. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32903. * @param source the dictionary to take the content from and copy to this dictionary
  32904. */
  32905. copyFrom(source: StringDictionary<T>): void;
  32906. /**
  32907. * Get a value based from its key
  32908. * @param key the given key to get the matching value from
  32909. * @return the value if found, otherwise undefined is returned
  32910. */
  32911. get(key: string): T | undefined;
  32912. /**
  32913. * Get a value from its key or add it if it doesn't exist.
  32914. * This method will ensure you that a given key/data will be present in the dictionary.
  32915. * @param key the given key to get the matching value from
  32916. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32917. * The factory will only be invoked if there's no data for the given key.
  32918. * @return the value corresponding to the key.
  32919. */
  32920. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32921. /**
  32922. * Get a value from its key if present in the dictionary otherwise add it
  32923. * @param key the key to get the value from
  32924. * @param val if there's no such key/value pair in the dictionary add it with this value
  32925. * @return the value corresponding to the key
  32926. */
  32927. getOrAdd(key: string, val: T): T;
  32928. /**
  32929. * Check if there's a given key in the dictionary
  32930. * @param key the key to check for
  32931. * @return true if the key is present, false otherwise
  32932. */
  32933. contains(key: string): boolean;
  32934. /**
  32935. * Add a new key and its corresponding value
  32936. * @param key the key to add
  32937. * @param value the value corresponding to the key
  32938. * @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
  32939. */
  32940. add(key: string, value: T): boolean;
  32941. /**
  32942. * Update a specific value associated to a key
  32943. * @param key defines the key to use
  32944. * @param value defines the value to store
  32945. * @returns true if the value was updated (or false if the key was not found)
  32946. */
  32947. set(key: string, value: T): boolean;
  32948. /**
  32949. * Get the element of the given key and remove it from the dictionary
  32950. * @param key defines the key to search
  32951. * @returns the value associated with the key or null if not found
  32952. */
  32953. getAndRemove(key: string): Nullable<T>;
  32954. /**
  32955. * Remove a key/value from the dictionary.
  32956. * @param key the key to remove
  32957. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32958. */
  32959. remove(key: string): boolean;
  32960. /**
  32961. * Clear the whole content of the dictionary
  32962. */
  32963. clear(): void;
  32964. /**
  32965. * Gets the current count
  32966. */
  32967. readonly count: number;
  32968. /**
  32969. * Execute a callback on each key/val of the dictionary.
  32970. * Note that you can remove any element in this dictionary in the callback implementation
  32971. * @param callback the callback to execute on a given key/value pair
  32972. */
  32973. forEach(callback: (key: string, val: T) => void): void;
  32974. /**
  32975. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32976. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32977. * Note that you can remove any element in this dictionary in the callback implementation
  32978. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32979. * @returns the first item
  32980. */
  32981. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32982. private _count;
  32983. private _data;
  32984. }
  32985. }
  32986. declare module BABYLON {
  32987. /** @hidden */
  32988. export interface ICollisionCoordinator {
  32989. createCollider(): Collider;
  32990. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32991. init(scene: Scene): void;
  32992. }
  32993. /** @hidden */
  32994. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32995. private _scene;
  32996. private _scaledPosition;
  32997. private _scaledVelocity;
  32998. private _finalPosition;
  32999. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33000. createCollider(): Collider;
  33001. init(scene: Scene): void;
  33002. private _collideWithWorld;
  33003. }
  33004. }
  33005. declare module BABYLON {
  33006. /**
  33007. * Class used to manage all inputs for the scene.
  33008. */
  33009. export class InputManager {
  33010. /** The distance in pixel that you have to move to prevent some events */
  33011. static DragMovementThreshold: number;
  33012. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33013. static LongPressDelay: number;
  33014. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33015. static DoubleClickDelay: number;
  33016. /** If you need to check double click without raising a single click at first click, enable this flag */
  33017. static ExclusiveDoubleClickMode: boolean;
  33018. private _wheelEventName;
  33019. private _onPointerMove;
  33020. private _onPointerDown;
  33021. private _onPointerUp;
  33022. private _initClickEvent;
  33023. private _initActionManager;
  33024. private _delayedSimpleClick;
  33025. private _delayedSimpleClickTimeout;
  33026. private _previousDelayedSimpleClickTimeout;
  33027. private _meshPickProceed;
  33028. private _previousButtonPressed;
  33029. private _currentPickResult;
  33030. private _previousPickResult;
  33031. private _totalPointersPressed;
  33032. private _doubleClickOccured;
  33033. private _pointerOverMesh;
  33034. private _pickedDownMesh;
  33035. private _pickedUpMesh;
  33036. private _pointerX;
  33037. private _pointerY;
  33038. private _unTranslatedPointerX;
  33039. private _unTranslatedPointerY;
  33040. private _startingPointerPosition;
  33041. private _previousStartingPointerPosition;
  33042. private _startingPointerTime;
  33043. private _previousStartingPointerTime;
  33044. private _pointerCaptures;
  33045. private _onKeyDown;
  33046. private _onKeyUp;
  33047. private _onCanvasFocusObserver;
  33048. private _onCanvasBlurObserver;
  33049. private _scene;
  33050. /**
  33051. * Creates a new InputManager
  33052. * @param scene defines the hosting scene
  33053. */
  33054. constructor(scene: Scene);
  33055. /**
  33056. * Gets the mesh that is currently under the pointer
  33057. */
  33058. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33059. /**
  33060. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33061. */
  33062. readonly unTranslatedPointer: Vector2;
  33063. /**
  33064. * Gets or sets the current on-screen X position of the pointer
  33065. */
  33066. pointerX: number;
  33067. /**
  33068. * Gets or sets the current on-screen Y position of the pointer
  33069. */
  33070. pointerY: number;
  33071. private _updatePointerPosition;
  33072. private _processPointerMove;
  33073. private _setRayOnPointerInfo;
  33074. private _checkPrePointerObservable;
  33075. /**
  33076. * Use this method to simulate a pointer move on a mesh
  33077. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33078. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33079. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33080. */
  33081. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33082. /**
  33083. * Use this method to simulate a pointer down on a mesh
  33084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33087. */
  33088. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33089. private _processPointerDown;
  33090. /** @hidden */
  33091. _isPointerSwiping(): boolean;
  33092. /**
  33093. * Use this method to simulate a pointer up on a mesh
  33094. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33095. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33096. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33097. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33098. */
  33099. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33100. private _processPointerUp;
  33101. /**
  33102. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33103. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33104. * @returns true if the pointer was captured
  33105. */
  33106. isPointerCaptured(pointerId?: number): boolean;
  33107. /**
  33108. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33109. * @param attachUp defines if you want to attach events to pointerup
  33110. * @param attachDown defines if you want to attach events to pointerdown
  33111. * @param attachMove defines if you want to attach events to pointermove
  33112. */
  33113. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33114. /**
  33115. * Detaches all event handlers
  33116. */
  33117. detachControl(): void;
  33118. /**
  33119. * Force the value of meshUnderPointer
  33120. * @param mesh defines the mesh to use
  33121. */
  33122. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33123. /**
  33124. * Gets the mesh under the pointer
  33125. * @returns a Mesh or null if no mesh is under the pointer
  33126. */
  33127. getPointerOverMesh(): Nullable<AbstractMesh>;
  33128. }
  33129. }
  33130. declare module BABYLON {
  33131. /**
  33132. * Helper class used to generate session unique ID
  33133. */
  33134. export class UniqueIdGenerator {
  33135. private static _UniqueIdCounter;
  33136. /**
  33137. * Gets an unique (relatively to the current scene) Id
  33138. */
  33139. static readonly UniqueId: number;
  33140. }
  33141. }
  33142. declare module BABYLON {
  33143. /**
  33144. * This class defines the direct association between an animation and a target
  33145. */
  33146. export class TargetedAnimation {
  33147. /**
  33148. * Animation to perform
  33149. */
  33150. animation: Animation;
  33151. /**
  33152. * Target to animate
  33153. */
  33154. target: any;
  33155. /**
  33156. * Serialize the object
  33157. * @returns the JSON object representing the current entity
  33158. */
  33159. serialize(): any;
  33160. }
  33161. /**
  33162. * Use this class to create coordinated animations on multiple targets
  33163. */
  33164. export class AnimationGroup implements IDisposable {
  33165. /** The name of the animation group */
  33166. name: string;
  33167. private _scene;
  33168. private _targetedAnimations;
  33169. private _animatables;
  33170. private _from;
  33171. private _to;
  33172. private _isStarted;
  33173. private _isPaused;
  33174. private _speedRatio;
  33175. private _loopAnimation;
  33176. /**
  33177. * Gets or sets the unique id of the node
  33178. */
  33179. uniqueId: number;
  33180. /**
  33181. * This observable will notify when one animation have ended
  33182. */
  33183. onAnimationEndObservable: Observable<TargetedAnimation>;
  33184. /**
  33185. * Observer raised when one animation loops
  33186. */
  33187. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33188. /**
  33189. * Observer raised when all animations have looped
  33190. */
  33191. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33192. /**
  33193. * This observable will notify when all animations have ended.
  33194. */
  33195. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33196. /**
  33197. * This observable will notify when all animations have paused.
  33198. */
  33199. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33200. /**
  33201. * This observable will notify when all animations are playing.
  33202. */
  33203. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33204. /**
  33205. * Gets the first frame
  33206. */
  33207. readonly from: number;
  33208. /**
  33209. * Gets the last frame
  33210. */
  33211. readonly to: number;
  33212. /**
  33213. * Define if the animations are started
  33214. */
  33215. readonly isStarted: boolean;
  33216. /**
  33217. * Gets a value indicating that the current group is playing
  33218. */
  33219. readonly isPlaying: boolean;
  33220. /**
  33221. * Gets or sets the speed ratio to use for all animations
  33222. */
  33223. /**
  33224. * Gets or sets the speed ratio to use for all animations
  33225. */
  33226. speedRatio: number;
  33227. /**
  33228. * Gets or sets if all animations should loop or not
  33229. */
  33230. loopAnimation: boolean;
  33231. /**
  33232. * Gets the targeted animations for this animation group
  33233. */
  33234. readonly targetedAnimations: Array<TargetedAnimation>;
  33235. /**
  33236. * returning the list of animatables controlled by this animation group.
  33237. */
  33238. readonly animatables: Array<Animatable>;
  33239. /**
  33240. * Instantiates a new Animation Group.
  33241. * This helps managing several animations at once.
  33242. * @see http://doc.babylonjs.com/how_to/group
  33243. * @param name Defines the name of the group
  33244. * @param scene Defines the scene the group belongs to
  33245. */
  33246. constructor(
  33247. /** The name of the animation group */
  33248. name: string, scene?: Nullable<Scene>);
  33249. /**
  33250. * Add an animation (with its target) in the group
  33251. * @param animation defines the animation we want to add
  33252. * @param target defines the target of the animation
  33253. * @returns the TargetedAnimation object
  33254. */
  33255. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33256. /**
  33257. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33258. * It can add constant keys at begin or end
  33259. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33260. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33261. * @returns the animation group
  33262. */
  33263. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33264. private _animationLoopCount;
  33265. private _animationLoopFlags;
  33266. private _processLoop;
  33267. /**
  33268. * Start all animations on given targets
  33269. * @param loop defines if animations must loop
  33270. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33271. * @param from defines the from key (optional)
  33272. * @param to defines the to key (optional)
  33273. * @returns the current animation group
  33274. */
  33275. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33276. /**
  33277. * Pause all animations
  33278. * @returns the animation group
  33279. */
  33280. pause(): AnimationGroup;
  33281. /**
  33282. * Play all animations to initial state
  33283. * This function will start() the animations if they were not started or will restart() them if they were paused
  33284. * @param loop defines if animations must loop
  33285. * @returns the animation group
  33286. */
  33287. play(loop?: boolean): AnimationGroup;
  33288. /**
  33289. * Reset all animations to initial state
  33290. * @returns the animation group
  33291. */
  33292. reset(): AnimationGroup;
  33293. /**
  33294. * Restart animations from key 0
  33295. * @returns the animation group
  33296. */
  33297. restart(): AnimationGroup;
  33298. /**
  33299. * Stop all animations
  33300. * @returns the animation group
  33301. */
  33302. stop(): AnimationGroup;
  33303. /**
  33304. * Set animation weight for all animatables
  33305. * @param weight defines the weight to use
  33306. * @return the animationGroup
  33307. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33308. */
  33309. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33310. /**
  33311. * Synchronize and normalize all animatables with a source animatable
  33312. * @param root defines the root animatable to synchronize with
  33313. * @return the animationGroup
  33314. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33315. */
  33316. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33317. /**
  33318. * Goes to a specific frame in this animation group
  33319. * @param frame the frame number to go to
  33320. * @return the animationGroup
  33321. */
  33322. goToFrame(frame: number): AnimationGroup;
  33323. /**
  33324. * Dispose all associated resources
  33325. */
  33326. dispose(): void;
  33327. private _checkAnimationGroupEnded;
  33328. /**
  33329. * Clone the current animation group and returns a copy
  33330. * @param newName defines the name of the new group
  33331. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33332. * @returns the new aniamtion group
  33333. */
  33334. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33335. /**
  33336. * Serializes the animationGroup to an object
  33337. * @returns Serialized object
  33338. */
  33339. serialize(): any;
  33340. /**
  33341. * Returns a new AnimationGroup object parsed from the source provided.
  33342. * @param parsedAnimationGroup defines the source
  33343. * @param scene defines the scene that will receive the animationGroup
  33344. * @returns a new AnimationGroup
  33345. */
  33346. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33347. /**
  33348. * Returns the string "AnimationGroup"
  33349. * @returns "AnimationGroup"
  33350. */
  33351. getClassName(): string;
  33352. /**
  33353. * Creates a detailled string about the object
  33354. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33355. * @returns a string representing the object
  33356. */
  33357. toString(fullDetails?: boolean): string;
  33358. }
  33359. }
  33360. declare module BABYLON {
  33361. /**
  33362. * Define an interface for all classes that will hold resources
  33363. */
  33364. export interface IDisposable {
  33365. /**
  33366. * Releases all held resources
  33367. */
  33368. dispose(): void;
  33369. }
  33370. /** Interface defining initialization parameters for Scene class */
  33371. export interface SceneOptions {
  33372. /**
  33373. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33374. * It will improve performance when the number of geometries becomes important.
  33375. */
  33376. useGeometryUniqueIdsMap?: boolean;
  33377. /**
  33378. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33379. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33380. */
  33381. useMaterialMeshMap?: boolean;
  33382. /**
  33383. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33384. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33385. */
  33386. useClonedMeshhMap?: boolean;
  33387. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33388. virtual?: boolean;
  33389. }
  33390. /**
  33391. * Represents a scene to be rendered by the engine.
  33392. * @see http://doc.babylonjs.com/features/scene
  33393. */
  33394. export class Scene extends AbstractScene implements IAnimatable {
  33395. /** The fog is deactivated */
  33396. static readonly FOGMODE_NONE: number;
  33397. /** The fog density is following an exponential function */
  33398. static readonly FOGMODE_EXP: number;
  33399. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33400. static readonly FOGMODE_EXP2: number;
  33401. /** The fog density is following a linear function. */
  33402. static readonly FOGMODE_LINEAR: number;
  33403. /**
  33404. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33406. */
  33407. static MinDeltaTime: number;
  33408. /**
  33409. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33411. */
  33412. static MaxDeltaTime: number;
  33413. /**
  33414. * Factory used to create the default material.
  33415. * @param name The name of the material to create
  33416. * @param scene The scene to create the material for
  33417. * @returns The default material
  33418. */
  33419. static DefaultMaterialFactory(scene: Scene): Material;
  33420. /**
  33421. * Factory used to create the a collision coordinator.
  33422. * @returns The collision coordinator
  33423. */
  33424. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33425. /** @hidden */
  33426. _inputManager: InputManager;
  33427. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33428. cameraToUseForPointers: Nullable<Camera>;
  33429. /** @hidden */
  33430. readonly _isScene: boolean;
  33431. /**
  33432. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33433. */
  33434. autoClear: boolean;
  33435. /**
  33436. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33437. */
  33438. autoClearDepthAndStencil: boolean;
  33439. /**
  33440. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33441. */
  33442. clearColor: Color4;
  33443. /**
  33444. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33445. */
  33446. ambientColor: Color3;
  33447. /**
  33448. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33449. * It should only be one of the following (if not the default embedded one):
  33450. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33451. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33452. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33453. * The material properties need to be setup according to the type of texture in use.
  33454. */
  33455. environmentBRDFTexture: BaseTexture;
  33456. /** @hidden */
  33457. protected _environmentTexture: Nullable<BaseTexture>;
  33458. /**
  33459. * Texture used in all pbr material as the reflection texture.
  33460. * As in the majority of the scene they are the same (exception for multi room and so on),
  33461. * this is easier to reference from here than from all the materials.
  33462. */
  33463. /**
  33464. * Texture used in all pbr material as the reflection texture.
  33465. * As in the majority of the scene they are the same (exception for multi room and so on),
  33466. * this is easier to set here than in all the materials.
  33467. */
  33468. environmentTexture: Nullable<BaseTexture>;
  33469. /** @hidden */
  33470. protected _environmentIntensity: number;
  33471. /**
  33472. * Intensity of the environment in all pbr material.
  33473. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33474. * As in the majority of the scene they are the same (exception for multi room and so on),
  33475. * this is easier to reference from here than from all the materials.
  33476. */
  33477. /**
  33478. * Intensity of the environment in all pbr material.
  33479. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33480. * As in the majority of the scene they are the same (exception for multi room and so on),
  33481. * this is easier to set here than in all the materials.
  33482. */
  33483. environmentIntensity: number;
  33484. /** @hidden */
  33485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33486. /**
  33487. * Default image processing configuration used either in the rendering
  33488. * Forward main pass or through the imageProcessingPostProcess if present.
  33489. * As in the majority of the scene they are the same (exception for multi camera),
  33490. * this is easier to reference from here than from all the materials and post process.
  33491. *
  33492. * No setter as we it is a shared configuration, you can set the values instead.
  33493. */
  33494. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33495. private _forceWireframe;
  33496. /**
  33497. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33498. */
  33499. forceWireframe: boolean;
  33500. private _forcePointsCloud;
  33501. /**
  33502. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33503. */
  33504. forcePointsCloud: boolean;
  33505. /**
  33506. * Gets or sets the active clipplane 1
  33507. */
  33508. clipPlane: Nullable<Plane>;
  33509. /**
  33510. * Gets or sets the active clipplane 2
  33511. */
  33512. clipPlane2: Nullable<Plane>;
  33513. /**
  33514. * Gets or sets the active clipplane 3
  33515. */
  33516. clipPlane3: Nullable<Plane>;
  33517. /**
  33518. * Gets or sets the active clipplane 4
  33519. */
  33520. clipPlane4: Nullable<Plane>;
  33521. /**
  33522. * Gets or sets a boolean indicating if animations are enabled
  33523. */
  33524. animationsEnabled: boolean;
  33525. private _animationPropertiesOverride;
  33526. /**
  33527. * Gets or sets the animation properties override
  33528. */
  33529. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33530. /**
  33531. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33532. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33533. */
  33534. useConstantAnimationDeltaTime: boolean;
  33535. /**
  33536. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33537. * Please note that it requires to run a ray cast through the scene on every frame
  33538. */
  33539. constantlyUpdateMeshUnderPointer: boolean;
  33540. /**
  33541. * Defines the HTML cursor to use when hovering over interactive elements
  33542. */
  33543. hoverCursor: string;
  33544. /**
  33545. * Defines the HTML default cursor to use (empty by default)
  33546. */
  33547. defaultCursor: string;
  33548. /**
  33549. * Defines wether cursors are handled by the scene.
  33550. */
  33551. doNotHandleCursors: boolean;
  33552. /**
  33553. * This is used to call preventDefault() on pointer down
  33554. * in order to block unwanted artifacts like system double clicks
  33555. */
  33556. preventDefaultOnPointerDown: boolean;
  33557. /**
  33558. * This is used to call preventDefault() on pointer up
  33559. * in order to block unwanted artifacts like system double clicks
  33560. */
  33561. preventDefaultOnPointerUp: boolean;
  33562. /**
  33563. * Gets or sets user defined metadata
  33564. */
  33565. metadata: any;
  33566. /**
  33567. * For internal use only. Please do not use.
  33568. */
  33569. reservedDataStore: any;
  33570. /**
  33571. * Gets the name of the plugin used to load this scene (null by default)
  33572. */
  33573. loadingPluginName: string;
  33574. /**
  33575. * Use this array to add regular expressions used to disable offline support for specific urls
  33576. */
  33577. disableOfflineSupportExceptionRules: RegExp[];
  33578. /**
  33579. * An event triggered when the scene is disposed.
  33580. */
  33581. onDisposeObservable: Observable<Scene>;
  33582. private _onDisposeObserver;
  33583. /** Sets a function to be executed when this scene is disposed. */
  33584. onDispose: () => void;
  33585. /**
  33586. * An event triggered before rendering the scene (right after animations and physics)
  33587. */
  33588. onBeforeRenderObservable: Observable<Scene>;
  33589. private _onBeforeRenderObserver;
  33590. /** Sets a function to be executed before rendering this scene */
  33591. beforeRender: Nullable<() => void>;
  33592. /**
  33593. * An event triggered after rendering the scene
  33594. */
  33595. onAfterRenderObservable: Observable<Scene>;
  33596. /**
  33597. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33598. */
  33599. onAfterRenderCameraObservable: Observable<Camera>;
  33600. private _onAfterRenderObserver;
  33601. /** Sets a function to be executed after rendering this scene */
  33602. afterRender: Nullable<() => void>;
  33603. /**
  33604. * An event triggered before animating the scene
  33605. */
  33606. onBeforeAnimationsObservable: Observable<Scene>;
  33607. /**
  33608. * An event triggered after animations processing
  33609. */
  33610. onAfterAnimationsObservable: Observable<Scene>;
  33611. /**
  33612. * An event triggered before draw calls are ready to be sent
  33613. */
  33614. onBeforeDrawPhaseObservable: Observable<Scene>;
  33615. /**
  33616. * An event triggered after draw calls have been sent
  33617. */
  33618. onAfterDrawPhaseObservable: Observable<Scene>;
  33619. /**
  33620. * An event triggered when the scene is ready
  33621. */
  33622. onReadyObservable: Observable<Scene>;
  33623. /**
  33624. * An event triggered before rendering a camera
  33625. */
  33626. onBeforeCameraRenderObservable: Observable<Camera>;
  33627. private _onBeforeCameraRenderObserver;
  33628. /** Sets a function to be executed before rendering a camera*/
  33629. beforeCameraRender: () => void;
  33630. /**
  33631. * An event triggered after rendering a camera
  33632. */
  33633. onAfterCameraRenderObservable: Observable<Camera>;
  33634. private _onAfterCameraRenderObserver;
  33635. /** Sets a function to be executed after rendering a camera*/
  33636. afterCameraRender: () => void;
  33637. /**
  33638. * An event triggered when active meshes evaluation is about to start
  33639. */
  33640. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33641. /**
  33642. * An event triggered when active meshes evaluation is done
  33643. */
  33644. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33645. /**
  33646. * An event triggered when particles rendering is about to start
  33647. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33648. */
  33649. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33650. /**
  33651. * An event triggered when particles rendering is done
  33652. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33653. */
  33654. onAfterParticlesRenderingObservable: Observable<Scene>;
  33655. /**
  33656. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33657. */
  33658. onDataLoadedObservable: Observable<Scene>;
  33659. /**
  33660. * An event triggered when a camera is created
  33661. */
  33662. onNewCameraAddedObservable: Observable<Camera>;
  33663. /**
  33664. * An event triggered when a camera is removed
  33665. */
  33666. onCameraRemovedObservable: Observable<Camera>;
  33667. /**
  33668. * An event triggered when a light is created
  33669. */
  33670. onNewLightAddedObservable: Observable<Light>;
  33671. /**
  33672. * An event triggered when a light is removed
  33673. */
  33674. onLightRemovedObservable: Observable<Light>;
  33675. /**
  33676. * An event triggered when a geometry is created
  33677. */
  33678. onNewGeometryAddedObservable: Observable<Geometry>;
  33679. /**
  33680. * An event triggered when a geometry is removed
  33681. */
  33682. onGeometryRemovedObservable: Observable<Geometry>;
  33683. /**
  33684. * An event triggered when a transform node is created
  33685. */
  33686. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33687. /**
  33688. * An event triggered when a transform node is removed
  33689. */
  33690. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33691. /**
  33692. * An event triggered when a mesh is created
  33693. */
  33694. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33695. /**
  33696. * An event triggered when a mesh is removed
  33697. */
  33698. onMeshRemovedObservable: Observable<AbstractMesh>;
  33699. /**
  33700. * An event triggered when a skeleton is created
  33701. */
  33702. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33703. /**
  33704. * An event triggered when a skeleton is removed
  33705. */
  33706. onSkeletonRemovedObservable: Observable<Skeleton>;
  33707. /**
  33708. * An event triggered when a material is created
  33709. */
  33710. onNewMaterialAddedObservable: Observable<Material>;
  33711. /**
  33712. * An event triggered when a material is removed
  33713. */
  33714. onMaterialRemovedObservable: Observable<Material>;
  33715. /**
  33716. * An event triggered when a texture is created
  33717. */
  33718. onNewTextureAddedObservable: Observable<BaseTexture>;
  33719. /**
  33720. * An event triggered when a texture is removed
  33721. */
  33722. onTextureRemovedObservable: Observable<BaseTexture>;
  33723. /**
  33724. * An event triggered when render targets are about to be rendered
  33725. * Can happen multiple times per frame.
  33726. */
  33727. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33728. /**
  33729. * An event triggered when render targets were rendered.
  33730. * Can happen multiple times per frame.
  33731. */
  33732. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33733. /**
  33734. * An event triggered before calculating deterministic simulation step
  33735. */
  33736. onBeforeStepObservable: Observable<Scene>;
  33737. /**
  33738. * An event triggered after calculating deterministic simulation step
  33739. */
  33740. onAfterStepObservable: Observable<Scene>;
  33741. /**
  33742. * An event triggered when the activeCamera property is updated
  33743. */
  33744. onActiveCameraChanged: Observable<Scene>;
  33745. /**
  33746. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33747. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33748. * 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)
  33749. */
  33750. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33751. /**
  33752. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33753. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33754. * 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)
  33755. */
  33756. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33757. /**
  33758. * This Observable will when a mesh has been imported into the scene.
  33759. */
  33760. onMeshImportedObservable: Observable<AbstractMesh>;
  33761. /**
  33762. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33763. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33764. */
  33765. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33766. /** @hidden */
  33767. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33768. /**
  33769. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33770. */
  33771. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33772. /**
  33773. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33774. */
  33775. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33776. /**
  33777. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33778. */
  33779. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33780. /** Callback called when a pointer move is detected */
  33781. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33782. /** Callback called when a pointer down is detected */
  33783. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33784. /** Callback called when a pointer up is detected */
  33785. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33786. /** Callback called when a pointer pick is detected */
  33787. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33788. /**
  33789. * 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).
  33790. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33791. */
  33792. onPrePointerObservable: Observable<PointerInfoPre>;
  33793. /**
  33794. * Observable event triggered each time an input event is received from the rendering canvas
  33795. */
  33796. onPointerObservable: Observable<PointerInfo>;
  33797. /**
  33798. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33799. */
  33800. readonly unTranslatedPointer: Vector2;
  33801. /**
  33802. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33803. */
  33804. static DragMovementThreshold: number;
  33805. /**
  33806. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33807. */
  33808. static LongPressDelay: number;
  33809. /**
  33810. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33811. */
  33812. static DoubleClickDelay: number;
  33813. /** If you need to check double click without raising a single click at first click, enable this flag */
  33814. static ExclusiveDoubleClickMode: boolean;
  33815. /** @hidden */
  33816. _mirroredCameraPosition: Nullable<Vector3>;
  33817. /**
  33818. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33819. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33820. */
  33821. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33822. /**
  33823. * Observable event triggered each time an keyboard event is received from the hosting window
  33824. */
  33825. onKeyboardObservable: Observable<KeyboardInfo>;
  33826. private _useRightHandedSystem;
  33827. /**
  33828. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33829. */
  33830. useRightHandedSystem: boolean;
  33831. private _timeAccumulator;
  33832. private _currentStepId;
  33833. private _currentInternalStep;
  33834. /**
  33835. * Sets the step Id used by deterministic lock step
  33836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33837. * @param newStepId defines the step Id
  33838. */
  33839. setStepId(newStepId: number): void;
  33840. /**
  33841. * Gets the step Id used by deterministic lock step
  33842. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33843. * @returns the step Id
  33844. */
  33845. getStepId(): number;
  33846. /**
  33847. * Gets the internal step used by deterministic lock step
  33848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33849. * @returns the internal step
  33850. */
  33851. getInternalStep(): number;
  33852. private _fogEnabled;
  33853. /**
  33854. * Gets or sets a boolean indicating if fog is enabled on this scene
  33855. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33856. * (Default is true)
  33857. */
  33858. fogEnabled: boolean;
  33859. private _fogMode;
  33860. /**
  33861. * Gets or sets the fog mode to use
  33862. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33863. * | mode | value |
  33864. * | --- | --- |
  33865. * | FOGMODE_NONE | 0 |
  33866. * | FOGMODE_EXP | 1 |
  33867. * | FOGMODE_EXP2 | 2 |
  33868. * | FOGMODE_LINEAR | 3 |
  33869. */
  33870. fogMode: number;
  33871. /**
  33872. * Gets or sets the fog color to use
  33873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33874. * (Default is Color3(0.2, 0.2, 0.3))
  33875. */
  33876. fogColor: Color3;
  33877. /**
  33878. * Gets or sets the fog density to use
  33879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33880. * (Default is 0.1)
  33881. */
  33882. fogDensity: number;
  33883. /**
  33884. * Gets or sets the fog start distance to use
  33885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33886. * (Default is 0)
  33887. */
  33888. fogStart: number;
  33889. /**
  33890. * Gets or sets the fog end distance to use
  33891. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33892. * (Default is 1000)
  33893. */
  33894. fogEnd: number;
  33895. private _shadowsEnabled;
  33896. /**
  33897. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33898. */
  33899. shadowsEnabled: boolean;
  33900. private _lightsEnabled;
  33901. /**
  33902. * Gets or sets a boolean indicating if lights are enabled on this scene
  33903. */
  33904. lightsEnabled: boolean;
  33905. /** All of the active cameras added to this scene. */
  33906. activeCameras: Camera[];
  33907. /** @hidden */
  33908. _activeCamera: Nullable<Camera>;
  33909. /** Gets or sets the current active camera */
  33910. activeCamera: Nullable<Camera>;
  33911. private _defaultMaterial;
  33912. /** The default material used on meshes when no material is affected */
  33913. /** The default material used on meshes when no material is affected */
  33914. defaultMaterial: Material;
  33915. private _texturesEnabled;
  33916. /**
  33917. * Gets or sets a boolean indicating if textures are enabled on this scene
  33918. */
  33919. texturesEnabled: boolean;
  33920. /**
  33921. * Gets or sets a boolean indicating if particles are enabled on this scene
  33922. */
  33923. particlesEnabled: boolean;
  33924. /**
  33925. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33926. */
  33927. spritesEnabled: boolean;
  33928. private _skeletonsEnabled;
  33929. /**
  33930. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33931. */
  33932. skeletonsEnabled: boolean;
  33933. /**
  33934. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33935. */
  33936. lensFlaresEnabled: boolean;
  33937. /**
  33938. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33939. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33940. */
  33941. collisionsEnabled: boolean;
  33942. private _collisionCoordinator;
  33943. /** @hidden */
  33944. readonly collisionCoordinator: ICollisionCoordinator;
  33945. /**
  33946. * Defines the gravity applied to this scene (used only for collisions)
  33947. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33948. */
  33949. gravity: Vector3;
  33950. /**
  33951. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33952. */
  33953. postProcessesEnabled: boolean;
  33954. /**
  33955. * The list of postprocesses added to the scene
  33956. */
  33957. postProcesses: PostProcess[];
  33958. /**
  33959. * Gets the current postprocess manager
  33960. */
  33961. postProcessManager: PostProcessManager;
  33962. /**
  33963. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33964. */
  33965. renderTargetsEnabled: boolean;
  33966. /**
  33967. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33968. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33969. */
  33970. dumpNextRenderTargets: boolean;
  33971. /**
  33972. * The list of user defined render targets added to the scene
  33973. */
  33974. customRenderTargets: RenderTargetTexture[];
  33975. /**
  33976. * Defines if texture loading must be delayed
  33977. * If true, textures will only be loaded when they need to be rendered
  33978. */
  33979. useDelayedTextureLoading: boolean;
  33980. /**
  33981. * Gets the list of meshes imported to the scene through SceneLoader
  33982. */
  33983. importedMeshesFiles: String[];
  33984. /**
  33985. * Gets or sets a boolean indicating if probes are enabled on this scene
  33986. */
  33987. probesEnabled: boolean;
  33988. /**
  33989. * Gets or sets the current offline provider to use to store scene data
  33990. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33991. */
  33992. offlineProvider: IOfflineProvider;
  33993. /**
  33994. * Gets or sets the action manager associated with the scene
  33995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33996. */
  33997. actionManager: AbstractActionManager;
  33998. private _meshesForIntersections;
  33999. /**
  34000. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34001. */
  34002. proceduralTexturesEnabled: boolean;
  34003. private _engine;
  34004. private _totalVertices;
  34005. /** @hidden */
  34006. _activeIndices: PerfCounter;
  34007. /** @hidden */
  34008. _activeParticles: PerfCounter;
  34009. /** @hidden */
  34010. _activeBones: PerfCounter;
  34011. private _animationRatio;
  34012. /** @hidden */
  34013. _animationTimeLast: number;
  34014. /** @hidden */
  34015. _animationTime: number;
  34016. /**
  34017. * Gets or sets a general scale for animation speed
  34018. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34019. */
  34020. animationTimeScale: number;
  34021. /** @hidden */
  34022. _cachedMaterial: Nullable<Material>;
  34023. /** @hidden */
  34024. _cachedEffect: Nullable<Effect>;
  34025. /** @hidden */
  34026. _cachedVisibility: Nullable<number>;
  34027. private _renderId;
  34028. private _frameId;
  34029. private _executeWhenReadyTimeoutId;
  34030. private _intermediateRendering;
  34031. private _viewUpdateFlag;
  34032. private _projectionUpdateFlag;
  34033. /** @hidden */
  34034. _toBeDisposed: Nullable<IDisposable>[];
  34035. private _activeRequests;
  34036. /** @hidden */
  34037. _pendingData: any[];
  34038. private _isDisposed;
  34039. /**
  34040. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34041. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34042. */
  34043. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34044. private _activeMeshes;
  34045. private _processedMaterials;
  34046. private _renderTargets;
  34047. /** @hidden */
  34048. _activeParticleSystems: SmartArray<IParticleSystem>;
  34049. private _activeSkeletons;
  34050. private _softwareSkinnedMeshes;
  34051. private _renderingManager;
  34052. /** @hidden */
  34053. _activeAnimatables: Animatable[];
  34054. private _transformMatrix;
  34055. private _sceneUbo;
  34056. /** @hidden */
  34057. _viewMatrix: Matrix;
  34058. private _projectionMatrix;
  34059. /** @hidden */
  34060. _forcedViewPosition: Nullable<Vector3>;
  34061. /** @hidden */
  34062. _frustumPlanes: Plane[];
  34063. /**
  34064. * Gets the list of frustum planes (built from the active camera)
  34065. */
  34066. readonly frustumPlanes: Plane[];
  34067. /**
  34068. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34069. * This is useful if there are more lights that the maximum simulteanous authorized
  34070. */
  34071. requireLightSorting: boolean;
  34072. /** @hidden */
  34073. readonly useMaterialMeshMap: boolean;
  34074. /** @hidden */
  34075. readonly useClonedMeshhMap: boolean;
  34076. private _externalData;
  34077. private _uid;
  34078. /**
  34079. * @hidden
  34080. * Backing store of defined scene components.
  34081. */
  34082. _components: ISceneComponent[];
  34083. /**
  34084. * @hidden
  34085. * Backing store of defined scene components.
  34086. */
  34087. _serializableComponents: ISceneSerializableComponent[];
  34088. /**
  34089. * List of components to register on the next registration step.
  34090. */
  34091. private _transientComponents;
  34092. /**
  34093. * Registers the transient components if needed.
  34094. */
  34095. private _registerTransientComponents;
  34096. /**
  34097. * @hidden
  34098. * Add a component to the scene.
  34099. * Note that the ccomponent could be registered on th next frame if this is called after
  34100. * the register component stage.
  34101. * @param component Defines the component to add to the scene
  34102. */
  34103. _addComponent(component: ISceneComponent): void;
  34104. /**
  34105. * @hidden
  34106. * Gets a component from the scene.
  34107. * @param name defines the name of the component to retrieve
  34108. * @returns the component or null if not present
  34109. */
  34110. _getComponent(name: string): Nullable<ISceneComponent>;
  34111. /**
  34112. * @hidden
  34113. * Defines the actions happening before camera updates.
  34114. */
  34115. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34116. /**
  34117. * @hidden
  34118. * Defines the actions happening before clear the canvas.
  34119. */
  34120. _beforeClearStage: Stage<SimpleStageAction>;
  34121. /**
  34122. * @hidden
  34123. * Defines the actions when collecting render targets for the frame.
  34124. */
  34125. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34126. /**
  34127. * @hidden
  34128. * Defines the actions happening for one camera in the frame.
  34129. */
  34130. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34131. /**
  34132. * @hidden
  34133. * Defines the actions happening during the per mesh ready checks.
  34134. */
  34135. _isReadyForMeshStage: Stage<MeshStageAction>;
  34136. /**
  34137. * @hidden
  34138. * Defines the actions happening before evaluate active mesh checks.
  34139. */
  34140. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34141. /**
  34142. * @hidden
  34143. * Defines the actions happening during the evaluate sub mesh checks.
  34144. */
  34145. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34146. /**
  34147. * @hidden
  34148. * Defines the actions happening during the active mesh stage.
  34149. */
  34150. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34151. /**
  34152. * @hidden
  34153. * Defines the actions happening during the per camera render target step.
  34154. */
  34155. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34156. /**
  34157. * @hidden
  34158. * Defines the actions happening just before the active camera is drawing.
  34159. */
  34160. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34161. /**
  34162. * @hidden
  34163. * Defines the actions happening just before a render target is drawing.
  34164. */
  34165. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34166. /**
  34167. * @hidden
  34168. * Defines the actions happening just before a rendering group is drawing.
  34169. */
  34170. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34171. /**
  34172. * @hidden
  34173. * Defines the actions happening just before a mesh is drawing.
  34174. */
  34175. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34176. /**
  34177. * @hidden
  34178. * Defines the actions happening just after a mesh has been drawn.
  34179. */
  34180. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34181. /**
  34182. * @hidden
  34183. * Defines the actions happening just after a rendering group has been drawn.
  34184. */
  34185. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34186. /**
  34187. * @hidden
  34188. * Defines the actions happening just after the active camera has been drawn.
  34189. */
  34190. _afterCameraDrawStage: Stage<CameraStageAction>;
  34191. /**
  34192. * @hidden
  34193. * Defines the actions happening just after a render target has been drawn.
  34194. */
  34195. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34196. /**
  34197. * @hidden
  34198. * Defines the actions happening just after rendering all cameras and computing intersections.
  34199. */
  34200. _afterRenderStage: Stage<SimpleStageAction>;
  34201. /**
  34202. * @hidden
  34203. * Defines the actions happening when a pointer move event happens.
  34204. */
  34205. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34206. /**
  34207. * @hidden
  34208. * Defines the actions happening when a pointer down event happens.
  34209. */
  34210. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34211. /**
  34212. * @hidden
  34213. * Defines the actions happening when a pointer up event happens.
  34214. */
  34215. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34216. /**
  34217. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34218. */
  34219. private geometriesByUniqueId;
  34220. /**
  34221. * Creates a new Scene
  34222. * @param engine defines the engine to use to render this scene
  34223. * @param options defines the scene options
  34224. */
  34225. constructor(engine: Engine, options?: SceneOptions);
  34226. /**
  34227. * Gets a string idenfifying the name of the class
  34228. * @returns "Scene" string
  34229. */
  34230. getClassName(): string;
  34231. private _defaultMeshCandidates;
  34232. /**
  34233. * @hidden
  34234. */
  34235. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34236. private _defaultSubMeshCandidates;
  34237. /**
  34238. * @hidden
  34239. */
  34240. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34241. /**
  34242. * Sets the default candidate providers for the scene.
  34243. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34244. * and getCollidingSubMeshCandidates to their default function
  34245. */
  34246. setDefaultCandidateProviders(): void;
  34247. /**
  34248. * Gets the mesh that is currently under the pointer
  34249. */
  34250. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34251. /**
  34252. * Gets or sets the current on-screen X position of the pointer
  34253. */
  34254. pointerX: number;
  34255. /**
  34256. * Gets or sets the current on-screen Y position of the pointer
  34257. */
  34258. pointerY: number;
  34259. /**
  34260. * Gets the cached material (ie. the latest rendered one)
  34261. * @returns the cached material
  34262. */
  34263. getCachedMaterial(): Nullable<Material>;
  34264. /**
  34265. * Gets the cached effect (ie. the latest rendered one)
  34266. * @returns the cached effect
  34267. */
  34268. getCachedEffect(): Nullable<Effect>;
  34269. /**
  34270. * Gets the cached visibility state (ie. the latest rendered one)
  34271. * @returns the cached visibility state
  34272. */
  34273. getCachedVisibility(): Nullable<number>;
  34274. /**
  34275. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34276. * @param material defines the current material
  34277. * @param effect defines the current effect
  34278. * @param visibility defines the current visibility state
  34279. * @returns true if one parameter is not cached
  34280. */
  34281. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34282. /**
  34283. * Gets the engine associated with the scene
  34284. * @returns an Engine
  34285. */
  34286. getEngine(): Engine;
  34287. /**
  34288. * Gets the total number of vertices rendered per frame
  34289. * @returns the total number of vertices rendered per frame
  34290. */
  34291. getTotalVertices(): number;
  34292. /**
  34293. * Gets the performance counter for total vertices
  34294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34295. */
  34296. readonly totalVerticesPerfCounter: PerfCounter;
  34297. /**
  34298. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34299. * @returns the total number of active indices rendered per frame
  34300. */
  34301. getActiveIndices(): number;
  34302. /**
  34303. * Gets the performance counter for active indices
  34304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34305. */
  34306. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34307. /**
  34308. * Gets the total number of active particles rendered per frame
  34309. * @returns the total number of active particles rendered per frame
  34310. */
  34311. getActiveParticles(): number;
  34312. /**
  34313. * Gets the performance counter for active particles
  34314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34315. */
  34316. readonly activeParticlesPerfCounter: PerfCounter;
  34317. /**
  34318. * Gets the total number of active bones rendered per frame
  34319. * @returns the total number of active bones rendered per frame
  34320. */
  34321. getActiveBones(): number;
  34322. /**
  34323. * Gets the performance counter for active bones
  34324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34325. */
  34326. readonly activeBonesPerfCounter: PerfCounter;
  34327. /**
  34328. * Gets the array of active meshes
  34329. * @returns an array of AbstractMesh
  34330. */
  34331. getActiveMeshes(): SmartArray<AbstractMesh>;
  34332. /**
  34333. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34334. * @returns a number
  34335. */
  34336. getAnimationRatio(): number;
  34337. /**
  34338. * Gets an unique Id for the current render phase
  34339. * @returns a number
  34340. */
  34341. getRenderId(): number;
  34342. /**
  34343. * Gets an unique Id for the current frame
  34344. * @returns a number
  34345. */
  34346. getFrameId(): number;
  34347. /** Call this function if you want to manually increment the render Id*/
  34348. incrementRenderId(): void;
  34349. private _createUbo;
  34350. /**
  34351. * Use this method to simulate a pointer move on a mesh
  34352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34355. * @returns the current scene
  34356. */
  34357. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34358. /**
  34359. * Use this method to simulate a pointer down on a mesh
  34360. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34361. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34362. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34363. * @returns the current scene
  34364. */
  34365. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34366. /**
  34367. * Use this method to simulate a pointer up on a mesh
  34368. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34369. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34370. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34371. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34372. * @returns the current scene
  34373. */
  34374. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34375. /**
  34376. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34377. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34378. * @returns true if the pointer was captured
  34379. */
  34380. isPointerCaptured(pointerId?: number): boolean;
  34381. /**
  34382. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34383. * @param attachUp defines if you want to attach events to pointerup
  34384. * @param attachDown defines if you want to attach events to pointerdown
  34385. * @param attachMove defines if you want to attach events to pointermove
  34386. */
  34387. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34388. /** Detaches all event handlers*/
  34389. detachControl(): void;
  34390. /**
  34391. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34392. * Delay loaded resources are not taking in account
  34393. * @return true if all required resources are ready
  34394. */
  34395. isReady(): boolean;
  34396. /** Resets all cached information relative to material (including effect and visibility) */
  34397. resetCachedMaterial(): void;
  34398. /**
  34399. * Registers a function to be called before every frame render
  34400. * @param func defines the function to register
  34401. */
  34402. registerBeforeRender(func: () => void): void;
  34403. /**
  34404. * Unregisters a function called before every frame render
  34405. * @param func defines the function to unregister
  34406. */
  34407. unregisterBeforeRender(func: () => void): void;
  34408. /**
  34409. * Registers a function to be called after every frame render
  34410. * @param func defines the function to register
  34411. */
  34412. registerAfterRender(func: () => void): void;
  34413. /**
  34414. * Unregisters a function called after every frame render
  34415. * @param func defines the function to unregister
  34416. */
  34417. unregisterAfterRender(func: () => void): void;
  34418. private _executeOnceBeforeRender;
  34419. /**
  34420. * The provided function will run before render once and will be disposed afterwards.
  34421. * A timeout delay can be provided so that the function will be executed in N ms.
  34422. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34423. * @param func The function to be executed.
  34424. * @param timeout optional delay in ms
  34425. */
  34426. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34427. /** @hidden */
  34428. _addPendingData(data: any): void;
  34429. /** @hidden */
  34430. _removePendingData(data: any): void;
  34431. /**
  34432. * Returns the number of items waiting to be loaded
  34433. * @returns the number of items waiting to be loaded
  34434. */
  34435. getWaitingItemsCount(): number;
  34436. /**
  34437. * Returns a boolean indicating if the scene is still loading data
  34438. */
  34439. readonly isLoading: boolean;
  34440. /**
  34441. * Registers a function to be executed when the scene is ready
  34442. * @param {Function} func - the function to be executed
  34443. */
  34444. executeWhenReady(func: () => void): void;
  34445. /**
  34446. * Returns a promise that resolves when the scene is ready
  34447. * @returns A promise that resolves when the scene is ready
  34448. */
  34449. whenReadyAsync(): Promise<void>;
  34450. /** @hidden */
  34451. _checkIsReady(): void;
  34452. /**
  34453. * Gets all animatable attached to the scene
  34454. */
  34455. readonly animatables: Animatable[];
  34456. /**
  34457. * Resets the last animation time frame.
  34458. * Useful to override when animations start running when loading a scene for the first time.
  34459. */
  34460. resetLastAnimationTimeFrame(): void;
  34461. /**
  34462. * Gets the current view matrix
  34463. * @returns a Matrix
  34464. */
  34465. getViewMatrix(): Matrix;
  34466. /**
  34467. * Gets the current projection matrix
  34468. * @returns a Matrix
  34469. */
  34470. getProjectionMatrix(): Matrix;
  34471. /**
  34472. * Gets the current transform matrix
  34473. * @returns a Matrix made of View * Projection
  34474. */
  34475. getTransformMatrix(): Matrix;
  34476. /**
  34477. * Sets the current transform matrix
  34478. * @param viewL defines the View matrix to use
  34479. * @param projectionL defines the Projection matrix to use
  34480. * @param viewR defines the right View matrix to use (if provided)
  34481. * @param projectionR defines the right Projection matrix to use (if provided)
  34482. */
  34483. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34484. /**
  34485. * Gets the uniform buffer used to store scene data
  34486. * @returns a UniformBuffer
  34487. */
  34488. getSceneUniformBuffer(): UniformBuffer;
  34489. /**
  34490. * Gets an unique (relatively to the current scene) Id
  34491. * @returns an unique number for the scene
  34492. */
  34493. getUniqueId(): number;
  34494. /**
  34495. * Add a mesh to the list of scene's meshes
  34496. * @param newMesh defines the mesh to add
  34497. * @param recursive if all child meshes should also be added to the scene
  34498. */
  34499. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34500. /**
  34501. * Remove a mesh for the list of scene's meshes
  34502. * @param toRemove defines the mesh to remove
  34503. * @param recursive if all child meshes should also be removed from the scene
  34504. * @returns the index where the mesh was in the mesh list
  34505. */
  34506. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34507. /**
  34508. * Add a transform node to the list of scene's transform nodes
  34509. * @param newTransformNode defines the transform node to add
  34510. */
  34511. addTransformNode(newTransformNode: TransformNode): void;
  34512. /**
  34513. * Remove a transform node for the list of scene's transform nodes
  34514. * @param toRemove defines the transform node to remove
  34515. * @returns the index where the transform node was in the transform node list
  34516. */
  34517. removeTransformNode(toRemove: TransformNode): number;
  34518. /**
  34519. * Remove a skeleton for the list of scene's skeletons
  34520. * @param toRemove defines the skeleton to remove
  34521. * @returns the index where the skeleton was in the skeleton list
  34522. */
  34523. removeSkeleton(toRemove: Skeleton): number;
  34524. /**
  34525. * Remove a morph target for the list of scene's morph targets
  34526. * @param toRemove defines the morph target to remove
  34527. * @returns the index where the morph target was in the morph target list
  34528. */
  34529. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34530. /**
  34531. * Remove a light for the list of scene's lights
  34532. * @param toRemove defines the light to remove
  34533. * @returns the index where the light was in the light list
  34534. */
  34535. removeLight(toRemove: Light): number;
  34536. /**
  34537. * Remove a camera for the list of scene's cameras
  34538. * @param toRemove defines the camera to remove
  34539. * @returns the index where the camera was in the camera list
  34540. */
  34541. removeCamera(toRemove: Camera): number;
  34542. /**
  34543. * Remove a particle system for the list of scene's particle systems
  34544. * @param toRemove defines the particle system to remove
  34545. * @returns the index where the particle system was in the particle system list
  34546. */
  34547. removeParticleSystem(toRemove: IParticleSystem): number;
  34548. /**
  34549. * Remove a animation for the list of scene's animations
  34550. * @param toRemove defines the animation to remove
  34551. * @returns the index where the animation was in the animation list
  34552. */
  34553. removeAnimation(toRemove: Animation): number;
  34554. /**
  34555. * Will stop the animation of the given target
  34556. * @param target - the target
  34557. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34558. * @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)
  34559. */
  34560. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34561. /**
  34562. * Removes the given animation group from this scene.
  34563. * @param toRemove The animation group to remove
  34564. * @returns The index of the removed animation group
  34565. */
  34566. removeAnimationGroup(toRemove: AnimationGroup): number;
  34567. /**
  34568. * Removes the given multi-material from this scene.
  34569. * @param toRemove The multi-material to remove
  34570. * @returns The index of the removed multi-material
  34571. */
  34572. removeMultiMaterial(toRemove: MultiMaterial): number;
  34573. /**
  34574. * Removes the given material from this scene.
  34575. * @param toRemove The material to remove
  34576. * @returns The index of the removed material
  34577. */
  34578. removeMaterial(toRemove: Material): number;
  34579. /**
  34580. * Removes the given action manager from this scene.
  34581. * @param toRemove The action manager to remove
  34582. * @returns The index of the removed action manager
  34583. */
  34584. removeActionManager(toRemove: AbstractActionManager): number;
  34585. /**
  34586. * Removes the given texture from this scene.
  34587. * @param toRemove The texture to remove
  34588. * @returns The index of the removed texture
  34589. */
  34590. removeTexture(toRemove: BaseTexture): number;
  34591. /**
  34592. * Adds the given light to this scene
  34593. * @param newLight The light to add
  34594. */
  34595. addLight(newLight: Light): void;
  34596. /**
  34597. * Sorts the list list based on light priorities
  34598. */
  34599. sortLightsByPriority(): void;
  34600. /**
  34601. * Adds the given camera to this scene
  34602. * @param newCamera The camera to add
  34603. */
  34604. addCamera(newCamera: Camera): void;
  34605. /**
  34606. * Adds the given skeleton to this scene
  34607. * @param newSkeleton The skeleton to add
  34608. */
  34609. addSkeleton(newSkeleton: Skeleton): void;
  34610. /**
  34611. * Adds the given particle system to this scene
  34612. * @param newParticleSystem The particle system to add
  34613. */
  34614. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34615. /**
  34616. * Adds the given animation to this scene
  34617. * @param newAnimation The animation to add
  34618. */
  34619. addAnimation(newAnimation: Animation): void;
  34620. /**
  34621. * Adds the given animation group to this scene.
  34622. * @param newAnimationGroup The animation group to add
  34623. */
  34624. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34625. /**
  34626. * Adds the given multi-material to this scene
  34627. * @param newMultiMaterial The multi-material to add
  34628. */
  34629. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34630. /**
  34631. * Adds the given material to this scene
  34632. * @param newMaterial The material to add
  34633. */
  34634. addMaterial(newMaterial: Material): void;
  34635. /**
  34636. * Adds the given morph target to this scene
  34637. * @param newMorphTargetManager The morph target to add
  34638. */
  34639. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34640. /**
  34641. * Adds the given geometry to this scene
  34642. * @param newGeometry The geometry to add
  34643. */
  34644. addGeometry(newGeometry: Geometry): void;
  34645. /**
  34646. * Adds the given action manager to this scene
  34647. * @param newActionManager The action manager to add
  34648. */
  34649. addActionManager(newActionManager: AbstractActionManager): void;
  34650. /**
  34651. * Adds the given texture to this scene.
  34652. * @param newTexture The texture to add
  34653. */
  34654. addTexture(newTexture: BaseTexture): void;
  34655. /**
  34656. * Switch active camera
  34657. * @param newCamera defines the new active camera
  34658. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34659. */
  34660. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34661. /**
  34662. * sets the active camera of the scene using its ID
  34663. * @param id defines the camera's ID
  34664. * @return the new active camera or null if none found.
  34665. */
  34666. setActiveCameraByID(id: string): Nullable<Camera>;
  34667. /**
  34668. * sets the active camera of the scene using its name
  34669. * @param name defines the camera's name
  34670. * @returns the new active camera or null if none found.
  34671. */
  34672. setActiveCameraByName(name: string): Nullable<Camera>;
  34673. /**
  34674. * get an animation group using its name
  34675. * @param name defines the material's name
  34676. * @return the animation group or null if none found.
  34677. */
  34678. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34679. /**
  34680. * Get a material using its unique id
  34681. * @param uniqueId defines the material's unique id
  34682. * @return the material or null if none found.
  34683. */
  34684. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34685. /**
  34686. * get a material using its id
  34687. * @param id defines the material's ID
  34688. * @return the material or null if none found.
  34689. */
  34690. getMaterialByID(id: string): Nullable<Material>;
  34691. /**
  34692. * Gets a the last added material using a given id
  34693. * @param id defines the material's ID
  34694. * @return the last material with the given id or null if none found.
  34695. */
  34696. getLastMaterialByID(id: string): Nullable<Material>;
  34697. /**
  34698. * Gets a material using its name
  34699. * @param name defines the material's name
  34700. * @return the material or null if none found.
  34701. */
  34702. getMaterialByName(name: string): Nullable<Material>;
  34703. /**
  34704. * Get a texture using its unique id
  34705. * @param uniqueId defines the texture's unique id
  34706. * @return the texture or null if none found.
  34707. */
  34708. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34709. /**
  34710. * Gets a camera using its id
  34711. * @param id defines the id to look for
  34712. * @returns the camera or null if not found
  34713. */
  34714. getCameraByID(id: string): Nullable<Camera>;
  34715. /**
  34716. * Gets a camera using its unique id
  34717. * @param uniqueId defines the unique id to look for
  34718. * @returns the camera or null if not found
  34719. */
  34720. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34721. /**
  34722. * Gets a camera using its name
  34723. * @param name defines the camera's name
  34724. * @return the camera or null if none found.
  34725. */
  34726. getCameraByName(name: string): Nullable<Camera>;
  34727. /**
  34728. * Gets a bone using its id
  34729. * @param id defines the bone's id
  34730. * @return the bone or null if not found
  34731. */
  34732. getBoneByID(id: string): Nullable<Bone>;
  34733. /**
  34734. * Gets a bone using its id
  34735. * @param name defines the bone's name
  34736. * @return the bone or null if not found
  34737. */
  34738. getBoneByName(name: string): Nullable<Bone>;
  34739. /**
  34740. * Gets a light node using its name
  34741. * @param name defines the the light's name
  34742. * @return the light or null if none found.
  34743. */
  34744. getLightByName(name: string): Nullable<Light>;
  34745. /**
  34746. * Gets a light node using its id
  34747. * @param id defines the light's id
  34748. * @return the light or null if none found.
  34749. */
  34750. getLightByID(id: string): Nullable<Light>;
  34751. /**
  34752. * Gets a light node using its scene-generated unique ID
  34753. * @param uniqueId defines the light's unique id
  34754. * @return the light or null if none found.
  34755. */
  34756. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34757. /**
  34758. * Gets a particle system by id
  34759. * @param id defines the particle system id
  34760. * @return the corresponding system or null if none found
  34761. */
  34762. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34763. /**
  34764. * Gets a geometry using its ID
  34765. * @param id defines the geometry's id
  34766. * @return the geometry or null if none found.
  34767. */
  34768. getGeometryByID(id: string): Nullable<Geometry>;
  34769. private _getGeometryByUniqueID;
  34770. /**
  34771. * Add a new geometry to this scene
  34772. * @param geometry defines the geometry to be added to the scene.
  34773. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34774. * @return a boolean defining if the geometry was added or not
  34775. */
  34776. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34777. /**
  34778. * Removes an existing geometry
  34779. * @param geometry defines the geometry to be removed from the scene
  34780. * @return a boolean defining if the geometry was removed or not
  34781. */
  34782. removeGeometry(geometry: Geometry): boolean;
  34783. /**
  34784. * Gets the list of geometries attached to the scene
  34785. * @returns an array of Geometry
  34786. */
  34787. getGeometries(): Geometry[];
  34788. /**
  34789. * Gets the first added mesh found of a given ID
  34790. * @param id defines the id to search for
  34791. * @return the mesh found or null if not found at all
  34792. */
  34793. getMeshByID(id: string): Nullable<AbstractMesh>;
  34794. /**
  34795. * Gets a list of meshes using their id
  34796. * @param id defines the id to search for
  34797. * @returns a list of meshes
  34798. */
  34799. getMeshesByID(id: string): Array<AbstractMesh>;
  34800. /**
  34801. * Gets the first added transform node found of a given ID
  34802. * @param id defines the id to search for
  34803. * @return the found transform node or null if not found at all.
  34804. */
  34805. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34806. /**
  34807. * Gets a transform node with its auto-generated unique id
  34808. * @param uniqueId efines the unique id to search for
  34809. * @return the found transform node or null if not found at all.
  34810. */
  34811. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34812. /**
  34813. * Gets a list of transform nodes using their id
  34814. * @param id defines the id to search for
  34815. * @returns a list of transform nodes
  34816. */
  34817. getTransformNodesByID(id: string): Array<TransformNode>;
  34818. /**
  34819. * Gets a mesh with its auto-generated unique id
  34820. * @param uniqueId defines the unique id to search for
  34821. * @return the found mesh or null if not found at all.
  34822. */
  34823. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34824. /**
  34825. * Gets a the last added mesh using a given id
  34826. * @param id defines the id to search for
  34827. * @return the found mesh or null if not found at all.
  34828. */
  34829. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34830. /**
  34831. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34832. * @param id defines the id to search for
  34833. * @return the found node or null if not found at all
  34834. */
  34835. getLastEntryByID(id: string): Nullable<Node>;
  34836. /**
  34837. * Gets a node (Mesh, Camera, Light) using a given id
  34838. * @param id defines the id to search for
  34839. * @return the found node or null if not found at all
  34840. */
  34841. getNodeByID(id: string): Nullable<Node>;
  34842. /**
  34843. * Gets a node (Mesh, Camera, Light) using a given name
  34844. * @param name defines the name to search for
  34845. * @return the found node or null if not found at all.
  34846. */
  34847. getNodeByName(name: string): Nullable<Node>;
  34848. /**
  34849. * Gets a mesh using a given name
  34850. * @param name defines the name to search for
  34851. * @return the found mesh or null if not found at all.
  34852. */
  34853. getMeshByName(name: string): Nullable<AbstractMesh>;
  34854. /**
  34855. * Gets a transform node using a given name
  34856. * @param name defines the name to search for
  34857. * @return the found transform node or null if not found at all.
  34858. */
  34859. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34860. /**
  34861. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34862. * @param id defines the id to search for
  34863. * @return the found skeleton or null if not found at all.
  34864. */
  34865. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34866. /**
  34867. * Gets a skeleton using a given auto generated unique id
  34868. * @param uniqueId defines the unique id to search for
  34869. * @return the found skeleton or null if not found at all.
  34870. */
  34871. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34872. /**
  34873. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34874. * @param id defines the id to search for
  34875. * @return the found skeleton or null if not found at all.
  34876. */
  34877. getSkeletonById(id: string): Nullable<Skeleton>;
  34878. /**
  34879. * Gets a skeleton using a given name
  34880. * @param name defines the name to search for
  34881. * @return the found skeleton or null if not found at all.
  34882. */
  34883. getSkeletonByName(name: string): Nullable<Skeleton>;
  34884. /**
  34885. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34886. * @param id defines the id to search for
  34887. * @return the found morph target manager or null if not found at all.
  34888. */
  34889. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34890. /**
  34891. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34892. * @param id defines the id to search for
  34893. * @return the found morph target or null if not found at all.
  34894. */
  34895. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34896. /**
  34897. * Gets a boolean indicating if the given mesh is active
  34898. * @param mesh defines the mesh to look for
  34899. * @returns true if the mesh is in the active list
  34900. */
  34901. isActiveMesh(mesh: AbstractMesh): boolean;
  34902. /**
  34903. * Return a unique id as a string which can serve as an identifier for the scene
  34904. */
  34905. readonly uid: string;
  34906. /**
  34907. * Add an externaly attached data from its key.
  34908. * This method call will fail and return false, if such key already exists.
  34909. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34910. * @param key the unique key that identifies the data
  34911. * @param data the data object to associate to the key for this Engine instance
  34912. * @return true if no such key were already present and the data was added successfully, false otherwise
  34913. */
  34914. addExternalData<T>(key: string, data: T): boolean;
  34915. /**
  34916. * Get an externaly attached data from its key
  34917. * @param key the unique key that identifies the data
  34918. * @return the associated data, if present (can be null), or undefined if not present
  34919. */
  34920. getExternalData<T>(key: string): Nullable<T>;
  34921. /**
  34922. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34923. * @param key the unique key that identifies the data
  34924. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34925. * @return the associated data, can be null if the factory returned null.
  34926. */
  34927. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34928. /**
  34929. * Remove an externaly attached data from the Engine instance
  34930. * @param key the unique key that identifies the data
  34931. * @return true if the data was successfully removed, false if it doesn't exist
  34932. */
  34933. removeExternalData(key: string): boolean;
  34934. private _evaluateSubMesh;
  34935. /**
  34936. * Clear the processed materials smart array preventing retention point in material dispose.
  34937. */
  34938. freeProcessedMaterials(): void;
  34939. private _preventFreeActiveMeshesAndRenderingGroups;
  34940. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34941. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34942. * when disposing several meshes in a row or a hierarchy of meshes.
  34943. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34944. */
  34945. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34946. /**
  34947. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34948. */
  34949. freeActiveMeshes(): void;
  34950. /**
  34951. * Clear the info related to rendering groups preventing retention points during dispose.
  34952. */
  34953. freeRenderingGroups(): void;
  34954. /** @hidden */
  34955. _isInIntermediateRendering(): boolean;
  34956. /**
  34957. * Lambda returning the list of potentially active meshes.
  34958. */
  34959. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34960. /**
  34961. * Lambda returning the list of potentially active sub meshes.
  34962. */
  34963. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34964. /**
  34965. * Lambda returning the list of potentially intersecting sub meshes.
  34966. */
  34967. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34968. /**
  34969. * Lambda returning the list of potentially colliding sub meshes.
  34970. */
  34971. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34972. private _activeMeshesFrozen;
  34973. private _skipEvaluateActiveMeshesCompletely;
  34974. /**
  34975. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34976. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  34977. * @returns the current scene
  34978. */
  34979. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  34980. /**
  34981. * Use this function to restart evaluating active meshes on every frame
  34982. * @returns the current scene
  34983. */
  34984. unfreezeActiveMeshes(): Scene;
  34985. private _evaluateActiveMeshes;
  34986. private _activeMesh;
  34987. /**
  34988. * Update the transform matrix to update from the current active camera
  34989. * @param force defines a boolean used to force the update even if cache is up to date
  34990. */
  34991. updateTransformMatrix(force?: boolean): void;
  34992. private _bindFrameBuffer;
  34993. /** @hidden */
  34994. _allowPostProcessClearColor: boolean;
  34995. /** @hidden */
  34996. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34997. private _processSubCameras;
  34998. private _checkIntersections;
  34999. /** @hidden */
  35000. _advancePhysicsEngineStep(step: number): void;
  35001. /**
  35002. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35003. */
  35004. getDeterministicFrameTime: () => number;
  35005. /** @hidden */
  35006. _animate(): void;
  35007. /** Execute all animations (for a frame) */
  35008. animate(): void;
  35009. /**
  35010. * Render the scene
  35011. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35012. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35013. */
  35014. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35015. /**
  35016. * Freeze all materials
  35017. * A frozen material will not be updatable but should be faster to render
  35018. */
  35019. freezeMaterials(): void;
  35020. /**
  35021. * Unfreeze all materials
  35022. * A frozen material will not be updatable but should be faster to render
  35023. */
  35024. unfreezeMaterials(): void;
  35025. /**
  35026. * Releases all held ressources
  35027. */
  35028. dispose(): void;
  35029. /**
  35030. * Gets if the scene is already disposed
  35031. */
  35032. readonly isDisposed: boolean;
  35033. /**
  35034. * Call this function to reduce memory footprint of the scene.
  35035. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35036. */
  35037. clearCachedVertexData(): void;
  35038. /**
  35039. * This function will remove the local cached buffer data from texture.
  35040. * It will save memory but will prevent the texture from being rebuilt
  35041. */
  35042. cleanCachedTextureBuffer(): void;
  35043. /**
  35044. * Get the world extend vectors with an optional filter
  35045. *
  35046. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35047. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35048. */
  35049. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35050. min: Vector3;
  35051. max: Vector3;
  35052. };
  35053. /**
  35054. * Creates a ray that can be used to pick in the scene
  35055. * @param x defines the x coordinate of the origin (on-screen)
  35056. * @param y defines the y coordinate of the origin (on-screen)
  35057. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35058. * @param camera defines the camera to use for the picking
  35059. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35060. * @returns a Ray
  35061. */
  35062. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35063. /**
  35064. * Creates a ray that can be used to pick in the scene
  35065. * @param x defines the x coordinate of the origin (on-screen)
  35066. * @param y defines the y coordinate of the origin (on-screen)
  35067. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35068. * @param result defines the ray where to store the picking ray
  35069. * @param camera defines the camera to use for the picking
  35070. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35071. * @returns the current scene
  35072. */
  35073. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35074. /**
  35075. * Creates a ray that can be used to pick in the scene
  35076. * @param x defines the x coordinate of the origin (on-screen)
  35077. * @param y defines the y coordinate of the origin (on-screen)
  35078. * @param camera defines the camera to use for the picking
  35079. * @returns a Ray
  35080. */
  35081. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35082. /**
  35083. * Creates a ray that can be used to pick in the scene
  35084. * @param x defines the x coordinate of the origin (on-screen)
  35085. * @param y defines the y coordinate of the origin (on-screen)
  35086. * @param result defines the ray where to store the picking ray
  35087. * @param camera defines the camera to use for the picking
  35088. * @returns the current scene
  35089. */
  35090. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35091. /** Launch a ray to try to pick a mesh in the scene
  35092. * @param x position on screen
  35093. * @param y position on screen
  35094. * @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
  35095. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35096. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35098. * @returns a PickingInfo
  35099. */
  35100. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35101. /** Use the given ray to pick a mesh in the scene
  35102. * @param ray The ray to use to pick meshes
  35103. * @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
  35104. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35106. * @returns a PickingInfo
  35107. */
  35108. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35109. /**
  35110. * Launch a ray to try to pick a mesh in the scene
  35111. * @param x X position on screen
  35112. * @param y Y position on screen
  35113. * @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
  35114. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35115. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35116. * @returns an array of PickingInfo
  35117. */
  35118. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35119. /**
  35120. * Launch a ray to try to pick a mesh in the scene
  35121. * @param ray Ray to use
  35122. * @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
  35123. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35124. * @returns an array of PickingInfo
  35125. */
  35126. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35127. /**
  35128. * Force the value of meshUnderPointer
  35129. * @param mesh defines the mesh to use
  35130. */
  35131. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35132. /**
  35133. * Gets the mesh under the pointer
  35134. * @returns a Mesh or null if no mesh is under the pointer
  35135. */
  35136. getPointerOverMesh(): Nullable<AbstractMesh>;
  35137. /** @hidden */
  35138. _rebuildGeometries(): void;
  35139. /** @hidden */
  35140. _rebuildTextures(): void;
  35141. private _getByTags;
  35142. /**
  35143. * Get a list of meshes by tags
  35144. * @param tagsQuery defines the tags query to use
  35145. * @param forEach defines a predicate used to filter results
  35146. * @returns an array of Mesh
  35147. */
  35148. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35149. /**
  35150. * Get a list of cameras by tags
  35151. * @param tagsQuery defines the tags query to use
  35152. * @param forEach defines a predicate used to filter results
  35153. * @returns an array of Camera
  35154. */
  35155. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35156. /**
  35157. * Get a list of lights by tags
  35158. * @param tagsQuery defines the tags query to use
  35159. * @param forEach defines a predicate used to filter results
  35160. * @returns an array of Light
  35161. */
  35162. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35163. /**
  35164. * Get a list of materials by tags
  35165. * @param tagsQuery defines the tags query to use
  35166. * @param forEach defines a predicate used to filter results
  35167. * @returns an array of Material
  35168. */
  35169. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35170. /**
  35171. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35172. * This allowed control for front to back rendering or reversly depending of the special needs.
  35173. *
  35174. * @param renderingGroupId The rendering group id corresponding to its index
  35175. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35176. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35177. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35178. */
  35179. 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;
  35180. /**
  35181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35182. *
  35183. * @param renderingGroupId The rendering group id corresponding to its index
  35184. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35185. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35186. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35187. */
  35188. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35189. /**
  35190. * Gets the current auto clear configuration for one rendering group of the rendering
  35191. * manager.
  35192. * @param index the rendering group index to get the information for
  35193. * @returns The auto clear setup for the requested rendering group
  35194. */
  35195. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35196. private _blockMaterialDirtyMechanism;
  35197. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35198. blockMaterialDirtyMechanism: boolean;
  35199. /**
  35200. * Will flag all materials as dirty to trigger new shader compilation
  35201. * @param flag defines the flag used to specify which material part must be marked as dirty
  35202. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35203. */
  35204. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35205. /** @hidden */
  35206. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35207. /** @hidden */
  35208. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35209. /** @hidden */
  35210. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35211. /** @hidden */
  35212. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35213. /** @hidden */
  35214. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35215. /** @hidden */
  35216. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35217. }
  35218. }
  35219. declare module BABYLON {
  35220. /**
  35221. * Set of assets to keep when moving a scene into an asset container.
  35222. */
  35223. export class KeepAssets extends AbstractScene {
  35224. }
  35225. /**
  35226. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35227. */
  35228. export class InstantiatedEntries {
  35229. /**
  35230. * List of new root nodes (eg. nodes with no parent)
  35231. */
  35232. rootNodes: TransformNode[];
  35233. /**
  35234. * List of new skeletons
  35235. */
  35236. skeletons: Skeleton[];
  35237. /**
  35238. * List of new animation groups
  35239. */
  35240. animationGroups: AnimationGroup[];
  35241. }
  35242. /**
  35243. * Container with a set of assets that can be added or removed from a scene.
  35244. */
  35245. export class AssetContainer extends AbstractScene {
  35246. /**
  35247. * The scene the AssetContainer belongs to.
  35248. */
  35249. scene: Scene;
  35250. /**
  35251. * Instantiates an AssetContainer.
  35252. * @param scene The scene the AssetContainer belongs to.
  35253. */
  35254. constructor(scene: Scene);
  35255. /**
  35256. * Instantiate or clone all meshes and add the new ones to the scene.
  35257. * Skeletons and animation groups will all be cloned
  35258. * @param nameFunction defines an optional function used to get new names for clones
  35259. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35260. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35261. */
  35262. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35263. /**
  35264. * Adds all the assets from the container to the scene.
  35265. */
  35266. addAllToScene(): void;
  35267. /**
  35268. * Removes all the assets in the container from the scene
  35269. */
  35270. removeAllFromScene(): void;
  35271. /**
  35272. * Disposes all the assets in the container
  35273. */
  35274. dispose(): void;
  35275. private _moveAssets;
  35276. /**
  35277. * Removes all the assets contained in the scene and adds them to the container.
  35278. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35279. */
  35280. moveAllFromScene(keepAssets?: KeepAssets): void;
  35281. /**
  35282. * 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.
  35283. * @returns the root mesh
  35284. */
  35285. createRootMesh(): Mesh;
  35286. }
  35287. }
  35288. declare module BABYLON {
  35289. /**
  35290. * Defines how the parser contract is defined.
  35291. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35292. */
  35293. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35294. /**
  35295. * Defines how the individual parser contract is defined.
  35296. * These parser can parse an individual asset
  35297. */
  35298. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35299. /**
  35300. * Base class of the scene acting as a container for the different elements composing a scene.
  35301. * This class is dynamically extended by the different components of the scene increasing
  35302. * flexibility and reducing coupling
  35303. */
  35304. export abstract class AbstractScene {
  35305. /**
  35306. * Stores the list of available parsers in the application.
  35307. */
  35308. private static _BabylonFileParsers;
  35309. /**
  35310. * Stores the list of available individual parsers in the application.
  35311. */
  35312. private static _IndividualBabylonFileParsers;
  35313. /**
  35314. * Adds a parser in the list of available ones
  35315. * @param name Defines the name of the parser
  35316. * @param parser Defines the parser to add
  35317. */
  35318. static AddParser(name: string, parser: BabylonFileParser): void;
  35319. /**
  35320. * Gets a general parser from the list of avaialble ones
  35321. * @param name Defines the name of the parser
  35322. * @returns the requested parser or null
  35323. */
  35324. static GetParser(name: string): Nullable<BabylonFileParser>;
  35325. /**
  35326. * Adds n individual parser in the list of available ones
  35327. * @param name Defines the name of the parser
  35328. * @param parser Defines the parser to add
  35329. */
  35330. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35331. /**
  35332. * Gets an individual parser from the list of avaialble ones
  35333. * @param name Defines the name of the parser
  35334. * @returns the requested parser or null
  35335. */
  35336. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35337. /**
  35338. * Parser json data and populate both a scene and its associated container object
  35339. * @param jsonData Defines the data to parse
  35340. * @param scene Defines the scene to parse the data for
  35341. * @param container Defines the container attached to the parsing sequence
  35342. * @param rootUrl Defines the root url of the data
  35343. */
  35344. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35345. /**
  35346. * Gets the list of root nodes (ie. nodes with no parent)
  35347. */
  35348. rootNodes: Node[];
  35349. /** All of the cameras added to this scene
  35350. * @see http://doc.babylonjs.com/babylon101/cameras
  35351. */
  35352. cameras: Camera[];
  35353. /**
  35354. * All of the lights added to this scene
  35355. * @see http://doc.babylonjs.com/babylon101/lights
  35356. */
  35357. lights: Light[];
  35358. /**
  35359. * All of the (abstract) meshes added to this scene
  35360. */
  35361. meshes: AbstractMesh[];
  35362. /**
  35363. * The list of skeletons added to the scene
  35364. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35365. */
  35366. skeletons: Skeleton[];
  35367. /**
  35368. * All of the particle systems added to this scene
  35369. * @see http://doc.babylonjs.com/babylon101/particles
  35370. */
  35371. particleSystems: IParticleSystem[];
  35372. /**
  35373. * Gets a list of Animations associated with the scene
  35374. */
  35375. animations: Animation[];
  35376. /**
  35377. * All of the animation groups added to this scene
  35378. * @see http://doc.babylonjs.com/how_to/group
  35379. */
  35380. animationGroups: AnimationGroup[];
  35381. /**
  35382. * All of the multi-materials added to this scene
  35383. * @see http://doc.babylonjs.com/how_to/multi_materials
  35384. */
  35385. multiMaterials: MultiMaterial[];
  35386. /**
  35387. * All of the materials added to this scene
  35388. * In the context of a Scene, it is not supposed to be modified manually.
  35389. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35390. * Note also that the order of the Material within the array is not significant and might change.
  35391. * @see http://doc.babylonjs.com/babylon101/materials
  35392. */
  35393. materials: Material[];
  35394. /**
  35395. * The list of morph target managers added to the scene
  35396. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35397. */
  35398. morphTargetManagers: MorphTargetManager[];
  35399. /**
  35400. * The list of geometries used in the scene.
  35401. */
  35402. geometries: Geometry[];
  35403. /**
  35404. * All of the tranform nodes added to this scene
  35405. * In the context of a Scene, it is not supposed to be modified manually.
  35406. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35407. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35408. * @see http://doc.babylonjs.com/how_to/transformnode
  35409. */
  35410. transformNodes: TransformNode[];
  35411. /**
  35412. * ActionManagers available on the scene.
  35413. */
  35414. actionManagers: AbstractActionManager[];
  35415. /**
  35416. * Textures to keep.
  35417. */
  35418. textures: BaseTexture[];
  35419. /**
  35420. * Environment texture for the scene
  35421. */
  35422. environmentTexture: Nullable<BaseTexture>;
  35423. }
  35424. }
  35425. declare module BABYLON {
  35426. /**
  35427. * Interface used to define options for Sound class
  35428. */
  35429. export interface ISoundOptions {
  35430. /**
  35431. * Does the sound autoplay once loaded.
  35432. */
  35433. autoplay?: boolean;
  35434. /**
  35435. * Does the sound loop after it finishes playing once.
  35436. */
  35437. loop?: boolean;
  35438. /**
  35439. * Sound's volume
  35440. */
  35441. volume?: number;
  35442. /**
  35443. * Is it a spatial sound?
  35444. */
  35445. spatialSound?: boolean;
  35446. /**
  35447. * Maximum distance to hear that sound
  35448. */
  35449. maxDistance?: number;
  35450. /**
  35451. * Uses user defined attenuation function
  35452. */
  35453. useCustomAttenuation?: boolean;
  35454. /**
  35455. * Define the roll off factor of spatial sounds.
  35456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35457. */
  35458. rolloffFactor?: number;
  35459. /**
  35460. * Define the reference distance the sound should be heard perfectly.
  35461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35462. */
  35463. refDistance?: number;
  35464. /**
  35465. * Define the distance attenuation model the sound will follow.
  35466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35467. */
  35468. distanceModel?: string;
  35469. /**
  35470. * Defines the playback speed (1 by default)
  35471. */
  35472. playbackRate?: number;
  35473. /**
  35474. * Defines if the sound is from a streaming source
  35475. */
  35476. streaming?: boolean;
  35477. /**
  35478. * Defines an optional length (in seconds) inside the sound file
  35479. */
  35480. length?: number;
  35481. /**
  35482. * Defines an optional offset (in seconds) inside the sound file
  35483. */
  35484. offset?: number;
  35485. /**
  35486. * If true, URLs will not be required to state the audio file codec to use.
  35487. */
  35488. skipCodecCheck?: boolean;
  35489. }
  35490. /**
  35491. * Defines a sound that can be played in the application.
  35492. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35494. */
  35495. export class Sound {
  35496. /**
  35497. * The name of the sound in the scene.
  35498. */
  35499. name: string;
  35500. /**
  35501. * Does the sound autoplay once loaded.
  35502. */
  35503. autoplay: boolean;
  35504. /**
  35505. * Does the sound loop after it finishes playing once.
  35506. */
  35507. loop: boolean;
  35508. /**
  35509. * Does the sound use a custom attenuation curve to simulate the falloff
  35510. * happening when the source gets further away from the camera.
  35511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35512. */
  35513. useCustomAttenuation: boolean;
  35514. /**
  35515. * The sound track id this sound belongs to.
  35516. */
  35517. soundTrackId: number;
  35518. /**
  35519. * Is this sound currently played.
  35520. */
  35521. isPlaying: boolean;
  35522. /**
  35523. * Is this sound currently paused.
  35524. */
  35525. isPaused: boolean;
  35526. /**
  35527. * Does this sound enables spatial sound.
  35528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35529. */
  35530. spatialSound: boolean;
  35531. /**
  35532. * Define the reference distance the sound should be heard perfectly.
  35533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35534. */
  35535. refDistance: number;
  35536. /**
  35537. * Define the roll off factor of spatial sounds.
  35538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35539. */
  35540. rolloffFactor: number;
  35541. /**
  35542. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35544. */
  35545. maxDistance: number;
  35546. /**
  35547. * Define the distance attenuation model the sound will follow.
  35548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35549. */
  35550. distanceModel: string;
  35551. /**
  35552. * @hidden
  35553. * Back Compat
  35554. **/
  35555. onended: () => any;
  35556. /**
  35557. * Observable event when the current playing sound finishes.
  35558. */
  35559. onEndedObservable: Observable<Sound>;
  35560. private _panningModel;
  35561. private _playbackRate;
  35562. private _streaming;
  35563. private _startTime;
  35564. private _startOffset;
  35565. private _position;
  35566. /** @hidden */
  35567. _positionInEmitterSpace: boolean;
  35568. private _localDirection;
  35569. private _volume;
  35570. private _isReadyToPlay;
  35571. private _isDirectional;
  35572. private _readyToPlayCallback;
  35573. private _audioBuffer;
  35574. private _soundSource;
  35575. private _streamingSource;
  35576. private _soundPanner;
  35577. private _soundGain;
  35578. private _inputAudioNode;
  35579. private _outputAudioNode;
  35580. private _coneInnerAngle;
  35581. private _coneOuterAngle;
  35582. private _coneOuterGain;
  35583. private _scene;
  35584. private _connectedTransformNode;
  35585. private _customAttenuationFunction;
  35586. private _registerFunc;
  35587. private _isOutputConnected;
  35588. private _htmlAudioElement;
  35589. private _urlType;
  35590. private _length?;
  35591. private _offset?;
  35592. /** @hidden */
  35593. static _SceneComponentInitialization: (scene: Scene) => void;
  35594. /**
  35595. * Create a sound and attach it to a scene
  35596. * @param name Name of your sound
  35597. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35598. * @param scene defines the scene the sound belongs to
  35599. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35600. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35601. */
  35602. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35603. /**
  35604. * Release the sound and its associated resources
  35605. */
  35606. dispose(): void;
  35607. /**
  35608. * Gets if the sounds is ready to be played or not.
  35609. * @returns true if ready, otherwise false
  35610. */
  35611. isReady(): boolean;
  35612. private _soundLoaded;
  35613. /**
  35614. * Sets the data of the sound from an audiobuffer
  35615. * @param audioBuffer The audioBuffer containing the data
  35616. */
  35617. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35618. /**
  35619. * Updates the current sounds options such as maxdistance, loop...
  35620. * @param options A JSON object containing values named as the object properties
  35621. */
  35622. updateOptions(options: ISoundOptions): void;
  35623. private _createSpatialParameters;
  35624. private _updateSpatialParameters;
  35625. /**
  35626. * Switch the panning model to HRTF:
  35627. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35629. */
  35630. switchPanningModelToHRTF(): void;
  35631. /**
  35632. * Switch the panning model to Equal Power:
  35633. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35635. */
  35636. switchPanningModelToEqualPower(): void;
  35637. private _switchPanningModel;
  35638. /**
  35639. * Connect this sound to a sound track audio node like gain...
  35640. * @param soundTrackAudioNode the sound track audio node to connect to
  35641. */
  35642. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35643. /**
  35644. * Transform this sound into a directional source
  35645. * @param coneInnerAngle Size of the inner cone in degree
  35646. * @param coneOuterAngle Size of the outer cone in degree
  35647. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35648. */
  35649. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35650. /**
  35651. * Gets or sets the inner angle for the directional cone.
  35652. */
  35653. /**
  35654. * Gets or sets the inner angle for the directional cone.
  35655. */
  35656. directionalConeInnerAngle: number;
  35657. /**
  35658. * Gets or sets the outer angle for the directional cone.
  35659. */
  35660. /**
  35661. * Gets or sets the outer angle for the directional cone.
  35662. */
  35663. directionalConeOuterAngle: number;
  35664. /**
  35665. * Sets the position of the emitter if spatial sound is enabled
  35666. * @param newPosition Defines the new posisiton
  35667. */
  35668. setPosition(newPosition: Vector3): void;
  35669. /**
  35670. * Sets the local direction of the emitter if spatial sound is enabled
  35671. * @param newLocalDirection Defines the new local direction
  35672. */
  35673. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35674. private _updateDirection;
  35675. /** @hidden */
  35676. updateDistanceFromListener(): void;
  35677. /**
  35678. * Sets a new custom attenuation function for the sound.
  35679. * @param callback Defines the function used for the attenuation
  35680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35681. */
  35682. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35683. /**
  35684. * Play the sound
  35685. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35686. * @param offset (optional) Start the sound at a specific time in seconds
  35687. * @param length (optional) Sound duration (in seconds)
  35688. */
  35689. play(time?: number, offset?: number, length?: number): void;
  35690. private _onended;
  35691. /**
  35692. * Stop the sound
  35693. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35694. */
  35695. stop(time?: number): void;
  35696. /**
  35697. * Put the sound in pause
  35698. */
  35699. pause(): void;
  35700. /**
  35701. * Sets a dedicated volume for this sounds
  35702. * @param newVolume Define the new volume of the sound
  35703. * @param time Define time for gradual change to new volume
  35704. */
  35705. setVolume(newVolume: number, time?: number): void;
  35706. /**
  35707. * Set the sound play back rate
  35708. * @param newPlaybackRate Define the playback rate the sound should be played at
  35709. */
  35710. setPlaybackRate(newPlaybackRate: number): void;
  35711. /**
  35712. * Gets the volume of the sound.
  35713. * @returns the volume of the sound
  35714. */
  35715. getVolume(): number;
  35716. /**
  35717. * Attach the sound to a dedicated mesh
  35718. * @param transformNode The transform node to connect the sound with
  35719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35720. */
  35721. attachToMesh(transformNode: TransformNode): void;
  35722. /**
  35723. * Detach the sound from the previously attached mesh
  35724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35725. */
  35726. detachFromMesh(): void;
  35727. private _onRegisterAfterWorldMatrixUpdate;
  35728. /**
  35729. * Clone the current sound in the scene.
  35730. * @returns the new sound clone
  35731. */
  35732. clone(): Nullable<Sound>;
  35733. /**
  35734. * Gets the current underlying audio buffer containing the data
  35735. * @returns the audio buffer
  35736. */
  35737. getAudioBuffer(): Nullable<AudioBuffer>;
  35738. /**
  35739. * Serializes the Sound in a JSON representation
  35740. * @returns the JSON representation of the sound
  35741. */
  35742. serialize(): any;
  35743. /**
  35744. * Parse a JSON representation of a sound to innstantiate in a given scene
  35745. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35746. * @param scene Define the scene the new parsed sound should be created in
  35747. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35748. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35749. * @returns the newly parsed sound
  35750. */
  35751. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35752. }
  35753. }
  35754. declare module BABYLON {
  35755. /**
  35756. * This defines an action helpful to play a defined sound on a triggered action.
  35757. */
  35758. export class PlaySoundAction extends Action {
  35759. private _sound;
  35760. /**
  35761. * Instantiate the action
  35762. * @param triggerOptions defines the trigger options
  35763. * @param sound defines the sound to play
  35764. * @param condition defines the trigger related conditions
  35765. */
  35766. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35767. /** @hidden */
  35768. _prepare(): void;
  35769. /**
  35770. * Execute the action and play the sound.
  35771. */
  35772. execute(): void;
  35773. /**
  35774. * Serializes the actions and its related information.
  35775. * @param parent defines the object to serialize in
  35776. * @returns the serialized object
  35777. */
  35778. serialize(parent: any): any;
  35779. }
  35780. /**
  35781. * This defines an action helpful to stop a defined sound on a triggered action.
  35782. */
  35783. export class StopSoundAction extends Action {
  35784. private _sound;
  35785. /**
  35786. * Instantiate the action
  35787. * @param triggerOptions defines the trigger options
  35788. * @param sound defines the sound to stop
  35789. * @param condition defines the trigger related conditions
  35790. */
  35791. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35792. /** @hidden */
  35793. _prepare(): void;
  35794. /**
  35795. * Execute the action and stop the sound.
  35796. */
  35797. execute(): void;
  35798. /**
  35799. * Serializes the actions and its related information.
  35800. * @param parent defines the object to serialize in
  35801. * @returns the serialized object
  35802. */
  35803. serialize(parent: any): any;
  35804. }
  35805. }
  35806. declare module BABYLON {
  35807. /**
  35808. * This defines an action responsible to change the value of a property
  35809. * by interpolating between its current value and the newly set one once triggered.
  35810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35811. */
  35812. export class InterpolateValueAction extends Action {
  35813. /**
  35814. * Defines the path of the property where the value should be interpolated
  35815. */
  35816. propertyPath: string;
  35817. /**
  35818. * Defines the target value at the end of the interpolation.
  35819. */
  35820. value: any;
  35821. /**
  35822. * Defines the time it will take for the property to interpolate to the value.
  35823. */
  35824. duration: number;
  35825. /**
  35826. * Defines if the other scene animations should be stopped when the action has been triggered
  35827. */
  35828. stopOtherAnimations?: boolean;
  35829. /**
  35830. * Defines a callback raised once the interpolation animation has been done.
  35831. */
  35832. onInterpolationDone?: () => void;
  35833. /**
  35834. * Observable triggered once the interpolation animation has been done.
  35835. */
  35836. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35837. private _target;
  35838. private _effectiveTarget;
  35839. private _property;
  35840. /**
  35841. * Instantiate the action
  35842. * @param triggerOptions defines the trigger options
  35843. * @param target defines the object containing the value to interpolate
  35844. * @param propertyPath defines the path to the property in the target object
  35845. * @param value defines the target value at the end of the interpolation
  35846. * @param duration deines the time it will take for the property to interpolate to the value.
  35847. * @param condition defines the trigger related conditions
  35848. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35849. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35850. */
  35851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35852. /** @hidden */
  35853. _prepare(): void;
  35854. /**
  35855. * Execute the action starts the value interpolation.
  35856. */
  35857. execute(): void;
  35858. /**
  35859. * Serializes the actions and its related information.
  35860. * @param parent defines the object to serialize in
  35861. * @returns the serialized object
  35862. */
  35863. serialize(parent: any): any;
  35864. }
  35865. }
  35866. declare module BABYLON {
  35867. /**
  35868. * Options allowed during the creation of a sound track.
  35869. */
  35870. export interface ISoundTrackOptions {
  35871. /**
  35872. * The volume the sound track should take during creation
  35873. */
  35874. volume?: number;
  35875. /**
  35876. * Define if the sound track is the main sound track of the scene
  35877. */
  35878. mainTrack?: boolean;
  35879. }
  35880. /**
  35881. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35882. * It will be also used in a future release to apply effects on a specific track.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35884. */
  35885. export class SoundTrack {
  35886. /**
  35887. * The unique identifier of the sound track in the scene.
  35888. */
  35889. id: number;
  35890. /**
  35891. * The list of sounds included in the sound track.
  35892. */
  35893. soundCollection: Array<Sound>;
  35894. private _outputAudioNode;
  35895. private _scene;
  35896. private _connectedAnalyser;
  35897. private _options;
  35898. private _isInitialized;
  35899. /**
  35900. * Creates a new sound track.
  35901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35902. * @param scene Define the scene the sound track belongs to
  35903. * @param options
  35904. */
  35905. constructor(scene: Scene, options?: ISoundTrackOptions);
  35906. private _initializeSoundTrackAudioGraph;
  35907. /**
  35908. * Release the sound track and its associated resources
  35909. */
  35910. dispose(): void;
  35911. /**
  35912. * Adds a sound to this sound track
  35913. * @param sound define the cound to add
  35914. * @ignoreNaming
  35915. */
  35916. AddSound(sound: Sound): void;
  35917. /**
  35918. * Removes a sound to this sound track
  35919. * @param sound define the cound to remove
  35920. * @ignoreNaming
  35921. */
  35922. RemoveSound(sound: Sound): void;
  35923. /**
  35924. * Set a global volume for the full sound track.
  35925. * @param newVolume Define the new volume of the sound track
  35926. */
  35927. setVolume(newVolume: number): void;
  35928. /**
  35929. * Switch the panning model to HRTF:
  35930. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35932. */
  35933. switchPanningModelToHRTF(): void;
  35934. /**
  35935. * Switch the panning model to Equal Power:
  35936. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35938. */
  35939. switchPanningModelToEqualPower(): void;
  35940. /**
  35941. * Connect the sound track to an audio analyser allowing some amazing
  35942. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35944. * @param analyser The analyser to connect to the engine
  35945. */
  35946. connectToAnalyser(analyser: Analyser): void;
  35947. }
  35948. }
  35949. declare module BABYLON {
  35950. interface AbstractScene {
  35951. /**
  35952. * The list of sounds used in the scene.
  35953. */
  35954. sounds: Nullable<Array<Sound>>;
  35955. }
  35956. interface Scene {
  35957. /**
  35958. * @hidden
  35959. * Backing field
  35960. */
  35961. _mainSoundTrack: SoundTrack;
  35962. /**
  35963. * The main sound track played by the scene.
  35964. * It cotains your primary collection of sounds.
  35965. */
  35966. mainSoundTrack: SoundTrack;
  35967. /**
  35968. * The list of sound tracks added to the scene
  35969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35970. */
  35971. soundTracks: Nullable<Array<SoundTrack>>;
  35972. /**
  35973. * Gets a sound using a given name
  35974. * @param name defines the name to search for
  35975. * @return the found sound or null if not found at all.
  35976. */
  35977. getSoundByName(name: string): Nullable<Sound>;
  35978. /**
  35979. * Gets or sets if audio support is enabled
  35980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35981. */
  35982. audioEnabled: boolean;
  35983. /**
  35984. * Gets or sets if audio will be output to headphones
  35985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35986. */
  35987. headphone: boolean;
  35988. /**
  35989. * Gets or sets custom audio listener position provider
  35990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35991. */
  35992. audioListenerPositionProvider: Nullable<() => Vector3>;
  35993. /**
  35994. * Gets or sets a refresh rate when using 3D audio positioning
  35995. */
  35996. audioPositioningRefreshRate: number;
  35997. }
  35998. /**
  35999. * Defines the sound scene component responsible to manage any sounds
  36000. * in a given scene.
  36001. */
  36002. export class AudioSceneComponent implements ISceneSerializableComponent {
  36003. /**
  36004. * The component name helpfull to identify the component in the list of scene components.
  36005. */
  36006. readonly name: string;
  36007. /**
  36008. * The scene the component belongs to.
  36009. */
  36010. scene: Scene;
  36011. private _audioEnabled;
  36012. /**
  36013. * Gets whether audio is enabled or not.
  36014. * Please use related enable/disable method to switch state.
  36015. */
  36016. readonly audioEnabled: boolean;
  36017. private _headphone;
  36018. /**
  36019. * Gets whether audio is outputing to headphone or not.
  36020. * Please use the according Switch methods to change output.
  36021. */
  36022. readonly headphone: boolean;
  36023. /**
  36024. * Gets or sets a refresh rate when using 3D audio positioning
  36025. */
  36026. audioPositioningRefreshRate: number;
  36027. private _audioListenerPositionProvider;
  36028. /**
  36029. * Gets the current audio listener position provider
  36030. */
  36031. /**
  36032. * Sets a custom listener position for all sounds in the scene
  36033. * By default, this is the position of the first active camera
  36034. */
  36035. audioListenerPositionProvider: Nullable<() => Vector3>;
  36036. /**
  36037. * Creates a new instance of the component for the given scene
  36038. * @param scene Defines the scene to register the component in
  36039. */
  36040. constructor(scene: Scene);
  36041. /**
  36042. * Registers the component in a given scene
  36043. */
  36044. register(): void;
  36045. /**
  36046. * Rebuilds the elements related to this component in case of
  36047. * context lost for instance.
  36048. */
  36049. rebuild(): void;
  36050. /**
  36051. * Serializes the component data to the specified json object
  36052. * @param serializationObject The object to serialize to
  36053. */
  36054. serialize(serializationObject: any): void;
  36055. /**
  36056. * Adds all the elements from the container to the scene
  36057. * @param container the container holding the elements
  36058. */
  36059. addFromContainer(container: AbstractScene): void;
  36060. /**
  36061. * Removes all the elements in the container from the scene
  36062. * @param container contains the elements to remove
  36063. * @param dispose if the removed element should be disposed (default: false)
  36064. */
  36065. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36066. /**
  36067. * Disposes the component and the associated ressources.
  36068. */
  36069. dispose(): void;
  36070. /**
  36071. * Disables audio in the associated scene.
  36072. */
  36073. disableAudio(): void;
  36074. /**
  36075. * Enables audio in the associated scene.
  36076. */
  36077. enableAudio(): void;
  36078. /**
  36079. * Switch audio to headphone output.
  36080. */
  36081. switchAudioModeForHeadphones(): void;
  36082. /**
  36083. * Switch audio to normal speakers.
  36084. */
  36085. switchAudioModeForNormalSpeakers(): void;
  36086. private _cachedCameraDirection;
  36087. private _cachedCameraPosition;
  36088. private _lastCheck;
  36089. private _afterRender;
  36090. }
  36091. }
  36092. declare module BABYLON {
  36093. /**
  36094. * Wraps one or more Sound objects and selects one with random weight for playback.
  36095. */
  36096. export class WeightedSound {
  36097. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36098. loop: boolean;
  36099. private _coneInnerAngle;
  36100. private _coneOuterAngle;
  36101. private _volume;
  36102. /** A Sound is currently playing. */
  36103. isPlaying: boolean;
  36104. /** A Sound is currently paused. */
  36105. isPaused: boolean;
  36106. private _sounds;
  36107. private _weights;
  36108. private _currentIndex?;
  36109. /**
  36110. * Creates a new WeightedSound from the list of sounds given.
  36111. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36112. * @param sounds Array of Sounds that will be selected from.
  36113. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36114. */
  36115. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36116. /**
  36117. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36118. */
  36119. /**
  36120. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36121. */
  36122. directionalConeInnerAngle: number;
  36123. /**
  36124. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36125. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36126. */
  36127. /**
  36128. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36129. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36130. */
  36131. directionalConeOuterAngle: number;
  36132. /**
  36133. * Playback volume.
  36134. */
  36135. /**
  36136. * Playback volume.
  36137. */
  36138. volume: number;
  36139. private _onended;
  36140. /**
  36141. * Suspend playback
  36142. */
  36143. pause(): void;
  36144. /**
  36145. * Stop playback
  36146. */
  36147. stop(): void;
  36148. /**
  36149. * Start playback.
  36150. * @param startOffset Position the clip head at a specific time in seconds.
  36151. */
  36152. play(startOffset?: number): void;
  36153. }
  36154. }
  36155. declare module BABYLON {
  36156. /**
  36157. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36159. */
  36160. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36161. /**
  36162. * Gets the name of the behavior.
  36163. */
  36164. readonly name: string;
  36165. /**
  36166. * The easing function used by animations
  36167. */
  36168. static EasingFunction: BackEase;
  36169. /**
  36170. * The easing mode used by animations
  36171. */
  36172. static EasingMode: number;
  36173. /**
  36174. * The duration of the animation, in milliseconds
  36175. */
  36176. transitionDuration: number;
  36177. /**
  36178. * Length of the distance animated by the transition when lower radius is reached
  36179. */
  36180. lowerRadiusTransitionRange: number;
  36181. /**
  36182. * Length of the distance animated by the transition when upper radius is reached
  36183. */
  36184. upperRadiusTransitionRange: number;
  36185. private _autoTransitionRange;
  36186. /**
  36187. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36188. */
  36189. /**
  36190. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36191. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36192. */
  36193. autoTransitionRange: boolean;
  36194. private _attachedCamera;
  36195. private _onAfterCheckInputsObserver;
  36196. private _onMeshTargetChangedObserver;
  36197. /**
  36198. * Initializes the behavior.
  36199. */
  36200. init(): void;
  36201. /**
  36202. * Attaches the behavior to its arc rotate camera.
  36203. * @param camera Defines the camera to attach the behavior to
  36204. */
  36205. attach(camera: ArcRotateCamera): void;
  36206. /**
  36207. * Detaches the behavior from its current arc rotate camera.
  36208. */
  36209. detach(): void;
  36210. private _radiusIsAnimating;
  36211. private _radiusBounceTransition;
  36212. private _animatables;
  36213. private _cachedWheelPrecision;
  36214. /**
  36215. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36216. * @param radiusLimit The limit to check against.
  36217. * @return Bool to indicate if at limit.
  36218. */
  36219. private _isRadiusAtLimit;
  36220. /**
  36221. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36222. * @param radiusDelta The delta by which to animate to. Can be negative.
  36223. */
  36224. private _applyBoundRadiusAnimation;
  36225. /**
  36226. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36227. */
  36228. protected _clearAnimationLocks(): void;
  36229. /**
  36230. * Stops and removes all animations that have been applied to the camera
  36231. */
  36232. stopAllAnimations(): void;
  36233. }
  36234. }
  36235. declare module BABYLON {
  36236. /**
  36237. * 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.
  36238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36239. */
  36240. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36241. /**
  36242. * Gets the name of the behavior.
  36243. */
  36244. readonly name: string;
  36245. private _mode;
  36246. private _radiusScale;
  36247. private _positionScale;
  36248. private _defaultElevation;
  36249. private _elevationReturnTime;
  36250. private _elevationReturnWaitTime;
  36251. private _zoomStopsAnimation;
  36252. private _framingTime;
  36253. /**
  36254. * The easing function used by animations
  36255. */
  36256. static EasingFunction: ExponentialEase;
  36257. /**
  36258. * The easing mode used by animations
  36259. */
  36260. static EasingMode: number;
  36261. /**
  36262. * Sets the current mode used by the behavior
  36263. */
  36264. /**
  36265. * Gets current mode used by the behavior.
  36266. */
  36267. mode: number;
  36268. /**
  36269. * Sets the scale applied to the radius (1 by default)
  36270. */
  36271. /**
  36272. * Gets the scale applied to the radius
  36273. */
  36274. radiusScale: number;
  36275. /**
  36276. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36277. */
  36278. /**
  36279. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36280. */
  36281. positionScale: number;
  36282. /**
  36283. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36284. * behaviour is triggered, in radians.
  36285. */
  36286. /**
  36287. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36288. * behaviour is triggered, in radians.
  36289. */
  36290. defaultElevation: number;
  36291. /**
  36292. * Sets the time (in milliseconds) taken to return to the default beta position.
  36293. * Negative value indicates camera should not return to default.
  36294. */
  36295. /**
  36296. * Gets the time (in milliseconds) taken to return to the default beta position.
  36297. * Negative value indicates camera should not return to default.
  36298. */
  36299. elevationReturnTime: number;
  36300. /**
  36301. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36302. */
  36303. /**
  36304. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36305. */
  36306. elevationReturnWaitTime: number;
  36307. /**
  36308. * Sets the flag that indicates if user zooming should stop animation.
  36309. */
  36310. /**
  36311. * Gets the flag that indicates if user zooming should stop animation.
  36312. */
  36313. zoomStopsAnimation: boolean;
  36314. /**
  36315. * Sets the transition time when framing the mesh, in milliseconds
  36316. */
  36317. /**
  36318. * Gets the transition time when framing the mesh, in milliseconds
  36319. */
  36320. framingTime: number;
  36321. /**
  36322. * Define if the behavior should automatically change the configured
  36323. * camera limits and sensibilities.
  36324. */
  36325. autoCorrectCameraLimitsAndSensibility: boolean;
  36326. private _onPrePointerObservableObserver;
  36327. private _onAfterCheckInputsObserver;
  36328. private _onMeshTargetChangedObserver;
  36329. private _attachedCamera;
  36330. private _isPointerDown;
  36331. private _lastInteractionTime;
  36332. /**
  36333. * Initializes the behavior.
  36334. */
  36335. init(): void;
  36336. /**
  36337. * Attaches the behavior to its arc rotate camera.
  36338. * @param camera Defines the camera to attach the behavior to
  36339. */
  36340. attach(camera: ArcRotateCamera): void;
  36341. /**
  36342. * Detaches the behavior from its current arc rotate camera.
  36343. */
  36344. detach(): void;
  36345. private _animatables;
  36346. private _betaIsAnimating;
  36347. private _betaTransition;
  36348. private _radiusTransition;
  36349. private _vectorTransition;
  36350. /**
  36351. * Targets the given mesh and updates zoom level accordingly.
  36352. * @param mesh The mesh to target.
  36353. * @param radius Optional. If a cached radius position already exists, overrides default.
  36354. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36355. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36356. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36357. */
  36358. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36359. /**
  36360. * Targets the given mesh with its children and updates zoom level accordingly.
  36361. * @param mesh The mesh to target.
  36362. * @param radius Optional. If a cached radius position already exists, overrides default.
  36363. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36366. */
  36367. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36368. /**
  36369. * Targets the given meshes with their children and updates zoom level accordingly.
  36370. * @param meshes The mesh to target.
  36371. * @param radius Optional. If a cached radius position already exists, overrides default.
  36372. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36375. */
  36376. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36377. /**
  36378. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36379. * @param minimumWorld Determines the smaller position of the bounding box extend
  36380. * @param maximumWorld Determines the bigger position of the bounding box extend
  36381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36383. */
  36384. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36385. /**
  36386. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36387. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36388. * frustum width.
  36389. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36390. * to fully enclose the mesh in the viewing frustum.
  36391. */
  36392. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36393. /**
  36394. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36395. * is automatically returned to its default position (expected to be above ground plane).
  36396. */
  36397. private _maintainCameraAboveGround;
  36398. /**
  36399. * Returns the frustum slope based on the canvas ratio and camera FOV
  36400. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36401. */
  36402. private _getFrustumSlope;
  36403. /**
  36404. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36405. */
  36406. private _clearAnimationLocks;
  36407. /**
  36408. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36409. */
  36410. private _applyUserInteraction;
  36411. /**
  36412. * Stops and removes all animations that have been applied to the camera
  36413. */
  36414. stopAllAnimations(): void;
  36415. /**
  36416. * Gets a value indicating if the user is moving the camera
  36417. */
  36418. readonly isUserIsMoving: boolean;
  36419. /**
  36420. * The camera can move all the way towards the mesh.
  36421. */
  36422. static IgnoreBoundsSizeMode: number;
  36423. /**
  36424. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36425. */
  36426. static FitFrustumSidesMode: number;
  36427. }
  36428. }
  36429. declare module BABYLON {
  36430. /**
  36431. * Base class for Camera Pointer Inputs.
  36432. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36433. * for example usage.
  36434. */
  36435. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36436. /**
  36437. * Defines the camera the input is attached to.
  36438. */
  36439. abstract camera: Camera;
  36440. /**
  36441. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36442. */
  36443. protected _altKey: boolean;
  36444. protected _ctrlKey: boolean;
  36445. protected _metaKey: boolean;
  36446. protected _shiftKey: boolean;
  36447. /**
  36448. * Which mouse buttons were pressed at time of last mouse event.
  36449. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36450. */
  36451. protected _buttonsPressed: number;
  36452. /**
  36453. * Defines the buttons associated with the input to handle camera move.
  36454. */
  36455. buttons: number[];
  36456. /**
  36457. * Attach the input controls to a specific dom element to get the input from.
  36458. * @param element Defines the element the controls should be listened from
  36459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36460. */
  36461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36462. /**
  36463. * Detach the current controls from the specified dom element.
  36464. * @param element Defines the element to stop listening the inputs from
  36465. */
  36466. detachControl(element: Nullable<HTMLElement>): void;
  36467. /**
  36468. * Gets the class name of the current input.
  36469. * @returns the class name
  36470. */
  36471. getClassName(): string;
  36472. /**
  36473. * Get the friendly name associated with the input class.
  36474. * @returns the input friendly name
  36475. */
  36476. getSimpleName(): string;
  36477. /**
  36478. * Called on pointer POINTERDOUBLETAP event.
  36479. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36480. */
  36481. protected onDoubleTap(type: string): void;
  36482. /**
  36483. * Called on pointer POINTERMOVE event if only a single touch is active.
  36484. * Override this method to provide functionality.
  36485. */
  36486. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36487. /**
  36488. * Called on pointer POINTERMOVE event if multiple touches are active.
  36489. * Override this method to provide functionality.
  36490. */
  36491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36492. /**
  36493. * Called on JS contextmenu event.
  36494. * Override this method to provide functionality.
  36495. */
  36496. protected onContextMenu(evt: PointerEvent): void;
  36497. /**
  36498. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36499. * press.
  36500. * Override this method to provide functionality.
  36501. */
  36502. protected onButtonDown(evt: PointerEvent): void;
  36503. /**
  36504. * Called each time a new POINTERUP event occurs. Ie, for each button
  36505. * release.
  36506. * Override this method to provide functionality.
  36507. */
  36508. protected onButtonUp(evt: PointerEvent): void;
  36509. /**
  36510. * Called when window becomes inactive.
  36511. * Override this method to provide functionality.
  36512. */
  36513. protected onLostFocus(): void;
  36514. private _pointerInput;
  36515. private _observer;
  36516. private _onLostFocus;
  36517. private pointA;
  36518. private pointB;
  36519. }
  36520. }
  36521. declare module BABYLON {
  36522. /**
  36523. * Manage the pointers inputs to control an arc rotate camera.
  36524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36525. */
  36526. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36527. /**
  36528. * Defines the camera the input is attached to.
  36529. */
  36530. camera: ArcRotateCamera;
  36531. /**
  36532. * Gets the class name of the current input.
  36533. * @returns the class name
  36534. */
  36535. getClassName(): string;
  36536. /**
  36537. * Defines the buttons associated with the input to handle camera move.
  36538. */
  36539. buttons: number[];
  36540. /**
  36541. * Defines the pointer angular sensibility along the X axis or how fast is
  36542. * the camera rotating.
  36543. */
  36544. angularSensibilityX: number;
  36545. /**
  36546. * Defines the pointer angular sensibility along the Y axis or how fast is
  36547. * the camera rotating.
  36548. */
  36549. angularSensibilityY: number;
  36550. /**
  36551. * Defines the pointer pinch precision or how fast is the camera zooming.
  36552. */
  36553. pinchPrecision: number;
  36554. /**
  36555. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36556. * from 0.
  36557. * It defines the percentage of current camera.radius to use as delta when
  36558. * pinch zoom is used.
  36559. */
  36560. pinchDeltaPercentage: number;
  36561. /**
  36562. * Defines the pointer panning sensibility or how fast is the camera moving.
  36563. */
  36564. panningSensibility: number;
  36565. /**
  36566. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36567. */
  36568. multiTouchPanning: boolean;
  36569. /**
  36570. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36571. * zoom (pinch) through multitouch.
  36572. */
  36573. multiTouchPanAndZoom: boolean;
  36574. /**
  36575. * Revers pinch action direction.
  36576. */
  36577. pinchInwards: boolean;
  36578. private _isPanClick;
  36579. private _twoFingerActivityCount;
  36580. private _isPinching;
  36581. /**
  36582. * Called on pointer POINTERMOVE event if only a single touch is active.
  36583. */
  36584. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36585. /**
  36586. * Called on pointer POINTERDOUBLETAP event.
  36587. */
  36588. protected onDoubleTap(type: string): void;
  36589. /**
  36590. * Called on pointer POINTERMOVE event if multiple touches are active.
  36591. */
  36592. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36593. /**
  36594. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36595. * press.
  36596. */
  36597. protected onButtonDown(evt: PointerEvent): void;
  36598. /**
  36599. * Called each time a new POINTERUP event occurs. Ie, for each button
  36600. * release.
  36601. */
  36602. protected onButtonUp(evt: PointerEvent): void;
  36603. /**
  36604. * Called when window becomes inactive.
  36605. */
  36606. protected onLostFocus(): void;
  36607. }
  36608. }
  36609. declare module BABYLON {
  36610. /**
  36611. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36613. */
  36614. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36615. /**
  36616. * Defines the camera the input is attached to.
  36617. */
  36618. camera: ArcRotateCamera;
  36619. /**
  36620. * Defines the list of key codes associated with the up action (increase alpha)
  36621. */
  36622. keysUp: number[];
  36623. /**
  36624. * Defines the list of key codes associated with the down action (decrease alpha)
  36625. */
  36626. keysDown: number[];
  36627. /**
  36628. * Defines the list of key codes associated with the left action (increase beta)
  36629. */
  36630. keysLeft: number[];
  36631. /**
  36632. * Defines the list of key codes associated with the right action (decrease beta)
  36633. */
  36634. keysRight: number[];
  36635. /**
  36636. * Defines the list of key codes associated with the reset action.
  36637. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36638. */
  36639. keysReset: number[];
  36640. /**
  36641. * Defines the panning sensibility of the inputs.
  36642. * (How fast is the camera paning)
  36643. */
  36644. panningSensibility: number;
  36645. /**
  36646. * Defines the zooming sensibility of the inputs.
  36647. * (How fast is the camera zooming)
  36648. */
  36649. zoomingSensibility: number;
  36650. /**
  36651. * Defines wether maintaining the alt key down switch the movement mode from
  36652. * orientation to zoom.
  36653. */
  36654. useAltToZoom: boolean;
  36655. /**
  36656. * Rotation speed of the camera
  36657. */
  36658. angularSpeed: number;
  36659. private _keys;
  36660. private _ctrlPressed;
  36661. private _altPressed;
  36662. private _onCanvasBlurObserver;
  36663. private _onKeyboardObserver;
  36664. private _engine;
  36665. private _scene;
  36666. /**
  36667. * Attach the input controls to a specific dom element to get the input from.
  36668. * @param element Defines the element the controls should be listened from
  36669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36670. */
  36671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36672. /**
  36673. * Detach the current controls from the specified dom element.
  36674. * @param element Defines the element to stop listening the inputs from
  36675. */
  36676. detachControl(element: Nullable<HTMLElement>): void;
  36677. /**
  36678. * Update the current camera state depending on the inputs that have been used this frame.
  36679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36680. */
  36681. checkInputs(): void;
  36682. /**
  36683. * Gets the class name of the current intput.
  36684. * @returns the class name
  36685. */
  36686. getClassName(): string;
  36687. /**
  36688. * Get the friendly name associated with the input class.
  36689. * @returns the input friendly name
  36690. */
  36691. getSimpleName(): string;
  36692. }
  36693. }
  36694. declare module BABYLON {
  36695. /**
  36696. * Manage the mouse wheel inputs to control an arc rotate camera.
  36697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36698. */
  36699. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36700. /**
  36701. * Defines the camera the input is attached to.
  36702. */
  36703. camera: ArcRotateCamera;
  36704. /**
  36705. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36706. */
  36707. wheelPrecision: number;
  36708. /**
  36709. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36710. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36711. */
  36712. wheelDeltaPercentage: number;
  36713. private _wheel;
  36714. private _observer;
  36715. private computeDeltaFromMouseWheelLegacyEvent;
  36716. /**
  36717. * Attach the input controls to a specific dom element to get the input from.
  36718. * @param element Defines the element the controls should be listened from
  36719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36720. */
  36721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36722. /**
  36723. * Detach the current controls from the specified dom element.
  36724. * @param element Defines the element to stop listening the inputs from
  36725. */
  36726. detachControl(element: Nullable<HTMLElement>): void;
  36727. /**
  36728. * Gets the class name of the current intput.
  36729. * @returns the class name
  36730. */
  36731. getClassName(): string;
  36732. /**
  36733. * Get the friendly name associated with the input class.
  36734. * @returns the input friendly name
  36735. */
  36736. getSimpleName(): string;
  36737. }
  36738. }
  36739. declare module BABYLON {
  36740. /**
  36741. * Default Inputs manager for the ArcRotateCamera.
  36742. * It groups all the default supported inputs for ease of use.
  36743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36744. */
  36745. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36746. /**
  36747. * Instantiates a new ArcRotateCameraInputsManager.
  36748. * @param camera Defines the camera the inputs belong to
  36749. */
  36750. constructor(camera: ArcRotateCamera);
  36751. /**
  36752. * Add mouse wheel input support to the input manager.
  36753. * @returns the current input manager
  36754. */
  36755. addMouseWheel(): ArcRotateCameraInputsManager;
  36756. /**
  36757. * Add pointers input support to the input manager.
  36758. * @returns the current input manager
  36759. */
  36760. addPointers(): ArcRotateCameraInputsManager;
  36761. /**
  36762. * Add keyboard input support to the input manager.
  36763. * @returns the current input manager
  36764. */
  36765. addKeyboard(): ArcRotateCameraInputsManager;
  36766. }
  36767. }
  36768. declare module BABYLON {
  36769. /**
  36770. * This represents an orbital type of camera.
  36771. *
  36772. * 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.
  36773. * 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.
  36774. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36775. */
  36776. export class ArcRotateCamera extends TargetCamera {
  36777. /**
  36778. * Defines the rotation angle of the camera along the longitudinal axis.
  36779. */
  36780. alpha: number;
  36781. /**
  36782. * Defines the rotation angle of the camera along the latitudinal axis.
  36783. */
  36784. beta: number;
  36785. /**
  36786. * Defines the radius of the camera from it s target point.
  36787. */
  36788. radius: number;
  36789. protected _target: Vector3;
  36790. protected _targetHost: Nullable<AbstractMesh>;
  36791. /**
  36792. * Defines the target point of the camera.
  36793. * The camera looks towards it form the radius distance.
  36794. */
  36795. target: Vector3;
  36796. /**
  36797. * Define the current local position of the camera in the scene
  36798. */
  36799. position: Vector3;
  36800. protected _upVector: Vector3;
  36801. protected _upToYMatrix: Matrix;
  36802. protected _YToUpMatrix: Matrix;
  36803. /**
  36804. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36805. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36806. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36807. */
  36808. upVector: Vector3;
  36809. /**
  36810. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36811. */
  36812. setMatUp(): void;
  36813. /**
  36814. * Current inertia value on the longitudinal axis.
  36815. * The bigger this number the longer it will take for the camera to stop.
  36816. */
  36817. inertialAlphaOffset: number;
  36818. /**
  36819. * Current inertia value on the latitudinal axis.
  36820. * The bigger this number the longer it will take for the camera to stop.
  36821. */
  36822. inertialBetaOffset: number;
  36823. /**
  36824. * Current inertia value on the radius axis.
  36825. * The bigger this number the longer it will take for the camera to stop.
  36826. */
  36827. inertialRadiusOffset: number;
  36828. /**
  36829. * Minimum allowed angle on the longitudinal axis.
  36830. * This can help limiting how the Camera is able to move in the scene.
  36831. */
  36832. lowerAlphaLimit: Nullable<number>;
  36833. /**
  36834. * Maximum allowed angle on the longitudinal axis.
  36835. * This can help limiting how the Camera is able to move in the scene.
  36836. */
  36837. upperAlphaLimit: Nullable<number>;
  36838. /**
  36839. * Minimum allowed angle on the latitudinal axis.
  36840. * This can help limiting how the Camera is able to move in the scene.
  36841. */
  36842. lowerBetaLimit: number;
  36843. /**
  36844. * Maximum allowed angle on the latitudinal axis.
  36845. * This can help limiting how the Camera is able to move in the scene.
  36846. */
  36847. upperBetaLimit: number;
  36848. /**
  36849. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36850. * This can help limiting how the Camera is able to move in the scene.
  36851. */
  36852. lowerRadiusLimit: Nullable<number>;
  36853. /**
  36854. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36855. * This can help limiting how the Camera is able to move in the scene.
  36856. */
  36857. upperRadiusLimit: Nullable<number>;
  36858. /**
  36859. * Defines the current inertia value used during panning of the camera along the X axis.
  36860. */
  36861. inertialPanningX: number;
  36862. /**
  36863. * Defines the current inertia value used during panning of the camera along the Y axis.
  36864. */
  36865. inertialPanningY: number;
  36866. /**
  36867. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36868. * Basically if your fingers moves away from more than this distance you will be considered
  36869. * in pinch mode.
  36870. */
  36871. pinchToPanMaxDistance: number;
  36872. /**
  36873. * Defines the maximum distance the camera can pan.
  36874. * This could help keeping the cammera always in your scene.
  36875. */
  36876. panningDistanceLimit: Nullable<number>;
  36877. /**
  36878. * Defines the target of the camera before paning.
  36879. */
  36880. panningOriginTarget: Vector3;
  36881. /**
  36882. * Defines the value of the inertia used during panning.
  36883. * 0 would mean stop inertia and one would mean no decelleration at all.
  36884. */
  36885. panningInertia: number;
  36886. /**
  36887. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36888. */
  36889. angularSensibilityX: number;
  36890. /**
  36891. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36892. */
  36893. angularSensibilityY: number;
  36894. /**
  36895. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36896. */
  36897. pinchPrecision: number;
  36898. /**
  36899. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36900. * It will be used instead of pinchDeltaPrecision if different from 0.
  36901. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36902. */
  36903. pinchDeltaPercentage: number;
  36904. /**
  36905. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36906. */
  36907. panningSensibility: number;
  36908. /**
  36909. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36910. */
  36911. keysUp: number[];
  36912. /**
  36913. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36914. */
  36915. keysDown: number[];
  36916. /**
  36917. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36918. */
  36919. keysLeft: number[];
  36920. /**
  36921. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36922. */
  36923. keysRight: number[];
  36924. /**
  36925. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36926. */
  36927. wheelPrecision: number;
  36928. /**
  36929. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36930. * It will be used instead of pinchDeltaPrecision if different from 0.
  36931. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36932. */
  36933. wheelDeltaPercentage: number;
  36934. /**
  36935. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36936. */
  36937. zoomOnFactor: number;
  36938. /**
  36939. * Defines a screen offset for the camera position.
  36940. */
  36941. targetScreenOffset: Vector2;
  36942. /**
  36943. * Allows the camera to be completely reversed.
  36944. * If false the camera can not arrive upside down.
  36945. */
  36946. allowUpsideDown: boolean;
  36947. /**
  36948. * Define if double tap/click is used to restore the previously saved state of the camera.
  36949. */
  36950. useInputToRestoreState: boolean;
  36951. /** @hidden */
  36952. _viewMatrix: Matrix;
  36953. /** @hidden */
  36954. _useCtrlForPanning: boolean;
  36955. /** @hidden */
  36956. _panningMouseButton: number;
  36957. /**
  36958. * Defines the input associated to the camera.
  36959. */
  36960. inputs: ArcRotateCameraInputsManager;
  36961. /** @hidden */
  36962. _reset: () => void;
  36963. /**
  36964. * Defines the allowed panning axis.
  36965. */
  36966. panningAxis: Vector3;
  36967. protected _localDirection: Vector3;
  36968. protected _transformedDirection: Vector3;
  36969. private _bouncingBehavior;
  36970. /**
  36971. * Gets the bouncing behavior of the camera if it has been enabled.
  36972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36973. */
  36974. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36975. /**
  36976. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36978. */
  36979. useBouncingBehavior: boolean;
  36980. private _framingBehavior;
  36981. /**
  36982. * Gets the framing behavior of the camera if it has been enabled.
  36983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36984. */
  36985. readonly framingBehavior: Nullable<FramingBehavior>;
  36986. /**
  36987. * Defines if the framing behavior of the camera is enabled on the camera.
  36988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36989. */
  36990. useFramingBehavior: boolean;
  36991. private _autoRotationBehavior;
  36992. /**
  36993. * Gets the auto rotation behavior of the camera if it has been enabled.
  36994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36995. */
  36996. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36997. /**
  36998. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37000. */
  37001. useAutoRotationBehavior: boolean;
  37002. /**
  37003. * Observable triggered when the mesh target has been changed on the camera.
  37004. */
  37005. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37006. /**
  37007. * Event raised when the camera is colliding with a mesh.
  37008. */
  37009. onCollide: (collidedMesh: AbstractMesh) => void;
  37010. /**
  37011. * Defines whether the camera should check collision with the objects oh the scene.
  37012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37013. */
  37014. checkCollisions: boolean;
  37015. /**
  37016. * Defines the collision radius of the camera.
  37017. * This simulates a sphere around the camera.
  37018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37019. */
  37020. collisionRadius: Vector3;
  37021. protected _collider: Collider;
  37022. protected _previousPosition: Vector3;
  37023. protected _collisionVelocity: Vector3;
  37024. protected _newPosition: Vector3;
  37025. protected _previousAlpha: number;
  37026. protected _previousBeta: number;
  37027. protected _previousRadius: number;
  37028. protected _collisionTriggered: boolean;
  37029. protected _targetBoundingCenter: Nullable<Vector3>;
  37030. private _computationVector;
  37031. /**
  37032. * Instantiates a new ArcRotateCamera in a given scene
  37033. * @param name Defines the name of the camera
  37034. * @param alpha Defines the camera rotation along the logitudinal axis
  37035. * @param beta Defines the camera rotation along the latitudinal axis
  37036. * @param radius Defines the camera distance from its target
  37037. * @param target Defines the camera target
  37038. * @param scene Defines the scene the camera belongs to
  37039. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37040. */
  37041. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37042. /** @hidden */
  37043. _initCache(): void;
  37044. /** @hidden */
  37045. _updateCache(ignoreParentClass?: boolean): void;
  37046. protected _getTargetPosition(): Vector3;
  37047. private _storedAlpha;
  37048. private _storedBeta;
  37049. private _storedRadius;
  37050. private _storedTarget;
  37051. private _storedTargetScreenOffset;
  37052. /**
  37053. * Stores the current state of the camera (alpha, beta, radius and target)
  37054. * @returns the camera itself
  37055. */
  37056. storeState(): Camera;
  37057. /**
  37058. * @hidden
  37059. * Restored camera state. You must call storeState() first
  37060. */
  37061. _restoreStateValues(): boolean;
  37062. /** @hidden */
  37063. _isSynchronizedViewMatrix(): boolean;
  37064. /**
  37065. * Attached controls to the current camera.
  37066. * @param element Defines the element the controls should be listened from
  37067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37068. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37069. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37070. */
  37071. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37072. /**
  37073. * Detach the current controls from the camera.
  37074. * The camera will stop reacting to inputs.
  37075. * @param element Defines the element to stop listening the inputs from
  37076. */
  37077. detachControl(element: HTMLElement): void;
  37078. /** @hidden */
  37079. _checkInputs(): void;
  37080. protected _checkLimits(): void;
  37081. /**
  37082. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37083. */
  37084. rebuildAnglesAndRadius(): void;
  37085. /**
  37086. * Use a position to define the current camera related information like alpha, beta and radius
  37087. * @param position Defines the position to set the camera at
  37088. */
  37089. setPosition(position: Vector3): void;
  37090. /**
  37091. * Defines the target the camera should look at.
  37092. * This will automatically adapt alpha beta and radius to fit within the new target.
  37093. * @param target Defines the new target as a Vector or a mesh
  37094. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37095. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37096. */
  37097. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37098. /** @hidden */
  37099. _getViewMatrix(): Matrix;
  37100. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37101. /**
  37102. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37103. * @param meshes Defines the mesh to zoom on
  37104. * @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)
  37105. */
  37106. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37107. /**
  37108. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37109. * The target will be changed but the radius
  37110. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37111. * @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)
  37112. */
  37113. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37114. min: Vector3;
  37115. max: Vector3;
  37116. distance: number;
  37117. }, doNotUpdateMaxZ?: boolean): void;
  37118. /**
  37119. * @override
  37120. * Override Camera.createRigCamera
  37121. */
  37122. createRigCamera(name: string, cameraIndex: number): Camera;
  37123. /**
  37124. * @hidden
  37125. * @override
  37126. * Override Camera._updateRigCameras
  37127. */
  37128. _updateRigCameras(): void;
  37129. /**
  37130. * Destroy the camera and release the current resources hold by it.
  37131. */
  37132. dispose(): void;
  37133. /**
  37134. * Gets the current object class name.
  37135. * @return the class name
  37136. */
  37137. getClassName(): string;
  37138. }
  37139. }
  37140. declare module BABYLON {
  37141. /**
  37142. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37144. */
  37145. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37146. /**
  37147. * Gets the name of the behavior.
  37148. */
  37149. readonly name: string;
  37150. private _zoomStopsAnimation;
  37151. private _idleRotationSpeed;
  37152. private _idleRotationWaitTime;
  37153. private _idleRotationSpinupTime;
  37154. /**
  37155. * Sets the flag that indicates if user zooming should stop animation.
  37156. */
  37157. /**
  37158. * Gets the flag that indicates if user zooming should stop animation.
  37159. */
  37160. zoomStopsAnimation: boolean;
  37161. /**
  37162. * Sets the default speed at which the camera rotates around the model.
  37163. */
  37164. /**
  37165. * Gets the default speed at which the camera rotates around the model.
  37166. */
  37167. idleRotationSpeed: number;
  37168. /**
  37169. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37170. */
  37171. /**
  37172. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37173. */
  37174. idleRotationWaitTime: number;
  37175. /**
  37176. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37177. */
  37178. /**
  37179. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37180. */
  37181. idleRotationSpinupTime: number;
  37182. /**
  37183. * Gets a value indicating if the camera is currently rotating because of this behavior
  37184. */
  37185. readonly rotationInProgress: boolean;
  37186. private _onPrePointerObservableObserver;
  37187. private _onAfterCheckInputsObserver;
  37188. private _attachedCamera;
  37189. private _isPointerDown;
  37190. private _lastFrameTime;
  37191. private _lastInteractionTime;
  37192. private _cameraRotationSpeed;
  37193. /**
  37194. * Initializes the behavior.
  37195. */
  37196. init(): void;
  37197. /**
  37198. * Attaches the behavior to its arc rotate camera.
  37199. * @param camera Defines the camera to attach the behavior to
  37200. */
  37201. attach(camera: ArcRotateCamera): void;
  37202. /**
  37203. * Detaches the behavior from its current arc rotate camera.
  37204. */
  37205. detach(): void;
  37206. /**
  37207. * Returns true if user is scrolling.
  37208. * @return true if user is scrolling.
  37209. */
  37210. private _userIsZooming;
  37211. private _lastFrameRadius;
  37212. private _shouldAnimationStopForInteraction;
  37213. /**
  37214. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37215. */
  37216. private _applyUserInteraction;
  37217. private _userIsMoving;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37223. */
  37224. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37225. private ui;
  37226. /**
  37227. * The name of the behavior
  37228. */
  37229. name: string;
  37230. /**
  37231. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37232. */
  37233. distanceAwayFromFace: number;
  37234. /**
  37235. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37236. */
  37237. distanceAwayFromBottomOfFace: number;
  37238. private _faceVectors;
  37239. private _target;
  37240. private _scene;
  37241. private _onRenderObserver;
  37242. private _tmpMatrix;
  37243. private _tmpVector;
  37244. /**
  37245. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37246. * @param ui The transform node that should be attched to the mesh
  37247. */
  37248. constructor(ui: TransformNode);
  37249. /**
  37250. * Initializes the behavior
  37251. */
  37252. init(): void;
  37253. private _closestFace;
  37254. private _zeroVector;
  37255. private _lookAtTmpMatrix;
  37256. private _lookAtToRef;
  37257. /**
  37258. * Attaches the AttachToBoxBehavior to the passed in mesh
  37259. * @param target The mesh that the specified node will be attached to
  37260. */
  37261. attach(target: Mesh): void;
  37262. /**
  37263. * Detaches the behavior from the mesh
  37264. */
  37265. detach(): void;
  37266. }
  37267. }
  37268. declare module BABYLON {
  37269. /**
  37270. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37271. */
  37272. export class FadeInOutBehavior implements Behavior<Mesh> {
  37273. /**
  37274. * Time in milliseconds to delay before fading in (Default: 0)
  37275. */
  37276. delay: number;
  37277. /**
  37278. * Time in milliseconds for the mesh to fade in (Default: 300)
  37279. */
  37280. fadeInTime: number;
  37281. private _millisecondsPerFrame;
  37282. private _hovered;
  37283. private _hoverValue;
  37284. private _ownerNode;
  37285. /**
  37286. * Instatiates the FadeInOutBehavior
  37287. */
  37288. constructor();
  37289. /**
  37290. * The name of the behavior
  37291. */
  37292. readonly name: string;
  37293. /**
  37294. * Initializes the behavior
  37295. */
  37296. init(): void;
  37297. /**
  37298. * Attaches the fade behavior on the passed in mesh
  37299. * @param ownerNode The mesh that will be faded in/out once attached
  37300. */
  37301. attach(ownerNode: Mesh): void;
  37302. /**
  37303. * Detaches the behavior from the mesh
  37304. */
  37305. detach(): void;
  37306. /**
  37307. * Triggers the mesh to begin fading in or out
  37308. * @param value if the object should fade in or out (true to fade in)
  37309. */
  37310. fadeIn(value: boolean): void;
  37311. private _update;
  37312. private _setAllVisibility;
  37313. }
  37314. }
  37315. declare module BABYLON {
  37316. /**
  37317. * Class containing a set of static utilities functions for managing Pivots
  37318. * @hidden
  37319. */
  37320. export class PivotTools {
  37321. private static _PivotCached;
  37322. private static _OldPivotPoint;
  37323. private static _PivotTranslation;
  37324. private static _PivotTmpVector;
  37325. /** @hidden */
  37326. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37327. /** @hidden */
  37328. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37329. }
  37330. }
  37331. declare module BABYLON {
  37332. /**
  37333. * Class containing static functions to help procedurally build meshes
  37334. */
  37335. export class PlaneBuilder {
  37336. /**
  37337. * Creates a plane mesh
  37338. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37339. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37340. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37342. * * 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
  37343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37344. * @param name defines the name of the mesh
  37345. * @param options defines the options used to create the mesh
  37346. * @param scene defines the hosting scene
  37347. * @returns the plane mesh
  37348. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37349. */
  37350. static CreatePlane(name: string, options: {
  37351. size?: number;
  37352. width?: number;
  37353. height?: number;
  37354. sideOrientation?: number;
  37355. frontUVs?: Vector4;
  37356. backUVs?: Vector4;
  37357. updatable?: boolean;
  37358. sourcePlane?: Plane;
  37359. }, scene?: Nullable<Scene>): Mesh;
  37360. }
  37361. }
  37362. declare module BABYLON {
  37363. /**
  37364. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37365. */
  37366. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37367. private static _AnyMouseID;
  37368. /**
  37369. * Abstract mesh the behavior is set on
  37370. */
  37371. attachedNode: AbstractMesh;
  37372. private _dragPlane;
  37373. private _scene;
  37374. private _pointerObserver;
  37375. private _beforeRenderObserver;
  37376. private static _planeScene;
  37377. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37378. /**
  37379. * 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)
  37380. */
  37381. maxDragAngle: number;
  37382. /**
  37383. * @hidden
  37384. */
  37385. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37386. /**
  37387. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37388. */
  37389. currentDraggingPointerID: number;
  37390. /**
  37391. * The last position where the pointer hit the drag plane in world space
  37392. */
  37393. lastDragPosition: Vector3;
  37394. /**
  37395. * If the behavior is currently in a dragging state
  37396. */
  37397. dragging: boolean;
  37398. /**
  37399. * 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)
  37400. */
  37401. dragDeltaRatio: number;
  37402. /**
  37403. * If the drag plane orientation should be updated during the dragging (Default: true)
  37404. */
  37405. updateDragPlane: boolean;
  37406. private _debugMode;
  37407. private _moving;
  37408. /**
  37409. * Fires each time the attached mesh is dragged with the pointer
  37410. * * delta between last drag position and current drag position in world space
  37411. * * dragDistance along the drag axis
  37412. * * dragPlaneNormal normal of the current drag plane used during the drag
  37413. * * dragPlanePoint in world space where the drag intersects the drag plane
  37414. */
  37415. onDragObservable: Observable<{
  37416. delta: Vector3;
  37417. dragPlanePoint: Vector3;
  37418. dragPlaneNormal: Vector3;
  37419. dragDistance: number;
  37420. pointerId: number;
  37421. }>;
  37422. /**
  37423. * Fires each time a drag begins (eg. mouse down on mesh)
  37424. */
  37425. onDragStartObservable: Observable<{
  37426. dragPlanePoint: Vector3;
  37427. pointerId: number;
  37428. }>;
  37429. /**
  37430. * Fires each time a drag ends (eg. mouse release after drag)
  37431. */
  37432. onDragEndObservable: Observable<{
  37433. dragPlanePoint: Vector3;
  37434. pointerId: number;
  37435. }>;
  37436. /**
  37437. * If the attached mesh should be moved when dragged
  37438. */
  37439. moveAttached: boolean;
  37440. /**
  37441. * If the drag behavior will react to drag events (Default: true)
  37442. */
  37443. enabled: boolean;
  37444. /**
  37445. * If pointer events should start and release the drag (Default: true)
  37446. */
  37447. startAndReleaseDragOnPointerEvents: boolean;
  37448. /**
  37449. * If camera controls should be detached during the drag
  37450. */
  37451. detachCameraControls: boolean;
  37452. /**
  37453. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37454. */
  37455. useObjectOrienationForDragging: boolean;
  37456. private _options;
  37457. /**
  37458. * Creates a pointer drag behavior that can be attached to a mesh
  37459. * @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)
  37460. */
  37461. constructor(options?: {
  37462. dragAxis?: Vector3;
  37463. dragPlaneNormal?: Vector3;
  37464. });
  37465. /**
  37466. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37467. */
  37468. validateDrag: (targetPosition: Vector3) => boolean;
  37469. /**
  37470. * The name of the behavior
  37471. */
  37472. readonly name: string;
  37473. /**
  37474. * Initializes the behavior
  37475. */
  37476. init(): void;
  37477. private _tmpVector;
  37478. private _alternatePickedPoint;
  37479. private _worldDragAxis;
  37480. private _targetPosition;
  37481. private _attachedElement;
  37482. /**
  37483. * Attaches the drag behavior the passed in mesh
  37484. * @param ownerNode The mesh that will be dragged around once attached
  37485. * @param predicate Predicate to use for pick filtering
  37486. */
  37487. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37488. /**
  37489. * Force relase the drag action by code.
  37490. */
  37491. releaseDrag(): void;
  37492. private _startDragRay;
  37493. private _lastPointerRay;
  37494. /**
  37495. * Simulates the start of a pointer drag event on the behavior
  37496. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37497. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37498. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37499. */
  37500. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37501. private _startDrag;
  37502. private _dragDelta;
  37503. private _moveDrag;
  37504. private _pickWithRayOnDragPlane;
  37505. private _pointA;
  37506. private _pointB;
  37507. private _pointC;
  37508. private _lineA;
  37509. private _lineB;
  37510. private _localAxis;
  37511. private _lookAt;
  37512. private _updateDragPlanePosition;
  37513. /**
  37514. * Detaches the behavior from the mesh
  37515. */
  37516. detach(): void;
  37517. }
  37518. }
  37519. declare module BABYLON {
  37520. /**
  37521. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37522. */
  37523. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37524. private _dragBehaviorA;
  37525. private _dragBehaviorB;
  37526. private _startDistance;
  37527. private _initialScale;
  37528. private _targetScale;
  37529. private _ownerNode;
  37530. private _sceneRenderObserver;
  37531. /**
  37532. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37533. */
  37534. constructor();
  37535. /**
  37536. * The name of the behavior
  37537. */
  37538. readonly name: string;
  37539. /**
  37540. * Initializes the behavior
  37541. */
  37542. init(): void;
  37543. private _getCurrentDistance;
  37544. /**
  37545. * Attaches the scale behavior the passed in mesh
  37546. * @param ownerNode The mesh that will be scaled around once attached
  37547. */
  37548. attach(ownerNode: Mesh): void;
  37549. /**
  37550. * Detaches the behavior from the mesh
  37551. */
  37552. detach(): void;
  37553. }
  37554. }
  37555. declare module BABYLON {
  37556. /**
  37557. * 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
  37558. */
  37559. export class SixDofDragBehavior implements Behavior<Mesh> {
  37560. private static _virtualScene;
  37561. private _ownerNode;
  37562. private _sceneRenderObserver;
  37563. private _scene;
  37564. private _targetPosition;
  37565. private _virtualOriginMesh;
  37566. private _virtualDragMesh;
  37567. private _pointerObserver;
  37568. private _moving;
  37569. private _startingOrientation;
  37570. /**
  37571. * 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)
  37572. */
  37573. private zDragFactor;
  37574. /**
  37575. * If the object should rotate to face the drag origin
  37576. */
  37577. rotateDraggedObject: boolean;
  37578. /**
  37579. * If the behavior is currently in a dragging state
  37580. */
  37581. dragging: boolean;
  37582. /**
  37583. * 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)
  37584. */
  37585. dragDeltaRatio: number;
  37586. /**
  37587. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37588. */
  37589. currentDraggingPointerID: number;
  37590. /**
  37591. * If camera controls should be detached during the drag
  37592. */
  37593. detachCameraControls: boolean;
  37594. /**
  37595. * Fires each time a drag starts
  37596. */
  37597. onDragStartObservable: Observable<{}>;
  37598. /**
  37599. * Fires each time a drag ends (eg. mouse release after drag)
  37600. */
  37601. onDragEndObservable: Observable<{}>;
  37602. /**
  37603. * 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
  37604. */
  37605. constructor();
  37606. /**
  37607. * The name of the behavior
  37608. */
  37609. readonly name: string;
  37610. /**
  37611. * Initializes the behavior
  37612. */
  37613. init(): void;
  37614. /**
  37615. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37616. */
  37617. private readonly _pointerCamera;
  37618. /**
  37619. * Attaches the scale behavior the passed in mesh
  37620. * @param ownerNode The mesh that will be scaled around once attached
  37621. */
  37622. attach(ownerNode: Mesh): void;
  37623. /**
  37624. * Detaches the behavior from the mesh
  37625. */
  37626. detach(): void;
  37627. }
  37628. }
  37629. declare module BABYLON {
  37630. /**
  37631. * Class used to apply inverse kinematics to bones
  37632. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37633. */
  37634. export class BoneIKController {
  37635. private static _tmpVecs;
  37636. private static _tmpQuat;
  37637. private static _tmpMats;
  37638. /**
  37639. * Gets or sets the target mesh
  37640. */
  37641. targetMesh: AbstractMesh;
  37642. /** Gets or sets the mesh used as pole */
  37643. poleTargetMesh: AbstractMesh;
  37644. /**
  37645. * Gets or sets the bone used as pole
  37646. */
  37647. poleTargetBone: Nullable<Bone>;
  37648. /**
  37649. * Gets or sets the target position
  37650. */
  37651. targetPosition: Vector3;
  37652. /**
  37653. * Gets or sets the pole target position
  37654. */
  37655. poleTargetPosition: Vector3;
  37656. /**
  37657. * Gets or sets the pole target local offset
  37658. */
  37659. poleTargetLocalOffset: Vector3;
  37660. /**
  37661. * Gets or sets the pole angle
  37662. */
  37663. poleAngle: number;
  37664. /**
  37665. * Gets or sets the mesh associated with the controller
  37666. */
  37667. mesh: AbstractMesh;
  37668. /**
  37669. * 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)
  37670. */
  37671. slerpAmount: number;
  37672. private _bone1Quat;
  37673. private _bone1Mat;
  37674. private _bone2Ang;
  37675. private _bone1;
  37676. private _bone2;
  37677. private _bone1Length;
  37678. private _bone2Length;
  37679. private _maxAngle;
  37680. private _maxReach;
  37681. private _rightHandedSystem;
  37682. private _bendAxis;
  37683. private _slerping;
  37684. private _adjustRoll;
  37685. /**
  37686. * Gets or sets maximum allowed angle
  37687. */
  37688. maxAngle: number;
  37689. /**
  37690. * Creates a new BoneIKController
  37691. * @param mesh defines the mesh to control
  37692. * @param bone defines the bone to control
  37693. * @param options defines options to set up the controller
  37694. */
  37695. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37696. targetMesh?: AbstractMesh;
  37697. poleTargetMesh?: AbstractMesh;
  37698. poleTargetBone?: Bone;
  37699. poleTargetLocalOffset?: Vector3;
  37700. poleAngle?: number;
  37701. bendAxis?: Vector3;
  37702. maxAngle?: number;
  37703. slerpAmount?: number;
  37704. });
  37705. private _setMaxAngle;
  37706. /**
  37707. * Force the controller to update the bones
  37708. */
  37709. update(): void;
  37710. }
  37711. }
  37712. declare module BABYLON {
  37713. /**
  37714. * Class used to make a bone look toward a point in space
  37715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37716. */
  37717. export class BoneLookController {
  37718. private static _tmpVecs;
  37719. private static _tmpQuat;
  37720. private static _tmpMats;
  37721. /**
  37722. * The target Vector3 that the bone will look at
  37723. */
  37724. target: Vector3;
  37725. /**
  37726. * The mesh that the bone is attached to
  37727. */
  37728. mesh: AbstractMesh;
  37729. /**
  37730. * The bone that will be looking to the target
  37731. */
  37732. bone: Bone;
  37733. /**
  37734. * The up axis of the coordinate system that is used when the bone is rotated
  37735. */
  37736. upAxis: Vector3;
  37737. /**
  37738. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37739. */
  37740. upAxisSpace: Space;
  37741. /**
  37742. * Used to make an adjustment to the yaw of the bone
  37743. */
  37744. adjustYaw: number;
  37745. /**
  37746. * Used to make an adjustment to the pitch of the bone
  37747. */
  37748. adjustPitch: number;
  37749. /**
  37750. * Used to make an adjustment to the roll of the bone
  37751. */
  37752. adjustRoll: number;
  37753. /**
  37754. * 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)
  37755. */
  37756. slerpAmount: number;
  37757. private _minYaw;
  37758. private _maxYaw;
  37759. private _minPitch;
  37760. private _maxPitch;
  37761. private _minYawSin;
  37762. private _minYawCos;
  37763. private _maxYawSin;
  37764. private _maxYawCos;
  37765. private _midYawConstraint;
  37766. private _minPitchTan;
  37767. private _maxPitchTan;
  37768. private _boneQuat;
  37769. private _slerping;
  37770. private _transformYawPitch;
  37771. private _transformYawPitchInv;
  37772. private _firstFrameSkipped;
  37773. private _yawRange;
  37774. private _fowardAxis;
  37775. /**
  37776. * Gets or sets the minimum yaw angle that the bone can look to
  37777. */
  37778. minYaw: number;
  37779. /**
  37780. * Gets or sets the maximum yaw angle that the bone can look to
  37781. */
  37782. maxYaw: number;
  37783. /**
  37784. * Gets or sets the minimum pitch angle that the bone can look to
  37785. */
  37786. minPitch: number;
  37787. /**
  37788. * Gets or sets the maximum pitch angle that the bone can look to
  37789. */
  37790. maxPitch: number;
  37791. /**
  37792. * Create a BoneLookController
  37793. * @param mesh the mesh that the bone belongs to
  37794. * @param bone the bone that will be looking to the target
  37795. * @param target the target Vector3 to look at
  37796. * @param options optional settings:
  37797. * * maxYaw: the maximum angle the bone will yaw to
  37798. * * minYaw: the minimum angle the bone will yaw to
  37799. * * maxPitch: the maximum angle the bone will pitch to
  37800. * * minPitch: the minimum angle the bone will yaw to
  37801. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37802. * * upAxis: the up axis of the coordinate system
  37803. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37804. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37805. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37806. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37807. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37808. * * adjustRoll: used to make an adjustment to the roll of the bone
  37809. **/
  37810. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37811. maxYaw?: number;
  37812. minYaw?: number;
  37813. maxPitch?: number;
  37814. minPitch?: number;
  37815. slerpAmount?: number;
  37816. upAxis?: Vector3;
  37817. upAxisSpace?: Space;
  37818. yawAxis?: Vector3;
  37819. pitchAxis?: Vector3;
  37820. adjustYaw?: number;
  37821. adjustPitch?: number;
  37822. adjustRoll?: number;
  37823. });
  37824. /**
  37825. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37826. */
  37827. update(): void;
  37828. private _getAngleDiff;
  37829. private _getAngleBetween;
  37830. private _isAngleBetween;
  37831. }
  37832. }
  37833. declare module BABYLON {
  37834. /**
  37835. * Manage the gamepad inputs to control an arc rotate camera.
  37836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37837. */
  37838. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37839. /**
  37840. * Defines the camera the input is attached to.
  37841. */
  37842. camera: ArcRotateCamera;
  37843. /**
  37844. * Defines the gamepad the input is gathering event from.
  37845. */
  37846. gamepad: Nullable<Gamepad>;
  37847. /**
  37848. * Defines the gamepad rotation sensiblity.
  37849. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37850. */
  37851. gamepadRotationSensibility: number;
  37852. /**
  37853. * Defines the gamepad move sensiblity.
  37854. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37855. */
  37856. gamepadMoveSensibility: number;
  37857. private _yAxisScale;
  37858. /**
  37859. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37860. */
  37861. invertYAxis: boolean;
  37862. private _onGamepadConnectedObserver;
  37863. private _onGamepadDisconnectedObserver;
  37864. /**
  37865. * Attach the input controls to a specific dom element to get the input from.
  37866. * @param element Defines the element the controls should be listened from
  37867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37868. */
  37869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37870. /**
  37871. * Detach the current controls from the specified dom element.
  37872. * @param element Defines the element to stop listening the inputs from
  37873. */
  37874. detachControl(element: Nullable<HTMLElement>): void;
  37875. /**
  37876. * Update the current camera state depending on the inputs that have been used this frame.
  37877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37878. */
  37879. checkInputs(): void;
  37880. /**
  37881. * Gets the class name of the current intput.
  37882. * @returns the class name
  37883. */
  37884. getClassName(): string;
  37885. /**
  37886. * Get the friendly name associated with the input class.
  37887. * @returns the input friendly name
  37888. */
  37889. getSimpleName(): string;
  37890. }
  37891. }
  37892. declare module BABYLON {
  37893. interface ArcRotateCameraInputsManager {
  37894. /**
  37895. * Add orientation input support to the input manager.
  37896. * @returns the current input manager
  37897. */
  37898. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37899. }
  37900. /**
  37901. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37903. */
  37904. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37905. /**
  37906. * Defines the camera the input is attached to.
  37907. */
  37908. camera: ArcRotateCamera;
  37909. /**
  37910. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37911. */
  37912. alphaCorrection: number;
  37913. /**
  37914. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37915. */
  37916. gammaCorrection: number;
  37917. private _alpha;
  37918. private _gamma;
  37919. private _dirty;
  37920. private _deviceOrientationHandler;
  37921. /**
  37922. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37923. */
  37924. constructor();
  37925. /**
  37926. * Attach the input controls to a specific dom element to get the input from.
  37927. * @param element Defines the element the controls should be listened from
  37928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37929. */
  37930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37931. /** @hidden */
  37932. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37933. /**
  37934. * Update the current camera state depending on the inputs that have been used this frame.
  37935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37936. */
  37937. checkInputs(): void;
  37938. /**
  37939. * Detach the current controls from the specified dom element.
  37940. * @param element Defines the element to stop listening the inputs from
  37941. */
  37942. detachControl(element: Nullable<HTMLElement>): void;
  37943. /**
  37944. * Gets the class name of the current intput.
  37945. * @returns the class name
  37946. */
  37947. getClassName(): string;
  37948. /**
  37949. * Get the friendly name associated with the input class.
  37950. * @returns the input friendly name
  37951. */
  37952. getSimpleName(): string;
  37953. }
  37954. }
  37955. declare module BABYLON {
  37956. /**
  37957. * Listen to mouse events to control the camera.
  37958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37959. */
  37960. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37961. /**
  37962. * Defines the camera the input is attached to.
  37963. */
  37964. camera: FlyCamera;
  37965. /**
  37966. * Defines if touch is enabled. (Default is true.)
  37967. */
  37968. touchEnabled: boolean;
  37969. /**
  37970. * Defines the buttons associated with the input to handle camera rotation.
  37971. */
  37972. buttons: number[];
  37973. /**
  37974. * Assign buttons for Yaw control.
  37975. */
  37976. buttonsYaw: number[];
  37977. /**
  37978. * Assign buttons for Pitch control.
  37979. */
  37980. buttonsPitch: number[];
  37981. /**
  37982. * Assign buttons for Roll control.
  37983. */
  37984. buttonsRoll: number[];
  37985. /**
  37986. * Detect if any button is being pressed while mouse is moved.
  37987. * -1 = Mouse locked.
  37988. * 0 = Left button.
  37989. * 1 = Middle Button.
  37990. * 2 = Right Button.
  37991. */
  37992. activeButton: number;
  37993. /**
  37994. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37995. * Higher values reduce its sensitivity.
  37996. */
  37997. angularSensibility: number;
  37998. private _mousemoveCallback;
  37999. private _observer;
  38000. private _rollObserver;
  38001. private previousPosition;
  38002. private noPreventDefault;
  38003. private element;
  38004. /**
  38005. * Listen to mouse events to control the camera.
  38006. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38008. */
  38009. constructor(touchEnabled?: boolean);
  38010. /**
  38011. * Attach the mouse control to the HTML DOM element.
  38012. * @param element Defines the element that listens to the input events.
  38013. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38014. */
  38015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38016. /**
  38017. * Detach the current controls from the specified dom element.
  38018. * @param element Defines the element to stop listening the inputs from
  38019. */
  38020. detachControl(element: Nullable<HTMLElement>): void;
  38021. /**
  38022. * Gets the class name of the current input.
  38023. * @returns the class name.
  38024. */
  38025. getClassName(): string;
  38026. /**
  38027. * Get the friendly name associated with the input class.
  38028. * @returns the input's friendly name.
  38029. */
  38030. getSimpleName(): string;
  38031. private _pointerInput;
  38032. private _onMouseMove;
  38033. /**
  38034. * Rotate camera by mouse offset.
  38035. */
  38036. private rotateCamera;
  38037. }
  38038. }
  38039. declare module BABYLON {
  38040. /**
  38041. * Default Inputs manager for the FlyCamera.
  38042. * It groups all the default supported inputs for ease of use.
  38043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38044. */
  38045. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38046. /**
  38047. * Instantiates a new FlyCameraInputsManager.
  38048. * @param camera Defines the camera the inputs belong to.
  38049. */
  38050. constructor(camera: FlyCamera);
  38051. /**
  38052. * Add keyboard input support to the input manager.
  38053. * @returns the new FlyCameraKeyboardMoveInput().
  38054. */
  38055. addKeyboard(): FlyCameraInputsManager;
  38056. /**
  38057. * Add mouse input support to the input manager.
  38058. * @param touchEnabled Enable touch screen support.
  38059. * @returns the new FlyCameraMouseInput().
  38060. */
  38061. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38062. }
  38063. }
  38064. declare module BABYLON {
  38065. /**
  38066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38067. * such as in a 3D Space Shooter or a Flight Simulator.
  38068. */
  38069. export class FlyCamera extends TargetCamera {
  38070. /**
  38071. * Define the collision ellipsoid of the camera.
  38072. * This is helpful for simulating a camera body, like a player's body.
  38073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38074. */
  38075. ellipsoid: Vector3;
  38076. /**
  38077. * Define an offset for the position of the ellipsoid around the camera.
  38078. * This can be helpful if the camera is attached away from the player's body center,
  38079. * such as at its head.
  38080. */
  38081. ellipsoidOffset: Vector3;
  38082. /**
  38083. * Enable or disable collisions of the camera with the rest of the scene objects.
  38084. */
  38085. checkCollisions: boolean;
  38086. /**
  38087. * Enable or disable gravity on the camera.
  38088. */
  38089. applyGravity: boolean;
  38090. /**
  38091. * Define the current direction the camera is moving to.
  38092. */
  38093. cameraDirection: Vector3;
  38094. /**
  38095. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38096. * This overrides and empties cameraRotation.
  38097. */
  38098. rotationQuaternion: Quaternion;
  38099. /**
  38100. * Track Roll to maintain the wanted Rolling when looking around.
  38101. */
  38102. _trackRoll: number;
  38103. /**
  38104. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38105. */
  38106. rollCorrect: number;
  38107. /**
  38108. * Mimic a banked turn, Rolling the camera when Yawing.
  38109. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38110. */
  38111. bankedTurn: boolean;
  38112. /**
  38113. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38114. */
  38115. bankedTurnLimit: number;
  38116. /**
  38117. * Value of 0 disables the banked Roll.
  38118. * Value of 1 is equal to the Yaw angle in radians.
  38119. */
  38120. bankedTurnMultiplier: number;
  38121. /**
  38122. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38123. */
  38124. inputs: FlyCameraInputsManager;
  38125. /**
  38126. * Gets the input sensibility for mouse input.
  38127. * Higher values reduce sensitivity.
  38128. */
  38129. /**
  38130. * Sets the input sensibility for a mouse input.
  38131. * Higher values reduce sensitivity.
  38132. */
  38133. angularSensibility: number;
  38134. /**
  38135. * Get the keys for camera movement forward.
  38136. */
  38137. /**
  38138. * Set the keys for camera movement forward.
  38139. */
  38140. keysForward: number[];
  38141. /**
  38142. * Get the keys for camera movement backward.
  38143. */
  38144. keysBackward: number[];
  38145. /**
  38146. * Get the keys for camera movement up.
  38147. */
  38148. /**
  38149. * Set the keys for camera movement up.
  38150. */
  38151. keysUp: number[];
  38152. /**
  38153. * Get the keys for camera movement down.
  38154. */
  38155. /**
  38156. * Set the keys for camera movement down.
  38157. */
  38158. keysDown: number[];
  38159. /**
  38160. * Get the keys for camera movement left.
  38161. */
  38162. /**
  38163. * Set the keys for camera movement left.
  38164. */
  38165. keysLeft: number[];
  38166. /**
  38167. * Set the keys for camera movement right.
  38168. */
  38169. /**
  38170. * Set the keys for camera movement right.
  38171. */
  38172. keysRight: number[];
  38173. /**
  38174. * Event raised when the camera collides with a mesh in the scene.
  38175. */
  38176. onCollide: (collidedMesh: AbstractMesh) => void;
  38177. private _collider;
  38178. private _needMoveForGravity;
  38179. private _oldPosition;
  38180. private _diffPosition;
  38181. private _newPosition;
  38182. /** @hidden */
  38183. _localDirection: Vector3;
  38184. /** @hidden */
  38185. _transformedDirection: Vector3;
  38186. /**
  38187. * Instantiates a FlyCamera.
  38188. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38189. * such as in a 3D Space Shooter or a Flight Simulator.
  38190. * @param name Define the name of the camera in the scene.
  38191. * @param position Define the starting position of the camera in the scene.
  38192. * @param scene Define the scene the camera belongs to.
  38193. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38194. */
  38195. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38196. /**
  38197. * Attach a control to the HTML DOM element.
  38198. * @param element Defines the element that listens to the input events.
  38199. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38200. */
  38201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38202. /**
  38203. * Detach a control from the HTML DOM element.
  38204. * The camera will stop reacting to that input.
  38205. * @param element Defines the element that listens to the input events.
  38206. */
  38207. detachControl(element: HTMLElement): void;
  38208. private _collisionMask;
  38209. /**
  38210. * Get the mask that the camera ignores in collision events.
  38211. */
  38212. /**
  38213. * Set the mask that the camera ignores in collision events.
  38214. */
  38215. collisionMask: number;
  38216. /** @hidden */
  38217. _collideWithWorld(displacement: Vector3): void;
  38218. /** @hidden */
  38219. private _onCollisionPositionChange;
  38220. /** @hidden */
  38221. _checkInputs(): void;
  38222. /** @hidden */
  38223. _decideIfNeedsToMove(): boolean;
  38224. /** @hidden */
  38225. _updatePosition(): void;
  38226. /**
  38227. * Restore the Roll to its target value at the rate specified.
  38228. * @param rate - Higher means slower restoring.
  38229. * @hidden
  38230. */
  38231. restoreRoll(rate: number): void;
  38232. /**
  38233. * Destroy the camera and release the current resources held by it.
  38234. */
  38235. dispose(): void;
  38236. /**
  38237. * Get the current object class name.
  38238. * @returns the class name.
  38239. */
  38240. getClassName(): string;
  38241. }
  38242. }
  38243. declare module BABYLON {
  38244. /**
  38245. * Listen to keyboard events to control the camera.
  38246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38247. */
  38248. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38249. /**
  38250. * Defines the camera the input is attached to.
  38251. */
  38252. camera: FlyCamera;
  38253. /**
  38254. * The list of keyboard keys used to control the forward move of the camera.
  38255. */
  38256. keysForward: number[];
  38257. /**
  38258. * The list of keyboard keys used to control the backward move of the camera.
  38259. */
  38260. keysBackward: number[];
  38261. /**
  38262. * The list of keyboard keys used to control the forward move of the camera.
  38263. */
  38264. keysUp: number[];
  38265. /**
  38266. * The list of keyboard keys used to control the backward move of the camera.
  38267. */
  38268. keysDown: number[];
  38269. /**
  38270. * The list of keyboard keys used to control the right strafe move of the camera.
  38271. */
  38272. keysRight: number[];
  38273. /**
  38274. * The list of keyboard keys used to control the left strafe move of the camera.
  38275. */
  38276. keysLeft: number[];
  38277. private _keys;
  38278. private _onCanvasBlurObserver;
  38279. private _onKeyboardObserver;
  38280. private _engine;
  38281. private _scene;
  38282. /**
  38283. * Attach the input controls to a specific dom element to get the input from.
  38284. * @param element Defines the element the controls should be listened from
  38285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38286. */
  38287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38288. /**
  38289. * Detach the current controls from the specified dom element.
  38290. * @param element Defines the element to stop listening the inputs from
  38291. */
  38292. detachControl(element: Nullable<HTMLElement>): void;
  38293. /**
  38294. * Gets the class name of the current intput.
  38295. * @returns the class name
  38296. */
  38297. getClassName(): string;
  38298. /** @hidden */
  38299. _onLostFocus(e: FocusEvent): void;
  38300. /**
  38301. * Get the friendly name associated with the input class.
  38302. * @returns the input friendly name
  38303. */
  38304. getSimpleName(): string;
  38305. /**
  38306. * Update the current camera state depending on the inputs that have been used this frame.
  38307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38308. */
  38309. checkInputs(): void;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /**
  38314. * Manage the mouse wheel inputs to control a follow camera.
  38315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38316. */
  38317. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38318. /**
  38319. * Defines the camera the input is attached to.
  38320. */
  38321. camera: FollowCamera;
  38322. /**
  38323. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38324. */
  38325. axisControlRadius: boolean;
  38326. /**
  38327. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38328. */
  38329. axisControlHeight: boolean;
  38330. /**
  38331. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38332. */
  38333. axisControlRotation: boolean;
  38334. /**
  38335. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38336. * relation to mouseWheel events.
  38337. */
  38338. wheelPrecision: number;
  38339. /**
  38340. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38341. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38342. */
  38343. wheelDeltaPercentage: number;
  38344. private _wheel;
  38345. private _observer;
  38346. /**
  38347. * Attach the input controls to a specific dom element to get the input from.
  38348. * @param element Defines the element the controls should be listened from
  38349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38350. */
  38351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38352. /**
  38353. * Detach the current controls from the specified dom element.
  38354. * @param element Defines the element to stop listening the inputs from
  38355. */
  38356. detachControl(element: Nullable<HTMLElement>): void;
  38357. /**
  38358. * Gets the class name of the current intput.
  38359. * @returns the class name
  38360. */
  38361. getClassName(): string;
  38362. /**
  38363. * Get the friendly name associated with the input class.
  38364. * @returns the input friendly name
  38365. */
  38366. getSimpleName(): string;
  38367. }
  38368. }
  38369. declare module BABYLON {
  38370. /**
  38371. * Manage the pointers inputs to control an follow camera.
  38372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38373. */
  38374. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38375. /**
  38376. * Defines the camera the input is attached to.
  38377. */
  38378. camera: FollowCamera;
  38379. /**
  38380. * Gets the class name of the current input.
  38381. * @returns the class name
  38382. */
  38383. getClassName(): string;
  38384. /**
  38385. * Defines the pointer angular sensibility along the X axis or how fast is
  38386. * the camera rotating.
  38387. * A negative number will reverse the axis direction.
  38388. */
  38389. angularSensibilityX: number;
  38390. /**
  38391. * Defines the pointer angular sensibility along the Y axis or how fast is
  38392. * the camera rotating.
  38393. * A negative number will reverse the axis direction.
  38394. */
  38395. angularSensibilityY: number;
  38396. /**
  38397. * Defines the pointer pinch precision or how fast is the camera zooming.
  38398. * A negative number will reverse the axis direction.
  38399. */
  38400. pinchPrecision: number;
  38401. /**
  38402. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38403. * from 0.
  38404. * It defines the percentage of current camera.radius to use as delta when
  38405. * pinch zoom is used.
  38406. */
  38407. pinchDeltaPercentage: number;
  38408. /**
  38409. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38410. */
  38411. axisXControlRadius: boolean;
  38412. /**
  38413. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38414. */
  38415. axisXControlHeight: boolean;
  38416. /**
  38417. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38418. */
  38419. axisXControlRotation: boolean;
  38420. /**
  38421. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38422. */
  38423. axisYControlRadius: boolean;
  38424. /**
  38425. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38426. */
  38427. axisYControlHeight: boolean;
  38428. /**
  38429. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38430. */
  38431. axisYControlRotation: boolean;
  38432. /**
  38433. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38434. */
  38435. axisPinchControlRadius: boolean;
  38436. /**
  38437. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38438. */
  38439. axisPinchControlHeight: boolean;
  38440. /**
  38441. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38442. */
  38443. axisPinchControlRotation: boolean;
  38444. /**
  38445. * Log error messages if basic misconfiguration has occurred.
  38446. */
  38447. warningEnable: boolean;
  38448. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38449. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38450. private _warningCounter;
  38451. private _warning;
  38452. }
  38453. }
  38454. declare module BABYLON {
  38455. /**
  38456. * Default Inputs manager for the FollowCamera.
  38457. * It groups all the default supported inputs for ease of use.
  38458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38459. */
  38460. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38461. /**
  38462. * Instantiates a new FollowCameraInputsManager.
  38463. * @param camera Defines the camera the inputs belong to
  38464. */
  38465. constructor(camera: FollowCamera);
  38466. /**
  38467. * Add keyboard input support to the input manager.
  38468. * @returns the current input manager
  38469. */
  38470. addKeyboard(): FollowCameraInputsManager;
  38471. /**
  38472. * Add mouse wheel input support to the input manager.
  38473. * @returns the current input manager
  38474. */
  38475. addMouseWheel(): FollowCameraInputsManager;
  38476. /**
  38477. * Add pointers input support to the input manager.
  38478. * @returns the current input manager
  38479. */
  38480. addPointers(): FollowCameraInputsManager;
  38481. /**
  38482. * Add orientation input support to the input manager.
  38483. * @returns the current input manager
  38484. */
  38485. addVRDeviceOrientation(): FollowCameraInputsManager;
  38486. }
  38487. }
  38488. declare module BABYLON {
  38489. /**
  38490. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38491. * an arc rotate version arcFollowCamera are available.
  38492. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38493. */
  38494. export class FollowCamera extends TargetCamera {
  38495. /**
  38496. * Distance the follow camera should follow an object at
  38497. */
  38498. radius: number;
  38499. /**
  38500. * Minimum allowed distance of the camera to the axis of rotation
  38501. * (The camera can not get closer).
  38502. * This can help limiting how the Camera is able to move in the scene.
  38503. */
  38504. lowerRadiusLimit: Nullable<number>;
  38505. /**
  38506. * Maximum allowed distance of the camera to the axis of rotation
  38507. * (The camera can not get further).
  38508. * This can help limiting how the Camera is able to move in the scene.
  38509. */
  38510. upperRadiusLimit: Nullable<number>;
  38511. /**
  38512. * Define a rotation offset between the camera and the object it follows
  38513. */
  38514. rotationOffset: number;
  38515. /**
  38516. * Minimum allowed angle to camera position relative to target object.
  38517. * This can help limiting how the Camera is able to move in the scene.
  38518. */
  38519. lowerRotationOffsetLimit: Nullable<number>;
  38520. /**
  38521. * Maximum allowed angle to camera position relative to target object.
  38522. * This can help limiting how the Camera is able to move in the scene.
  38523. */
  38524. upperRotationOffsetLimit: Nullable<number>;
  38525. /**
  38526. * Define a height offset between the camera and the object it follows.
  38527. * It can help following an object from the top (like a car chaing a plane)
  38528. */
  38529. heightOffset: number;
  38530. /**
  38531. * Minimum allowed height of camera position relative to target object.
  38532. * This can help limiting how the Camera is able to move in the scene.
  38533. */
  38534. lowerHeightOffsetLimit: Nullable<number>;
  38535. /**
  38536. * Maximum allowed height of camera position relative to target object.
  38537. * This can help limiting how the Camera is able to move in the scene.
  38538. */
  38539. upperHeightOffsetLimit: Nullable<number>;
  38540. /**
  38541. * Define how fast the camera can accelerate to follow it s target.
  38542. */
  38543. cameraAcceleration: number;
  38544. /**
  38545. * Define the speed limit of the camera following an object.
  38546. */
  38547. maxCameraSpeed: number;
  38548. /**
  38549. * Define the target of the camera.
  38550. */
  38551. lockedTarget: Nullable<AbstractMesh>;
  38552. /**
  38553. * Defines the input associated with the camera.
  38554. */
  38555. inputs: FollowCameraInputsManager;
  38556. /**
  38557. * Instantiates the follow camera.
  38558. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38559. * @param name Define the name of the camera in the scene
  38560. * @param position Define the position of the camera
  38561. * @param scene Define the scene the camera belong to
  38562. * @param lockedTarget Define the target of the camera
  38563. */
  38564. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38565. private _follow;
  38566. /**
  38567. * Attached controls to the current camera.
  38568. * @param element Defines the element the controls should be listened from
  38569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38570. */
  38571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38572. /**
  38573. * Detach the current controls from the camera.
  38574. * The camera will stop reacting to inputs.
  38575. * @param element Defines the element to stop listening the inputs from
  38576. */
  38577. detachControl(element: HTMLElement): void;
  38578. /** @hidden */
  38579. _checkInputs(): void;
  38580. private _checkLimits;
  38581. /**
  38582. * Gets the camera class name.
  38583. * @returns the class name
  38584. */
  38585. getClassName(): string;
  38586. }
  38587. /**
  38588. * Arc Rotate version of the follow camera.
  38589. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38590. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38591. */
  38592. export class ArcFollowCamera extends TargetCamera {
  38593. /** The longitudinal angle of the camera */
  38594. alpha: number;
  38595. /** The latitudinal angle of the camera */
  38596. beta: number;
  38597. /** The radius of the camera from its target */
  38598. radius: number;
  38599. /** Define the camera target (the messh it should follow) */
  38600. target: Nullable<AbstractMesh>;
  38601. private _cartesianCoordinates;
  38602. /**
  38603. * Instantiates a new ArcFollowCamera
  38604. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38605. * @param name Define the name of the camera
  38606. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38607. * @param beta Define the rotation angle of the camera around the elevation axis
  38608. * @param radius Define the radius of the camera from its target point
  38609. * @param target Define the target of the camera
  38610. * @param scene Define the scene the camera belongs to
  38611. */
  38612. constructor(name: string,
  38613. /** The longitudinal angle of the camera */
  38614. alpha: number,
  38615. /** The latitudinal angle of the camera */
  38616. beta: number,
  38617. /** The radius of the camera from its target */
  38618. radius: number,
  38619. /** Define the camera target (the messh it should follow) */
  38620. target: Nullable<AbstractMesh>, scene: Scene);
  38621. private _follow;
  38622. /** @hidden */
  38623. _checkInputs(): void;
  38624. /**
  38625. * Returns the class name of the object.
  38626. * It is mostly used internally for serialization purposes.
  38627. */
  38628. getClassName(): string;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. /**
  38633. * Manage the keyboard inputs to control the movement of a follow camera.
  38634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38635. */
  38636. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38637. /**
  38638. * Defines the camera the input is attached to.
  38639. */
  38640. camera: FollowCamera;
  38641. /**
  38642. * Defines the list of key codes associated with the up action (increase heightOffset)
  38643. */
  38644. keysHeightOffsetIncr: number[];
  38645. /**
  38646. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38647. */
  38648. keysHeightOffsetDecr: number[];
  38649. /**
  38650. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38651. */
  38652. keysHeightOffsetModifierAlt: boolean;
  38653. /**
  38654. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38655. */
  38656. keysHeightOffsetModifierCtrl: boolean;
  38657. /**
  38658. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38659. */
  38660. keysHeightOffsetModifierShift: boolean;
  38661. /**
  38662. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38663. */
  38664. keysRotationOffsetIncr: number[];
  38665. /**
  38666. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38667. */
  38668. keysRotationOffsetDecr: number[];
  38669. /**
  38670. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38671. */
  38672. keysRotationOffsetModifierAlt: boolean;
  38673. /**
  38674. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38675. */
  38676. keysRotationOffsetModifierCtrl: boolean;
  38677. /**
  38678. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38679. */
  38680. keysRotationOffsetModifierShift: boolean;
  38681. /**
  38682. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38683. */
  38684. keysRadiusIncr: number[];
  38685. /**
  38686. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38687. */
  38688. keysRadiusDecr: number[];
  38689. /**
  38690. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38691. */
  38692. keysRadiusModifierAlt: boolean;
  38693. /**
  38694. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38695. */
  38696. keysRadiusModifierCtrl: boolean;
  38697. /**
  38698. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38699. */
  38700. keysRadiusModifierShift: boolean;
  38701. /**
  38702. * Defines the rate of change of heightOffset.
  38703. */
  38704. heightSensibility: number;
  38705. /**
  38706. * Defines the rate of change of rotationOffset.
  38707. */
  38708. rotationSensibility: number;
  38709. /**
  38710. * Defines the rate of change of radius.
  38711. */
  38712. radiusSensibility: number;
  38713. private _keys;
  38714. private _ctrlPressed;
  38715. private _altPressed;
  38716. private _shiftPressed;
  38717. private _onCanvasBlurObserver;
  38718. private _onKeyboardObserver;
  38719. private _engine;
  38720. private _scene;
  38721. /**
  38722. * Attach the input controls to a specific dom element to get the input from.
  38723. * @param element Defines the element the controls should be listened from
  38724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38725. */
  38726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38727. /**
  38728. * Detach the current controls from the specified dom element.
  38729. * @param element Defines the element to stop listening the inputs from
  38730. */
  38731. detachControl(element: Nullable<HTMLElement>): void;
  38732. /**
  38733. * Update the current camera state depending on the inputs that have been used this frame.
  38734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38735. */
  38736. checkInputs(): void;
  38737. /**
  38738. * Gets the class name of the current input.
  38739. * @returns the class name
  38740. */
  38741. getClassName(): string;
  38742. /**
  38743. * Get the friendly name associated with the input class.
  38744. * @returns the input friendly name
  38745. */
  38746. getSimpleName(): string;
  38747. /**
  38748. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38749. * allow modification of the heightOffset value.
  38750. */
  38751. private _modifierHeightOffset;
  38752. /**
  38753. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38754. * allow modification of the rotationOffset value.
  38755. */
  38756. private _modifierRotationOffset;
  38757. /**
  38758. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38759. * allow modification of the radius value.
  38760. */
  38761. private _modifierRadius;
  38762. }
  38763. }
  38764. declare module BABYLON {
  38765. interface FreeCameraInputsManager {
  38766. /**
  38767. * @hidden
  38768. */
  38769. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38770. /**
  38771. * Add orientation input support to the input manager.
  38772. * @returns the current input manager
  38773. */
  38774. addDeviceOrientation(): FreeCameraInputsManager;
  38775. }
  38776. /**
  38777. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38778. * Screen rotation is taken into account.
  38779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38780. */
  38781. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38782. private _camera;
  38783. private _screenOrientationAngle;
  38784. private _constantTranform;
  38785. private _screenQuaternion;
  38786. private _alpha;
  38787. private _beta;
  38788. private _gamma;
  38789. /**
  38790. * Can be used to detect if a device orientation sensor is availible on a device
  38791. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38792. * @returns a promise that will resolve on orientation change
  38793. */
  38794. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38795. /**
  38796. * @hidden
  38797. */
  38798. _onDeviceOrientationChangedObservable: Observable<void>;
  38799. /**
  38800. * Instantiates a new input
  38801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38802. */
  38803. constructor();
  38804. /**
  38805. * Define the camera controlled by the input.
  38806. */
  38807. camera: FreeCamera;
  38808. /**
  38809. * Attach the input controls to a specific dom element to get the input from.
  38810. * @param element Defines the element the controls should be listened from
  38811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38812. */
  38813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38814. private _orientationChanged;
  38815. private _deviceOrientation;
  38816. /**
  38817. * Detach the current controls from the specified dom element.
  38818. * @param element Defines the element to stop listening the inputs from
  38819. */
  38820. detachControl(element: Nullable<HTMLElement>): void;
  38821. /**
  38822. * Update the current camera state depending on the inputs that have been used this frame.
  38823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38824. */
  38825. checkInputs(): void;
  38826. /**
  38827. * Gets the class name of the current intput.
  38828. * @returns the class name
  38829. */
  38830. getClassName(): string;
  38831. /**
  38832. * Get the friendly name associated with the input class.
  38833. * @returns the input friendly name
  38834. */
  38835. getSimpleName(): string;
  38836. }
  38837. }
  38838. declare module BABYLON {
  38839. /**
  38840. * Manage the gamepad inputs to control a free camera.
  38841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38842. */
  38843. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38844. /**
  38845. * Define the camera the input is attached to.
  38846. */
  38847. camera: FreeCamera;
  38848. /**
  38849. * Define the Gamepad controlling the input
  38850. */
  38851. gamepad: Nullable<Gamepad>;
  38852. /**
  38853. * Defines the gamepad rotation sensiblity.
  38854. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38855. */
  38856. gamepadAngularSensibility: number;
  38857. /**
  38858. * Defines the gamepad move sensiblity.
  38859. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38860. */
  38861. gamepadMoveSensibility: number;
  38862. private _yAxisScale;
  38863. /**
  38864. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38865. */
  38866. invertYAxis: boolean;
  38867. private _onGamepadConnectedObserver;
  38868. private _onGamepadDisconnectedObserver;
  38869. private _cameraTransform;
  38870. private _deltaTransform;
  38871. private _vector3;
  38872. private _vector2;
  38873. /**
  38874. * Attach the input controls to a specific dom element to get the input from.
  38875. * @param element Defines the element the controls should be listened from
  38876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38877. */
  38878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38879. /**
  38880. * Detach the current controls from the specified dom element.
  38881. * @param element Defines the element to stop listening the inputs from
  38882. */
  38883. detachControl(element: Nullable<HTMLElement>): void;
  38884. /**
  38885. * Update the current camera state depending on the inputs that have been used this frame.
  38886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38887. */
  38888. checkInputs(): void;
  38889. /**
  38890. * Gets the class name of the current intput.
  38891. * @returns the class name
  38892. */
  38893. getClassName(): string;
  38894. /**
  38895. * Get the friendly name associated with the input class.
  38896. * @returns the input friendly name
  38897. */
  38898. getSimpleName(): string;
  38899. }
  38900. }
  38901. declare module BABYLON {
  38902. /**
  38903. * Defines the potential axis of a Joystick
  38904. */
  38905. export enum JoystickAxis {
  38906. /** X axis */
  38907. X = 0,
  38908. /** Y axis */
  38909. Y = 1,
  38910. /** Z axis */
  38911. Z = 2
  38912. }
  38913. /**
  38914. * Class used to define virtual joystick (used in touch mode)
  38915. */
  38916. export class VirtualJoystick {
  38917. /**
  38918. * Gets or sets a boolean indicating that left and right values must be inverted
  38919. */
  38920. reverseLeftRight: boolean;
  38921. /**
  38922. * Gets or sets a boolean indicating that up and down values must be inverted
  38923. */
  38924. reverseUpDown: boolean;
  38925. /**
  38926. * Gets the offset value for the position (ie. the change of the position value)
  38927. */
  38928. deltaPosition: Vector3;
  38929. /**
  38930. * Gets a boolean indicating if the virtual joystick was pressed
  38931. */
  38932. pressed: boolean;
  38933. /**
  38934. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38935. */
  38936. static Canvas: Nullable<HTMLCanvasElement>;
  38937. private static _globalJoystickIndex;
  38938. private static vjCanvasContext;
  38939. private static vjCanvasWidth;
  38940. private static vjCanvasHeight;
  38941. private static halfWidth;
  38942. private _action;
  38943. private _axisTargetedByLeftAndRight;
  38944. private _axisTargetedByUpAndDown;
  38945. private _joystickSensibility;
  38946. private _inversedSensibility;
  38947. private _joystickPointerID;
  38948. private _joystickColor;
  38949. private _joystickPointerPos;
  38950. private _joystickPreviousPointerPos;
  38951. private _joystickPointerStartPos;
  38952. private _deltaJoystickVector;
  38953. private _leftJoystick;
  38954. private _touches;
  38955. private _onPointerDownHandlerRef;
  38956. private _onPointerMoveHandlerRef;
  38957. private _onPointerUpHandlerRef;
  38958. private _onResize;
  38959. /**
  38960. * Creates a new virtual joystick
  38961. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38962. */
  38963. constructor(leftJoystick?: boolean);
  38964. /**
  38965. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38966. * @param newJoystickSensibility defines the new sensibility
  38967. */
  38968. setJoystickSensibility(newJoystickSensibility: number): void;
  38969. private _onPointerDown;
  38970. private _onPointerMove;
  38971. private _onPointerUp;
  38972. /**
  38973. * Change the color of the virtual joystick
  38974. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38975. */
  38976. setJoystickColor(newColor: string): void;
  38977. /**
  38978. * Defines a callback to call when the joystick is touched
  38979. * @param action defines the callback
  38980. */
  38981. setActionOnTouch(action: () => any): void;
  38982. /**
  38983. * Defines which axis you'd like to control for left & right
  38984. * @param axis defines the axis to use
  38985. */
  38986. setAxisForLeftRight(axis: JoystickAxis): void;
  38987. /**
  38988. * Defines which axis you'd like to control for up & down
  38989. * @param axis defines the axis to use
  38990. */
  38991. setAxisForUpDown(axis: JoystickAxis): void;
  38992. private _drawVirtualJoystick;
  38993. /**
  38994. * Release internal HTML canvas
  38995. */
  38996. releaseCanvas(): void;
  38997. }
  38998. }
  38999. declare module BABYLON {
  39000. interface FreeCameraInputsManager {
  39001. /**
  39002. * Add virtual joystick input support to the input manager.
  39003. * @returns the current input manager
  39004. */
  39005. addVirtualJoystick(): FreeCameraInputsManager;
  39006. }
  39007. /**
  39008. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39010. */
  39011. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39012. /**
  39013. * Defines the camera the input is attached to.
  39014. */
  39015. camera: FreeCamera;
  39016. private _leftjoystick;
  39017. private _rightjoystick;
  39018. /**
  39019. * Gets the left stick of the virtual joystick.
  39020. * @returns The virtual Joystick
  39021. */
  39022. getLeftJoystick(): VirtualJoystick;
  39023. /**
  39024. * Gets the right stick of the virtual joystick.
  39025. * @returns The virtual Joystick
  39026. */
  39027. getRightJoystick(): VirtualJoystick;
  39028. /**
  39029. * Update the current camera state depending on the inputs that have been used this frame.
  39030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39031. */
  39032. checkInputs(): void;
  39033. /**
  39034. * Attach the input controls to a specific dom element to get the input from.
  39035. * @param element Defines the element the controls should be listened from
  39036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39037. */
  39038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39039. /**
  39040. * Detach the current controls from the specified dom element.
  39041. * @param element Defines the element to stop listening the inputs from
  39042. */
  39043. detachControl(element: Nullable<HTMLElement>): void;
  39044. /**
  39045. * Gets the class name of the current intput.
  39046. * @returns the class name
  39047. */
  39048. getClassName(): string;
  39049. /**
  39050. * Get the friendly name associated with the input class.
  39051. * @returns the input friendly name
  39052. */
  39053. getSimpleName(): string;
  39054. }
  39055. }
  39056. declare module BABYLON {
  39057. /**
  39058. * This represents a FPS type of camera controlled by touch.
  39059. * This is like a universal camera minus the Gamepad controls.
  39060. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39061. */
  39062. export class TouchCamera extends FreeCamera {
  39063. /**
  39064. * Defines the touch sensibility for rotation.
  39065. * The higher the faster.
  39066. */
  39067. touchAngularSensibility: number;
  39068. /**
  39069. * Defines the touch sensibility for move.
  39070. * The higher the faster.
  39071. */
  39072. touchMoveSensibility: number;
  39073. /**
  39074. * Instantiates a new touch camera.
  39075. * This represents a FPS type of camera controlled by touch.
  39076. * This is like a universal camera minus the Gamepad controls.
  39077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39078. * @param name Define the name of the camera in the scene
  39079. * @param position Define the start position of the camera in the scene
  39080. * @param scene Define the scene the camera belongs to
  39081. */
  39082. constructor(name: string, position: Vector3, scene: Scene);
  39083. /**
  39084. * Gets the current object class name.
  39085. * @return the class name
  39086. */
  39087. getClassName(): string;
  39088. /** @hidden */
  39089. _setupInputs(): void;
  39090. }
  39091. }
  39092. declare module BABYLON {
  39093. /**
  39094. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39095. * being tilted forward or back and left or right.
  39096. */
  39097. export class DeviceOrientationCamera extends FreeCamera {
  39098. private _initialQuaternion;
  39099. private _quaternionCache;
  39100. private _tmpDragQuaternion;
  39101. private _disablePointerInputWhenUsingDeviceOrientation;
  39102. /**
  39103. * Creates a new device orientation camera
  39104. * @param name The name of the camera
  39105. * @param position The start position camera
  39106. * @param scene The scene the camera belongs to
  39107. */
  39108. constructor(name: string, position: Vector3, scene: Scene);
  39109. /**
  39110. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39111. */
  39112. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39113. private _dragFactor;
  39114. /**
  39115. * Enabled turning on the y axis when the orientation sensor is active
  39116. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39117. */
  39118. enableHorizontalDragging(dragFactor?: number): void;
  39119. /**
  39120. * Gets the current instance class name ("DeviceOrientationCamera").
  39121. * This helps avoiding instanceof at run time.
  39122. * @returns the class name
  39123. */
  39124. getClassName(): string;
  39125. /**
  39126. * @hidden
  39127. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39128. */
  39129. _checkInputs(): void;
  39130. /**
  39131. * Reset the camera to its default orientation on the specified axis only.
  39132. * @param axis The axis to reset
  39133. */
  39134. resetToCurrentRotation(axis?: Axis): void;
  39135. }
  39136. }
  39137. declare module BABYLON {
  39138. /**
  39139. * Defines supported buttons for XBox360 compatible gamepads
  39140. */
  39141. export enum Xbox360Button {
  39142. /** A */
  39143. A = 0,
  39144. /** B */
  39145. B = 1,
  39146. /** X */
  39147. X = 2,
  39148. /** Y */
  39149. Y = 3,
  39150. /** Start */
  39151. Start = 4,
  39152. /** Back */
  39153. Back = 5,
  39154. /** Left button */
  39155. LB = 6,
  39156. /** Right button */
  39157. RB = 7,
  39158. /** Left stick */
  39159. LeftStick = 8,
  39160. /** Right stick */
  39161. RightStick = 9
  39162. }
  39163. /** Defines values for XBox360 DPad */
  39164. export enum Xbox360Dpad {
  39165. /** Up */
  39166. Up = 0,
  39167. /** Down */
  39168. Down = 1,
  39169. /** Left */
  39170. Left = 2,
  39171. /** Right */
  39172. Right = 3
  39173. }
  39174. /**
  39175. * Defines a XBox360 gamepad
  39176. */
  39177. export class Xbox360Pad extends Gamepad {
  39178. private _leftTrigger;
  39179. private _rightTrigger;
  39180. private _onlefttriggerchanged;
  39181. private _onrighttriggerchanged;
  39182. private _onbuttondown;
  39183. private _onbuttonup;
  39184. private _ondpaddown;
  39185. private _ondpadup;
  39186. /** Observable raised when a button is pressed */
  39187. onButtonDownObservable: Observable<Xbox360Button>;
  39188. /** Observable raised when a button is released */
  39189. onButtonUpObservable: Observable<Xbox360Button>;
  39190. /** Observable raised when a pad is pressed */
  39191. onPadDownObservable: Observable<Xbox360Dpad>;
  39192. /** Observable raised when a pad is released */
  39193. onPadUpObservable: Observable<Xbox360Dpad>;
  39194. private _buttonA;
  39195. private _buttonB;
  39196. private _buttonX;
  39197. private _buttonY;
  39198. private _buttonBack;
  39199. private _buttonStart;
  39200. private _buttonLB;
  39201. private _buttonRB;
  39202. private _buttonLeftStick;
  39203. private _buttonRightStick;
  39204. private _dPadUp;
  39205. private _dPadDown;
  39206. private _dPadLeft;
  39207. private _dPadRight;
  39208. private _isXboxOnePad;
  39209. /**
  39210. * Creates a new XBox360 gamepad object
  39211. * @param id defines the id of this gamepad
  39212. * @param index defines its index
  39213. * @param gamepad defines the internal HTML gamepad object
  39214. * @param xboxOne defines if it is a XBox One gamepad
  39215. */
  39216. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39217. /**
  39218. * Defines the callback to call when left trigger is pressed
  39219. * @param callback defines the callback to use
  39220. */
  39221. onlefttriggerchanged(callback: (value: number) => void): void;
  39222. /**
  39223. * Defines the callback to call when right trigger is pressed
  39224. * @param callback defines the callback to use
  39225. */
  39226. onrighttriggerchanged(callback: (value: number) => void): void;
  39227. /**
  39228. * Gets the left trigger value
  39229. */
  39230. /**
  39231. * Sets the left trigger value
  39232. */
  39233. leftTrigger: number;
  39234. /**
  39235. * Gets the right trigger value
  39236. */
  39237. /**
  39238. * Sets the right trigger value
  39239. */
  39240. rightTrigger: number;
  39241. /**
  39242. * Defines the callback to call when a button is pressed
  39243. * @param callback defines the callback to use
  39244. */
  39245. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39246. /**
  39247. * Defines the callback to call when a button is released
  39248. * @param callback defines the callback to use
  39249. */
  39250. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39251. /**
  39252. * Defines the callback to call when a pad is pressed
  39253. * @param callback defines the callback to use
  39254. */
  39255. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39256. /**
  39257. * Defines the callback to call when a pad is released
  39258. * @param callback defines the callback to use
  39259. */
  39260. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39261. private _setButtonValue;
  39262. private _setDPadValue;
  39263. /**
  39264. * Gets the value of the `A` button
  39265. */
  39266. /**
  39267. * Sets the value of the `A` button
  39268. */
  39269. buttonA: number;
  39270. /**
  39271. * Gets the value of the `B` button
  39272. */
  39273. /**
  39274. * Sets the value of the `B` button
  39275. */
  39276. buttonB: number;
  39277. /**
  39278. * Gets the value of the `X` button
  39279. */
  39280. /**
  39281. * Sets the value of the `X` button
  39282. */
  39283. buttonX: number;
  39284. /**
  39285. * Gets the value of the `Y` button
  39286. */
  39287. /**
  39288. * Sets the value of the `Y` button
  39289. */
  39290. buttonY: number;
  39291. /**
  39292. * Gets the value of the `Start` button
  39293. */
  39294. /**
  39295. * Sets the value of the `Start` button
  39296. */
  39297. buttonStart: number;
  39298. /**
  39299. * Gets the value of the `Back` button
  39300. */
  39301. /**
  39302. * Sets the value of the `Back` button
  39303. */
  39304. buttonBack: number;
  39305. /**
  39306. * Gets the value of the `Left` button
  39307. */
  39308. /**
  39309. * Sets the value of the `Left` button
  39310. */
  39311. buttonLB: number;
  39312. /**
  39313. * Gets the value of the `Right` button
  39314. */
  39315. /**
  39316. * Sets the value of the `Right` button
  39317. */
  39318. buttonRB: number;
  39319. /**
  39320. * Gets the value of the Left joystick
  39321. */
  39322. /**
  39323. * Sets the value of the Left joystick
  39324. */
  39325. buttonLeftStick: number;
  39326. /**
  39327. * Gets the value of the Right joystick
  39328. */
  39329. /**
  39330. * Sets the value of the Right joystick
  39331. */
  39332. buttonRightStick: number;
  39333. /**
  39334. * Gets the value of D-pad up
  39335. */
  39336. /**
  39337. * Sets the value of D-pad up
  39338. */
  39339. dPadUp: number;
  39340. /**
  39341. * Gets the value of D-pad down
  39342. */
  39343. /**
  39344. * Sets the value of D-pad down
  39345. */
  39346. dPadDown: number;
  39347. /**
  39348. * Gets the value of D-pad left
  39349. */
  39350. /**
  39351. * Sets the value of D-pad left
  39352. */
  39353. dPadLeft: number;
  39354. /**
  39355. * Gets the value of D-pad right
  39356. */
  39357. /**
  39358. * Sets the value of D-pad right
  39359. */
  39360. dPadRight: number;
  39361. /**
  39362. * Force the gamepad to synchronize with device values
  39363. */
  39364. update(): void;
  39365. /**
  39366. * Disposes the gamepad
  39367. */
  39368. dispose(): void;
  39369. }
  39370. }
  39371. declare module BABYLON {
  39372. /**
  39373. * Defines supported buttons for DualShock compatible gamepads
  39374. */
  39375. export enum DualShockButton {
  39376. /** Cross */
  39377. Cross = 0,
  39378. /** Circle */
  39379. Circle = 1,
  39380. /** Square */
  39381. Square = 2,
  39382. /** Triangle */
  39383. Triangle = 3,
  39384. /** Options */
  39385. Options = 4,
  39386. /** Share */
  39387. Share = 5,
  39388. /** L1 */
  39389. L1 = 6,
  39390. /** R1 */
  39391. R1 = 7,
  39392. /** Left stick */
  39393. LeftStick = 8,
  39394. /** Right stick */
  39395. RightStick = 9
  39396. }
  39397. /** Defines values for DualShock DPad */
  39398. export enum DualShockDpad {
  39399. /** Up */
  39400. Up = 0,
  39401. /** Down */
  39402. Down = 1,
  39403. /** Left */
  39404. Left = 2,
  39405. /** Right */
  39406. Right = 3
  39407. }
  39408. /**
  39409. * Defines a DualShock gamepad
  39410. */
  39411. export class DualShockPad extends Gamepad {
  39412. private _leftTrigger;
  39413. private _rightTrigger;
  39414. private _onlefttriggerchanged;
  39415. private _onrighttriggerchanged;
  39416. private _onbuttondown;
  39417. private _onbuttonup;
  39418. private _ondpaddown;
  39419. private _ondpadup;
  39420. /** Observable raised when a button is pressed */
  39421. onButtonDownObservable: Observable<DualShockButton>;
  39422. /** Observable raised when a button is released */
  39423. onButtonUpObservable: Observable<DualShockButton>;
  39424. /** Observable raised when a pad is pressed */
  39425. onPadDownObservable: Observable<DualShockDpad>;
  39426. /** Observable raised when a pad is released */
  39427. onPadUpObservable: Observable<DualShockDpad>;
  39428. private _buttonCross;
  39429. private _buttonCircle;
  39430. private _buttonSquare;
  39431. private _buttonTriangle;
  39432. private _buttonShare;
  39433. private _buttonOptions;
  39434. private _buttonL1;
  39435. private _buttonR1;
  39436. private _buttonLeftStick;
  39437. private _buttonRightStick;
  39438. private _dPadUp;
  39439. private _dPadDown;
  39440. private _dPadLeft;
  39441. private _dPadRight;
  39442. /**
  39443. * Creates a new DualShock gamepad object
  39444. * @param id defines the id of this gamepad
  39445. * @param index defines its index
  39446. * @param gamepad defines the internal HTML gamepad object
  39447. */
  39448. constructor(id: string, index: number, gamepad: any);
  39449. /**
  39450. * Defines the callback to call when left trigger is pressed
  39451. * @param callback defines the callback to use
  39452. */
  39453. onlefttriggerchanged(callback: (value: number) => void): void;
  39454. /**
  39455. * Defines the callback to call when right trigger is pressed
  39456. * @param callback defines the callback to use
  39457. */
  39458. onrighttriggerchanged(callback: (value: number) => void): void;
  39459. /**
  39460. * Gets the left trigger value
  39461. */
  39462. /**
  39463. * Sets the left trigger value
  39464. */
  39465. leftTrigger: number;
  39466. /**
  39467. * Gets the right trigger value
  39468. */
  39469. /**
  39470. * Sets the right trigger value
  39471. */
  39472. rightTrigger: number;
  39473. /**
  39474. * Defines the callback to call when a button is pressed
  39475. * @param callback defines the callback to use
  39476. */
  39477. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39478. /**
  39479. * Defines the callback to call when a button is released
  39480. * @param callback defines the callback to use
  39481. */
  39482. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39483. /**
  39484. * Defines the callback to call when a pad is pressed
  39485. * @param callback defines the callback to use
  39486. */
  39487. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39488. /**
  39489. * Defines the callback to call when a pad is released
  39490. * @param callback defines the callback to use
  39491. */
  39492. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39493. private _setButtonValue;
  39494. private _setDPadValue;
  39495. /**
  39496. * Gets the value of the `Cross` button
  39497. */
  39498. /**
  39499. * Sets the value of the `Cross` button
  39500. */
  39501. buttonCross: number;
  39502. /**
  39503. * Gets the value of the `Circle` button
  39504. */
  39505. /**
  39506. * Sets the value of the `Circle` button
  39507. */
  39508. buttonCircle: number;
  39509. /**
  39510. * Gets the value of the `Square` button
  39511. */
  39512. /**
  39513. * Sets the value of the `Square` button
  39514. */
  39515. buttonSquare: number;
  39516. /**
  39517. * Gets the value of the `Triangle` button
  39518. */
  39519. /**
  39520. * Sets the value of the `Triangle` button
  39521. */
  39522. buttonTriangle: number;
  39523. /**
  39524. * Gets the value of the `Options` button
  39525. */
  39526. /**
  39527. * Sets the value of the `Options` button
  39528. */
  39529. buttonOptions: number;
  39530. /**
  39531. * Gets the value of the `Share` button
  39532. */
  39533. /**
  39534. * Sets the value of the `Share` button
  39535. */
  39536. buttonShare: number;
  39537. /**
  39538. * Gets the value of the `L1` button
  39539. */
  39540. /**
  39541. * Sets the value of the `L1` button
  39542. */
  39543. buttonL1: number;
  39544. /**
  39545. * Gets the value of the `R1` button
  39546. */
  39547. /**
  39548. * Sets the value of the `R1` button
  39549. */
  39550. buttonR1: number;
  39551. /**
  39552. * Gets the value of the Left joystick
  39553. */
  39554. /**
  39555. * Sets the value of the Left joystick
  39556. */
  39557. buttonLeftStick: number;
  39558. /**
  39559. * Gets the value of the Right joystick
  39560. */
  39561. /**
  39562. * Sets the value of the Right joystick
  39563. */
  39564. buttonRightStick: number;
  39565. /**
  39566. * Gets the value of D-pad up
  39567. */
  39568. /**
  39569. * Sets the value of D-pad up
  39570. */
  39571. dPadUp: number;
  39572. /**
  39573. * Gets the value of D-pad down
  39574. */
  39575. /**
  39576. * Sets the value of D-pad down
  39577. */
  39578. dPadDown: number;
  39579. /**
  39580. * Gets the value of D-pad left
  39581. */
  39582. /**
  39583. * Sets the value of D-pad left
  39584. */
  39585. dPadLeft: number;
  39586. /**
  39587. * Gets the value of D-pad right
  39588. */
  39589. /**
  39590. * Sets the value of D-pad right
  39591. */
  39592. dPadRight: number;
  39593. /**
  39594. * Force the gamepad to synchronize with device values
  39595. */
  39596. update(): void;
  39597. /**
  39598. * Disposes the gamepad
  39599. */
  39600. dispose(): void;
  39601. }
  39602. }
  39603. declare module BABYLON {
  39604. /**
  39605. * Manager for handling gamepads
  39606. */
  39607. export class GamepadManager {
  39608. private _scene?;
  39609. private _babylonGamepads;
  39610. private _oneGamepadConnected;
  39611. /** @hidden */
  39612. _isMonitoring: boolean;
  39613. private _gamepadEventSupported;
  39614. private _gamepadSupport;
  39615. /**
  39616. * observable to be triggered when the gamepad controller has been connected
  39617. */
  39618. onGamepadConnectedObservable: Observable<Gamepad>;
  39619. /**
  39620. * observable to be triggered when the gamepad controller has been disconnected
  39621. */
  39622. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39623. private _onGamepadConnectedEvent;
  39624. private _onGamepadDisconnectedEvent;
  39625. /**
  39626. * Initializes the gamepad manager
  39627. * @param _scene BabylonJS scene
  39628. */
  39629. constructor(_scene?: Scene | undefined);
  39630. /**
  39631. * The gamepads in the game pad manager
  39632. */
  39633. readonly gamepads: Gamepad[];
  39634. /**
  39635. * Get the gamepad controllers based on type
  39636. * @param type The type of gamepad controller
  39637. * @returns Nullable gamepad
  39638. */
  39639. getGamepadByType(type?: number): Nullable<Gamepad>;
  39640. /**
  39641. * Disposes the gamepad manager
  39642. */
  39643. dispose(): void;
  39644. private _addNewGamepad;
  39645. private _startMonitoringGamepads;
  39646. private _stopMonitoringGamepads;
  39647. /** @hidden */
  39648. _checkGamepadsStatus(): void;
  39649. private _updateGamepadObjects;
  39650. }
  39651. }
  39652. declare module BABYLON {
  39653. interface Scene {
  39654. /** @hidden */
  39655. _gamepadManager: Nullable<GamepadManager>;
  39656. /**
  39657. * Gets the gamepad manager associated with the scene
  39658. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39659. */
  39660. gamepadManager: GamepadManager;
  39661. }
  39662. /**
  39663. * Interface representing a free camera inputs manager
  39664. */
  39665. interface FreeCameraInputsManager {
  39666. /**
  39667. * Adds gamepad input support to the FreeCameraInputsManager.
  39668. * @returns the FreeCameraInputsManager
  39669. */
  39670. addGamepad(): FreeCameraInputsManager;
  39671. }
  39672. /**
  39673. * Interface representing an arc rotate camera inputs manager
  39674. */
  39675. interface ArcRotateCameraInputsManager {
  39676. /**
  39677. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39678. * @returns the camera inputs manager
  39679. */
  39680. addGamepad(): ArcRotateCameraInputsManager;
  39681. }
  39682. /**
  39683. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39684. */
  39685. export class GamepadSystemSceneComponent implements ISceneComponent {
  39686. /**
  39687. * The component name helpfull to identify the component in the list of scene components.
  39688. */
  39689. readonly name: string;
  39690. /**
  39691. * The scene the component belongs to.
  39692. */
  39693. scene: Scene;
  39694. /**
  39695. * Creates a new instance of the component for the given scene
  39696. * @param scene Defines the scene to register the component in
  39697. */
  39698. constructor(scene: Scene);
  39699. /**
  39700. * Registers the component in a given scene
  39701. */
  39702. register(): void;
  39703. /**
  39704. * Rebuilds the elements related to this component in case of
  39705. * context lost for instance.
  39706. */
  39707. rebuild(): void;
  39708. /**
  39709. * Disposes the component and the associated ressources
  39710. */
  39711. dispose(): void;
  39712. private _beforeCameraUpdate;
  39713. }
  39714. }
  39715. declare module BABYLON {
  39716. /**
  39717. * 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,
  39718. * which still works and will still be found in many Playgrounds.
  39719. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39720. */
  39721. export class UniversalCamera extends TouchCamera {
  39722. /**
  39723. * Defines the gamepad rotation sensiblity.
  39724. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39725. */
  39726. gamepadAngularSensibility: number;
  39727. /**
  39728. * Defines the gamepad move sensiblity.
  39729. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39730. */
  39731. gamepadMoveSensibility: number;
  39732. /**
  39733. * 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,
  39734. * which still works and will still be found in many Playgrounds.
  39735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39736. * @param name Define the name of the camera in the scene
  39737. * @param position Define the start position of the camera in the scene
  39738. * @param scene Define the scene the camera belongs to
  39739. */
  39740. constructor(name: string, position: Vector3, scene: Scene);
  39741. /**
  39742. * Gets the current object class name.
  39743. * @return the class name
  39744. */
  39745. getClassName(): string;
  39746. }
  39747. }
  39748. declare module BABYLON {
  39749. /**
  39750. * This represents a FPS type of camera. This is only here for back compat purpose.
  39751. * Please use the UniversalCamera instead as both are identical.
  39752. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39753. */
  39754. export class GamepadCamera extends UniversalCamera {
  39755. /**
  39756. * Instantiates a new Gamepad Camera
  39757. * This represents a FPS type of camera. This is only here for back compat purpose.
  39758. * Please use the UniversalCamera instead as both are identical.
  39759. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39760. * @param name Define the name of the camera in the scene
  39761. * @param position Define the start position of the camera in the scene
  39762. * @param scene Define the scene the camera belongs to
  39763. */
  39764. constructor(name: string, position: Vector3, scene: Scene);
  39765. /**
  39766. * Gets the current object class name.
  39767. * @return the class name
  39768. */
  39769. getClassName(): string;
  39770. }
  39771. }
  39772. declare module BABYLON {
  39773. /** @hidden */
  39774. export var passPixelShader: {
  39775. name: string;
  39776. shader: string;
  39777. };
  39778. }
  39779. declare module BABYLON {
  39780. /** @hidden */
  39781. export var passCubePixelShader: {
  39782. name: string;
  39783. shader: string;
  39784. };
  39785. }
  39786. declare module BABYLON {
  39787. /**
  39788. * PassPostProcess which produces an output the same as it's input
  39789. */
  39790. export class PassPostProcess extends PostProcess {
  39791. /**
  39792. * Creates the PassPostProcess
  39793. * @param name The name of the effect.
  39794. * @param options The required width/height ratio to downsize to before computing the render pass.
  39795. * @param camera The camera to apply the render pass to.
  39796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39797. * @param engine The engine which the post process will be applied. (default: current engine)
  39798. * @param reusable If the post process can be reused on the same frame. (default: false)
  39799. * @param textureType The type of texture to be used when performing the post processing.
  39800. * @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)
  39801. */
  39802. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39803. }
  39804. /**
  39805. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39806. */
  39807. export class PassCubePostProcess extends PostProcess {
  39808. private _face;
  39809. /**
  39810. * Gets or sets the cube face to display.
  39811. * * 0 is +X
  39812. * * 1 is -X
  39813. * * 2 is +Y
  39814. * * 3 is -Y
  39815. * * 4 is +Z
  39816. * * 5 is -Z
  39817. */
  39818. face: number;
  39819. /**
  39820. * Creates the PassCubePostProcess
  39821. * @param name The name of the effect.
  39822. * @param options The required width/height ratio to downsize to before computing the render pass.
  39823. * @param camera The camera to apply the render pass to.
  39824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39825. * @param engine The engine which the post process will be applied. (default: current engine)
  39826. * @param reusable If the post process can be reused on the same frame. (default: false)
  39827. * @param textureType The type of texture to be used when performing the post processing.
  39828. * @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)
  39829. */
  39830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39831. }
  39832. }
  39833. declare module BABYLON {
  39834. /** @hidden */
  39835. export var anaglyphPixelShader: {
  39836. name: string;
  39837. shader: string;
  39838. };
  39839. }
  39840. declare module BABYLON {
  39841. /**
  39842. * Postprocess used to generate anaglyphic rendering
  39843. */
  39844. export class AnaglyphPostProcess extends PostProcess {
  39845. private _passedProcess;
  39846. /**
  39847. * Creates a new AnaglyphPostProcess
  39848. * @param name defines postprocess name
  39849. * @param options defines creation options or target ratio scale
  39850. * @param rigCameras defines cameras using this postprocess
  39851. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39852. * @param engine defines hosting engine
  39853. * @param reusable defines if the postprocess will be reused multiple times per frame
  39854. */
  39855. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39856. }
  39857. }
  39858. declare module BABYLON {
  39859. /**
  39860. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39861. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39862. */
  39863. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39864. /**
  39865. * Creates a new AnaglyphArcRotateCamera
  39866. * @param name defines camera name
  39867. * @param alpha defines alpha angle (in radians)
  39868. * @param beta defines beta angle (in radians)
  39869. * @param radius defines radius
  39870. * @param target defines camera target
  39871. * @param interaxialDistance defines distance between each color axis
  39872. * @param scene defines the hosting scene
  39873. */
  39874. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39875. /**
  39876. * Gets camera class name
  39877. * @returns AnaglyphArcRotateCamera
  39878. */
  39879. getClassName(): string;
  39880. }
  39881. }
  39882. declare module BABYLON {
  39883. /**
  39884. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39885. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39886. */
  39887. export class AnaglyphFreeCamera extends FreeCamera {
  39888. /**
  39889. * Creates a new AnaglyphFreeCamera
  39890. * @param name defines camera name
  39891. * @param position defines initial position
  39892. * @param interaxialDistance defines distance between each color axis
  39893. * @param scene defines the hosting scene
  39894. */
  39895. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39896. /**
  39897. * Gets camera class name
  39898. * @returns AnaglyphFreeCamera
  39899. */
  39900. getClassName(): string;
  39901. }
  39902. }
  39903. declare module BABYLON {
  39904. /**
  39905. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39906. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39907. */
  39908. export class AnaglyphGamepadCamera extends GamepadCamera {
  39909. /**
  39910. * Creates a new AnaglyphGamepadCamera
  39911. * @param name defines camera name
  39912. * @param position defines initial position
  39913. * @param interaxialDistance defines distance between each color axis
  39914. * @param scene defines the hosting scene
  39915. */
  39916. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39917. /**
  39918. * Gets camera class name
  39919. * @returns AnaglyphGamepadCamera
  39920. */
  39921. getClassName(): string;
  39922. }
  39923. }
  39924. declare module BABYLON {
  39925. /**
  39926. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39927. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39928. */
  39929. export class AnaglyphUniversalCamera extends UniversalCamera {
  39930. /**
  39931. * Creates a new AnaglyphUniversalCamera
  39932. * @param name defines camera name
  39933. * @param position defines initial position
  39934. * @param interaxialDistance defines distance between each color axis
  39935. * @param scene defines the hosting scene
  39936. */
  39937. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39938. /**
  39939. * Gets camera class name
  39940. * @returns AnaglyphUniversalCamera
  39941. */
  39942. getClassName(): string;
  39943. }
  39944. }
  39945. declare module BABYLON {
  39946. /** @hidden */
  39947. export var stereoscopicInterlacePixelShader: {
  39948. name: string;
  39949. shader: string;
  39950. };
  39951. }
  39952. declare module BABYLON {
  39953. /**
  39954. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39955. */
  39956. export class StereoscopicInterlacePostProcess extends PostProcess {
  39957. private _stepSize;
  39958. private _passedProcess;
  39959. /**
  39960. * Initializes a StereoscopicInterlacePostProcess
  39961. * @param name The name of the effect.
  39962. * @param rigCameras The rig cameras to be appled to the post process
  39963. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39965. * @param engine The engine which the post process will be applied. (default: current engine)
  39966. * @param reusable If the post process can be reused on the same frame. (default: false)
  39967. */
  39968. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39969. }
  39970. }
  39971. declare module BABYLON {
  39972. /**
  39973. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39974. * @see http://doc.babylonjs.com/features/cameras
  39975. */
  39976. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39977. /**
  39978. * Creates a new StereoscopicArcRotateCamera
  39979. * @param name defines camera name
  39980. * @param alpha defines alpha angle (in radians)
  39981. * @param beta defines beta angle (in radians)
  39982. * @param radius defines radius
  39983. * @param target defines camera target
  39984. * @param interaxialDistance defines distance between each color axis
  39985. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39986. * @param scene defines the hosting scene
  39987. */
  39988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39989. /**
  39990. * Gets camera class name
  39991. * @returns StereoscopicArcRotateCamera
  39992. */
  39993. getClassName(): string;
  39994. }
  39995. }
  39996. declare module BABYLON {
  39997. /**
  39998. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39999. * @see http://doc.babylonjs.com/features/cameras
  40000. */
  40001. export class StereoscopicFreeCamera extends FreeCamera {
  40002. /**
  40003. * Creates a new StereoscopicFreeCamera
  40004. * @param name defines camera name
  40005. * @param position defines initial position
  40006. * @param interaxialDistance defines distance between each color axis
  40007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40008. * @param scene defines the hosting scene
  40009. */
  40010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40011. /**
  40012. * Gets camera class name
  40013. * @returns StereoscopicFreeCamera
  40014. */
  40015. getClassName(): string;
  40016. }
  40017. }
  40018. declare module BABYLON {
  40019. /**
  40020. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40021. * @see http://doc.babylonjs.com/features/cameras
  40022. */
  40023. export class StereoscopicGamepadCamera extends GamepadCamera {
  40024. /**
  40025. * Creates a new StereoscopicGamepadCamera
  40026. * @param name defines camera name
  40027. * @param position defines initial position
  40028. * @param interaxialDistance defines distance between each color axis
  40029. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40030. * @param scene defines the hosting scene
  40031. */
  40032. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40033. /**
  40034. * Gets camera class name
  40035. * @returns StereoscopicGamepadCamera
  40036. */
  40037. getClassName(): string;
  40038. }
  40039. }
  40040. declare module BABYLON {
  40041. /**
  40042. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40043. * @see http://doc.babylonjs.com/features/cameras
  40044. */
  40045. export class StereoscopicUniversalCamera extends UniversalCamera {
  40046. /**
  40047. * Creates a new StereoscopicUniversalCamera
  40048. * @param name defines camera name
  40049. * @param position defines initial position
  40050. * @param interaxialDistance defines distance between each color axis
  40051. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40052. * @param scene defines the hosting scene
  40053. */
  40054. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40055. /**
  40056. * Gets camera class name
  40057. * @returns StereoscopicUniversalCamera
  40058. */
  40059. getClassName(): string;
  40060. }
  40061. }
  40062. declare module BABYLON {
  40063. /**
  40064. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40065. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40066. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40067. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40068. */
  40069. export class VirtualJoysticksCamera extends FreeCamera {
  40070. /**
  40071. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40072. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40073. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40074. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40075. * @param name Define the name of the camera in the scene
  40076. * @param position Define the start position of the camera in the scene
  40077. * @param scene Define the scene the camera belongs to
  40078. */
  40079. constructor(name: string, position: Vector3, scene: Scene);
  40080. /**
  40081. * Gets the current object class name.
  40082. * @return the class name
  40083. */
  40084. getClassName(): string;
  40085. }
  40086. }
  40087. declare module BABYLON {
  40088. /**
  40089. * This represents all the required metrics to create a VR camera.
  40090. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40091. */
  40092. export class VRCameraMetrics {
  40093. /**
  40094. * Define the horizontal resolution off the screen.
  40095. */
  40096. hResolution: number;
  40097. /**
  40098. * Define the vertical resolution off the screen.
  40099. */
  40100. vResolution: number;
  40101. /**
  40102. * Define the horizontal screen size.
  40103. */
  40104. hScreenSize: number;
  40105. /**
  40106. * Define the vertical screen size.
  40107. */
  40108. vScreenSize: number;
  40109. /**
  40110. * Define the vertical screen center position.
  40111. */
  40112. vScreenCenter: number;
  40113. /**
  40114. * Define the distance of the eyes to the screen.
  40115. */
  40116. eyeToScreenDistance: number;
  40117. /**
  40118. * Define the distance between both lenses
  40119. */
  40120. lensSeparationDistance: number;
  40121. /**
  40122. * Define the distance between both viewer's eyes.
  40123. */
  40124. interpupillaryDistance: number;
  40125. /**
  40126. * Define the distortion factor of the VR postprocess.
  40127. * Please, touch with care.
  40128. */
  40129. distortionK: number[];
  40130. /**
  40131. * Define the chromatic aberration correction factors for the VR post process.
  40132. */
  40133. chromaAbCorrection: number[];
  40134. /**
  40135. * Define the scale factor of the post process.
  40136. * The smaller the better but the slower.
  40137. */
  40138. postProcessScaleFactor: number;
  40139. /**
  40140. * Define an offset for the lens center.
  40141. */
  40142. lensCenterOffset: number;
  40143. /**
  40144. * Define if the current vr camera should compensate the distortion of the lense or not.
  40145. */
  40146. compensateDistortion: boolean;
  40147. /**
  40148. * Defines if multiview should be enabled when rendering (Default: false)
  40149. */
  40150. multiviewEnabled: boolean;
  40151. /**
  40152. * Gets the rendering aspect ratio based on the provided resolutions.
  40153. */
  40154. readonly aspectRatio: number;
  40155. /**
  40156. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40157. */
  40158. readonly aspectRatioFov: number;
  40159. /**
  40160. * @hidden
  40161. */
  40162. readonly leftHMatrix: Matrix;
  40163. /**
  40164. * @hidden
  40165. */
  40166. readonly rightHMatrix: Matrix;
  40167. /**
  40168. * @hidden
  40169. */
  40170. readonly leftPreViewMatrix: Matrix;
  40171. /**
  40172. * @hidden
  40173. */
  40174. readonly rightPreViewMatrix: Matrix;
  40175. /**
  40176. * Get the default VRMetrics based on the most generic setup.
  40177. * @returns the default vr metrics
  40178. */
  40179. static GetDefault(): VRCameraMetrics;
  40180. }
  40181. }
  40182. declare module BABYLON {
  40183. /** @hidden */
  40184. export var vrDistortionCorrectionPixelShader: {
  40185. name: string;
  40186. shader: string;
  40187. };
  40188. }
  40189. declare module BABYLON {
  40190. /**
  40191. * VRDistortionCorrectionPostProcess used for mobile VR
  40192. */
  40193. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40194. private _isRightEye;
  40195. private _distortionFactors;
  40196. private _postProcessScaleFactor;
  40197. private _lensCenterOffset;
  40198. private _scaleIn;
  40199. private _scaleFactor;
  40200. private _lensCenter;
  40201. /**
  40202. * Initializes the VRDistortionCorrectionPostProcess
  40203. * @param name The name of the effect.
  40204. * @param camera The camera to apply the render pass to.
  40205. * @param isRightEye If this is for the right eye distortion
  40206. * @param vrMetrics All the required metrics for the VR camera
  40207. */
  40208. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40209. }
  40210. }
  40211. declare module BABYLON {
  40212. /**
  40213. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40214. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40215. */
  40216. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40217. /**
  40218. * Creates a new VRDeviceOrientationArcRotateCamera
  40219. * @param name defines camera name
  40220. * @param alpha defines the camera rotation along the logitudinal axis
  40221. * @param beta defines the camera rotation along the latitudinal axis
  40222. * @param radius defines the camera distance from its target
  40223. * @param target defines the camera target
  40224. * @param scene defines the scene the camera belongs to
  40225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40227. */
  40228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40229. /**
  40230. * Gets camera class name
  40231. * @returns VRDeviceOrientationArcRotateCamera
  40232. */
  40233. getClassName(): string;
  40234. }
  40235. }
  40236. declare module BABYLON {
  40237. /**
  40238. * Camera used to simulate VR rendering (based on FreeCamera)
  40239. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40240. */
  40241. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40242. /**
  40243. * Creates a new VRDeviceOrientationFreeCamera
  40244. * @param name defines camera name
  40245. * @param position defines the start position of the camera
  40246. * @param scene defines the scene the camera belongs to
  40247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40249. */
  40250. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40251. /**
  40252. * Gets camera class name
  40253. * @returns VRDeviceOrientationFreeCamera
  40254. */
  40255. getClassName(): string;
  40256. }
  40257. }
  40258. declare module BABYLON {
  40259. /**
  40260. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40261. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40262. */
  40263. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40264. /**
  40265. * Creates a new VRDeviceOrientationGamepadCamera
  40266. * @param name defines camera name
  40267. * @param position defines the start position of the camera
  40268. * @param scene defines the scene the camera belongs to
  40269. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40270. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40271. */
  40272. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40273. /**
  40274. * Gets camera class name
  40275. * @returns VRDeviceOrientationGamepadCamera
  40276. */
  40277. getClassName(): string;
  40278. }
  40279. }
  40280. declare module BABYLON {
  40281. /**
  40282. * Base class of materials working in push mode in babylon JS
  40283. * @hidden
  40284. */
  40285. export class PushMaterial extends Material {
  40286. protected _activeEffect: Effect;
  40287. protected _normalMatrix: Matrix;
  40288. /**
  40289. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40290. * This means that the material can keep using a previous shader while a new one is being compiled.
  40291. * This is mostly used when shader parallel compilation is supported (true by default)
  40292. */
  40293. allowShaderHotSwapping: boolean;
  40294. constructor(name: string, scene: Scene);
  40295. getEffect(): Effect;
  40296. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40297. /**
  40298. * Binds the given world matrix to the active effect
  40299. *
  40300. * @param world the matrix to bind
  40301. */
  40302. bindOnlyWorldMatrix(world: Matrix): void;
  40303. /**
  40304. * Binds the given normal matrix to the active effect
  40305. *
  40306. * @param normalMatrix the matrix to bind
  40307. */
  40308. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40309. bind(world: Matrix, mesh?: Mesh): void;
  40310. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40311. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40312. }
  40313. }
  40314. declare module BABYLON {
  40315. /**
  40316. * This groups all the flags used to control the materials channel.
  40317. */
  40318. export class MaterialFlags {
  40319. private static _DiffuseTextureEnabled;
  40320. /**
  40321. * Are diffuse textures enabled in the application.
  40322. */
  40323. static DiffuseTextureEnabled: boolean;
  40324. private static _AmbientTextureEnabled;
  40325. /**
  40326. * Are ambient textures enabled in the application.
  40327. */
  40328. static AmbientTextureEnabled: boolean;
  40329. private static _OpacityTextureEnabled;
  40330. /**
  40331. * Are opacity textures enabled in the application.
  40332. */
  40333. static OpacityTextureEnabled: boolean;
  40334. private static _ReflectionTextureEnabled;
  40335. /**
  40336. * Are reflection textures enabled in the application.
  40337. */
  40338. static ReflectionTextureEnabled: boolean;
  40339. private static _EmissiveTextureEnabled;
  40340. /**
  40341. * Are emissive textures enabled in the application.
  40342. */
  40343. static EmissiveTextureEnabled: boolean;
  40344. private static _SpecularTextureEnabled;
  40345. /**
  40346. * Are specular textures enabled in the application.
  40347. */
  40348. static SpecularTextureEnabled: boolean;
  40349. private static _BumpTextureEnabled;
  40350. /**
  40351. * Are bump textures enabled in the application.
  40352. */
  40353. static BumpTextureEnabled: boolean;
  40354. private static _LightmapTextureEnabled;
  40355. /**
  40356. * Are lightmap textures enabled in the application.
  40357. */
  40358. static LightmapTextureEnabled: boolean;
  40359. private static _RefractionTextureEnabled;
  40360. /**
  40361. * Are refraction textures enabled in the application.
  40362. */
  40363. static RefractionTextureEnabled: boolean;
  40364. private static _ColorGradingTextureEnabled;
  40365. /**
  40366. * Are color grading textures enabled in the application.
  40367. */
  40368. static ColorGradingTextureEnabled: boolean;
  40369. private static _FresnelEnabled;
  40370. /**
  40371. * Are fresnels enabled in the application.
  40372. */
  40373. static FresnelEnabled: boolean;
  40374. private static _ClearCoatTextureEnabled;
  40375. /**
  40376. * Are clear coat textures enabled in the application.
  40377. */
  40378. static ClearCoatTextureEnabled: boolean;
  40379. private static _ClearCoatBumpTextureEnabled;
  40380. /**
  40381. * Are clear coat bump textures enabled in the application.
  40382. */
  40383. static ClearCoatBumpTextureEnabled: boolean;
  40384. private static _ClearCoatTintTextureEnabled;
  40385. /**
  40386. * Are clear coat tint textures enabled in the application.
  40387. */
  40388. static ClearCoatTintTextureEnabled: boolean;
  40389. private static _SheenTextureEnabled;
  40390. /**
  40391. * Are sheen textures enabled in the application.
  40392. */
  40393. static SheenTextureEnabled: boolean;
  40394. private static _AnisotropicTextureEnabled;
  40395. /**
  40396. * Are anisotropic textures enabled in the application.
  40397. */
  40398. static AnisotropicTextureEnabled: boolean;
  40399. private static _ThicknessTextureEnabled;
  40400. /**
  40401. * Are thickness textures enabled in the application.
  40402. */
  40403. static ThicknessTextureEnabled: boolean;
  40404. }
  40405. }
  40406. declare module BABYLON {
  40407. /** @hidden */
  40408. export var defaultFragmentDeclaration: {
  40409. name: string;
  40410. shader: string;
  40411. };
  40412. }
  40413. declare module BABYLON {
  40414. /** @hidden */
  40415. export var defaultUboDeclaration: {
  40416. name: string;
  40417. shader: string;
  40418. };
  40419. }
  40420. declare module BABYLON {
  40421. /** @hidden */
  40422. export var lightFragmentDeclaration: {
  40423. name: string;
  40424. shader: string;
  40425. };
  40426. }
  40427. declare module BABYLON {
  40428. /** @hidden */
  40429. export var lightUboDeclaration: {
  40430. name: string;
  40431. shader: string;
  40432. };
  40433. }
  40434. declare module BABYLON {
  40435. /** @hidden */
  40436. export var lightsFragmentFunctions: {
  40437. name: string;
  40438. shader: string;
  40439. };
  40440. }
  40441. declare module BABYLON {
  40442. /** @hidden */
  40443. export var shadowsFragmentFunctions: {
  40444. name: string;
  40445. shader: string;
  40446. };
  40447. }
  40448. declare module BABYLON {
  40449. /** @hidden */
  40450. export var fresnelFunction: {
  40451. name: string;
  40452. shader: string;
  40453. };
  40454. }
  40455. declare module BABYLON {
  40456. /** @hidden */
  40457. export var reflectionFunction: {
  40458. name: string;
  40459. shader: string;
  40460. };
  40461. }
  40462. declare module BABYLON {
  40463. /** @hidden */
  40464. export var bumpFragmentFunctions: {
  40465. name: string;
  40466. shader: string;
  40467. };
  40468. }
  40469. declare module BABYLON {
  40470. /** @hidden */
  40471. export var logDepthDeclaration: {
  40472. name: string;
  40473. shader: string;
  40474. };
  40475. }
  40476. declare module BABYLON {
  40477. /** @hidden */
  40478. export var bumpFragment: {
  40479. name: string;
  40480. shader: string;
  40481. };
  40482. }
  40483. declare module BABYLON {
  40484. /** @hidden */
  40485. export var depthPrePass: {
  40486. name: string;
  40487. shader: string;
  40488. };
  40489. }
  40490. declare module BABYLON {
  40491. /** @hidden */
  40492. export var lightFragment: {
  40493. name: string;
  40494. shader: string;
  40495. };
  40496. }
  40497. declare module BABYLON {
  40498. /** @hidden */
  40499. export var logDepthFragment: {
  40500. name: string;
  40501. shader: string;
  40502. };
  40503. }
  40504. declare module BABYLON {
  40505. /** @hidden */
  40506. export var defaultPixelShader: {
  40507. name: string;
  40508. shader: string;
  40509. };
  40510. }
  40511. declare module BABYLON {
  40512. /** @hidden */
  40513. export var defaultVertexDeclaration: {
  40514. name: string;
  40515. shader: string;
  40516. };
  40517. }
  40518. declare module BABYLON {
  40519. /** @hidden */
  40520. export var bumpVertexDeclaration: {
  40521. name: string;
  40522. shader: string;
  40523. };
  40524. }
  40525. declare module BABYLON {
  40526. /** @hidden */
  40527. export var bumpVertex: {
  40528. name: string;
  40529. shader: string;
  40530. };
  40531. }
  40532. declare module BABYLON {
  40533. /** @hidden */
  40534. export var fogVertex: {
  40535. name: string;
  40536. shader: string;
  40537. };
  40538. }
  40539. declare module BABYLON {
  40540. /** @hidden */
  40541. export var shadowsVertex: {
  40542. name: string;
  40543. shader: string;
  40544. };
  40545. }
  40546. declare module BABYLON {
  40547. /** @hidden */
  40548. export var pointCloudVertex: {
  40549. name: string;
  40550. shader: string;
  40551. };
  40552. }
  40553. declare module BABYLON {
  40554. /** @hidden */
  40555. export var logDepthVertex: {
  40556. name: string;
  40557. shader: string;
  40558. };
  40559. }
  40560. declare module BABYLON {
  40561. /** @hidden */
  40562. export var defaultVertexShader: {
  40563. name: string;
  40564. shader: string;
  40565. };
  40566. }
  40567. declare module BABYLON {
  40568. /** @hidden */
  40569. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40570. MAINUV1: boolean;
  40571. MAINUV2: boolean;
  40572. DIFFUSE: boolean;
  40573. DIFFUSEDIRECTUV: number;
  40574. AMBIENT: boolean;
  40575. AMBIENTDIRECTUV: number;
  40576. OPACITY: boolean;
  40577. OPACITYDIRECTUV: number;
  40578. OPACITYRGB: boolean;
  40579. REFLECTION: boolean;
  40580. EMISSIVE: boolean;
  40581. EMISSIVEDIRECTUV: number;
  40582. SPECULAR: boolean;
  40583. SPECULARDIRECTUV: number;
  40584. BUMP: boolean;
  40585. BUMPDIRECTUV: number;
  40586. PARALLAX: boolean;
  40587. PARALLAXOCCLUSION: boolean;
  40588. SPECULAROVERALPHA: boolean;
  40589. CLIPPLANE: boolean;
  40590. CLIPPLANE2: boolean;
  40591. CLIPPLANE3: boolean;
  40592. CLIPPLANE4: boolean;
  40593. ALPHATEST: boolean;
  40594. DEPTHPREPASS: boolean;
  40595. ALPHAFROMDIFFUSE: boolean;
  40596. POINTSIZE: boolean;
  40597. FOG: boolean;
  40598. SPECULARTERM: boolean;
  40599. DIFFUSEFRESNEL: boolean;
  40600. OPACITYFRESNEL: boolean;
  40601. REFLECTIONFRESNEL: boolean;
  40602. REFRACTIONFRESNEL: boolean;
  40603. EMISSIVEFRESNEL: boolean;
  40604. FRESNEL: boolean;
  40605. NORMAL: boolean;
  40606. UV1: boolean;
  40607. UV2: boolean;
  40608. VERTEXCOLOR: boolean;
  40609. VERTEXALPHA: boolean;
  40610. NUM_BONE_INFLUENCERS: number;
  40611. BonesPerMesh: number;
  40612. BONETEXTURE: boolean;
  40613. INSTANCES: boolean;
  40614. GLOSSINESS: boolean;
  40615. ROUGHNESS: boolean;
  40616. EMISSIVEASILLUMINATION: boolean;
  40617. LINKEMISSIVEWITHDIFFUSE: boolean;
  40618. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40619. LIGHTMAP: boolean;
  40620. LIGHTMAPDIRECTUV: number;
  40621. OBJECTSPACE_NORMALMAP: boolean;
  40622. USELIGHTMAPASSHADOWMAP: boolean;
  40623. REFLECTIONMAP_3D: boolean;
  40624. REFLECTIONMAP_SPHERICAL: boolean;
  40625. REFLECTIONMAP_PLANAR: boolean;
  40626. REFLECTIONMAP_CUBIC: boolean;
  40627. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40628. REFLECTIONMAP_PROJECTION: boolean;
  40629. REFLECTIONMAP_SKYBOX: boolean;
  40630. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40631. REFLECTIONMAP_EXPLICIT: boolean;
  40632. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40633. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40634. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40635. INVERTCUBICMAP: boolean;
  40636. LOGARITHMICDEPTH: boolean;
  40637. REFRACTION: boolean;
  40638. REFRACTIONMAP_3D: boolean;
  40639. REFLECTIONOVERALPHA: boolean;
  40640. TWOSIDEDLIGHTING: boolean;
  40641. SHADOWFLOAT: boolean;
  40642. MORPHTARGETS: boolean;
  40643. MORPHTARGETS_NORMAL: boolean;
  40644. MORPHTARGETS_TANGENT: boolean;
  40645. MORPHTARGETS_UV: boolean;
  40646. NUM_MORPH_INFLUENCERS: number;
  40647. NONUNIFORMSCALING: boolean;
  40648. PREMULTIPLYALPHA: boolean;
  40649. IMAGEPROCESSING: boolean;
  40650. VIGNETTE: boolean;
  40651. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40652. VIGNETTEBLENDMODEOPAQUE: boolean;
  40653. TONEMAPPING: boolean;
  40654. TONEMAPPING_ACES: boolean;
  40655. CONTRAST: boolean;
  40656. COLORCURVES: boolean;
  40657. COLORGRADING: boolean;
  40658. COLORGRADING3D: boolean;
  40659. SAMPLER3DGREENDEPTH: boolean;
  40660. SAMPLER3DBGRMAP: boolean;
  40661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40662. MULTIVIEW: boolean;
  40663. /**
  40664. * If the reflection texture on this material is in linear color space
  40665. * @hidden
  40666. */
  40667. IS_REFLECTION_LINEAR: boolean;
  40668. /**
  40669. * If the refraction texture on this material is in linear color space
  40670. * @hidden
  40671. */
  40672. IS_REFRACTION_LINEAR: boolean;
  40673. EXPOSURE: boolean;
  40674. constructor();
  40675. setReflectionMode(modeToEnable: string): void;
  40676. }
  40677. /**
  40678. * This is the default material used in Babylon. It is the best trade off between quality
  40679. * and performances.
  40680. * @see http://doc.babylonjs.com/babylon101/materials
  40681. */
  40682. export class StandardMaterial extends PushMaterial {
  40683. private _diffuseTexture;
  40684. /**
  40685. * The basic texture of the material as viewed under a light.
  40686. */
  40687. diffuseTexture: Nullable<BaseTexture>;
  40688. private _ambientTexture;
  40689. /**
  40690. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40691. */
  40692. ambientTexture: Nullable<BaseTexture>;
  40693. private _opacityTexture;
  40694. /**
  40695. * Define the transparency of the material from a texture.
  40696. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40697. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40698. */
  40699. opacityTexture: Nullable<BaseTexture>;
  40700. private _reflectionTexture;
  40701. /**
  40702. * Define the texture used to display the reflection.
  40703. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40704. */
  40705. reflectionTexture: Nullable<BaseTexture>;
  40706. private _emissiveTexture;
  40707. /**
  40708. * Define texture of the material as if self lit.
  40709. * This will be mixed in the final result even in the absence of light.
  40710. */
  40711. emissiveTexture: Nullable<BaseTexture>;
  40712. private _specularTexture;
  40713. /**
  40714. * Define how the color and intensity of the highlight given by the light in the material.
  40715. */
  40716. specularTexture: Nullable<BaseTexture>;
  40717. private _bumpTexture;
  40718. /**
  40719. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40720. * 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.
  40721. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40722. */
  40723. bumpTexture: Nullable<BaseTexture>;
  40724. private _lightmapTexture;
  40725. /**
  40726. * Complex lighting can be computationally expensive to compute at runtime.
  40727. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40728. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40729. */
  40730. lightmapTexture: Nullable<BaseTexture>;
  40731. private _refractionTexture;
  40732. /**
  40733. * Define the texture used to display the refraction.
  40734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40735. */
  40736. refractionTexture: Nullable<BaseTexture>;
  40737. /**
  40738. * The color of the material lit by the environmental background lighting.
  40739. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40740. */
  40741. ambientColor: Color3;
  40742. /**
  40743. * The basic color of the material as viewed under a light.
  40744. */
  40745. diffuseColor: Color3;
  40746. /**
  40747. * Define how the color and intensity of the highlight given by the light in the material.
  40748. */
  40749. specularColor: Color3;
  40750. /**
  40751. * Define the color of the material as if self lit.
  40752. * This will be mixed in the final result even in the absence of light.
  40753. */
  40754. emissiveColor: Color3;
  40755. /**
  40756. * Defines how sharp are the highlights in the material.
  40757. * The bigger the value the sharper giving a more glossy feeling to the result.
  40758. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40759. */
  40760. specularPower: number;
  40761. private _useAlphaFromDiffuseTexture;
  40762. /**
  40763. * Does the transparency come from the diffuse texture alpha channel.
  40764. */
  40765. useAlphaFromDiffuseTexture: boolean;
  40766. private _useEmissiveAsIllumination;
  40767. /**
  40768. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40769. */
  40770. useEmissiveAsIllumination: boolean;
  40771. private _linkEmissiveWithDiffuse;
  40772. /**
  40773. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40774. * the emissive level when the final color is close to one.
  40775. */
  40776. linkEmissiveWithDiffuse: boolean;
  40777. private _useSpecularOverAlpha;
  40778. /**
  40779. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40780. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40781. */
  40782. useSpecularOverAlpha: boolean;
  40783. private _useReflectionOverAlpha;
  40784. /**
  40785. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40786. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40787. */
  40788. useReflectionOverAlpha: boolean;
  40789. private _disableLighting;
  40790. /**
  40791. * Does lights from the scene impacts this material.
  40792. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40793. */
  40794. disableLighting: boolean;
  40795. private _useObjectSpaceNormalMap;
  40796. /**
  40797. * Allows using an object space normal map (instead of tangent space).
  40798. */
  40799. useObjectSpaceNormalMap: boolean;
  40800. private _useParallax;
  40801. /**
  40802. * Is parallax enabled or not.
  40803. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40804. */
  40805. useParallax: boolean;
  40806. private _useParallaxOcclusion;
  40807. /**
  40808. * Is parallax occlusion enabled or not.
  40809. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40810. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40811. */
  40812. useParallaxOcclusion: boolean;
  40813. /**
  40814. * 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.
  40815. */
  40816. parallaxScaleBias: number;
  40817. private _roughness;
  40818. /**
  40819. * Helps to define how blurry the reflections should appears in the material.
  40820. */
  40821. roughness: number;
  40822. /**
  40823. * In case of refraction, define the value of the index of refraction.
  40824. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40825. */
  40826. indexOfRefraction: number;
  40827. /**
  40828. * Invert the refraction texture alongside the y axis.
  40829. * It can be useful with procedural textures or probe for instance.
  40830. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40831. */
  40832. invertRefractionY: boolean;
  40833. /**
  40834. * Defines the alpha limits in alpha test mode.
  40835. */
  40836. alphaCutOff: number;
  40837. private _useLightmapAsShadowmap;
  40838. /**
  40839. * In case of light mapping, define whether the map contains light or shadow informations.
  40840. */
  40841. useLightmapAsShadowmap: boolean;
  40842. private _diffuseFresnelParameters;
  40843. /**
  40844. * Define the diffuse fresnel parameters of the material.
  40845. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40846. */
  40847. diffuseFresnelParameters: FresnelParameters;
  40848. private _opacityFresnelParameters;
  40849. /**
  40850. * Define the opacity fresnel parameters of the material.
  40851. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40852. */
  40853. opacityFresnelParameters: FresnelParameters;
  40854. private _reflectionFresnelParameters;
  40855. /**
  40856. * Define the reflection fresnel parameters of the material.
  40857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40858. */
  40859. reflectionFresnelParameters: FresnelParameters;
  40860. private _refractionFresnelParameters;
  40861. /**
  40862. * Define the refraction fresnel parameters of the material.
  40863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40864. */
  40865. refractionFresnelParameters: FresnelParameters;
  40866. private _emissiveFresnelParameters;
  40867. /**
  40868. * Define the emissive fresnel parameters of the material.
  40869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40870. */
  40871. emissiveFresnelParameters: FresnelParameters;
  40872. private _useReflectionFresnelFromSpecular;
  40873. /**
  40874. * If true automatically deducts the fresnels values from the material specularity.
  40875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40876. */
  40877. useReflectionFresnelFromSpecular: boolean;
  40878. private _useGlossinessFromSpecularMapAlpha;
  40879. /**
  40880. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40881. */
  40882. useGlossinessFromSpecularMapAlpha: boolean;
  40883. private _maxSimultaneousLights;
  40884. /**
  40885. * Defines the maximum number of lights that can be used in the material
  40886. */
  40887. maxSimultaneousLights: number;
  40888. private _invertNormalMapX;
  40889. /**
  40890. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40891. */
  40892. invertNormalMapX: boolean;
  40893. private _invertNormalMapY;
  40894. /**
  40895. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40896. */
  40897. invertNormalMapY: boolean;
  40898. private _twoSidedLighting;
  40899. /**
  40900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40901. */
  40902. twoSidedLighting: boolean;
  40903. /**
  40904. * Default configuration related to image processing available in the standard Material.
  40905. */
  40906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40907. /**
  40908. * Gets the image processing configuration used either in this material.
  40909. */
  40910. /**
  40911. * Sets the Default image processing configuration used either in the this material.
  40912. *
  40913. * If sets to null, the scene one is in use.
  40914. */
  40915. imageProcessingConfiguration: ImageProcessingConfiguration;
  40916. /**
  40917. * Keep track of the image processing observer to allow dispose and replace.
  40918. */
  40919. private _imageProcessingObserver;
  40920. /**
  40921. * Attaches a new image processing configuration to the Standard Material.
  40922. * @param configuration
  40923. */
  40924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40925. /**
  40926. * Gets wether the color curves effect is enabled.
  40927. */
  40928. /**
  40929. * Sets wether the color curves effect is enabled.
  40930. */
  40931. cameraColorCurvesEnabled: boolean;
  40932. /**
  40933. * Gets wether the color grading effect is enabled.
  40934. */
  40935. /**
  40936. * Gets wether the color grading effect is enabled.
  40937. */
  40938. cameraColorGradingEnabled: boolean;
  40939. /**
  40940. * Gets wether tonemapping is enabled or not.
  40941. */
  40942. /**
  40943. * Sets wether tonemapping is enabled or not
  40944. */
  40945. cameraToneMappingEnabled: boolean;
  40946. /**
  40947. * The camera exposure used on this material.
  40948. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40949. * This corresponds to a photographic exposure.
  40950. */
  40951. /**
  40952. * The camera exposure used on this material.
  40953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40954. * This corresponds to a photographic exposure.
  40955. */
  40956. cameraExposure: number;
  40957. /**
  40958. * Gets The camera contrast used on this material.
  40959. */
  40960. /**
  40961. * Sets The camera contrast used on this material.
  40962. */
  40963. cameraContrast: number;
  40964. /**
  40965. * Gets the Color Grading 2D Lookup Texture.
  40966. */
  40967. /**
  40968. * Sets the Color Grading 2D Lookup Texture.
  40969. */
  40970. cameraColorGradingTexture: Nullable<BaseTexture>;
  40971. /**
  40972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40974. * 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;
  40975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40976. */
  40977. /**
  40978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40980. * 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;
  40981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40982. */
  40983. cameraColorCurves: Nullable<ColorCurves>;
  40984. /**
  40985. * Custom callback helping to override the default shader used in the material.
  40986. */
  40987. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40988. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40989. protected _worldViewProjectionMatrix: Matrix;
  40990. protected _globalAmbientColor: Color3;
  40991. protected _useLogarithmicDepth: boolean;
  40992. protected _rebuildInParallel: boolean;
  40993. /**
  40994. * Instantiates a new standard material.
  40995. * This is the default material used in Babylon. It is the best trade off between quality
  40996. * and performances.
  40997. * @see http://doc.babylonjs.com/babylon101/materials
  40998. * @param name Define the name of the material in the scene
  40999. * @param scene Define the scene the material belong to
  41000. */
  41001. constructor(name: string, scene: Scene);
  41002. /**
  41003. * Gets a boolean indicating that current material needs to register RTT
  41004. */
  41005. readonly hasRenderTargetTextures: boolean;
  41006. /**
  41007. * Gets the current class name of the material e.g. "StandardMaterial"
  41008. * Mainly use in serialization.
  41009. * @returns the class name
  41010. */
  41011. getClassName(): string;
  41012. /**
  41013. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41014. * You can try switching to logarithmic depth.
  41015. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41016. */
  41017. useLogarithmicDepth: boolean;
  41018. /**
  41019. * Specifies if the material will require alpha blending
  41020. * @returns a boolean specifying if alpha blending is needed
  41021. */
  41022. needAlphaBlending(): boolean;
  41023. /**
  41024. * Specifies if this material should be rendered in alpha test mode
  41025. * @returns a boolean specifying if an alpha test is needed.
  41026. */
  41027. needAlphaTesting(): boolean;
  41028. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41029. /**
  41030. * Get the texture used for alpha test purpose.
  41031. * @returns the diffuse texture in case of the standard material.
  41032. */
  41033. getAlphaTestTexture(): Nullable<BaseTexture>;
  41034. /**
  41035. * Get if the submesh is ready to be used and all its information available.
  41036. * Child classes can use it to update shaders
  41037. * @param mesh defines the mesh to check
  41038. * @param subMesh defines which submesh to check
  41039. * @param useInstances specifies that instances should be used
  41040. * @returns a boolean indicating that the submesh is ready or not
  41041. */
  41042. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41043. /**
  41044. * Builds the material UBO layouts.
  41045. * Used internally during the effect preparation.
  41046. */
  41047. buildUniformLayout(): void;
  41048. /**
  41049. * Unbinds the material from the mesh
  41050. */
  41051. unbind(): void;
  41052. /**
  41053. * Binds the submesh to this material by preparing the effect and shader to draw
  41054. * @param world defines the world transformation matrix
  41055. * @param mesh defines the mesh containing the submesh
  41056. * @param subMesh defines the submesh to bind the material to
  41057. */
  41058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41059. /**
  41060. * Get the list of animatables in the material.
  41061. * @returns the list of animatables object used in the material
  41062. */
  41063. getAnimatables(): IAnimatable[];
  41064. /**
  41065. * Gets the active textures from the material
  41066. * @returns an array of textures
  41067. */
  41068. getActiveTextures(): BaseTexture[];
  41069. /**
  41070. * Specifies if the material uses a texture
  41071. * @param texture defines the texture to check against the material
  41072. * @returns a boolean specifying if the material uses the texture
  41073. */
  41074. hasTexture(texture: BaseTexture): boolean;
  41075. /**
  41076. * Disposes the material
  41077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41079. */
  41080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41081. /**
  41082. * Makes a duplicate of the material, and gives it a new name
  41083. * @param name defines the new name for the duplicated material
  41084. * @returns the cloned material
  41085. */
  41086. clone(name: string): StandardMaterial;
  41087. /**
  41088. * Serializes this material in a JSON representation
  41089. * @returns the serialized material object
  41090. */
  41091. serialize(): any;
  41092. /**
  41093. * Creates a standard material from parsed material data
  41094. * @param source defines the JSON representation of the material
  41095. * @param scene defines the hosting scene
  41096. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41097. * @returns a new standard material
  41098. */
  41099. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41100. /**
  41101. * Are diffuse textures enabled in the application.
  41102. */
  41103. static DiffuseTextureEnabled: boolean;
  41104. /**
  41105. * Are ambient textures enabled in the application.
  41106. */
  41107. static AmbientTextureEnabled: boolean;
  41108. /**
  41109. * Are opacity textures enabled in the application.
  41110. */
  41111. static OpacityTextureEnabled: boolean;
  41112. /**
  41113. * Are reflection textures enabled in the application.
  41114. */
  41115. static ReflectionTextureEnabled: boolean;
  41116. /**
  41117. * Are emissive textures enabled in the application.
  41118. */
  41119. static EmissiveTextureEnabled: boolean;
  41120. /**
  41121. * Are specular textures enabled in the application.
  41122. */
  41123. static SpecularTextureEnabled: boolean;
  41124. /**
  41125. * Are bump textures enabled in the application.
  41126. */
  41127. static BumpTextureEnabled: boolean;
  41128. /**
  41129. * Are lightmap textures enabled in the application.
  41130. */
  41131. static LightmapTextureEnabled: boolean;
  41132. /**
  41133. * Are refraction textures enabled in the application.
  41134. */
  41135. static RefractionTextureEnabled: boolean;
  41136. /**
  41137. * Are color grading textures enabled in the application.
  41138. */
  41139. static ColorGradingTextureEnabled: boolean;
  41140. /**
  41141. * Are fresnels enabled in the application.
  41142. */
  41143. static FresnelEnabled: boolean;
  41144. }
  41145. }
  41146. declare module BABYLON {
  41147. /** @hidden */
  41148. export var imageProcessingPixelShader: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module BABYLON {
  41154. /**
  41155. * ImageProcessingPostProcess
  41156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41157. */
  41158. export class ImageProcessingPostProcess extends PostProcess {
  41159. /**
  41160. * Default configuration related to image processing available in the PBR Material.
  41161. */
  41162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41163. /**
  41164. * Gets the image processing configuration used either in this material.
  41165. */
  41166. /**
  41167. * Sets the Default image processing configuration used either in the this material.
  41168. *
  41169. * If sets to null, the scene one is in use.
  41170. */
  41171. imageProcessingConfiguration: ImageProcessingConfiguration;
  41172. /**
  41173. * Keep track of the image processing observer to allow dispose and replace.
  41174. */
  41175. private _imageProcessingObserver;
  41176. /**
  41177. * Attaches a new image processing configuration to the PBR Material.
  41178. * @param configuration
  41179. */
  41180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41181. /**
  41182. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41183. */
  41184. /**
  41185. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41186. */
  41187. colorCurves: Nullable<ColorCurves>;
  41188. /**
  41189. * Gets wether the color curves effect is enabled.
  41190. */
  41191. /**
  41192. * Sets wether the color curves effect is enabled.
  41193. */
  41194. colorCurvesEnabled: boolean;
  41195. /**
  41196. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41197. */
  41198. /**
  41199. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41200. */
  41201. colorGradingTexture: Nullable<BaseTexture>;
  41202. /**
  41203. * Gets wether the color grading effect is enabled.
  41204. */
  41205. /**
  41206. * Gets wether the color grading effect is enabled.
  41207. */
  41208. colorGradingEnabled: boolean;
  41209. /**
  41210. * Gets exposure used in the effect.
  41211. */
  41212. /**
  41213. * Sets exposure used in the effect.
  41214. */
  41215. exposure: number;
  41216. /**
  41217. * Gets wether tonemapping is enabled or not.
  41218. */
  41219. /**
  41220. * Sets wether tonemapping is enabled or not
  41221. */
  41222. toneMappingEnabled: boolean;
  41223. /**
  41224. * Gets the type of tone mapping effect.
  41225. */
  41226. /**
  41227. * Sets the type of tone mapping effect.
  41228. */
  41229. toneMappingType: number;
  41230. /**
  41231. * Gets contrast used in the effect.
  41232. */
  41233. /**
  41234. * Sets contrast used in the effect.
  41235. */
  41236. contrast: number;
  41237. /**
  41238. * Gets Vignette stretch size.
  41239. */
  41240. /**
  41241. * Sets Vignette stretch size.
  41242. */
  41243. vignetteStretch: number;
  41244. /**
  41245. * Gets Vignette centre X Offset.
  41246. */
  41247. /**
  41248. * Sets Vignette centre X Offset.
  41249. */
  41250. vignetteCentreX: number;
  41251. /**
  41252. * Gets Vignette centre Y Offset.
  41253. */
  41254. /**
  41255. * Sets Vignette centre Y Offset.
  41256. */
  41257. vignetteCentreY: number;
  41258. /**
  41259. * Gets Vignette weight or intensity of the vignette effect.
  41260. */
  41261. /**
  41262. * Sets Vignette weight or intensity of the vignette effect.
  41263. */
  41264. vignetteWeight: number;
  41265. /**
  41266. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41267. * if vignetteEnabled is set to true.
  41268. */
  41269. /**
  41270. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41271. * if vignetteEnabled is set to true.
  41272. */
  41273. vignetteColor: Color4;
  41274. /**
  41275. * Gets Camera field of view used by the Vignette effect.
  41276. */
  41277. /**
  41278. * Sets Camera field of view used by the Vignette effect.
  41279. */
  41280. vignetteCameraFov: number;
  41281. /**
  41282. * Gets the vignette blend mode allowing different kind of effect.
  41283. */
  41284. /**
  41285. * Sets the vignette blend mode allowing different kind of effect.
  41286. */
  41287. vignetteBlendMode: number;
  41288. /**
  41289. * Gets wether the vignette effect is enabled.
  41290. */
  41291. /**
  41292. * Sets wether the vignette effect is enabled.
  41293. */
  41294. vignetteEnabled: boolean;
  41295. private _fromLinearSpace;
  41296. /**
  41297. * Gets wether the input of the processing is in Gamma or Linear Space.
  41298. */
  41299. /**
  41300. * Sets wether the input of the processing is in Gamma or Linear Space.
  41301. */
  41302. fromLinearSpace: boolean;
  41303. /**
  41304. * Defines cache preventing GC.
  41305. */
  41306. private _defines;
  41307. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41308. /**
  41309. * "ImageProcessingPostProcess"
  41310. * @returns "ImageProcessingPostProcess"
  41311. */
  41312. getClassName(): string;
  41313. protected _updateParameters(): void;
  41314. dispose(camera?: Camera): void;
  41315. }
  41316. }
  41317. declare module BABYLON {
  41318. /**
  41319. * Class containing static functions to help procedurally build meshes
  41320. */
  41321. export class GroundBuilder {
  41322. /**
  41323. * Creates a ground mesh
  41324. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41325. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41327. * @param name defines the name of the mesh
  41328. * @param options defines the options used to create the mesh
  41329. * @param scene defines the hosting scene
  41330. * @returns the ground mesh
  41331. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41332. */
  41333. static CreateGround(name: string, options: {
  41334. width?: number;
  41335. height?: number;
  41336. subdivisions?: number;
  41337. subdivisionsX?: number;
  41338. subdivisionsY?: number;
  41339. updatable?: boolean;
  41340. }, scene: any): Mesh;
  41341. /**
  41342. * Creates a tiled ground mesh
  41343. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41344. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41345. * * 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
  41346. * * 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
  41347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41348. * @param name defines the name of the mesh
  41349. * @param options defines the options used to create the mesh
  41350. * @param scene defines the hosting scene
  41351. * @returns the tiled ground mesh
  41352. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41353. */
  41354. static CreateTiledGround(name: string, options: {
  41355. xmin: number;
  41356. zmin: number;
  41357. xmax: number;
  41358. zmax: number;
  41359. subdivisions?: {
  41360. w: number;
  41361. h: number;
  41362. };
  41363. precision?: {
  41364. w: number;
  41365. h: number;
  41366. };
  41367. updatable?: boolean;
  41368. }, scene?: Nullable<Scene>): Mesh;
  41369. /**
  41370. * Creates a ground mesh from a height map
  41371. * * The parameter `url` sets the URL of the height map image resource.
  41372. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41373. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41374. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41375. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41376. * * 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.
  41377. * * 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).
  41378. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41380. * @param name defines the name of the mesh
  41381. * @param url defines the url to the height map
  41382. * @param options defines the options used to create the mesh
  41383. * @param scene defines the hosting scene
  41384. * @returns the ground mesh
  41385. * @see https://doc.babylonjs.com/babylon101/height_map
  41386. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41387. */
  41388. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41389. width?: number;
  41390. height?: number;
  41391. subdivisions?: number;
  41392. minHeight?: number;
  41393. maxHeight?: number;
  41394. colorFilter?: Color3;
  41395. alphaFilter?: number;
  41396. updatable?: boolean;
  41397. onReady?: (mesh: GroundMesh) => void;
  41398. }, scene?: Nullable<Scene>): GroundMesh;
  41399. }
  41400. }
  41401. declare module BABYLON {
  41402. /**
  41403. * Class containing static functions to help procedurally build meshes
  41404. */
  41405. export class TorusBuilder {
  41406. /**
  41407. * Creates a torus mesh
  41408. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41409. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41410. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41412. * * 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
  41413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41414. * @param name defines the name of the mesh
  41415. * @param options defines the options used to create the mesh
  41416. * @param scene defines the hosting scene
  41417. * @returns the torus mesh
  41418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41419. */
  41420. static CreateTorus(name: string, options: {
  41421. diameter?: number;
  41422. thickness?: number;
  41423. tessellation?: number;
  41424. updatable?: boolean;
  41425. sideOrientation?: number;
  41426. frontUVs?: Vector4;
  41427. backUVs?: Vector4;
  41428. }, scene: any): Mesh;
  41429. }
  41430. }
  41431. declare module BABYLON {
  41432. /**
  41433. * Class containing static functions to help procedurally build meshes
  41434. */
  41435. export class CylinderBuilder {
  41436. /**
  41437. * Creates a cylinder or a cone mesh
  41438. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41439. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41440. * * 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.
  41441. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41442. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41443. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41444. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41445. * * 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).
  41446. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41447. * * 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).
  41448. * * 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
  41449. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41450. * * 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
  41451. * * 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.
  41452. * * If `enclose` is false, a ring surface is one element.
  41453. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41454. * * 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
  41455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41456. * * 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
  41457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41458. * @param name defines the name of the mesh
  41459. * @param options defines the options used to create the mesh
  41460. * @param scene defines the hosting scene
  41461. * @returns the cylinder mesh
  41462. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41463. */
  41464. static CreateCylinder(name: string, options: {
  41465. height?: number;
  41466. diameterTop?: number;
  41467. diameterBottom?: number;
  41468. diameter?: number;
  41469. tessellation?: number;
  41470. subdivisions?: number;
  41471. arc?: number;
  41472. faceColors?: Color4[];
  41473. faceUV?: Vector4[];
  41474. updatable?: boolean;
  41475. hasRings?: boolean;
  41476. enclose?: boolean;
  41477. cap?: number;
  41478. sideOrientation?: number;
  41479. frontUVs?: Vector4;
  41480. backUVs?: Vector4;
  41481. }, scene: any): Mesh;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * Options to modify the vr teleportation behavior.
  41487. */
  41488. export interface VRTeleportationOptions {
  41489. /**
  41490. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41491. */
  41492. floorMeshName?: string;
  41493. /**
  41494. * A list of meshes to be used as the teleportation floor. (default: empty)
  41495. */
  41496. floorMeshes?: Mesh[];
  41497. }
  41498. /**
  41499. * Options to modify the vr experience helper's behavior.
  41500. */
  41501. export interface VRExperienceHelperOptions extends WebVROptions {
  41502. /**
  41503. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41504. */
  41505. createDeviceOrientationCamera?: boolean;
  41506. /**
  41507. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41508. */
  41509. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41510. /**
  41511. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41512. */
  41513. laserToggle?: boolean;
  41514. /**
  41515. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41516. */
  41517. floorMeshes?: Mesh[];
  41518. /**
  41519. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41520. */
  41521. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41522. }
  41523. /**
  41524. * Event containing information after VR has been entered
  41525. */
  41526. export class OnAfterEnteringVRObservableEvent {
  41527. /**
  41528. * If entering vr was successful
  41529. */
  41530. success: boolean;
  41531. }
  41532. /**
  41533. * Helps to quickly add VR support to an existing scene.
  41534. * See http://doc.babylonjs.com/how_to/webvr_helper
  41535. */
  41536. export class VRExperienceHelper {
  41537. /** Options to modify the vr experience helper's behavior. */
  41538. webVROptions: VRExperienceHelperOptions;
  41539. private _scene;
  41540. private _position;
  41541. private _btnVR;
  41542. private _btnVRDisplayed;
  41543. private _webVRsupported;
  41544. private _webVRready;
  41545. private _webVRrequesting;
  41546. private _webVRpresenting;
  41547. private _hasEnteredVR;
  41548. private _fullscreenVRpresenting;
  41549. private _inputElement;
  41550. private _webVRCamera;
  41551. private _vrDeviceOrientationCamera;
  41552. private _deviceOrientationCamera;
  41553. private _existingCamera;
  41554. private _onKeyDown;
  41555. private _onVrDisplayPresentChange;
  41556. private _onVRDisplayChanged;
  41557. private _onVRRequestPresentStart;
  41558. private _onVRRequestPresentComplete;
  41559. /**
  41560. * 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)
  41561. */
  41562. enableGazeEvenWhenNoPointerLock: boolean;
  41563. /**
  41564. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41565. */
  41566. exitVROnDoubleTap: boolean;
  41567. /**
  41568. * Observable raised right before entering VR.
  41569. */
  41570. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41571. /**
  41572. * Observable raised when entering VR has completed.
  41573. */
  41574. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41575. /**
  41576. * Observable raised when exiting VR.
  41577. */
  41578. onExitingVRObservable: Observable<VRExperienceHelper>;
  41579. /**
  41580. * Observable raised when controller mesh is loaded.
  41581. */
  41582. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41583. /** Return this.onEnteringVRObservable
  41584. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41585. */
  41586. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41587. /** Return this.onExitingVRObservable
  41588. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41589. */
  41590. readonly onExitingVR: Observable<VRExperienceHelper>;
  41591. /** Return this.onControllerMeshLoadedObservable
  41592. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41593. */
  41594. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41595. private _rayLength;
  41596. private _useCustomVRButton;
  41597. private _teleportationRequested;
  41598. private _teleportActive;
  41599. private _floorMeshName;
  41600. private _floorMeshesCollection;
  41601. private _rotationAllowed;
  41602. private _teleportBackwardsVector;
  41603. private _teleportationTarget;
  41604. private _isDefaultTeleportationTarget;
  41605. private _postProcessMove;
  41606. private _teleportationFillColor;
  41607. private _teleportationBorderColor;
  41608. private _rotationAngle;
  41609. private _haloCenter;
  41610. private _cameraGazer;
  41611. private _padSensibilityUp;
  41612. private _padSensibilityDown;
  41613. private _leftController;
  41614. private _rightController;
  41615. /**
  41616. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41617. */
  41618. onNewMeshSelected: Observable<AbstractMesh>;
  41619. /**
  41620. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41621. * This observable will provide the mesh and the controller used to select the mesh
  41622. */
  41623. onMeshSelectedWithController: Observable<{
  41624. mesh: AbstractMesh;
  41625. controller: WebVRController;
  41626. }>;
  41627. /**
  41628. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41629. */
  41630. onNewMeshPicked: Observable<PickingInfo>;
  41631. private _circleEase;
  41632. /**
  41633. * Observable raised before camera teleportation
  41634. */
  41635. onBeforeCameraTeleport: Observable<Vector3>;
  41636. /**
  41637. * Observable raised after camera teleportation
  41638. */
  41639. onAfterCameraTeleport: Observable<Vector3>;
  41640. /**
  41641. * Observable raised when current selected mesh gets unselected
  41642. */
  41643. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41644. private _raySelectionPredicate;
  41645. /**
  41646. * To be optionaly changed by user to define custom ray selection
  41647. */
  41648. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41649. /**
  41650. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41651. */
  41652. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41653. /**
  41654. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41655. */
  41656. teleportationEnabled: boolean;
  41657. private _defaultHeight;
  41658. private _teleportationInitialized;
  41659. private _interactionsEnabled;
  41660. private _interactionsRequested;
  41661. private _displayGaze;
  41662. private _displayLaserPointer;
  41663. /**
  41664. * The mesh used to display where the user is going to teleport.
  41665. */
  41666. /**
  41667. * Sets the mesh to be used to display where the user is going to teleport.
  41668. */
  41669. teleportationTarget: Mesh;
  41670. /**
  41671. * 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
  41672. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41673. * See http://doc.babylonjs.com/resources/baking_transformations
  41674. */
  41675. gazeTrackerMesh: Mesh;
  41676. /**
  41677. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41678. */
  41679. updateGazeTrackerScale: boolean;
  41680. /**
  41681. * If the gaze trackers color should be updated when selecting meshes
  41682. */
  41683. updateGazeTrackerColor: boolean;
  41684. /**
  41685. * If the controller laser color should be updated when selecting meshes
  41686. */
  41687. updateControllerLaserColor: boolean;
  41688. /**
  41689. * The gaze tracking mesh corresponding to the left controller
  41690. */
  41691. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41692. /**
  41693. * The gaze tracking mesh corresponding to the right controller
  41694. */
  41695. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41696. /**
  41697. * If the ray of the gaze should be displayed.
  41698. */
  41699. /**
  41700. * Sets if the ray of the gaze should be displayed.
  41701. */
  41702. displayGaze: boolean;
  41703. /**
  41704. * If the ray of the LaserPointer should be displayed.
  41705. */
  41706. /**
  41707. * Sets if the ray of the LaserPointer should be displayed.
  41708. */
  41709. displayLaserPointer: boolean;
  41710. /**
  41711. * The deviceOrientationCamera used as the camera when not in VR.
  41712. */
  41713. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41714. /**
  41715. * Based on the current WebVR support, returns the current VR camera used.
  41716. */
  41717. readonly currentVRCamera: Nullable<Camera>;
  41718. /**
  41719. * The webVRCamera which is used when in VR.
  41720. */
  41721. readonly webVRCamera: WebVRFreeCamera;
  41722. /**
  41723. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41724. */
  41725. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41726. /**
  41727. * The html button that is used to trigger entering into VR.
  41728. */
  41729. readonly vrButton: Nullable<HTMLButtonElement>;
  41730. private readonly _teleportationRequestInitiated;
  41731. /**
  41732. * Defines wether or not Pointer lock should be requested when switching to
  41733. * full screen.
  41734. */
  41735. requestPointerLockOnFullScreen: boolean;
  41736. /**
  41737. * Instantiates a VRExperienceHelper.
  41738. * Helps to quickly add VR support to an existing scene.
  41739. * @param scene The scene the VRExperienceHelper belongs to.
  41740. * @param webVROptions Options to modify the vr experience helper's behavior.
  41741. */
  41742. constructor(scene: Scene,
  41743. /** Options to modify the vr experience helper's behavior. */
  41744. webVROptions?: VRExperienceHelperOptions);
  41745. private _onDefaultMeshLoaded;
  41746. private _onResize;
  41747. private _onFullscreenChange;
  41748. /**
  41749. * Gets a value indicating if we are currently in VR mode.
  41750. */
  41751. readonly isInVRMode: boolean;
  41752. private onVrDisplayPresentChange;
  41753. private onVRDisplayChanged;
  41754. private moveButtonToBottomRight;
  41755. private displayVRButton;
  41756. private updateButtonVisibility;
  41757. private _cachedAngularSensibility;
  41758. /**
  41759. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41760. * Otherwise, will use the fullscreen API.
  41761. */
  41762. enterVR(): void;
  41763. /**
  41764. * Attempt to exit VR, or fullscreen.
  41765. */
  41766. exitVR(): void;
  41767. /**
  41768. * The position of the vr experience helper.
  41769. */
  41770. /**
  41771. * Sets the position of the vr experience helper.
  41772. */
  41773. position: Vector3;
  41774. /**
  41775. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41776. */
  41777. enableInteractions(): void;
  41778. private readonly _noControllerIsActive;
  41779. private beforeRender;
  41780. private _isTeleportationFloor;
  41781. /**
  41782. * Adds a floor mesh to be used for teleportation.
  41783. * @param floorMesh the mesh to be used for teleportation.
  41784. */
  41785. addFloorMesh(floorMesh: Mesh): void;
  41786. /**
  41787. * Removes a floor mesh from being used for teleportation.
  41788. * @param floorMesh the mesh to be removed.
  41789. */
  41790. removeFloorMesh(floorMesh: Mesh): void;
  41791. /**
  41792. * Enables interactions and teleportation using the VR controllers and gaze.
  41793. * @param vrTeleportationOptions options to modify teleportation behavior.
  41794. */
  41795. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41796. private _onNewGamepadConnected;
  41797. private _tryEnableInteractionOnController;
  41798. private _onNewGamepadDisconnected;
  41799. private _enableInteractionOnController;
  41800. private _checkTeleportWithRay;
  41801. private _checkRotate;
  41802. private _checkTeleportBackwards;
  41803. private _enableTeleportationOnController;
  41804. private _createTeleportationCircles;
  41805. private _displayTeleportationTarget;
  41806. private _hideTeleportationTarget;
  41807. private _rotateCamera;
  41808. private _moveTeleportationSelectorTo;
  41809. private _workingVector;
  41810. private _workingQuaternion;
  41811. private _workingMatrix;
  41812. /**
  41813. * Teleports the users feet to the desired location
  41814. * @param location The location where the user's feet should be placed
  41815. */
  41816. teleportCamera(location: Vector3): void;
  41817. private _convertNormalToDirectionOfRay;
  41818. private _castRayAndSelectObject;
  41819. private _notifySelectedMeshUnselected;
  41820. /**
  41821. * Sets the color of the laser ray from the vr controllers.
  41822. * @param color new color for the ray.
  41823. */
  41824. changeLaserColor(color: Color3): void;
  41825. /**
  41826. * Sets the color of the ray from the vr headsets gaze.
  41827. * @param color new color for the ray.
  41828. */
  41829. changeGazeColor(color: Color3): void;
  41830. /**
  41831. * Exits VR and disposes of the vr experience helper
  41832. */
  41833. dispose(): void;
  41834. /**
  41835. * Gets the name of the VRExperienceHelper class
  41836. * @returns "VRExperienceHelper"
  41837. */
  41838. getClassName(): string;
  41839. }
  41840. }
  41841. declare module BABYLON {
  41842. /**
  41843. * States of the webXR experience
  41844. */
  41845. export enum WebXRState {
  41846. /**
  41847. * Transitioning to being in XR mode
  41848. */
  41849. ENTERING_XR = 0,
  41850. /**
  41851. * Transitioning to non XR mode
  41852. */
  41853. EXITING_XR = 1,
  41854. /**
  41855. * In XR mode and presenting
  41856. */
  41857. IN_XR = 2,
  41858. /**
  41859. * Not entered XR mode
  41860. */
  41861. NOT_IN_XR = 3
  41862. }
  41863. /**
  41864. * Abstraction of the XR render target
  41865. */
  41866. export interface WebXRRenderTarget extends IDisposable {
  41867. /**
  41868. * xrpresent context of the canvas which can be used to display/mirror xr content
  41869. */
  41870. canvasContext: WebGLRenderingContext;
  41871. /**
  41872. * xr layer for the canvas
  41873. */
  41874. xrLayer: Nullable<XRWebGLLayer>;
  41875. /**
  41876. * Initializes the xr layer for the session
  41877. * @param xrSession xr session
  41878. * @returns a promise that will resolve once the XR Layer has been created
  41879. */
  41880. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41881. }
  41882. }
  41883. declare module BABYLON {
  41884. /**
  41885. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41886. */
  41887. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41888. private _engine;
  41889. private _canvas;
  41890. /**
  41891. * xrpresent context of the canvas which can be used to display/mirror xr content
  41892. */
  41893. canvasContext: WebGLRenderingContext;
  41894. /**
  41895. * xr layer for the canvas
  41896. */
  41897. xrLayer: Nullable<XRWebGLLayer>;
  41898. /**
  41899. * Initializes the xr layer for the session
  41900. * @param xrSession xr session
  41901. * @returns a promise that will resolve once the XR Layer has been created
  41902. */
  41903. initializeXRLayerAsync(xrSession: any): any;
  41904. /**
  41905. * Initializes the canvas to be added/removed upon entering/exiting xr
  41906. * @param engine the Babylon engine
  41907. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41908. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41909. */
  41910. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41911. /**
  41912. * Disposes of the object
  41913. */
  41914. dispose(): void;
  41915. private _setManagedOutputCanvas;
  41916. private _addCanvas;
  41917. private _removeCanvas;
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * Manages an XRSession to work with Babylon's engine
  41923. * @see https://doc.babylonjs.com/how_to/webxr
  41924. */
  41925. export class WebXRSessionManager implements IDisposable {
  41926. private scene;
  41927. /**
  41928. * Fires every time a new xrFrame arrives which can be used to update the camera
  41929. */
  41930. onXRFrameObservable: Observable<any>;
  41931. /**
  41932. * Fires when the xr session is ended either by the device or manually done
  41933. */
  41934. onXRSessionEnded: Observable<any>;
  41935. /**
  41936. * Underlying xr session
  41937. */
  41938. session: XRSession;
  41939. /**
  41940. * Type of reference space used when creating the session
  41941. */
  41942. referenceSpace: XRReferenceSpace;
  41943. /**
  41944. * Current XR frame
  41945. */
  41946. currentFrame: Nullable<XRFrame>;
  41947. private _xrNavigator;
  41948. private baseLayer;
  41949. private _rttProvider;
  41950. private _sessionEnded;
  41951. /**
  41952. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41953. * @param scene The scene which the session should be created for
  41954. */
  41955. constructor(scene: Scene);
  41956. /**
  41957. * Initializes the manager
  41958. * After initialization enterXR can be called to start an XR session
  41959. * @returns Promise which resolves after it is initialized
  41960. */
  41961. initializeAsync(): Promise<void>;
  41962. /**
  41963. * Initializes an xr session
  41964. * @param xrSessionMode mode to initialize
  41965. * @param optionalFeatures defines optional values to pass to the session builder
  41966. * @returns a promise which will resolve once the session has been initialized
  41967. */
  41968. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41969. /**
  41970. * Sets the reference space on the xr session
  41971. * @param referenceSpace space to set
  41972. * @returns a promise that will resolve once the reference space has been set
  41973. */
  41974. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41975. /**
  41976. * Updates the render state of the session
  41977. * @param state state to set
  41978. * @returns a promise that resolves once the render state has been updated
  41979. */
  41980. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41981. /**
  41982. * Starts rendering to the xr layer
  41983. * @returns a promise that will resolve once rendering has started
  41984. */
  41985. startRenderingToXRAsync(): Promise<void>;
  41986. /**
  41987. * Gets the correct render target texture to be rendered this frame for this eye
  41988. * @param eye the eye for which to get the render target
  41989. * @returns the render target for the specified eye
  41990. */
  41991. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41992. /**
  41993. * Stops the xrSession and restores the renderloop
  41994. * @returns Promise which resolves after it exits XR
  41995. */
  41996. exitXRAsync(): Promise<void>;
  41997. /**
  41998. * Checks if a session would be supported for the creation options specified
  41999. * @param sessionMode session mode to check if supported eg. immersive-vr
  42000. * @returns true if supported
  42001. */
  42002. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42003. /**
  42004. * Creates a WebXRRenderTarget object for the XR session
  42005. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42006. * @returns a WebXR render target to which the session can render
  42007. */
  42008. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  42009. /**
  42010. * @hidden
  42011. * Converts the render layer of xrSession to a render target
  42012. * @param session session to create render target for
  42013. * @param scene scene the new render target should be created for
  42014. */
  42015. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42016. /**
  42017. * Disposes of the session manager
  42018. */
  42019. dispose(): void;
  42020. }
  42021. }
  42022. declare module BABYLON {
  42023. /**
  42024. * WebXR Camera which holds the views for the xrSession
  42025. * @see https://doc.babylonjs.com/how_to/webxr
  42026. */
  42027. export class WebXRCamera extends FreeCamera {
  42028. private static _TmpMatrix;
  42029. /**
  42030. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42031. * @param name the name of the camera
  42032. * @param scene the scene to add the camera to
  42033. */
  42034. constructor(name: string, scene: Scene);
  42035. private _updateNumberOfRigCameras;
  42036. /** @hidden */
  42037. _updateForDualEyeDebugging(): void;
  42038. /**
  42039. * Updates the cameras position from the current pose information of the XR session
  42040. * @param xrSessionManager the session containing pose information
  42041. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42042. */
  42043. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. /**
  42048. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42049. * @see https://doc.babylonjs.com/how_to/webxr
  42050. */
  42051. export class WebXRExperienceHelper implements IDisposable {
  42052. private scene;
  42053. /**
  42054. * 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
  42055. */
  42056. container: AbstractMesh;
  42057. /**
  42058. * Camera used to render xr content
  42059. */
  42060. camera: WebXRCamera;
  42061. /**
  42062. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42063. */
  42064. state: WebXRState;
  42065. private _setState;
  42066. private static _TmpVector;
  42067. /**
  42068. * Fires when the state of the experience helper has changed
  42069. */
  42070. onStateChangedObservable: Observable<WebXRState>;
  42071. /** Session manager used to keep track of xr session */
  42072. sessionManager: WebXRSessionManager;
  42073. private _nonVRCamera;
  42074. private _originalSceneAutoClear;
  42075. private _supported;
  42076. /**
  42077. * Creates the experience helper
  42078. * @param scene the scene to attach the experience helper to
  42079. * @returns a promise for the experience helper
  42080. */
  42081. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42082. /**
  42083. * Creates a WebXRExperienceHelper
  42084. * @param scene The scene the helper should be created in
  42085. */
  42086. private constructor();
  42087. /**
  42088. * Exits XR mode and returns the scene to its original state
  42089. * @returns promise that resolves after xr mode has exited
  42090. */
  42091. exitXRAsync(): Promise<void>;
  42092. /**
  42093. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42094. * @param sessionMode options for the XR session
  42095. * @param referenceSpaceType frame of reference of the XR session
  42096. * @param renderTarget the output canvas that will be used to enter XR mode
  42097. * @returns promise that resolves after xr mode has entered
  42098. */
  42099. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  42100. /**
  42101. * Updates the global position of the camera by moving the camera's container
  42102. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42103. * @param position The desired global position of the camera
  42104. */
  42105. setPositionOfCameraUsingContainer(position: Vector3): void;
  42106. /**
  42107. * Rotates the xr camera by rotating the camera's container around the camera's position
  42108. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42109. * @param rotation the desired quaternion rotation to apply to the camera
  42110. */
  42111. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42112. /**
  42113. * Disposes of the experience helper
  42114. */
  42115. dispose(): void;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * Button which can be used to enter a different mode of XR
  42121. */
  42122. export class WebXREnterExitUIButton {
  42123. /** button element */
  42124. element: HTMLElement;
  42125. /** XR initialization options for the button */
  42126. sessionMode: XRSessionMode;
  42127. /** Reference space type */
  42128. referenceSpaceType: XRReferenceSpaceType;
  42129. /**
  42130. * Creates a WebXREnterExitUIButton
  42131. * @param element button element
  42132. * @param sessionMode XR initialization session mode
  42133. * @param referenceSpaceType the type of reference space to be used
  42134. */
  42135. constructor(
  42136. /** button element */
  42137. element: HTMLElement,
  42138. /** XR initialization options for the button */
  42139. sessionMode: XRSessionMode,
  42140. /** Reference space type */
  42141. referenceSpaceType: XRReferenceSpaceType);
  42142. /**
  42143. * Overwritable function which can be used to update the button's visuals when the state changes
  42144. * @param activeButton the current active button in the UI
  42145. */
  42146. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42147. }
  42148. /**
  42149. * Options to create the webXR UI
  42150. */
  42151. export class WebXREnterExitUIOptions {
  42152. /**
  42153. * Context to enter xr with
  42154. */
  42155. renderTarget?: Nullable<WebXRRenderTarget>;
  42156. /**
  42157. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42158. */
  42159. customButtons?: Array<WebXREnterExitUIButton>;
  42160. }
  42161. /**
  42162. * UI to allow the user to enter/exit XR mode
  42163. */
  42164. export class WebXREnterExitUI implements IDisposable {
  42165. private scene;
  42166. private _overlay;
  42167. private _buttons;
  42168. private _activeButton;
  42169. /**
  42170. * Fired every time the active button is changed.
  42171. *
  42172. * When xr is entered via a button that launches xr that button will be the callback parameter
  42173. *
  42174. * When exiting xr the callback parameter will be null)
  42175. */
  42176. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42177. /**
  42178. * Creates UI to allow the user to enter/exit XR mode
  42179. * @param scene the scene to add the ui to
  42180. * @param helper the xr experience helper to enter/exit xr with
  42181. * @param options options to configure the UI
  42182. * @returns the created ui
  42183. */
  42184. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42185. private constructor();
  42186. private _updateButtons;
  42187. /**
  42188. * Disposes of the object
  42189. */
  42190. dispose(): void;
  42191. }
  42192. }
  42193. declare module BABYLON {
  42194. /**
  42195. * Represents an XR input
  42196. */
  42197. export class WebXRController {
  42198. private scene;
  42199. /** The underlying input source for the controller */
  42200. inputSource: XRInputSource;
  42201. private parentContainer;
  42202. /**
  42203. * 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
  42204. */
  42205. grip?: AbstractMesh;
  42206. /**
  42207. * Pointer which can be used to select objects or attach a visible laser to
  42208. */
  42209. pointer: AbstractMesh;
  42210. private _gamepadMode;
  42211. /**
  42212. * If available, this is the gamepad object related to this controller.
  42213. * Using this object it is possible to get click events and trackpad changes of the
  42214. * webxr controller that is currently being used.
  42215. */
  42216. gamepadController?: WebVRController;
  42217. /**
  42218. * Event that fires when the controller is removed/disposed
  42219. */
  42220. onDisposeObservable: Observable<{}>;
  42221. private _tmpMatrix;
  42222. private _tmpQuaternion;
  42223. private _tmpVector;
  42224. /**
  42225. * Creates the controller
  42226. * @see https://doc.babylonjs.com/how_to/webxr
  42227. * @param scene the scene which the controller should be associated to
  42228. * @param inputSource the underlying input source for the controller
  42229. * @param parentContainer parent that the controller meshes should be children of
  42230. */
  42231. constructor(scene: Scene,
  42232. /** The underlying input source for the controller */
  42233. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42234. /**
  42235. * Updates the controller pose based on the given XRFrame
  42236. * @param xrFrame xr frame to update the pose with
  42237. * @param referenceSpace reference space to use
  42238. */
  42239. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42240. /**
  42241. * Gets a world space ray coming from the controller
  42242. * @param result the resulting ray
  42243. */
  42244. getWorldPointerRayToRef(result: Ray): void;
  42245. /**
  42246. * Get the scene associated with this controller
  42247. * @returns the scene object
  42248. */
  42249. getScene(): Scene;
  42250. /**
  42251. * Disposes of the object
  42252. */
  42253. dispose(): void;
  42254. }
  42255. }
  42256. declare module BABYLON {
  42257. /**
  42258. * XR input used to track XR inputs such as controllers/rays
  42259. */
  42260. export class WebXRInput implements IDisposable {
  42261. /**
  42262. * Base experience the input listens to
  42263. */
  42264. baseExperience: WebXRExperienceHelper;
  42265. /**
  42266. * XR controllers being tracked
  42267. */
  42268. controllers: Array<WebXRController>;
  42269. private _frameObserver;
  42270. private _stateObserver;
  42271. /**
  42272. * Event when a controller has been connected/added
  42273. */
  42274. onControllerAddedObservable: Observable<WebXRController>;
  42275. /**
  42276. * Event when a controller has been removed/disconnected
  42277. */
  42278. onControllerRemovedObservable: Observable<WebXRController>;
  42279. /**
  42280. * Initializes the WebXRInput
  42281. * @param baseExperience experience helper which the input should be created for
  42282. */
  42283. constructor(
  42284. /**
  42285. * Base experience the input listens to
  42286. */
  42287. baseExperience: WebXRExperienceHelper);
  42288. private _onInputSourcesChange;
  42289. private _addAndRemoveControllers;
  42290. /**
  42291. * Disposes of the object
  42292. */
  42293. dispose(): void;
  42294. }
  42295. }
  42296. declare module BABYLON {
  42297. /**
  42298. * Enables teleportation
  42299. */
  42300. export class WebXRControllerTeleportation {
  42301. private _teleportationFillColor;
  42302. private _teleportationBorderColor;
  42303. private _tmpRay;
  42304. private _tmpVector;
  42305. /**
  42306. * Creates a WebXRControllerTeleportation
  42307. * @param input input manager to add teleportation to
  42308. * @param floorMeshes floormeshes which can be teleported to
  42309. */
  42310. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42311. }
  42312. }
  42313. declare module BABYLON {
  42314. /**
  42315. * Handles pointer input automatically for the pointer of XR controllers
  42316. */
  42317. export class WebXRControllerPointerSelection {
  42318. private static _idCounter;
  42319. private _tmpRay;
  42320. /**
  42321. * Creates a WebXRControllerPointerSelection
  42322. * @param input input manager to setup pointer selection
  42323. */
  42324. constructor(input: WebXRInput);
  42325. private _convertNormalToDirectionOfRay;
  42326. private _updatePointerDistance;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * Class used to represent data loading progression
  42332. */
  42333. export class SceneLoaderProgressEvent {
  42334. /** defines if data length to load can be evaluated */
  42335. readonly lengthComputable: boolean;
  42336. /** defines the loaded data length */
  42337. readonly loaded: number;
  42338. /** defines the data length to load */
  42339. readonly total: number;
  42340. /**
  42341. * Create a new progress event
  42342. * @param lengthComputable defines if data length to load can be evaluated
  42343. * @param loaded defines the loaded data length
  42344. * @param total defines the data length to load
  42345. */
  42346. constructor(
  42347. /** defines if data length to load can be evaluated */
  42348. lengthComputable: boolean,
  42349. /** defines the loaded data length */
  42350. loaded: number,
  42351. /** defines the data length to load */
  42352. total: number);
  42353. /**
  42354. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42355. * @param event defines the source event
  42356. * @returns a new SceneLoaderProgressEvent
  42357. */
  42358. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42359. }
  42360. /**
  42361. * Interface used by SceneLoader plugins to define supported file extensions
  42362. */
  42363. export interface ISceneLoaderPluginExtensions {
  42364. /**
  42365. * Defines the list of supported extensions
  42366. */
  42367. [extension: string]: {
  42368. isBinary: boolean;
  42369. };
  42370. }
  42371. /**
  42372. * Interface used by SceneLoader plugin factory
  42373. */
  42374. export interface ISceneLoaderPluginFactory {
  42375. /**
  42376. * Defines the name of the factory
  42377. */
  42378. name: string;
  42379. /**
  42380. * Function called to create a new plugin
  42381. * @return the new plugin
  42382. */
  42383. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42384. /**
  42385. * The callback that returns true if the data can be directly loaded.
  42386. * @param data string containing the file data
  42387. * @returns if the data can be loaded directly
  42388. */
  42389. canDirectLoad?(data: string): boolean;
  42390. }
  42391. /**
  42392. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42393. */
  42394. export interface ISceneLoaderPluginBase {
  42395. /**
  42396. * The friendly name of this plugin.
  42397. */
  42398. name: string;
  42399. /**
  42400. * The file extensions supported by this plugin.
  42401. */
  42402. extensions: string | ISceneLoaderPluginExtensions;
  42403. /**
  42404. * The callback called when loading from a url.
  42405. * @param scene scene loading this url
  42406. * @param url url to load
  42407. * @param onSuccess callback called when the file successfully loads
  42408. * @param onProgress callback called while file is loading (if the server supports this mode)
  42409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42410. * @param onError callback called when the file fails to load
  42411. * @returns a file request object
  42412. */
  42413. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42414. /**
  42415. * The callback called when loading from a file object.
  42416. * @param scene scene loading this file
  42417. * @param file defines the file to load
  42418. * @param onSuccess defines the callback to call when data is loaded
  42419. * @param onProgress defines the callback to call during loading process
  42420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42421. * @param onError defines the callback to call when an error occurs
  42422. * @returns a file request object
  42423. */
  42424. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42425. /**
  42426. * The callback that returns true if the data can be directly loaded.
  42427. * @param data string containing the file data
  42428. * @returns if the data can be loaded directly
  42429. */
  42430. canDirectLoad?(data: string): boolean;
  42431. /**
  42432. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42433. * @param scene scene loading this data
  42434. * @param data string containing the data
  42435. * @returns data to pass to the plugin
  42436. */
  42437. directLoad?(scene: Scene, data: string): any;
  42438. /**
  42439. * The callback that allows custom handling of the root url based on the response url.
  42440. * @param rootUrl the original root url
  42441. * @param responseURL the response url if available
  42442. * @returns the new root url
  42443. */
  42444. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42445. }
  42446. /**
  42447. * Interface used to define a SceneLoader plugin
  42448. */
  42449. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42450. /**
  42451. * Import meshes into a scene.
  42452. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42453. * @param scene The scene to import into
  42454. * @param data The data to import
  42455. * @param rootUrl The root url for scene and resources
  42456. * @param meshes The meshes array to import into
  42457. * @param particleSystems The particle systems array to import into
  42458. * @param skeletons The skeletons array to import into
  42459. * @param onError The callback when import fails
  42460. * @returns True if successful or false otherwise
  42461. */
  42462. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42463. /**
  42464. * Load into a scene.
  42465. * @param scene The scene to load into
  42466. * @param data The data to import
  42467. * @param rootUrl The root url for scene and resources
  42468. * @param onError The callback when import fails
  42469. * @returns True if successful or false otherwise
  42470. */
  42471. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42472. /**
  42473. * Load into an asset container.
  42474. * @param scene The scene to load into
  42475. * @param data The data to import
  42476. * @param rootUrl The root url for scene and resources
  42477. * @param onError The callback when import fails
  42478. * @returns The loaded asset container
  42479. */
  42480. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42481. }
  42482. /**
  42483. * Interface used to define an async SceneLoader plugin
  42484. */
  42485. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42486. /**
  42487. * Import meshes into a scene.
  42488. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42489. * @param scene The scene to import into
  42490. * @param data The data to import
  42491. * @param rootUrl The root url for scene and resources
  42492. * @param onProgress The callback when the load progresses
  42493. * @param fileName Defines the name of the file to load
  42494. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42495. */
  42496. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42497. meshes: AbstractMesh[];
  42498. particleSystems: IParticleSystem[];
  42499. skeletons: Skeleton[];
  42500. animationGroups: AnimationGroup[];
  42501. }>;
  42502. /**
  42503. * Load into a scene.
  42504. * @param scene The scene to load into
  42505. * @param data The data to import
  42506. * @param rootUrl The root url for scene and resources
  42507. * @param onProgress The callback when the load progresses
  42508. * @param fileName Defines the name of the file to load
  42509. * @returns Nothing
  42510. */
  42511. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42512. /**
  42513. * Load into an asset container.
  42514. * @param scene The scene to load into
  42515. * @param data The data to import
  42516. * @param rootUrl The root url for scene and resources
  42517. * @param onProgress The callback when the load progresses
  42518. * @param fileName Defines the name of the file to load
  42519. * @returns The loaded asset container
  42520. */
  42521. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42522. }
  42523. /**
  42524. * Class used to load scene from various file formats using registered plugins
  42525. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42526. */
  42527. export class SceneLoader {
  42528. /**
  42529. * No logging while loading
  42530. */
  42531. static readonly NO_LOGGING: number;
  42532. /**
  42533. * Minimal logging while loading
  42534. */
  42535. static readonly MINIMAL_LOGGING: number;
  42536. /**
  42537. * Summary logging while loading
  42538. */
  42539. static readonly SUMMARY_LOGGING: number;
  42540. /**
  42541. * Detailled logging while loading
  42542. */
  42543. static readonly DETAILED_LOGGING: number;
  42544. /**
  42545. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42546. */
  42547. static ForceFullSceneLoadingForIncremental: boolean;
  42548. /**
  42549. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42550. */
  42551. static ShowLoadingScreen: boolean;
  42552. /**
  42553. * Defines the current logging level (while loading the scene)
  42554. * @ignorenaming
  42555. */
  42556. static loggingLevel: number;
  42557. /**
  42558. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42559. */
  42560. static CleanBoneMatrixWeights: boolean;
  42561. /**
  42562. * Event raised when a plugin is used to load a scene
  42563. */
  42564. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42565. private static _registeredPlugins;
  42566. private static _getDefaultPlugin;
  42567. private static _getPluginForExtension;
  42568. private static _getPluginForDirectLoad;
  42569. private static _getPluginForFilename;
  42570. private static _getDirectLoad;
  42571. private static _loadData;
  42572. private static _getFileInfo;
  42573. /**
  42574. * Gets a plugin that can load the given extension
  42575. * @param extension defines the extension to load
  42576. * @returns a plugin or null if none works
  42577. */
  42578. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42579. /**
  42580. * Gets a boolean indicating that the given extension can be loaded
  42581. * @param extension defines the extension to load
  42582. * @returns true if the extension is supported
  42583. */
  42584. static IsPluginForExtensionAvailable(extension: string): boolean;
  42585. /**
  42586. * Adds a new plugin to the list of registered plugins
  42587. * @param plugin defines the plugin to add
  42588. */
  42589. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42590. /**
  42591. * Import meshes into a scene
  42592. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42593. * @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)
  42594. * @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)
  42595. * @param scene the instance of BABYLON.Scene to append to
  42596. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42597. * @param onProgress a callback with a progress event for each file being loaded
  42598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42599. * @param pluginExtension the extension used to determine the plugin
  42600. * @returns The loaded plugin
  42601. */
  42602. 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>;
  42603. /**
  42604. * Import meshes into a scene
  42605. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42606. * @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)
  42607. * @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)
  42608. * @param scene the instance of BABYLON.Scene to append to
  42609. * @param onProgress a callback with a progress event for each file being loaded
  42610. * @param pluginExtension the extension used to determine the plugin
  42611. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42612. */
  42613. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42614. meshes: AbstractMesh[];
  42615. particleSystems: IParticleSystem[];
  42616. skeletons: Skeleton[];
  42617. animationGroups: AnimationGroup[];
  42618. }>;
  42619. /**
  42620. * Load a scene
  42621. * @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)
  42622. * @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)
  42623. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42624. * @param onSuccess a callback with the scene when import succeeds
  42625. * @param onProgress a callback with a progress event for each file being loaded
  42626. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42627. * @param pluginExtension the extension used to determine the plugin
  42628. * @returns The loaded plugin
  42629. */
  42630. 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>;
  42631. /**
  42632. * Load a scene
  42633. * @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)
  42634. * @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)
  42635. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42636. * @param onProgress a callback with a progress event for each file being loaded
  42637. * @param pluginExtension the extension used to determine the plugin
  42638. * @returns The loaded scene
  42639. */
  42640. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42641. /**
  42642. * Append a scene
  42643. * @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)
  42644. * @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)
  42645. * @param scene is the instance of BABYLON.Scene to append to
  42646. * @param onSuccess a callback with the scene when import succeeds
  42647. * @param onProgress a callback with a progress event for each file being loaded
  42648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42649. * @param pluginExtension the extension used to determine the plugin
  42650. * @returns The loaded plugin
  42651. */
  42652. 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>;
  42653. /**
  42654. * Append a scene
  42655. * @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)
  42656. * @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)
  42657. * @param scene is the instance of BABYLON.Scene to append to
  42658. * @param onProgress a callback with a progress event for each file being loaded
  42659. * @param pluginExtension the extension used to determine the plugin
  42660. * @returns The given scene
  42661. */
  42662. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42663. /**
  42664. * Load a scene into an asset container
  42665. * @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)
  42666. * @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)
  42667. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42668. * @param onSuccess a callback with the scene when import succeeds
  42669. * @param onProgress a callback with a progress event for each file being loaded
  42670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42671. * @param pluginExtension the extension used to determine the plugin
  42672. * @returns The loaded plugin
  42673. */
  42674. 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>;
  42675. /**
  42676. * Load a scene into an asset container
  42677. * @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)
  42678. * @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)
  42679. * @param scene is the instance of Scene to append to
  42680. * @param onProgress a callback with a progress event for each file being loaded
  42681. * @param pluginExtension the extension used to determine the plugin
  42682. * @returns The loaded asset container
  42683. */
  42684. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42685. }
  42686. }
  42687. declare module BABYLON {
  42688. /**
  42689. * Generic Controller
  42690. */
  42691. export class GenericController extends WebVRController {
  42692. /**
  42693. * Base Url for the controller model.
  42694. */
  42695. static readonly MODEL_BASE_URL: string;
  42696. /**
  42697. * File name for the controller model.
  42698. */
  42699. static readonly MODEL_FILENAME: string;
  42700. /**
  42701. * Creates a new GenericController from a gamepad
  42702. * @param vrGamepad the gamepad that the controller should be created from
  42703. */
  42704. constructor(vrGamepad: any);
  42705. /**
  42706. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42707. * @param scene scene in which to add meshes
  42708. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42709. */
  42710. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42711. /**
  42712. * Called once for each button that changed state since the last frame
  42713. * @param buttonIdx Which button index changed
  42714. * @param state New state of the button
  42715. * @param changes Which properties on the state changed since last frame
  42716. */
  42717. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42718. }
  42719. }
  42720. declare module BABYLON {
  42721. /**
  42722. * Defines the WindowsMotionController object that the state of the windows motion controller
  42723. */
  42724. export class WindowsMotionController extends WebVRController {
  42725. /**
  42726. * The base url used to load the left and right controller models
  42727. */
  42728. static MODEL_BASE_URL: string;
  42729. /**
  42730. * The name of the left controller model file
  42731. */
  42732. static MODEL_LEFT_FILENAME: string;
  42733. /**
  42734. * The name of the right controller model file
  42735. */
  42736. static MODEL_RIGHT_FILENAME: string;
  42737. /**
  42738. * The controller name prefix for this controller type
  42739. */
  42740. static readonly GAMEPAD_ID_PREFIX: string;
  42741. /**
  42742. * The controller id pattern for this controller type
  42743. */
  42744. private static readonly GAMEPAD_ID_PATTERN;
  42745. private _loadedMeshInfo;
  42746. private readonly _mapping;
  42747. /**
  42748. * Fired when the trackpad on this controller is clicked
  42749. */
  42750. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42751. /**
  42752. * Fired when the trackpad on this controller is modified
  42753. */
  42754. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42755. /**
  42756. * The current x and y values of this controller's trackpad
  42757. */
  42758. trackpad: StickValues;
  42759. /**
  42760. * Creates a new WindowsMotionController from a gamepad
  42761. * @param vrGamepad the gamepad that the controller should be created from
  42762. */
  42763. constructor(vrGamepad: any);
  42764. /**
  42765. * Fired when the trigger on this controller is modified
  42766. */
  42767. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42768. /**
  42769. * Fired when the menu button on this controller is modified
  42770. */
  42771. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42772. /**
  42773. * Fired when the grip button on this controller is modified
  42774. */
  42775. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42776. /**
  42777. * Fired when the thumbstick button on this controller is modified
  42778. */
  42779. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the touchpad button on this controller is modified
  42782. */
  42783. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42784. /**
  42785. * Fired when the touchpad values on this controller are modified
  42786. */
  42787. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42788. private _updateTrackpad;
  42789. /**
  42790. * Called once per frame by the engine.
  42791. */
  42792. update(): void;
  42793. /**
  42794. * Called once for each button that changed state since the last frame
  42795. * @param buttonIdx Which button index changed
  42796. * @param state New state of the button
  42797. * @param changes Which properties on the state changed since last frame
  42798. */
  42799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42800. /**
  42801. * Moves the buttons on the controller mesh based on their current state
  42802. * @param buttonName the name of the button to move
  42803. * @param buttonValue the value of the button which determines the buttons new position
  42804. */
  42805. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42806. /**
  42807. * Moves the axis on the controller mesh based on its current state
  42808. * @param axis the index of the axis
  42809. * @param axisValue the value of the axis which determines the meshes new position
  42810. * @hidden
  42811. */
  42812. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42813. /**
  42814. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42815. * @param scene scene in which to add meshes
  42816. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42817. */
  42818. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42819. /**
  42820. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42821. * can be transformed by button presses and axes values, based on this._mapping.
  42822. *
  42823. * @param scene scene in which the meshes exist
  42824. * @param meshes list of meshes that make up the controller model to process
  42825. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42826. */
  42827. private processModel;
  42828. private createMeshInfo;
  42829. /**
  42830. * Gets the ray of the controller in the direction the controller is pointing
  42831. * @param length the length the resulting ray should be
  42832. * @returns a ray in the direction the controller is pointing
  42833. */
  42834. getForwardRay(length?: number): Ray;
  42835. /**
  42836. * Disposes of the controller
  42837. */
  42838. dispose(): void;
  42839. }
  42840. }
  42841. declare module BABYLON {
  42842. /**
  42843. * Oculus Touch Controller
  42844. */
  42845. export class OculusTouchController extends WebVRController {
  42846. /**
  42847. * Base Url for the controller model.
  42848. */
  42849. static MODEL_BASE_URL: string;
  42850. /**
  42851. * File name for the left controller model.
  42852. */
  42853. static MODEL_LEFT_FILENAME: string;
  42854. /**
  42855. * File name for the right controller model.
  42856. */
  42857. static MODEL_RIGHT_FILENAME: string;
  42858. /**
  42859. * Base Url for the Quest controller model.
  42860. */
  42861. static QUEST_MODEL_BASE_URL: string;
  42862. /**
  42863. * @hidden
  42864. * If the controllers are running on a device that needs the updated Quest controller models
  42865. */
  42866. static _IsQuest: boolean;
  42867. /**
  42868. * Fired when the secondary trigger on this controller is modified
  42869. */
  42870. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42871. /**
  42872. * Fired when the thumb rest on this controller is modified
  42873. */
  42874. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42875. /**
  42876. * Creates a new OculusTouchController from a gamepad
  42877. * @param vrGamepad the gamepad that the controller should be created from
  42878. */
  42879. constructor(vrGamepad: any);
  42880. /**
  42881. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42882. * @param scene scene in which to add meshes
  42883. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42884. */
  42885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42886. /**
  42887. * Fired when the A button on this controller is modified
  42888. */
  42889. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42890. /**
  42891. * Fired when the B button on this controller is modified
  42892. */
  42893. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42894. /**
  42895. * Fired when the X button on this controller is modified
  42896. */
  42897. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42898. /**
  42899. * Fired when the Y button on this controller is modified
  42900. */
  42901. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42902. /**
  42903. * Called once for each button that changed state since the last frame
  42904. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42905. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42906. * 2) secondary trigger (same)
  42907. * 3) A (right) X (left), touch, pressed = value
  42908. * 4) B / Y
  42909. * 5) thumb rest
  42910. * @param buttonIdx Which button index changed
  42911. * @param state New state of the button
  42912. * @param changes Which properties on the state changed since last frame
  42913. */
  42914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42915. }
  42916. }
  42917. declare module BABYLON {
  42918. /**
  42919. * Vive Controller
  42920. */
  42921. export class ViveController extends WebVRController {
  42922. /**
  42923. * Base Url for the controller model.
  42924. */
  42925. static MODEL_BASE_URL: string;
  42926. /**
  42927. * File name for the controller model.
  42928. */
  42929. static MODEL_FILENAME: string;
  42930. /**
  42931. * Creates a new ViveController from a gamepad
  42932. * @param vrGamepad the gamepad that the controller should be created from
  42933. */
  42934. constructor(vrGamepad: any);
  42935. /**
  42936. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42937. * @param scene scene in which to add meshes
  42938. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42939. */
  42940. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42941. /**
  42942. * Fired when the left button on this controller is modified
  42943. */
  42944. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42945. /**
  42946. * Fired when the right button on this controller is modified
  42947. */
  42948. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42949. /**
  42950. * Fired when the menu button on this controller is modified
  42951. */
  42952. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42953. /**
  42954. * Called once for each button that changed state since the last frame
  42955. * Vive mapping:
  42956. * 0: touchpad
  42957. * 1: trigger
  42958. * 2: left AND right buttons
  42959. * 3: menu button
  42960. * @param buttonIdx Which button index changed
  42961. * @param state New state of the button
  42962. * @param changes Which properties on the state changed since last frame
  42963. */
  42964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42970. */
  42971. export class WebXRControllerModelLoader {
  42972. /**
  42973. * Creates the WebXRControllerModelLoader
  42974. * @param input xr input that creates the controllers
  42975. */
  42976. constructor(input: WebXRInput);
  42977. }
  42978. }
  42979. declare module BABYLON {
  42980. /**
  42981. * Contains an array of blocks representing the octree
  42982. */
  42983. export interface IOctreeContainer<T> {
  42984. /**
  42985. * Blocks within the octree
  42986. */
  42987. blocks: Array<OctreeBlock<T>>;
  42988. }
  42989. /**
  42990. * Class used to store a cell in an octree
  42991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42992. */
  42993. export class OctreeBlock<T> {
  42994. /**
  42995. * Gets the content of the current block
  42996. */
  42997. entries: T[];
  42998. /**
  42999. * Gets the list of block children
  43000. */
  43001. blocks: Array<OctreeBlock<T>>;
  43002. private _depth;
  43003. private _maxDepth;
  43004. private _capacity;
  43005. private _minPoint;
  43006. private _maxPoint;
  43007. private _boundingVectors;
  43008. private _creationFunc;
  43009. /**
  43010. * Creates a new block
  43011. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43012. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43013. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43014. * @param depth defines the current depth of this block in the octree
  43015. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43016. * @param creationFunc defines a callback to call when an element is added to the block
  43017. */
  43018. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43019. /**
  43020. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43021. */
  43022. readonly capacity: number;
  43023. /**
  43024. * Gets the minimum vector (in world space) of the block's bounding box
  43025. */
  43026. readonly minPoint: Vector3;
  43027. /**
  43028. * Gets the maximum vector (in world space) of the block's bounding box
  43029. */
  43030. readonly maxPoint: Vector3;
  43031. /**
  43032. * Add a new element to this block
  43033. * @param entry defines the element to add
  43034. */
  43035. addEntry(entry: T): void;
  43036. /**
  43037. * Remove an element from this block
  43038. * @param entry defines the element to remove
  43039. */
  43040. removeEntry(entry: T): void;
  43041. /**
  43042. * Add an array of elements to this block
  43043. * @param entries defines the array of elements to add
  43044. */
  43045. addEntries(entries: T[]): void;
  43046. /**
  43047. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43048. * @param frustumPlanes defines the frustum planes to test
  43049. * @param selection defines the array to store current content if selection is positive
  43050. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43051. */
  43052. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43053. /**
  43054. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43055. * @param sphereCenter defines the bounding sphere center
  43056. * @param sphereRadius defines the bounding sphere radius
  43057. * @param selection defines the array to store current content if selection is positive
  43058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43059. */
  43060. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43061. /**
  43062. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43063. * @param ray defines the ray to test with
  43064. * @param selection defines the array to store current content if selection is positive
  43065. */
  43066. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43067. /**
  43068. * Subdivide the content into child blocks (this block will then be empty)
  43069. */
  43070. createInnerBlocks(): void;
  43071. /**
  43072. * @hidden
  43073. */
  43074. 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;
  43075. }
  43076. }
  43077. declare module BABYLON {
  43078. /**
  43079. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43080. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43081. */
  43082. export class Octree<T> {
  43083. /** 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.) */
  43084. maxDepth: number;
  43085. /**
  43086. * Blocks within the octree containing objects
  43087. */
  43088. blocks: Array<OctreeBlock<T>>;
  43089. /**
  43090. * Content stored in the octree
  43091. */
  43092. dynamicContent: T[];
  43093. private _maxBlockCapacity;
  43094. private _selectionContent;
  43095. private _creationFunc;
  43096. /**
  43097. * Creates a octree
  43098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43099. * @param creationFunc function to be used to instatiate the octree
  43100. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43101. * @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.)
  43102. */
  43103. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43104. /** 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.) */
  43105. maxDepth?: number);
  43106. /**
  43107. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43108. * @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);
  43109. * @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);
  43110. * @param entries meshes to be added to the octree blocks
  43111. */
  43112. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43113. /**
  43114. * Adds a mesh to the octree
  43115. * @param entry Mesh to add to the octree
  43116. */
  43117. addMesh(entry: T): void;
  43118. /**
  43119. * Remove an element from the octree
  43120. * @param entry defines the element to remove
  43121. */
  43122. removeMesh(entry: T): void;
  43123. /**
  43124. * Selects an array of meshes within the frustum
  43125. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43126. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43127. * @returns array of meshes within the frustum
  43128. */
  43129. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43130. /**
  43131. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43132. * @param sphereCenter defines the bounding sphere center
  43133. * @param sphereRadius defines the bounding sphere radius
  43134. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43135. * @returns an array of objects that intersect the sphere
  43136. */
  43137. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43138. /**
  43139. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43140. * @param ray defines the ray to test with
  43141. * @returns array of intersected objects
  43142. */
  43143. intersectsRay(ray: Ray): SmartArray<T>;
  43144. /**
  43145. * Adds a mesh into the octree block if it intersects the block
  43146. */
  43147. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43148. /**
  43149. * Adds a submesh into the octree block if it intersects the block
  43150. */
  43151. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43152. }
  43153. }
  43154. declare module BABYLON {
  43155. interface Scene {
  43156. /**
  43157. * @hidden
  43158. * Backing Filed
  43159. */
  43160. _selectionOctree: Octree<AbstractMesh>;
  43161. /**
  43162. * Gets the octree used to boost mesh selection (picking)
  43163. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43164. */
  43165. selectionOctree: Octree<AbstractMesh>;
  43166. /**
  43167. * Creates or updates the octree used to boost selection (picking)
  43168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43169. * @param maxCapacity defines the maximum capacity per leaf
  43170. * @param maxDepth defines the maximum depth of the octree
  43171. * @returns an octree of AbstractMesh
  43172. */
  43173. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43174. }
  43175. interface AbstractMesh {
  43176. /**
  43177. * @hidden
  43178. * Backing Field
  43179. */
  43180. _submeshesOctree: Octree<SubMesh>;
  43181. /**
  43182. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43183. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43184. * @param maxCapacity defines the maximum size of each block (64 by default)
  43185. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43186. * @returns the new octree
  43187. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43189. */
  43190. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43191. }
  43192. /**
  43193. * Defines the octree scene component responsible to manage any octrees
  43194. * in a given scene.
  43195. */
  43196. export class OctreeSceneComponent {
  43197. /**
  43198. * The component name help to identify the component in the list of scene components.
  43199. */
  43200. readonly name: string;
  43201. /**
  43202. * The scene the component belongs to.
  43203. */
  43204. scene: Scene;
  43205. /**
  43206. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43207. */
  43208. readonly checksIsEnabled: boolean;
  43209. /**
  43210. * Creates a new instance of the component for the given scene
  43211. * @param scene Defines the scene to register the component in
  43212. */
  43213. constructor(scene: Scene);
  43214. /**
  43215. * Registers the component in a given scene
  43216. */
  43217. register(): void;
  43218. /**
  43219. * Return the list of active meshes
  43220. * @returns the list of active meshes
  43221. */
  43222. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43223. /**
  43224. * Return the list of active sub meshes
  43225. * @param mesh The mesh to get the candidates sub meshes from
  43226. * @returns the list of active sub meshes
  43227. */
  43228. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43229. private _tempRay;
  43230. /**
  43231. * Return the list of sub meshes intersecting with a given local ray
  43232. * @param mesh defines the mesh to find the submesh for
  43233. * @param localRay defines the ray in local space
  43234. * @returns the list of intersecting sub meshes
  43235. */
  43236. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43237. /**
  43238. * Return the list of sub meshes colliding with a collider
  43239. * @param mesh defines the mesh to find the submesh for
  43240. * @param collider defines the collider to evaluate the collision against
  43241. * @returns the list of colliding sub meshes
  43242. */
  43243. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43244. /**
  43245. * Rebuilds the elements related to this component in case of
  43246. * context lost for instance.
  43247. */
  43248. rebuild(): void;
  43249. /**
  43250. * Disposes the component and the associated ressources.
  43251. */
  43252. dispose(): void;
  43253. }
  43254. }
  43255. declare module BABYLON {
  43256. /**
  43257. * Renders a layer on top of an existing scene
  43258. */
  43259. export class UtilityLayerRenderer implements IDisposable {
  43260. /** the original scene that will be rendered on top of */
  43261. originalScene: Scene;
  43262. private _pointerCaptures;
  43263. private _lastPointerEvents;
  43264. private static _DefaultUtilityLayer;
  43265. private static _DefaultKeepDepthUtilityLayer;
  43266. private _sharedGizmoLight;
  43267. private _renderCamera;
  43268. /**
  43269. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43270. * @returns the camera that is used when rendering the utility layer
  43271. */
  43272. getRenderCamera(): Nullable<Camera>;
  43273. /**
  43274. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43275. * @param cam the camera that should be used when rendering the utility layer
  43276. */
  43277. setRenderCamera(cam: Nullable<Camera>): void;
  43278. /**
  43279. * @hidden
  43280. * Light which used by gizmos to get light shading
  43281. */
  43282. _getSharedGizmoLight(): HemisphericLight;
  43283. /**
  43284. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43285. */
  43286. pickUtilitySceneFirst: boolean;
  43287. /**
  43288. * 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)
  43289. */
  43290. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43291. /**
  43292. * 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)
  43293. */
  43294. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43295. /**
  43296. * The scene that is rendered on top of the original scene
  43297. */
  43298. utilityLayerScene: Scene;
  43299. /**
  43300. * If the utility layer should automatically be rendered on top of existing scene
  43301. */
  43302. shouldRender: boolean;
  43303. /**
  43304. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43305. */
  43306. onlyCheckPointerDownEvents: boolean;
  43307. /**
  43308. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43309. */
  43310. processAllEvents: boolean;
  43311. /**
  43312. * Observable raised when the pointer move from the utility layer scene to the main scene
  43313. */
  43314. onPointerOutObservable: Observable<number>;
  43315. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43316. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43317. private _afterRenderObserver;
  43318. private _sceneDisposeObserver;
  43319. private _originalPointerObserver;
  43320. /**
  43321. * Instantiates a UtilityLayerRenderer
  43322. * @param originalScene the original scene that will be rendered on top of
  43323. * @param handleEvents boolean indicating if the utility layer should handle events
  43324. */
  43325. constructor(
  43326. /** the original scene that will be rendered on top of */
  43327. originalScene: Scene, handleEvents?: boolean);
  43328. private _notifyObservers;
  43329. /**
  43330. * Renders the utility layers scene on top of the original scene
  43331. */
  43332. render(): void;
  43333. /**
  43334. * Disposes of the renderer
  43335. */
  43336. dispose(): void;
  43337. private _updateCamera;
  43338. }
  43339. }
  43340. declare module BABYLON {
  43341. /**
  43342. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43343. */
  43344. export class Gizmo implements IDisposable {
  43345. /** The utility layer the gizmo will be added to */
  43346. gizmoLayer: UtilityLayerRenderer;
  43347. /**
  43348. * The root mesh of the gizmo
  43349. */
  43350. _rootMesh: Mesh;
  43351. private _attachedMesh;
  43352. /**
  43353. * Ratio for the scale of the gizmo (Default: 1)
  43354. */
  43355. scaleRatio: number;
  43356. /**
  43357. * If a custom mesh has been set (Default: false)
  43358. */
  43359. protected _customMeshSet: boolean;
  43360. /**
  43361. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43362. * * When set, interactions will be enabled
  43363. */
  43364. attachedMesh: Nullable<AbstractMesh>;
  43365. /**
  43366. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43367. * @param mesh The mesh to replace the default mesh of the gizmo
  43368. */
  43369. setCustomMesh(mesh: Mesh): void;
  43370. /**
  43371. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43372. */
  43373. updateGizmoRotationToMatchAttachedMesh: boolean;
  43374. /**
  43375. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43376. */
  43377. updateGizmoPositionToMatchAttachedMesh: boolean;
  43378. /**
  43379. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43380. */
  43381. updateScale: boolean;
  43382. protected _interactionsEnabled: boolean;
  43383. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43384. private _beforeRenderObserver;
  43385. private _tempVector;
  43386. /**
  43387. * Creates a gizmo
  43388. * @param gizmoLayer The utility layer the gizmo will be added to
  43389. */
  43390. constructor(
  43391. /** The utility layer the gizmo will be added to */
  43392. gizmoLayer?: UtilityLayerRenderer);
  43393. /**
  43394. * Updates the gizmo to match the attached mesh's position/rotation
  43395. */
  43396. protected _update(): void;
  43397. /**
  43398. * Disposes of the gizmo
  43399. */
  43400. dispose(): void;
  43401. }
  43402. }
  43403. declare module BABYLON {
  43404. /**
  43405. * Single plane drag gizmo
  43406. */
  43407. export class PlaneDragGizmo extends Gizmo {
  43408. /**
  43409. * Drag behavior responsible for the gizmos dragging interactions
  43410. */
  43411. dragBehavior: PointerDragBehavior;
  43412. private _pointerObserver;
  43413. /**
  43414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43415. */
  43416. snapDistance: number;
  43417. /**
  43418. * Event that fires each time the gizmo snaps to a new location.
  43419. * * snapDistance is the the change in distance
  43420. */
  43421. onSnapObservable: Observable<{
  43422. snapDistance: number;
  43423. }>;
  43424. private _plane;
  43425. private _coloredMaterial;
  43426. private _hoverMaterial;
  43427. private _isEnabled;
  43428. private _parent;
  43429. /** @hidden */
  43430. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43431. /** @hidden */
  43432. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43433. /**
  43434. * Creates a PlaneDragGizmo
  43435. * @param gizmoLayer The utility layer the gizmo will be added to
  43436. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43437. * @param color The color of the gizmo
  43438. */
  43439. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43441. /**
  43442. * If the gizmo is enabled
  43443. */
  43444. isEnabled: boolean;
  43445. /**
  43446. * Disposes of the gizmo
  43447. */
  43448. dispose(): void;
  43449. }
  43450. }
  43451. declare module BABYLON {
  43452. /**
  43453. * Gizmo that enables dragging a mesh along 3 axis
  43454. */
  43455. export class PositionGizmo extends Gizmo {
  43456. /**
  43457. * Internal gizmo used for interactions on the x axis
  43458. */
  43459. xGizmo: AxisDragGizmo;
  43460. /**
  43461. * Internal gizmo used for interactions on the y axis
  43462. */
  43463. yGizmo: AxisDragGizmo;
  43464. /**
  43465. * Internal gizmo used for interactions on the z axis
  43466. */
  43467. zGizmo: AxisDragGizmo;
  43468. /**
  43469. * Internal gizmo used for interactions on the yz plane
  43470. */
  43471. xPlaneGizmo: PlaneDragGizmo;
  43472. /**
  43473. * Internal gizmo used for interactions on the xz plane
  43474. */
  43475. yPlaneGizmo: PlaneDragGizmo;
  43476. /**
  43477. * Internal gizmo used for interactions on the xy plane
  43478. */
  43479. zPlaneGizmo: PlaneDragGizmo;
  43480. /**
  43481. * private variables
  43482. */
  43483. private _meshAttached;
  43484. private _updateGizmoRotationToMatchAttachedMesh;
  43485. private _snapDistance;
  43486. private _scaleRatio;
  43487. /** Fires an event when any of it's sub gizmos are dragged */
  43488. onDragStartObservable: Observable<unknown>;
  43489. /** Fires an event when any of it's sub gizmos are released from dragging */
  43490. onDragEndObservable: Observable<unknown>;
  43491. /**
  43492. * If set to true, planar drag is enabled
  43493. */
  43494. private _planarGizmoEnabled;
  43495. attachedMesh: Nullable<AbstractMesh>;
  43496. /**
  43497. * Creates a PositionGizmo
  43498. * @param gizmoLayer The utility layer the gizmo will be added to
  43499. */
  43500. constructor(gizmoLayer?: UtilityLayerRenderer);
  43501. /**
  43502. * If the planar drag gizmo is enabled
  43503. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43504. */
  43505. planarGizmoEnabled: boolean;
  43506. updateGizmoRotationToMatchAttachedMesh: boolean;
  43507. /**
  43508. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43509. */
  43510. snapDistance: number;
  43511. /**
  43512. * Ratio for the scale of the gizmo (Default: 1)
  43513. */
  43514. scaleRatio: number;
  43515. /**
  43516. * Disposes of the gizmo
  43517. */
  43518. dispose(): void;
  43519. /**
  43520. * CustomMeshes are not supported by this gizmo
  43521. * @param mesh The mesh to replace the default mesh of the gizmo
  43522. */
  43523. setCustomMesh(mesh: Mesh): void;
  43524. }
  43525. }
  43526. declare module BABYLON {
  43527. /**
  43528. * Single axis drag gizmo
  43529. */
  43530. export class AxisDragGizmo extends Gizmo {
  43531. /**
  43532. * Drag behavior responsible for the gizmos dragging interactions
  43533. */
  43534. dragBehavior: PointerDragBehavior;
  43535. private _pointerObserver;
  43536. /**
  43537. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43538. */
  43539. snapDistance: number;
  43540. /**
  43541. * Event that fires each time the gizmo snaps to a new location.
  43542. * * snapDistance is the the change in distance
  43543. */
  43544. onSnapObservable: Observable<{
  43545. snapDistance: number;
  43546. }>;
  43547. private _isEnabled;
  43548. private _parent;
  43549. private _arrow;
  43550. private _coloredMaterial;
  43551. private _hoverMaterial;
  43552. /** @hidden */
  43553. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43554. /** @hidden */
  43555. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43556. /**
  43557. * Creates an AxisDragGizmo
  43558. * @param gizmoLayer The utility layer the gizmo will be added to
  43559. * @param dragAxis The axis which the gizmo will be able to drag on
  43560. * @param color The color of the gizmo
  43561. */
  43562. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43563. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43564. /**
  43565. * If the gizmo is enabled
  43566. */
  43567. isEnabled: boolean;
  43568. /**
  43569. * Disposes of the gizmo
  43570. */
  43571. dispose(): void;
  43572. }
  43573. }
  43574. declare module BABYLON.Debug {
  43575. /**
  43576. * The Axes viewer will show 3 axes in a specific point in space
  43577. */
  43578. export class AxesViewer {
  43579. private _xAxis;
  43580. private _yAxis;
  43581. private _zAxis;
  43582. private _scaleLinesFactor;
  43583. private _instanced;
  43584. /**
  43585. * Gets the hosting scene
  43586. */
  43587. scene: Scene;
  43588. /**
  43589. * Gets or sets a number used to scale line length
  43590. */
  43591. scaleLines: number;
  43592. /** Gets the node hierarchy used to render x-axis */
  43593. readonly xAxis: TransformNode;
  43594. /** Gets the node hierarchy used to render y-axis */
  43595. readonly yAxis: TransformNode;
  43596. /** Gets the node hierarchy used to render z-axis */
  43597. readonly zAxis: TransformNode;
  43598. /**
  43599. * Creates a new AxesViewer
  43600. * @param scene defines the hosting scene
  43601. * @param scaleLines defines a number used to scale line length (1 by default)
  43602. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43603. * @param xAxis defines the node hierarchy used to render the x-axis
  43604. * @param yAxis defines the node hierarchy used to render the y-axis
  43605. * @param zAxis defines the node hierarchy used to render the z-axis
  43606. */
  43607. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43608. /**
  43609. * Force the viewer to update
  43610. * @param position defines the position of the viewer
  43611. * @param xaxis defines the x axis of the viewer
  43612. * @param yaxis defines the y axis of the viewer
  43613. * @param zaxis defines the z axis of the viewer
  43614. */
  43615. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43616. /**
  43617. * Creates an instance of this axes viewer.
  43618. * @returns a new axes viewer with instanced meshes
  43619. */
  43620. createInstance(): AxesViewer;
  43621. /** Releases resources */
  43622. dispose(): void;
  43623. private static _SetRenderingGroupId;
  43624. }
  43625. }
  43626. declare module BABYLON.Debug {
  43627. /**
  43628. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43629. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43630. */
  43631. export class BoneAxesViewer extends AxesViewer {
  43632. /**
  43633. * Gets or sets the target mesh where to display the axes viewer
  43634. */
  43635. mesh: Nullable<Mesh>;
  43636. /**
  43637. * Gets or sets the target bone where to display the axes viewer
  43638. */
  43639. bone: Nullable<Bone>;
  43640. /** Gets current position */
  43641. pos: Vector3;
  43642. /** Gets direction of X axis */
  43643. xaxis: Vector3;
  43644. /** Gets direction of Y axis */
  43645. yaxis: Vector3;
  43646. /** Gets direction of Z axis */
  43647. zaxis: Vector3;
  43648. /**
  43649. * Creates a new BoneAxesViewer
  43650. * @param scene defines the hosting scene
  43651. * @param bone defines the target bone
  43652. * @param mesh defines the target mesh
  43653. * @param scaleLines defines a scaling factor for line length (1 by default)
  43654. */
  43655. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43656. /**
  43657. * Force the viewer to update
  43658. */
  43659. update(): void;
  43660. /** Releases resources */
  43661. dispose(): void;
  43662. }
  43663. }
  43664. declare module BABYLON {
  43665. /**
  43666. * Interface used to define scene explorer extensibility option
  43667. */
  43668. export interface IExplorerExtensibilityOption {
  43669. /**
  43670. * Define the option label
  43671. */
  43672. label: string;
  43673. /**
  43674. * Defines the action to execute on click
  43675. */
  43676. action: (entity: any) => void;
  43677. }
  43678. /**
  43679. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43680. */
  43681. export interface IExplorerExtensibilityGroup {
  43682. /**
  43683. * Defines a predicate to test if a given type mut be extended
  43684. */
  43685. predicate: (entity: any) => boolean;
  43686. /**
  43687. * Gets the list of options added to a type
  43688. */
  43689. entries: IExplorerExtensibilityOption[];
  43690. }
  43691. /**
  43692. * Interface used to define the options to use to create the Inspector
  43693. */
  43694. export interface IInspectorOptions {
  43695. /**
  43696. * Display in overlay mode (default: false)
  43697. */
  43698. overlay?: boolean;
  43699. /**
  43700. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43701. */
  43702. globalRoot?: HTMLElement;
  43703. /**
  43704. * Display the Scene explorer
  43705. */
  43706. showExplorer?: boolean;
  43707. /**
  43708. * Display the property inspector
  43709. */
  43710. showInspector?: boolean;
  43711. /**
  43712. * Display in embed mode (both panes on the right)
  43713. */
  43714. embedMode?: boolean;
  43715. /**
  43716. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43717. */
  43718. handleResize?: boolean;
  43719. /**
  43720. * Allow the panes to popup (default: true)
  43721. */
  43722. enablePopup?: boolean;
  43723. /**
  43724. * Allow the panes to be closed by users (default: true)
  43725. */
  43726. enableClose?: boolean;
  43727. /**
  43728. * Optional list of extensibility entries
  43729. */
  43730. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43731. /**
  43732. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43733. */
  43734. inspectorURL?: string;
  43735. }
  43736. interface Scene {
  43737. /**
  43738. * @hidden
  43739. * Backing field
  43740. */
  43741. _debugLayer: DebugLayer;
  43742. /**
  43743. * Gets the debug layer (aka Inspector) associated with the scene
  43744. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43745. */
  43746. debugLayer: DebugLayer;
  43747. }
  43748. /**
  43749. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43750. * what is happening in your scene
  43751. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43752. */
  43753. export class DebugLayer {
  43754. /**
  43755. * Define the url to get the inspector script from.
  43756. * By default it uses the babylonjs CDN.
  43757. * @ignoreNaming
  43758. */
  43759. static InspectorURL: string;
  43760. private _scene;
  43761. private BJSINSPECTOR;
  43762. private _onPropertyChangedObservable?;
  43763. /**
  43764. * Observable triggered when a property is changed through the inspector.
  43765. */
  43766. readonly onPropertyChangedObservable: any;
  43767. /**
  43768. * Instantiates a new debug layer.
  43769. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43770. * what is happening in your scene
  43771. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43772. * @param scene Defines the scene to inspect
  43773. */
  43774. constructor(scene: Scene);
  43775. /** Creates the inspector window. */
  43776. private _createInspector;
  43777. /**
  43778. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43779. * @param entity defines the entity to select
  43780. * @param lineContainerTitle defines the specific block to highlight
  43781. */
  43782. select(entity: any, lineContainerTitle?: string): void;
  43783. /** Get the inspector from bundle or global */
  43784. private _getGlobalInspector;
  43785. /**
  43786. * Get if the inspector is visible or not.
  43787. * @returns true if visible otherwise, false
  43788. */
  43789. isVisible(): boolean;
  43790. /**
  43791. * Hide the inspector and close its window.
  43792. */
  43793. hide(): void;
  43794. /**
  43795. * Launch the debugLayer.
  43796. * @param config Define the configuration of the inspector
  43797. * @return a promise fulfilled when the debug layer is visible
  43798. */
  43799. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43800. }
  43801. }
  43802. declare module BABYLON {
  43803. /**
  43804. * Class containing static functions to help procedurally build meshes
  43805. */
  43806. export class BoxBuilder {
  43807. /**
  43808. * Creates a box mesh
  43809. * * The parameter `size` sets the size (float) of each box side (default 1)
  43810. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43811. * * 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)
  43812. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43814. * * 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
  43815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43816. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43817. * @param name defines the name of the mesh
  43818. * @param options defines the options used to create the mesh
  43819. * @param scene defines the hosting scene
  43820. * @returns the box mesh
  43821. */
  43822. static CreateBox(name: string, options: {
  43823. size?: number;
  43824. width?: number;
  43825. height?: number;
  43826. depth?: number;
  43827. faceUV?: Vector4[];
  43828. faceColors?: Color4[];
  43829. sideOrientation?: number;
  43830. frontUVs?: Vector4;
  43831. backUVs?: Vector4;
  43832. wrap?: boolean;
  43833. topBaseAt?: number;
  43834. bottomBaseAt?: number;
  43835. updatable?: boolean;
  43836. }, scene?: Nullable<Scene>): Mesh;
  43837. }
  43838. }
  43839. declare module BABYLON {
  43840. /**
  43841. * Class containing static functions to help procedurally build meshes
  43842. */
  43843. export class SphereBuilder {
  43844. /**
  43845. * Creates a sphere mesh
  43846. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43847. * * 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`)
  43848. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43849. * * 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
  43850. * * 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)
  43851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43852. * * 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
  43853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43854. * @param name defines the name of the mesh
  43855. * @param options defines the options used to create the mesh
  43856. * @param scene defines the hosting scene
  43857. * @returns the sphere mesh
  43858. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43859. */
  43860. static CreateSphere(name: string, options: {
  43861. segments?: number;
  43862. diameter?: number;
  43863. diameterX?: number;
  43864. diameterY?: number;
  43865. diameterZ?: number;
  43866. arc?: number;
  43867. slice?: number;
  43868. sideOrientation?: number;
  43869. frontUVs?: Vector4;
  43870. backUVs?: Vector4;
  43871. updatable?: boolean;
  43872. }, scene?: Nullable<Scene>): Mesh;
  43873. }
  43874. }
  43875. declare module BABYLON.Debug {
  43876. /**
  43877. * Used to show the physics impostor around the specific mesh
  43878. */
  43879. export class PhysicsViewer {
  43880. /** @hidden */
  43881. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43882. /** @hidden */
  43883. protected _meshes: Array<Nullable<AbstractMesh>>;
  43884. /** @hidden */
  43885. protected _scene: Nullable<Scene>;
  43886. /** @hidden */
  43887. protected _numMeshes: number;
  43888. /** @hidden */
  43889. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43890. private _renderFunction;
  43891. private _utilityLayer;
  43892. private _debugBoxMesh;
  43893. private _debugSphereMesh;
  43894. private _debugCylinderMesh;
  43895. private _debugMaterial;
  43896. private _debugMeshMeshes;
  43897. /**
  43898. * Creates a new PhysicsViewer
  43899. * @param scene defines the hosting scene
  43900. */
  43901. constructor(scene: Scene);
  43902. /** @hidden */
  43903. protected _updateDebugMeshes(): void;
  43904. /**
  43905. * Renders a specified physic impostor
  43906. * @param impostor defines the impostor to render
  43907. * @param targetMesh defines the mesh represented by the impostor
  43908. * @returns the new debug mesh used to render the impostor
  43909. */
  43910. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43911. /**
  43912. * Hides a specified physic impostor
  43913. * @param impostor defines the impostor to hide
  43914. */
  43915. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43916. private _getDebugMaterial;
  43917. private _getDebugBoxMesh;
  43918. private _getDebugSphereMesh;
  43919. private _getDebugCylinderMesh;
  43920. private _getDebugMeshMesh;
  43921. private _getDebugMesh;
  43922. /** Releases all resources */
  43923. dispose(): void;
  43924. }
  43925. }
  43926. declare module BABYLON {
  43927. /**
  43928. * Class containing static functions to help procedurally build meshes
  43929. */
  43930. export class LinesBuilder {
  43931. /**
  43932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43933. * * 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
  43934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43939. * * 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
  43940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43943. * @param name defines the name of the new line system
  43944. * @param options defines the options used to create the line system
  43945. * @param scene defines the hosting scene
  43946. * @returns a new line system mesh
  43947. */
  43948. static CreateLineSystem(name: string, options: {
  43949. lines: Vector3[][];
  43950. updatable?: boolean;
  43951. instance?: Nullable<LinesMesh>;
  43952. colors?: Nullable<Color4[][]>;
  43953. useVertexAlpha?: boolean;
  43954. }, scene: Nullable<Scene>): LinesMesh;
  43955. /**
  43956. * Creates a line mesh
  43957. * 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
  43958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43959. * * The parameter `points` is an array successive Vector3
  43960. * * 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
  43961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43963. * * When updating an instance, remember that only point positions can change, not the number of points
  43964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43966. * @param name defines the name of the new line system
  43967. * @param options defines the options used to create the line system
  43968. * @param scene defines the hosting scene
  43969. * @returns a new line mesh
  43970. */
  43971. static CreateLines(name: string, options: {
  43972. points: Vector3[];
  43973. updatable?: boolean;
  43974. instance?: Nullable<LinesMesh>;
  43975. colors?: Color4[];
  43976. useVertexAlpha?: boolean;
  43977. }, scene?: Nullable<Scene>): LinesMesh;
  43978. /**
  43979. * Creates a dashed line mesh
  43980. * * 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
  43981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43982. * * The parameter `points` is an array successive Vector3
  43983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43986. * * 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
  43987. * * When updating an instance, remember that only point positions can change, not the number of points
  43988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43989. * @param name defines the name of the mesh
  43990. * @param options defines the options used to create the mesh
  43991. * @param scene defines the hosting scene
  43992. * @returns the dashed line mesh
  43993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43994. */
  43995. static CreateDashedLines(name: string, options: {
  43996. points: Vector3[];
  43997. dashSize?: number;
  43998. gapSize?: number;
  43999. dashNb?: number;
  44000. updatable?: boolean;
  44001. instance?: LinesMesh;
  44002. }, scene?: Nullable<Scene>): LinesMesh;
  44003. }
  44004. }
  44005. declare module BABYLON {
  44006. /**
  44007. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44008. * in order to better appreciate the issue one might have.
  44009. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44010. */
  44011. export class RayHelper {
  44012. /**
  44013. * Defines the ray we are currently tryin to visualize.
  44014. */
  44015. ray: Nullable<Ray>;
  44016. private _renderPoints;
  44017. private _renderLine;
  44018. private _renderFunction;
  44019. private _scene;
  44020. private _updateToMeshFunction;
  44021. private _attachedToMesh;
  44022. private _meshSpaceDirection;
  44023. private _meshSpaceOrigin;
  44024. /**
  44025. * Helper function to create a colored helper in a scene in one line.
  44026. * @param ray Defines the ray we are currently tryin to visualize
  44027. * @param scene Defines the scene the ray is used in
  44028. * @param color Defines the color we want to see the ray in
  44029. * @returns The newly created ray helper.
  44030. */
  44031. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44032. /**
  44033. * Instantiate a new ray helper.
  44034. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44035. * in order to better appreciate the issue one might have.
  44036. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44037. * @param ray Defines the ray we are currently tryin to visualize
  44038. */
  44039. constructor(ray: Ray);
  44040. /**
  44041. * Shows the ray we are willing to debug.
  44042. * @param scene Defines the scene the ray needs to be rendered in
  44043. * @param color Defines the color the ray needs to be rendered in
  44044. */
  44045. show(scene: Scene, color?: Color3): void;
  44046. /**
  44047. * Hides the ray we are debugging.
  44048. */
  44049. hide(): void;
  44050. private _render;
  44051. /**
  44052. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44053. * @param mesh Defines the mesh we want the helper attached to
  44054. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44055. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44056. * @param length Defines the length of the ray
  44057. */
  44058. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44059. /**
  44060. * Detach the ray helper from the mesh it has previously been attached to.
  44061. */
  44062. detachFromMesh(): void;
  44063. private _updateToMesh;
  44064. /**
  44065. * Dispose the helper and release its associated resources.
  44066. */
  44067. dispose(): void;
  44068. }
  44069. }
  44070. declare module BABYLON.Debug {
  44071. /**
  44072. * Class used to render a debug view of a given skeleton
  44073. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44074. */
  44075. export class SkeletonViewer {
  44076. /** defines the skeleton to render */
  44077. skeleton: Skeleton;
  44078. /** defines the mesh attached to the skeleton */
  44079. mesh: AbstractMesh;
  44080. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44081. autoUpdateBonesMatrices: boolean;
  44082. /** defines the rendering group id to use with the viewer */
  44083. renderingGroupId: number;
  44084. /** Gets or sets the color used to render the skeleton */
  44085. color: Color3;
  44086. private _scene;
  44087. private _debugLines;
  44088. private _debugMesh;
  44089. private _isEnabled;
  44090. private _renderFunction;
  44091. private _utilityLayer;
  44092. /**
  44093. * Returns the mesh used to render the bones
  44094. */
  44095. readonly debugMesh: Nullable<LinesMesh>;
  44096. /**
  44097. * Creates a new SkeletonViewer
  44098. * @param skeleton defines the skeleton to render
  44099. * @param mesh defines the mesh attached to the skeleton
  44100. * @param scene defines the hosting scene
  44101. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44102. * @param renderingGroupId defines the rendering group id to use with the viewer
  44103. */
  44104. constructor(
  44105. /** defines the skeleton to render */
  44106. skeleton: Skeleton,
  44107. /** defines the mesh attached to the skeleton */
  44108. mesh: AbstractMesh, scene: Scene,
  44109. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44110. autoUpdateBonesMatrices?: boolean,
  44111. /** defines the rendering group id to use with the viewer */
  44112. renderingGroupId?: number);
  44113. /** Gets or sets a boolean indicating if the viewer is enabled */
  44114. isEnabled: boolean;
  44115. private _getBonePosition;
  44116. private _getLinesForBonesWithLength;
  44117. private _getLinesForBonesNoLength;
  44118. /** Update the viewer to sync with current skeleton state */
  44119. update(): void;
  44120. /** Release associated resources */
  44121. dispose(): void;
  44122. }
  44123. }
  44124. declare module BABYLON {
  44125. /**
  44126. * Options to create the null engine
  44127. */
  44128. export class NullEngineOptions {
  44129. /**
  44130. * Render width (Default: 512)
  44131. */
  44132. renderWidth: number;
  44133. /**
  44134. * Render height (Default: 256)
  44135. */
  44136. renderHeight: number;
  44137. /**
  44138. * Texture size (Default: 512)
  44139. */
  44140. textureSize: number;
  44141. /**
  44142. * If delta time between frames should be constant
  44143. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44144. */
  44145. deterministicLockstep: boolean;
  44146. /**
  44147. * Maximum about of steps between frames (Default: 4)
  44148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44149. */
  44150. lockstepMaxSteps: number;
  44151. }
  44152. /**
  44153. * The null engine class provides support for headless version of babylon.js.
  44154. * This can be used in server side scenario or for testing purposes
  44155. */
  44156. export class NullEngine extends Engine {
  44157. private _options;
  44158. /**
  44159. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44161. * @returns true if engine is in deterministic lock step mode
  44162. */
  44163. isDeterministicLockStep(): boolean;
  44164. /**
  44165. * Gets the max steps when engine is running in deterministic lock step
  44166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44167. * @returns the max steps
  44168. */
  44169. getLockstepMaxSteps(): number;
  44170. /**
  44171. * Gets the current hardware scaling level.
  44172. * By default the hardware scaling level is computed from the window device ratio.
  44173. * 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.
  44174. * @returns a number indicating the current hardware scaling level
  44175. */
  44176. getHardwareScalingLevel(): number;
  44177. constructor(options?: NullEngineOptions);
  44178. /**
  44179. * Creates a vertex buffer
  44180. * @param vertices the data for the vertex buffer
  44181. * @returns the new WebGL static buffer
  44182. */
  44183. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44184. /**
  44185. * Creates a new index buffer
  44186. * @param indices defines the content of the index buffer
  44187. * @param updatable defines if the index buffer must be updatable
  44188. * @returns a new webGL buffer
  44189. */
  44190. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44191. /**
  44192. * Clear the current render buffer or the current render target (if any is set up)
  44193. * @param color defines the color to use
  44194. * @param backBuffer defines if the back buffer must be cleared
  44195. * @param depth defines if the depth buffer must be cleared
  44196. * @param stencil defines if the stencil buffer must be cleared
  44197. */
  44198. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44199. /**
  44200. * Gets the current render width
  44201. * @param useScreen defines if screen size must be used (or the current render target if any)
  44202. * @returns a number defining the current render width
  44203. */
  44204. getRenderWidth(useScreen?: boolean): number;
  44205. /**
  44206. * Gets the current render height
  44207. * @param useScreen defines if screen size must be used (or the current render target if any)
  44208. * @returns a number defining the current render height
  44209. */
  44210. getRenderHeight(useScreen?: boolean): number;
  44211. /**
  44212. * Set the WebGL's viewport
  44213. * @param viewport defines the viewport element to be used
  44214. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44215. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44216. */
  44217. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44218. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44219. /**
  44220. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44221. * @param pipelineContext defines the pipeline context to use
  44222. * @param uniformsNames defines the list of uniform names
  44223. * @returns an array of webGL uniform locations
  44224. */
  44225. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44226. /**
  44227. * Gets the lsit of active attributes for a given webGL program
  44228. * @param pipelineContext defines the pipeline context to use
  44229. * @param attributesNames defines the list of attribute names to get
  44230. * @returns an array of indices indicating the offset of each attribute
  44231. */
  44232. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44233. /**
  44234. * Binds an effect to the webGL context
  44235. * @param effect defines the effect to bind
  44236. */
  44237. bindSamplers(effect: Effect): void;
  44238. /**
  44239. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44240. * @param effect defines the effect to activate
  44241. */
  44242. enableEffect(effect: Effect): void;
  44243. /**
  44244. * Set various states to the webGL context
  44245. * @param culling defines backface culling state
  44246. * @param zOffset defines the value to apply to zOffset (0 by default)
  44247. * @param force defines if states must be applied even if cache is up to date
  44248. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44249. */
  44250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44251. /**
  44252. * Set the value of an uniform to an array of int32
  44253. * @param uniform defines the webGL uniform location where to store the value
  44254. * @param array defines the array of int32 to store
  44255. */
  44256. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44257. /**
  44258. * Set the value of an uniform to an array of int32 (stored as vec2)
  44259. * @param uniform defines the webGL uniform location where to store the value
  44260. * @param array defines the array of int32 to store
  44261. */
  44262. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44263. /**
  44264. * Set the value of an uniform to an array of int32 (stored as vec3)
  44265. * @param uniform defines the webGL uniform location where to store the value
  44266. * @param array defines the array of int32 to store
  44267. */
  44268. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44269. /**
  44270. * Set the value of an uniform to an array of int32 (stored as vec4)
  44271. * @param uniform defines the webGL uniform location where to store the value
  44272. * @param array defines the array of int32 to store
  44273. */
  44274. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44275. /**
  44276. * Set the value of an uniform to an array of float32
  44277. * @param uniform defines the webGL uniform location where to store the value
  44278. * @param array defines the array of float32 to store
  44279. */
  44280. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44281. /**
  44282. * Set the value of an uniform to an array of float32 (stored as vec2)
  44283. * @param uniform defines the webGL uniform location where to store the value
  44284. * @param array defines the array of float32 to store
  44285. */
  44286. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44287. /**
  44288. * Set the value of an uniform to an array of float32 (stored as vec3)
  44289. * @param uniform defines the webGL uniform location where to store the value
  44290. * @param array defines the array of float32 to store
  44291. */
  44292. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44293. /**
  44294. * Set the value of an uniform to an array of float32 (stored as vec4)
  44295. * @param uniform defines the webGL uniform location where to store the value
  44296. * @param array defines the array of float32 to store
  44297. */
  44298. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44299. /**
  44300. * Set the value of an uniform to an array of number
  44301. * @param uniform defines the webGL uniform location where to store the value
  44302. * @param array defines the array of number to store
  44303. */
  44304. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44305. /**
  44306. * Set the value of an uniform to an array of number (stored as vec2)
  44307. * @param uniform defines the webGL uniform location where to store the value
  44308. * @param array defines the array of number to store
  44309. */
  44310. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44311. /**
  44312. * Set the value of an uniform to an array of number (stored as vec3)
  44313. * @param uniform defines the webGL uniform location where to store the value
  44314. * @param array defines the array of number to store
  44315. */
  44316. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44317. /**
  44318. * Set the value of an uniform to an array of number (stored as vec4)
  44319. * @param uniform defines the webGL uniform location where to store the value
  44320. * @param array defines the array of number to store
  44321. */
  44322. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44323. /**
  44324. * Set the value of an uniform to an array of float32 (stored as matrices)
  44325. * @param uniform defines the webGL uniform location where to store the value
  44326. * @param matrices defines the array of float32 to store
  44327. */
  44328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44329. /**
  44330. * Set the value of an uniform to a matrix (3x3)
  44331. * @param uniform defines the webGL uniform location where to store the value
  44332. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44333. */
  44334. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44335. /**
  44336. * Set the value of an uniform to a matrix (2x2)
  44337. * @param uniform defines the webGL uniform location where to store the value
  44338. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44339. */
  44340. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44341. /**
  44342. * Set the value of an uniform to a number (float)
  44343. * @param uniform defines the webGL uniform location where to store the value
  44344. * @param value defines the float number to store
  44345. */
  44346. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44347. /**
  44348. * Set the value of an uniform to a vec2
  44349. * @param uniform defines the webGL uniform location where to store the value
  44350. * @param x defines the 1st component of the value
  44351. * @param y defines the 2nd component of the value
  44352. */
  44353. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44354. /**
  44355. * Set the value of an uniform to a vec3
  44356. * @param uniform defines the webGL uniform location where to store the value
  44357. * @param x defines the 1st component of the value
  44358. * @param y defines the 2nd component of the value
  44359. * @param z defines the 3rd component of the value
  44360. */
  44361. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44362. /**
  44363. * Set the value of an uniform to a boolean
  44364. * @param uniform defines the webGL uniform location where to store the value
  44365. * @param bool defines the boolean to store
  44366. */
  44367. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44368. /**
  44369. * Set the value of an uniform to a vec4
  44370. * @param uniform defines the webGL uniform location where to store the value
  44371. * @param x defines the 1st component of the value
  44372. * @param y defines the 2nd component of the value
  44373. * @param z defines the 3rd component of the value
  44374. * @param w defines the 4th component of the value
  44375. */
  44376. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44377. /**
  44378. * Sets the current alpha mode
  44379. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44380. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44381. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44382. */
  44383. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44384. /**
  44385. * Bind webGl buffers directly to the webGL context
  44386. * @param vertexBuffers defines the vertex buffer to bind
  44387. * @param indexBuffer defines the index buffer to bind
  44388. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44389. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44390. * @param effect defines the effect associated with the vertex buffer
  44391. */
  44392. bindBuffers(vertexBuffers: {
  44393. [key: string]: VertexBuffer;
  44394. }, indexBuffer: DataBuffer, effect: Effect): void;
  44395. /**
  44396. * Force the entire cache to be cleared
  44397. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44398. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44399. */
  44400. wipeCaches(bruteForce?: boolean): void;
  44401. /**
  44402. * Send a draw order
  44403. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44404. * @param indexStart defines the starting index
  44405. * @param indexCount defines the number of index to draw
  44406. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44407. */
  44408. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44409. /**
  44410. * Draw a list of indexed primitives
  44411. * @param fillMode defines the primitive to use
  44412. * @param indexStart defines the starting index
  44413. * @param indexCount defines the number of index to draw
  44414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44415. */
  44416. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44417. /**
  44418. * Draw a list of unindexed primitives
  44419. * @param fillMode defines the primitive to use
  44420. * @param verticesStart defines the index of first vertex to draw
  44421. * @param verticesCount defines the count of vertices to draw
  44422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44423. */
  44424. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44425. /** @hidden */
  44426. _createTexture(): WebGLTexture;
  44427. /** @hidden */
  44428. _releaseTexture(texture: InternalTexture): void;
  44429. /**
  44430. * Usually called from Texture.ts.
  44431. * Passed information to create a WebGLTexture
  44432. * @param urlArg defines a value which contains one of the following:
  44433. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44434. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44435. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44437. * @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)
  44438. * @param scene needed for loading to the correct scene
  44439. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44440. * @param onLoad optional callback to be called upon successful completion
  44441. * @param onError optional callback to be called upon failure
  44442. * @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
  44443. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44444. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44445. * @param forcedExtension defines the extension to use to pick the right loader
  44446. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44447. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44448. */
  44449. 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;
  44450. /**
  44451. * Creates a new render target texture
  44452. * @param size defines the size of the texture
  44453. * @param options defines the options used to create the texture
  44454. * @returns a new render target texture stored in an InternalTexture
  44455. */
  44456. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44457. /**
  44458. * Update the sampling mode of a given texture
  44459. * @param samplingMode defines the required sampling mode
  44460. * @param texture defines the texture to update
  44461. */
  44462. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44463. /**
  44464. * Binds the frame buffer to the specified texture.
  44465. * @param texture The texture to render to or null for the default canvas
  44466. * @param faceIndex The face of the texture to render to in case of cube texture
  44467. * @param requiredWidth The width of the target to render to
  44468. * @param requiredHeight The height of the target to render to
  44469. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44470. * @param depthStencilTexture The depth stencil texture to use to render
  44471. * @param lodLevel defines le lod level to bind to the frame buffer
  44472. */
  44473. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44474. /**
  44475. * Unbind the current render target texture from the webGL context
  44476. * @param texture defines the render target texture to unbind
  44477. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44478. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44479. */
  44480. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44481. /**
  44482. * Creates a dynamic vertex buffer
  44483. * @param vertices the data for the dynamic vertex buffer
  44484. * @returns the new WebGL dynamic buffer
  44485. */
  44486. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44487. /**
  44488. * Update the content of a dynamic texture
  44489. * @param texture defines the texture to update
  44490. * @param canvas defines the canvas containing the source
  44491. * @param invertY defines if data must be stored with Y axis inverted
  44492. * @param premulAlpha defines if alpha is stored as premultiplied
  44493. * @param format defines the format of the data
  44494. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44495. */
  44496. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44497. /**
  44498. * Gets a boolean indicating if all created effects are ready
  44499. * @returns true if all effects are ready
  44500. */
  44501. areAllEffectsReady(): boolean;
  44502. /**
  44503. * @hidden
  44504. * Get the current error code of the webGL context
  44505. * @returns the error code
  44506. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44507. */
  44508. getError(): number;
  44509. /** @hidden */
  44510. _getUnpackAlignement(): number;
  44511. /** @hidden */
  44512. _unpackFlipY(value: boolean): void;
  44513. /**
  44514. * Update a dynamic index buffer
  44515. * @param indexBuffer defines the target index buffer
  44516. * @param indices defines the data to update
  44517. * @param offset defines the offset in the target index buffer where update should start
  44518. */
  44519. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44520. /**
  44521. * Updates a dynamic vertex buffer.
  44522. * @param vertexBuffer the vertex buffer to update
  44523. * @param vertices the data used to update the vertex buffer
  44524. * @param byteOffset the byte offset of the data (optional)
  44525. * @param byteLength the byte length of the data (optional)
  44526. */
  44527. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44528. /** @hidden */
  44529. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44530. /** @hidden */
  44531. _bindTexture(channel: number, texture: InternalTexture): void;
  44532. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44533. /**
  44534. * 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
  44535. */
  44536. releaseEffects(): void;
  44537. displayLoadingUI(): void;
  44538. hideLoadingUI(): void;
  44539. /** @hidden */
  44540. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44541. /** @hidden */
  44542. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44543. /** @hidden */
  44544. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44545. /** @hidden */
  44546. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44547. }
  44548. }
  44549. declare module BABYLON {
  44550. /** @hidden */
  44551. export class _OcclusionDataStorage {
  44552. /** @hidden */
  44553. occlusionInternalRetryCounter: number;
  44554. /** @hidden */
  44555. isOcclusionQueryInProgress: boolean;
  44556. /** @hidden */
  44557. isOccluded: boolean;
  44558. /** @hidden */
  44559. occlusionRetryCount: number;
  44560. /** @hidden */
  44561. occlusionType: number;
  44562. /** @hidden */
  44563. occlusionQueryAlgorithmType: number;
  44564. }
  44565. interface Engine {
  44566. /**
  44567. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44568. * @return the new query
  44569. */
  44570. createQuery(): WebGLQuery;
  44571. /**
  44572. * Delete and release a webGL query
  44573. * @param query defines the query to delete
  44574. * @return the current engine
  44575. */
  44576. deleteQuery(query: WebGLQuery): Engine;
  44577. /**
  44578. * Check if a given query has resolved and got its value
  44579. * @param query defines the query to check
  44580. * @returns true if the query got its value
  44581. */
  44582. isQueryResultAvailable(query: WebGLQuery): boolean;
  44583. /**
  44584. * Gets the value of a given query
  44585. * @param query defines the query to check
  44586. * @returns the value of the query
  44587. */
  44588. getQueryResult(query: WebGLQuery): number;
  44589. /**
  44590. * Initiates an occlusion query
  44591. * @param algorithmType defines the algorithm to use
  44592. * @param query defines the query to use
  44593. * @returns the current engine
  44594. * @see http://doc.babylonjs.com/features/occlusionquery
  44595. */
  44596. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44597. /**
  44598. * Ends an occlusion query
  44599. * @see http://doc.babylonjs.com/features/occlusionquery
  44600. * @param algorithmType defines the algorithm to use
  44601. * @returns the current engine
  44602. */
  44603. endOcclusionQuery(algorithmType: number): Engine;
  44604. /**
  44605. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44606. * Please note that only one query can be issued at a time
  44607. * @returns a time token used to track the time span
  44608. */
  44609. startTimeQuery(): Nullable<_TimeToken>;
  44610. /**
  44611. * Ends a time query
  44612. * @param token defines the token used to measure the time span
  44613. * @returns the time spent (in ns)
  44614. */
  44615. endTimeQuery(token: _TimeToken): int;
  44616. /** @hidden */
  44617. _currentNonTimestampToken: Nullable<_TimeToken>;
  44618. /** @hidden */
  44619. _createTimeQuery(): WebGLQuery;
  44620. /** @hidden */
  44621. _deleteTimeQuery(query: WebGLQuery): void;
  44622. /** @hidden */
  44623. _getGlAlgorithmType(algorithmType: number): number;
  44624. /** @hidden */
  44625. _getTimeQueryResult(query: WebGLQuery): any;
  44626. /** @hidden */
  44627. _getTimeQueryAvailability(query: WebGLQuery): any;
  44628. }
  44629. interface AbstractMesh {
  44630. /**
  44631. * Backing filed
  44632. * @hidden
  44633. */
  44634. __occlusionDataStorage: _OcclusionDataStorage;
  44635. /**
  44636. * Access property
  44637. * @hidden
  44638. */
  44639. _occlusionDataStorage: _OcclusionDataStorage;
  44640. /**
  44641. * 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.
  44642. * The default value is -1 which means don't break the query and wait till the result
  44643. * @see http://doc.babylonjs.com/features/occlusionquery
  44644. */
  44645. occlusionRetryCount: number;
  44646. /**
  44647. * 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:
  44648. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44649. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44650. * * 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.
  44651. * @see http://doc.babylonjs.com/features/occlusionquery
  44652. */
  44653. occlusionType: number;
  44654. /**
  44655. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44656. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44657. * * 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.
  44658. * @see http://doc.babylonjs.com/features/occlusionquery
  44659. */
  44660. occlusionQueryAlgorithmType: number;
  44661. /**
  44662. * 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
  44663. * @see http://doc.babylonjs.com/features/occlusionquery
  44664. */
  44665. isOccluded: boolean;
  44666. /**
  44667. * Flag to check the progress status of the query
  44668. * @see http://doc.babylonjs.com/features/occlusionquery
  44669. */
  44670. isOcclusionQueryInProgress: boolean;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /** @hidden */
  44675. export var _forceTransformFeedbackToBundle: boolean;
  44676. interface Engine {
  44677. /**
  44678. * Creates a webGL transform feedback object
  44679. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44680. * @returns the webGL transform feedback object
  44681. */
  44682. createTransformFeedback(): WebGLTransformFeedback;
  44683. /**
  44684. * Delete a webGL transform feedback object
  44685. * @param value defines the webGL transform feedback object to delete
  44686. */
  44687. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44688. /**
  44689. * Bind a webGL transform feedback object to the webgl context
  44690. * @param value defines the webGL transform feedback object to bind
  44691. */
  44692. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44693. /**
  44694. * Begins a transform feedback operation
  44695. * @param usePoints defines if points or triangles must be used
  44696. */
  44697. beginTransformFeedback(usePoints: boolean): void;
  44698. /**
  44699. * Ends a transform feedback operation
  44700. */
  44701. endTransformFeedback(): void;
  44702. /**
  44703. * Specify the varyings to use with transform feedback
  44704. * @param program defines the associated webGL program
  44705. * @param value defines the list of strings representing the varying names
  44706. */
  44707. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44708. /**
  44709. * Bind a webGL buffer for a transform feedback operation
  44710. * @param value defines the webGL buffer to bind
  44711. */
  44712. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44713. }
  44714. }
  44715. declare module BABYLON {
  44716. /**
  44717. * Creation options of the multi render target texture.
  44718. */
  44719. export interface IMultiRenderTargetOptions {
  44720. /**
  44721. * Define if the texture needs to create mip maps after render.
  44722. */
  44723. generateMipMaps?: boolean;
  44724. /**
  44725. * Define the types of all the draw buffers we want to create
  44726. */
  44727. types?: number[];
  44728. /**
  44729. * Define the sampling modes of all the draw buffers we want to create
  44730. */
  44731. samplingModes?: number[];
  44732. /**
  44733. * Define if a depth buffer is required
  44734. */
  44735. generateDepthBuffer?: boolean;
  44736. /**
  44737. * Define if a stencil buffer is required
  44738. */
  44739. generateStencilBuffer?: boolean;
  44740. /**
  44741. * Define if a depth texture is required instead of a depth buffer
  44742. */
  44743. generateDepthTexture?: boolean;
  44744. /**
  44745. * Define the number of desired draw buffers
  44746. */
  44747. textureCount?: number;
  44748. /**
  44749. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44750. */
  44751. doNotChangeAspectRatio?: boolean;
  44752. /**
  44753. * Define the default type of the buffers we are creating
  44754. */
  44755. defaultType?: number;
  44756. }
  44757. /**
  44758. * A multi render target, like a render target provides the ability to render to a texture.
  44759. * Unlike the render target, it can render to several draw buffers in one draw.
  44760. * This is specially interesting in deferred rendering or for any effects requiring more than
  44761. * just one color from a single pass.
  44762. */
  44763. export class MultiRenderTarget extends RenderTargetTexture {
  44764. private _internalTextures;
  44765. private _textures;
  44766. private _multiRenderTargetOptions;
  44767. /**
  44768. * Get if draw buffers are currently supported by the used hardware and browser.
  44769. */
  44770. readonly isSupported: boolean;
  44771. /**
  44772. * Get the list of textures generated by the multi render target.
  44773. */
  44774. readonly textures: Texture[];
  44775. /**
  44776. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44777. */
  44778. readonly depthTexture: Texture;
  44779. /**
  44780. * Set the wrapping mode on U of all the textures we are rendering to.
  44781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44782. */
  44783. wrapU: number;
  44784. /**
  44785. * Set the wrapping mode on V of all the textures we are rendering to.
  44786. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44787. */
  44788. wrapV: number;
  44789. /**
  44790. * Instantiate a new multi render target texture.
  44791. * A multi render target, like a render target provides the ability to render to a texture.
  44792. * Unlike the render target, it can render to several draw buffers in one draw.
  44793. * This is specially interesting in deferred rendering or for any effects requiring more than
  44794. * just one color from a single pass.
  44795. * @param name Define the name of the texture
  44796. * @param size Define the size of the buffers to render to
  44797. * @param count Define the number of target we are rendering into
  44798. * @param scene Define the scene the texture belongs to
  44799. * @param options Define the options used to create the multi render target
  44800. */
  44801. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44802. /** @hidden */
  44803. _rebuild(): void;
  44804. private _createInternalTextures;
  44805. private _createTextures;
  44806. /**
  44807. * Define the number of samples used if MSAA is enabled.
  44808. */
  44809. samples: number;
  44810. /**
  44811. * Resize all the textures in the multi render target.
  44812. * Be carrefull as it will recreate all the data in the new texture.
  44813. * @param size Define the new size
  44814. */
  44815. resize(size: any): void;
  44816. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44817. /**
  44818. * Dispose the render targets and their associated resources
  44819. */
  44820. dispose(): void;
  44821. /**
  44822. * Release all the underlying texture used as draw buffers.
  44823. */
  44824. releaseInternalTextures(): void;
  44825. }
  44826. }
  44827. declare module BABYLON {
  44828. interface ThinEngine {
  44829. /**
  44830. * Unbind a list of render target textures from the webGL context
  44831. * This is used only when drawBuffer extension or webGL2 are active
  44832. * @param textures defines the render target textures to unbind
  44833. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44834. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44835. */
  44836. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44837. /**
  44838. * Create a multi render target texture
  44839. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44840. * @param size defines the size of the texture
  44841. * @param options defines the creation options
  44842. * @returns the cube texture as an InternalTexture
  44843. */
  44844. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44845. /**
  44846. * Update the sample count for a given multiple render target texture
  44847. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44848. * @param textures defines the textures to update
  44849. * @param samples defines the sample count to set
  44850. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44851. */
  44852. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44853. }
  44854. }
  44855. declare module BABYLON {
  44856. /**
  44857. * Class used to define an additional view for the engine
  44858. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44859. */
  44860. export class EngineView {
  44861. /** Defines the canvas where to render the view */
  44862. target: HTMLCanvasElement;
  44863. /** Defines an optional camera used to render the view (will use active camera else) */
  44864. camera?: Camera;
  44865. }
  44866. interface Engine {
  44867. /**
  44868. * Gets or sets the HTML element to use for attaching events
  44869. */
  44870. inputElement: Nullable<HTMLElement>;
  44871. /**
  44872. * Gets the current engine view
  44873. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44874. */
  44875. activeView: Nullable<EngineView>;
  44876. /** Gets or sets the list of views */
  44877. views: EngineView[];
  44878. /**
  44879. * Register a new child canvas
  44880. * @param canvas defines the canvas to register
  44881. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44882. * @returns the associated view
  44883. */
  44884. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44885. /**
  44886. * Remove a registered child canvas
  44887. * @param canvas defines the canvas to remove
  44888. * @returns the current engine
  44889. */
  44890. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44891. }
  44892. }
  44893. declare module BABYLON {
  44894. /**
  44895. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44896. */
  44897. export interface CubeMapInfo {
  44898. /**
  44899. * The pixel array for the front face.
  44900. * This is stored in format, left to right, up to down format.
  44901. */
  44902. front: Nullable<ArrayBufferView>;
  44903. /**
  44904. * The pixel array for the back face.
  44905. * This is stored in format, left to right, up to down format.
  44906. */
  44907. back: Nullable<ArrayBufferView>;
  44908. /**
  44909. * The pixel array for the left face.
  44910. * This is stored in format, left to right, up to down format.
  44911. */
  44912. left: Nullable<ArrayBufferView>;
  44913. /**
  44914. * The pixel array for the right face.
  44915. * This is stored in format, left to right, up to down format.
  44916. */
  44917. right: Nullable<ArrayBufferView>;
  44918. /**
  44919. * The pixel array for the up face.
  44920. * This is stored in format, left to right, up to down format.
  44921. */
  44922. up: Nullable<ArrayBufferView>;
  44923. /**
  44924. * The pixel array for the down face.
  44925. * This is stored in format, left to right, up to down format.
  44926. */
  44927. down: Nullable<ArrayBufferView>;
  44928. /**
  44929. * The size of the cubemap stored.
  44930. *
  44931. * Each faces will be size * size pixels.
  44932. */
  44933. size: number;
  44934. /**
  44935. * The format of the texture.
  44936. *
  44937. * RGBA, RGB.
  44938. */
  44939. format: number;
  44940. /**
  44941. * The type of the texture data.
  44942. *
  44943. * UNSIGNED_INT, FLOAT.
  44944. */
  44945. type: number;
  44946. /**
  44947. * Specifies whether the texture is in gamma space.
  44948. */
  44949. gammaSpace: boolean;
  44950. }
  44951. /**
  44952. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44953. */
  44954. export class PanoramaToCubeMapTools {
  44955. private static FACE_FRONT;
  44956. private static FACE_BACK;
  44957. private static FACE_RIGHT;
  44958. private static FACE_LEFT;
  44959. private static FACE_DOWN;
  44960. private static FACE_UP;
  44961. /**
  44962. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44963. *
  44964. * @param float32Array The source data.
  44965. * @param inputWidth The width of the input panorama.
  44966. * @param inputHeight The height of the input panorama.
  44967. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44968. * @return The cubemap data
  44969. */
  44970. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44971. private static CreateCubemapTexture;
  44972. private static CalcProjectionSpherical;
  44973. }
  44974. }
  44975. declare module BABYLON {
  44976. /**
  44977. * Helper class dealing with the extraction of spherical polynomial dataArray
  44978. * from a cube map.
  44979. */
  44980. export class CubeMapToSphericalPolynomialTools {
  44981. private static FileFaces;
  44982. /**
  44983. * Converts a texture to the according Spherical Polynomial data.
  44984. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44985. *
  44986. * @param texture The texture to extract the information from.
  44987. * @return The Spherical Polynomial data.
  44988. */
  44989. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44990. /**
  44991. * Converts a cubemap to the according Spherical Polynomial data.
  44992. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44993. *
  44994. * @param cubeInfo The Cube map to extract the information from.
  44995. * @return The Spherical Polynomial data.
  44996. */
  44997. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44998. }
  44999. }
  45000. declare module BABYLON {
  45001. interface BaseTexture {
  45002. /**
  45003. * Get the polynomial representation of the texture data.
  45004. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45005. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45006. */
  45007. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45008. }
  45009. }
  45010. declare module BABYLON {
  45011. /** @hidden */
  45012. export var rgbdEncodePixelShader: {
  45013. name: string;
  45014. shader: string;
  45015. };
  45016. }
  45017. declare module BABYLON {
  45018. /** @hidden */
  45019. export var rgbdDecodePixelShader: {
  45020. name: string;
  45021. shader: string;
  45022. };
  45023. }
  45024. declare module BABYLON {
  45025. /**
  45026. * Raw texture data and descriptor sufficient for WebGL texture upload
  45027. */
  45028. export interface EnvironmentTextureInfo {
  45029. /**
  45030. * Version of the environment map
  45031. */
  45032. version: number;
  45033. /**
  45034. * Width of image
  45035. */
  45036. width: number;
  45037. /**
  45038. * Irradiance information stored in the file.
  45039. */
  45040. irradiance: any;
  45041. /**
  45042. * Specular information stored in the file.
  45043. */
  45044. specular: any;
  45045. }
  45046. /**
  45047. * Defines One Image in the file. It requires only the position in the file
  45048. * as well as the length.
  45049. */
  45050. interface BufferImageData {
  45051. /**
  45052. * Length of the image data.
  45053. */
  45054. length: number;
  45055. /**
  45056. * Position of the data from the null terminator delimiting the end of the JSON.
  45057. */
  45058. position: number;
  45059. }
  45060. /**
  45061. * Defines the specular data enclosed in the file.
  45062. * This corresponds to the version 1 of the data.
  45063. */
  45064. export interface EnvironmentTextureSpecularInfoV1 {
  45065. /**
  45066. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45067. */
  45068. specularDataPosition?: number;
  45069. /**
  45070. * This contains all the images data needed to reconstruct the cubemap.
  45071. */
  45072. mipmaps: Array<BufferImageData>;
  45073. /**
  45074. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45075. */
  45076. lodGenerationScale: number;
  45077. }
  45078. /**
  45079. * Sets of helpers addressing the serialization and deserialization of environment texture
  45080. * stored in a BabylonJS env file.
  45081. * Those files are usually stored as .env files.
  45082. */
  45083. export class EnvironmentTextureTools {
  45084. /**
  45085. * Magic number identifying the env file.
  45086. */
  45087. private static _MagicBytes;
  45088. /**
  45089. * Gets the environment info from an env file.
  45090. * @param data The array buffer containing the .env bytes.
  45091. * @returns the environment file info (the json header) if successfully parsed.
  45092. */
  45093. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45094. /**
  45095. * Creates an environment texture from a loaded cube texture.
  45096. * @param texture defines the cube texture to convert in env file
  45097. * @return a promise containing the environment data if succesfull.
  45098. */
  45099. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45100. /**
  45101. * Creates a JSON representation of the spherical data.
  45102. * @param texture defines the texture containing the polynomials
  45103. * @return the JSON representation of the spherical info
  45104. */
  45105. private static _CreateEnvTextureIrradiance;
  45106. /**
  45107. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45108. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45109. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45110. * @return the views described by info providing access to the underlying buffer
  45111. */
  45112. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45113. /**
  45114. * Uploads the texture info contained in the env file to the GPU.
  45115. * @param texture defines the internal texture to upload to
  45116. * @param arrayBuffer defines the buffer cotaining the data to load
  45117. * @param info defines the texture info retrieved through the GetEnvInfo method
  45118. * @returns a promise
  45119. */
  45120. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45121. private static _OnImageReadyAsync;
  45122. /**
  45123. * Uploads the levels of image data to the GPU.
  45124. * @param texture defines the internal texture to upload to
  45125. * @param imageData defines the array buffer views of image data [mipmap][face]
  45126. * @returns a promise
  45127. */
  45128. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45129. /**
  45130. * Uploads spherical polynomials information to the texture.
  45131. * @param texture defines the texture we are trying to upload the information to
  45132. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45133. */
  45134. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45135. /** @hidden */
  45136. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45137. }
  45138. }
  45139. declare module BABYLON {
  45140. /**
  45141. * Contains position and normal vectors for a vertex
  45142. */
  45143. export class PositionNormalVertex {
  45144. /** the position of the vertex (defaut: 0,0,0) */
  45145. position: Vector3;
  45146. /** the normal of the vertex (defaut: 0,1,0) */
  45147. normal: Vector3;
  45148. /**
  45149. * Creates a PositionNormalVertex
  45150. * @param position the position of the vertex (defaut: 0,0,0)
  45151. * @param normal the normal of the vertex (defaut: 0,1,0)
  45152. */
  45153. constructor(
  45154. /** the position of the vertex (defaut: 0,0,0) */
  45155. position?: Vector3,
  45156. /** the normal of the vertex (defaut: 0,1,0) */
  45157. normal?: Vector3);
  45158. /**
  45159. * Clones the PositionNormalVertex
  45160. * @returns the cloned PositionNormalVertex
  45161. */
  45162. clone(): PositionNormalVertex;
  45163. }
  45164. /**
  45165. * Contains position, normal and uv vectors for a vertex
  45166. */
  45167. export class PositionNormalTextureVertex {
  45168. /** the position of the vertex (defaut: 0,0,0) */
  45169. position: Vector3;
  45170. /** the normal of the vertex (defaut: 0,1,0) */
  45171. normal: Vector3;
  45172. /** the uv of the vertex (default: 0,0) */
  45173. uv: Vector2;
  45174. /**
  45175. * Creates a PositionNormalTextureVertex
  45176. * @param position the position of the vertex (defaut: 0,0,0)
  45177. * @param normal the normal of the vertex (defaut: 0,1,0)
  45178. * @param uv the uv of the vertex (default: 0,0)
  45179. */
  45180. constructor(
  45181. /** the position of the vertex (defaut: 0,0,0) */
  45182. position?: Vector3,
  45183. /** the normal of the vertex (defaut: 0,1,0) */
  45184. normal?: Vector3,
  45185. /** the uv of the vertex (default: 0,0) */
  45186. uv?: Vector2);
  45187. /**
  45188. * Clones the PositionNormalTextureVertex
  45189. * @returns the cloned PositionNormalTextureVertex
  45190. */
  45191. clone(): PositionNormalTextureVertex;
  45192. }
  45193. }
  45194. declare module BABYLON {
  45195. /** @hidden */
  45196. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45197. private _genericAttributeLocation;
  45198. private _varyingLocationCount;
  45199. private _varyingLocationMap;
  45200. private _replacements;
  45201. private _textureCount;
  45202. private _uniforms;
  45203. lineProcessor(line: string): string;
  45204. attributeProcessor(attribute: string): string;
  45205. varyingProcessor(varying: string, isFragment: boolean): string;
  45206. uniformProcessor(uniform: string): string;
  45207. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45208. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45209. }
  45210. }
  45211. declare module BABYLON {
  45212. /**
  45213. * Container for accessors for natively-stored mesh data buffers.
  45214. */
  45215. class NativeDataBuffer extends DataBuffer {
  45216. /**
  45217. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45218. */
  45219. nativeIndexBuffer?: any;
  45220. /**
  45221. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45222. */
  45223. nativeVertexBuffer?: any;
  45224. }
  45225. /** @hidden */
  45226. class NativeTexture extends InternalTexture {
  45227. getInternalTexture(): InternalTexture;
  45228. getViewCount(): number;
  45229. }
  45230. /** @hidden */
  45231. export class NativeEngine extends Engine {
  45232. private readonly _native;
  45233. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45234. private readonly INVALID_HANDLE;
  45235. getHardwareScalingLevel(): number;
  45236. constructor();
  45237. /**
  45238. * Can be used to override the current requestAnimationFrame requester.
  45239. * @hidden
  45240. */
  45241. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45242. /**
  45243. * Override default engine behavior.
  45244. * @param color
  45245. * @param backBuffer
  45246. * @param depth
  45247. * @param stencil
  45248. */
  45249. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45250. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45251. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45252. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45253. recordVertexArrayObject(vertexBuffers: {
  45254. [key: string]: VertexBuffer;
  45255. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45256. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45257. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45258. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45259. /**
  45260. * Draw a list of indexed primitives
  45261. * @param fillMode defines the primitive to use
  45262. * @param indexStart defines the starting index
  45263. * @param indexCount defines the number of index to draw
  45264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45265. */
  45266. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45267. /**
  45268. * Draw a list of unindexed primitives
  45269. * @param fillMode defines the primitive to use
  45270. * @param verticesStart defines the index of first vertex to draw
  45271. * @param verticesCount defines the count of vertices to draw
  45272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45273. */
  45274. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45275. createPipelineContext(): IPipelineContext;
  45276. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45277. /** @hidden */
  45278. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45279. /** @hidden */
  45280. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45281. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45283. protected _setProgram(program: WebGLProgram): void;
  45284. _releaseEffect(effect: Effect): void;
  45285. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45286. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45287. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45288. bindSamplers(effect: Effect): void;
  45289. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45290. getRenderWidth(useScreen?: boolean): number;
  45291. getRenderHeight(useScreen?: boolean): number;
  45292. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45294. /**
  45295. * Set the z offset to apply to current rendering
  45296. * @param value defines the offset to apply
  45297. */
  45298. setZOffset(value: number): void;
  45299. /**
  45300. * Gets the current value of the zOffset
  45301. * @returns the current zOffset state
  45302. */
  45303. getZOffset(): number;
  45304. /**
  45305. * Enable or disable depth buffering
  45306. * @param enable defines the state to set
  45307. */
  45308. setDepthBuffer(enable: boolean): void;
  45309. /**
  45310. * Gets a boolean indicating if depth writing is enabled
  45311. * @returns the current depth writing state
  45312. */
  45313. getDepthWrite(): boolean;
  45314. /**
  45315. * Enable or disable depth writing
  45316. * @param enable defines the state to set
  45317. */
  45318. setDepthWrite(enable: boolean): void;
  45319. /**
  45320. * Enable or disable color writing
  45321. * @param enable defines the state to set
  45322. */
  45323. setColorWrite(enable: boolean): void;
  45324. /**
  45325. * Gets a boolean indicating if color writing is enabled
  45326. * @returns the current color writing state
  45327. */
  45328. getColorWrite(): boolean;
  45329. /**
  45330. * Sets alpha constants used by some alpha blending modes
  45331. * @param r defines the red component
  45332. * @param g defines the green component
  45333. * @param b defines the blue component
  45334. * @param a defines the alpha component
  45335. */
  45336. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45337. /**
  45338. * Sets the current alpha mode
  45339. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45340. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45342. */
  45343. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45344. /**
  45345. * Gets the current alpha mode
  45346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45347. * @returns the current alpha mode
  45348. */
  45349. getAlphaMode(): number;
  45350. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45351. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45352. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45353. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45354. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45355. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45356. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45357. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45358. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45359. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45360. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45361. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45362. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45363. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45364. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45365. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45366. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45367. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45368. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45369. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45370. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45371. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45372. wipeCaches(bruteForce?: boolean): void;
  45373. _createTexture(): WebGLTexture;
  45374. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45375. /**
  45376. * Usually called from BABYLON.Texture.ts.
  45377. * Passed information to create a WebGLTexture
  45378. * @param urlArg defines a value which contains one of the following:
  45379. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45380. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45381. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45382. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45383. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45384. * @param scene needed for loading to the correct scene
  45385. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45386. * @param onLoad optional callback to be called upon successful completion
  45387. * @param onError optional callback to be called upon failure
  45388. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45389. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45390. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45391. * @param forcedExtension defines the extension to use to pick the right loader
  45392. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45393. */
  45394. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45395. /**
  45396. * Creates a cube texture
  45397. * @param rootUrl defines the url where the files to load is located
  45398. * @param scene defines the current scene
  45399. * @param files defines the list of files to load (1 per face)
  45400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45401. * @param onLoad defines an optional callback raised when the texture is loaded
  45402. * @param onError defines an optional callback raised if there is an issue to load the texture
  45403. * @param format defines the format of the data
  45404. * @param forcedExtension defines the extension to use to pick the right loader
  45405. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45408. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45409. * @returns the cube texture as an InternalTexture
  45410. */
  45411. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45412. private _getSamplingFilter;
  45413. private static _GetNativeTextureFormat;
  45414. createRenderTargetTexture(size: number | {
  45415. width: number;
  45416. height: number;
  45417. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45418. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45419. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45420. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45421. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45422. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45423. /**
  45424. * Updates a dynamic vertex buffer.
  45425. * @param vertexBuffer the vertex buffer to update
  45426. * @param data the data used to update the vertex buffer
  45427. * @param byteOffset the byte offset of the data (optional)
  45428. * @param byteLength the byte length of the data (optional)
  45429. */
  45430. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45431. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45432. private _updateAnisotropicLevel;
  45433. private _getAddressMode;
  45434. /** @hidden */
  45435. _bindTexture(channel: number, texture: InternalTexture): void;
  45436. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45437. releaseEffects(): void;
  45438. /** @hidden */
  45439. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45440. /** @hidden */
  45441. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45442. /** @hidden */
  45443. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45444. /** @hidden */
  45445. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45446. }
  45447. }
  45448. declare module BABYLON {
  45449. /**
  45450. * Gather the list of clipboard event types as constants.
  45451. */
  45452. export class ClipboardEventTypes {
  45453. /**
  45454. * The clipboard event is fired when a copy command is active (pressed).
  45455. */
  45456. static readonly COPY: number;
  45457. /**
  45458. * The clipboard event is fired when a cut command is active (pressed).
  45459. */
  45460. static readonly CUT: number;
  45461. /**
  45462. * The clipboard event is fired when a paste command is active (pressed).
  45463. */
  45464. static readonly PASTE: number;
  45465. }
  45466. /**
  45467. * This class is used to store clipboard related info for the onClipboardObservable event.
  45468. */
  45469. export class ClipboardInfo {
  45470. /**
  45471. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45472. */
  45473. type: number;
  45474. /**
  45475. * Defines the related dom event
  45476. */
  45477. event: ClipboardEvent;
  45478. /**
  45479. *Creates an instance of ClipboardInfo.
  45480. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45481. * @param event Defines the related dom event
  45482. */
  45483. constructor(
  45484. /**
  45485. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45486. */
  45487. type: number,
  45488. /**
  45489. * Defines the related dom event
  45490. */
  45491. event: ClipboardEvent);
  45492. /**
  45493. * Get the clipboard event's type from the keycode.
  45494. * @param keyCode Defines the keyCode for the current keyboard event.
  45495. * @return {number}
  45496. */
  45497. static GetTypeFromCharacter(keyCode: number): number;
  45498. }
  45499. }
  45500. declare module BABYLON {
  45501. /**
  45502. * Google Daydream controller
  45503. */
  45504. export class DaydreamController extends WebVRController {
  45505. /**
  45506. * Base Url for the controller model.
  45507. */
  45508. static MODEL_BASE_URL: string;
  45509. /**
  45510. * File name for the controller model.
  45511. */
  45512. static MODEL_FILENAME: string;
  45513. /**
  45514. * Gamepad Id prefix used to identify Daydream Controller.
  45515. */
  45516. static readonly GAMEPAD_ID_PREFIX: string;
  45517. /**
  45518. * Creates a new DaydreamController from a gamepad
  45519. * @param vrGamepad the gamepad that the controller should be created from
  45520. */
  45521. constructor(vrGamepad: any);
  45522. /**
  45523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45524. * @param scene scene in which to add meshes
  45525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45526. */
  45527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45528. /**
  45529. * Called once for each button that changed state since the last frame
  45530. * @param buttonIdx Which button index changed
  45531. * @param state New state of the button
  45532. * @param changes Which properties on the state changed since last frame
  45533. */
  45534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45535. }
  45536. }
  45537. declare module BABYLON {
  45538. /**
  45539. * Gear VR Controller
  45540. */
  45541. export class GearVRController extends WebVRController {
  45542. /**
  45543. * Base Url for the controller model.
  45544. */
  45545. static MODEL_BASE_URL: string;
  45546. /**
  45547. * File name for the controller model.
  45548. */
  45549. static MODEL_FILENAME: string;
  45550. /**
  45551. * Gamepad Id prefix used to identify this controller.
  45552. */
  45553. static readonly GAMEPAD_ID_PREFIX: string;
  45554. private readonly _buttonIndexToObservableNameMap;
  45555. /**
  45556. * Creates a new GearVRController from a gamepad
  45557. * @param vrGamepad the gamepad that the controller should be created from
  45558. */
  45559. constructor(vrGamepad: any);
  45560. /**
  45561. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45562. * @param scene scene in which to add meshes
  45563. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45564. */
  45565. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45566. /**
  45567. * Called once for each button that changed state since the last frame
  45568. * @param buttonIdx Which button index changed
  45569. * @param state New state of the button
  45570. * @param changes Which properties on the state changed since last frame
  45571. */
  45572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45573. }
  45574. }
  45575. declare module BABYLON {
  45576. /**
  45577. * Class containing static functions to help procedurally build meshes
  45578. */
  45579. export class PolyhedronBuilder {
  45580. /**
  45581. * Creates a polyhedron mesh
  45582. * * 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
  45583. * * The parameter `size` (positive float, default 1) sets the polygon size
  45584. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45585. * * 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`
  45586. * * 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
  45587. * * 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)`)
  45588. * * 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
  45589. * * 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
  45590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45591. * * 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
  45592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45593. * @param name defines the name of the mesh
  45594. * @param options defines the options used to create the mesh
  45595. * @param scene defines the hosting scene
  45596. * @returns the polyhedron mesh
  45597. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45598. */
  45599. static CreatePolyhedron(name: string, options: {
  45600. type?: number;
  45601. size?: number;
  45602. sizeX?: number;
  45603. sizeY?: number;
  45604. sizeZ?: number;
  45605. custom?: any;
  45606. faceUV?: Vector4[];
  45607. faceColors?: Color4[];
  45608. flat?: boolean;
  45609. updatable?: boolean;
  45610. sideOrientation?: number;
  45611. frontUVs?: Vector4;
  45612. backUVs?: Vector4;
  45613. }, scene?: Nullable<Scene>): Mesh;
  45614. }
  45615. }
  45616. declare module BABYLON {
  45617. /**
  45618. * Gizmo that enables scaling a mesh along 3 axis
  45619. */
  45620. export class ScaleGizmo extends Gizmo {
  45621. /**
  45622. * Internal gizmo used for interactions on the x axis
  45623. */
  45624. xGizmo: AxisScaleGizmo;
  45625. /**
  45626. * Internal gizmo used for interactions on the y axis
  45627. */
  45628. yGizmo: AxisScaleGizmo;
  45629. /**
  45630. * Internal gizmo used for interactions on the z axis
  45631. */
  45632. zGizmo: AxisScaleGizmo;
  45633. /**
  45634. * Internal gizmo used to scale all axis equally
  45635. */
  45636. uniformScaleGizmo: AxisScaleGizmo;
  45637. private _meshAttached;
  45638. private _updateGizmoRotationToMatchAttachedMesh;
  45639. private _snapDistance;
  45640. private _scaleRatio;
  45641. private _uniformScalingMesh;
  45642. private _octahedron;
  45643. /** Fires an event when any of it's sub gizmos are dragged */
  45644. onDragStartObservable: Observable<unknown>;
  45645. /** Fires an event when any of it's sub gizmos are released from dragging */
  45646. onDragEndObservable: Observable<unknown>;
  45647. attachedMesh: Nullable<AbstractMesh>;
  45648. /**
  45649. * Creates a ScaleGizmo
  45650. * @param gizmoLayer The utility layer the gizmo will be added to
  45651. */
  45652. constructor(gizmoLayer?: UtilityLayerRenderer);
  45653. updateGizmoRotationToMatchAttachedMesh: boolean;
  45654. /**
  45655. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45656. */
  45657. snapDistance: number;
  45658. /**
  45659. * Ratio for the scale of the gizmo (Default: 1)
  45660. */
  45661. scaleRatio: number;
  45662. /**
  45663. * Disposes of the gizmo
  45664. */
  45665. dispose(): void;
  45666. }
  45667. }
  45668. declare module BABYLON {
  45669. /**
  45670. * Single axis scale gizmo
  45671. */
  45672. export class AxisScaleGizmo extends Gizmo {
  45673. /**
  45674. * Drag behavior responsible for the gizmos dragging interactions
  45675. */
  45676. dragBehavior: PointerDragBehavior;
  45677. private _pointerObserver;
  45678. /**
  45679. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45680. */
  45681. snapDistance: number;
  45682. /**
  45683. * Event that fires each time the gizmo snaps to a new location.
  45684. * * snapDistance is the the change in distance
  45685. */
  45686. onSnapObservable: Observable<{
  45687. snapDistance: number;
  45688. }>;
  45689. /**
  45690. * If the scaling operation should be done on all axis (default: false)
  45691. */
  45692. uniformScaling: boolean;
  45693. private _isEnabled;
  45694. private _parent;
  45695. private _arrow;
  45696. private _coloredMaterial;
  45697. private _hoverMaterial;
  45698. /**
  45699. * Creates an AxisScaleGizmo
  45700. * @param gizmoLayer The utility layer the gizmo will be added to
  45701. * @param dragAxis The axis which the gizmo will be able to scale on
  45702. * @param color The color of the gizmo
  45703. */
  45704. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45706. /**
  45707. * If the gizmo is enabled
  45708. */
  45709. isEnabled: boolean;
  45710. /**
  45711. * Disposes of the gizmo
  45712. */
  45713. dispose(): void;
  45714. /**
  45715. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45716. * @param mesh The mesh to replace the default mesh of the gizmo
  45717. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45718. */
  45719. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45720. }
  45721. }
  45722. declare module BABYLON {
  45723. /**
  45724. * Bounding box gizmo
  45725. */
  45726. export class BoundingBoxGizmo extends Gizmo {
  45727. private _lineBoundingBox;
  45728. private _rotateSpheresParent;
  45729. private _scaleBoxesParent;
  45730. private _boundingDimensions;
  45731. private _renderObserver;
  45732. private _pointerObserver;
  45733. private _scaleDragSpeed;
  45734. private _tmpQuaternion;
  45735. private _tmpVector;
  45736. private _tmpRotationMatrix;
  45737. /**
  45738. * 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)
  45739. */
  45740. ignoreChildren: boolean;
  45741. /**
  45742. * 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)
  45743. */
  45744. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45745. /**
  45746. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45747. */
  45748. rotationSphereSize: number;
  45749. /**
  45750. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45751. */
  45752. scaleBoxSize: number;
  45753. /**
  45754. * 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)
  45755. */
  45756. fixedDragMeshScreenSize: boolean;
  45757. /**
  45758. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45759. */
  45760. fixedDragMeshScreenSizeDistanceFactor: number;
  45761. /**
  45762. * Fired when a rotation sphere or scale box is dragged
  45763. */
  45764. onDragStartObservable: Observable<{}>;
  45765. /**
  45766. * Fired when a scale box is dragged
  45767. */
  45768. onScaleBoxDragObservable: Observable<{}>;
  45769. /**
  45770. * Fired when a scale box drag is ended
  45771. */
  45772. onScaleBoxDragEndObservable: Observable<{}>;
  45773. /**
  45774. * Fired when a rotation sphere is dragged
  45775. */
  45776. onRotationSphereDragObservable: Observable<{}>;
  45777. /**
  45778. * Fired when a rotation sphere drag is ended
  45779. */
  45780. onRotationSphereDragEndObservable: Observable<{}>;
  45781. /**
  45782. * 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)
  45783. */
  45784. scalePivot: Nullable<Vector3>;
  45785. /**
  45786. * Mesh used as a pivot to rotate the attached mesh
  45787. */
  45788. private _anchorMesh;
  45789. private _existingMeshScale;
  45790. private _dragMesh;
  45791. private pointerDragBehavior;
  45792. private coloredMaterial;
  45793. private hoverColoredMaterial;
  45794. /**
  45795. * Sets the color of the bounding box gizmo
  45796. * @param color the color to set
  45797. */
  45798. setColor(color: Color3): void;
  45799. /**
  45800. * Creates an BoundingBoxGizmo
  45801. * @param gizmoLayer The utility layer the gizmo will be added to
  45802. * @param color The color of the gizmo
  45803. */
  45804. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45805. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45806. private _selectNode;
  45807. /**
  45808. * Updates the bounding box information for the Gizmo
  45809. */
  45810. updateBoundingBox(): void;
  45811. private _updateRotationSpheres;
  45812. private _updateScaleBoxes;
  45813. /**
  45814. * Enables rotation on the specified axis and disables rotation on the others
  45815. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45816. */
  45817. setEnabledRotationAxis(axis: string): void;
  45818. /**
  45819. * Enables/disables scaling
  45820. * @param enable if scaling should be enabled
  45821. */
  45822. setEnabledScaling(enable: boolean): void;
  45823. private _updateDummy;
  45824. /**
  45825. * Enables a pointer drag behavior on the bounding box of the gizmo
  45826. */
  45827. enableDragBehavior(): void;
  45828. /**
  45829. * Disposes of the gizmo
  45830. */
  45831. dispose(): void;
  45832. /**
  45833. * 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)
  45834. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45835. * @returns the bounding box mesh with the passed in mesh as a child
  45836. */
  45837. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45838. /**
  45839. * CustomMeshes are not supported by this gizmo
  45840. * @param mesh The mesh to replace the default mesh of the gizmo
  45841. */
  45842. setCustomMesh(mesh: Mesh): void;
  45843. }
  45844. }
  45845. declare module BABYLON {
  45846. /**
  45847. * Single plane rotation gizmo
  45848. */
  45849. export class PlaneRotationGizmo extends Gizmo {
  45850. /**
  45851. * Drag behavior responsible for the gizmos dragging interactions
  45852. */
  45853. dragBehavior: PointerDragBehavior;
  45854. private _pointerObserver;
  45855. /**
  45856. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45857. */
  45858. snapDistance: number;
  45859. /**
  45860. * Event that fires each time the gizmo snaps to a new location.
  45861. * * snapDistance is the the change in distance
  45862. */
  45863. onSnapObservable: Observable<{
  45864. snapDistance: number;
  45865. }>;
  45866. private _isEnabled;
  45867. private _parent;
  45868. /**
  45869. * Creates a PlaneRotationGizmo
  45870. * @param gizmoLayer The utility layer the gizmo will be added to
  45871. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45872. * @param color The color of the gizmo
  45873. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45874. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45875. */
  45876. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45877. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45878. /**
  45879. * If the gizmo is enabled
  45880. */
  45881. isEnabled: boolean;
  45882. /**
  45883. * Disposes of the gizmo
  45884. */
  45885. dispose(): void;
  45886. }
  45887. }
  45888. declare module BABYLON {
  45889. /**
  45890. * Gizmo that enables rotating a mesh along 3 axis
  45891. */
  45892. export class RotationGizmo extends Gizmo {
  45893. /**
  45894. * Internal gizmo used for interactions on the x axis
  45895. */
  45896. xGizmo: PlaneRotationGizmo;
  45897. /**
  45898. * Internal gizmo used for interactions on the y axis
  45899. */
  45900. yGizmo: PlaneRotationGizmo;
  45901. /**
  45902. * Internal gizmo used for interactions on the z axis
  45903. */
  45904. zGizmo: PlaneRotationGizmo;
  45905. /** Fires an event when any of it's sub gizmos are dragged */
  45906. onDragStartObservable: Observable<unknown>;
  45907. /** Fires an event when any of it's sub gizmos are released from dragging */
  45908. onDragEndObservable: Observable<unknown>;
  45909. private _meshAttached;
  45910. attachedMesh: Nullable<AbstractMesh>;
  45911. /**
  45912. * Creates a RotationGizmo
  45913. * @param gizmoLayer The utility layer the gizmo will be added to
  45914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45915. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45916. */
  45917. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45918. updateGizmoRotationToMatchAttachedMesh: boolean;
  45919. /**
  45920. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45921. */
  45922. snapDistance: number;
  45923. /**
  45924. * Ratio for the scale of the gizmo (Default: 1)
  45925. */
  45926. scaleRatio: number;
  45927. /**
  45928. * Disposes of the gizmo
  45929. */
  45930. dispose(): void;
  45931. /**
  45932. * CustomMeshes are not supported by this gizmo
  45933. * @param mesh The mesh to replace the default mesh of the gizmo
  45934. */
  45935. setCustomMesh(mesh: Mesh): void;
  45936. }
  45937. }
  45938. declare module BABYLON {
  45939. /**
  45940. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45941. */
  45942. export class GizmoManager implements IDisposable {
  45943. private scene;
  45944. /**
  45945. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45946. */
  45947. gizmos: {
  45948. positionGizmo: Nullable<PositionGizmo>;
  45949. rotationGizmo: Nullable<RotationGizmo>;
  45950. scaleGizmo: Nullable<ScaleGizmo>;
  45951. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45952. };
  45953. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45954. clearGizmoOnEmptyPointerEvent: boolean;
  45955. /** Fires an event when the manager is attached to a mesh */
  45956. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45957. private _gizmosEnabled;
  45958. private _pointerObserver;
  45959. private _attachedMesh;
  45960. private _boundingBoxColor;
  45961. private _defaultUtilityLayer;
  45962. private _defaultKeepDepthUtilityLayer;
  45963. /**
  45964. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45965. */
  45966. boundingBoxDragBehavior: SixDofDragBehavior;
  45967. /**
  45968. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45969. */
  45970. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45971. /**
  45972. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45973. */
  45974. usePointerToAttachGizmos: boolean;
  45975. /**
  45976. * Utility layer that the bounding box gizmo belongs to
  45977. */
  45978. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45979. /**
  45980. * Utility layer that all gizmos besides bounding box belong to
  45981. */
  45982. readonly utilityLayer: UtilityLayerRenderer;
  45983. /**
  45984. * Instatiates a gizmo manager
  45985. * @param scene the scene to overlay the gizmos on top of
  45986. */
  45987. constructor(scene: Scene);
  45988. /**
  45989. * Attaches a set of gizmos to the specified mesh
  45990. * @param mesh The mesh the gizmo's should be attached to
  45991. */
  45992. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45993. /**
  45994. * If the position gizmo is enabled
  45995. */
  45996. positionGizmoEnabled: boolean;
  45997. /**
  45998. * If the rotation gizmo is enabled
  45999. */
  46000. rotationGizmoEnabled: boolean;
  46001. /**
  46002. * If the scale gizmo is enabled
  46003. */
  46004. scaleGizmoEnabled: boolean;
  46005. /**
  46006. * If the boundingBox gizmo is enabled
  46007. */
  46008. boundingBoxGizmoEnabled: boolean;
  46009. /**
  46010. * Disposes of the gizmo manager
  46011. */
  46012. dispose(): void;
  46013. }
  46014. }
  46015. declare module BABYLON {
  46016. /**
  46017. * A directional light is defined by a direction (what a surprise!).
  46018. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46019. * 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.
  46020. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46021. */
  46022. export class DirectionalLight extends ShadowLight {
  46023. private _shadowFrustumSize;
  46024. /**
  46025. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46026. */
  46027. /**
  46028. * Specifies a fix frustum size for the shadow generation.
  46029. */
  46030. shadowFrustumSize: number;
  46031. private _shadowOrthoScale;
  46032. /**
  46033. * Gets the shadow projection scale against the optimal computed one.
  46034. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46035. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46036. */
  46037. /**
  46038. * Sets the shadow projection scale against the optimal computed one.
  46039. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46040. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46041. */
  46042. shadowOrthoScale: number;
  46043. /**
  46044. * Automatically compute the projection matrix to best fit (including all the casters)
  46045. * on each frame.
  46046. */
  46047. autoUpdateExtends: boolean;
  46048. private _orthoLeft;
  46049. private _orthoRight;
  46050. private _orthoTop;
  46051. private _orthoBottom;
  46052. /**
  46053. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46054. * The directional light is emitted from everywhere in the given direction.
  46055. * It can cast shadows.
  46056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46057. * @param name The friendly name of the light
  46058. * @param direction The direction of the light
  46059. * @param scene The scene the light belongs to
  46060. */
  46061. constructor(name: string, direction: Vector3, scene: Scene);
  46062. /**
  46063. * Returns the string "DirectionalLight".
  46064. * @return The class name
  46065. */
  46066. getClassName(): string;
  46067. /**
  46068. * Returns the integer 1.
  46069. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46070. */
  46071. getTypeID(): number;
  46072. /**
  46073. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46074. * Returns the DirectionalLight Shadow projection matrix.
  46075. */
  46076. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46077. /**
  46078. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46079. * Returns the DirectionalLight Shadow projection matrix.
  46080. */
  46081. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46082. /**
  46083. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46084. * Returns the DirectionalLight Shadow projection matrix.
  46085. */
  46086. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46087. protected _buildUniformLayout(): void;
  46088. /**
  46089. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46090. * @param effect The effect to update
  46091. * @param lightIndex The index of the light in the effect to update
  46092. * @returns The directional light
  46093. */
  46094. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46095. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46096. /**
  46097. * Gets the minZ used for shadow according to both the scene and the light.
  46098. *
  46099. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46100. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46101. * @param activeCamera The camera we are returning the min for
  46102. * @returns the depth min z
  46103. */
  46104. getDepthMinZ(activeCamera: Camera): number;
  46105. /**
  46106. * Gets the maxZ used for shadow according to both the scene and the light.
  46107. *
  46108. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46109. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46110. * @param activeCamera The camera we are returning the max for
  46111. * @returns the depth max z
  46112. */
  46113. getDepthMaxZ(activeCamera: Camera): number;
  46114. /**
  46115. * Prepares the list of defines specific to the light type.
  46116. * @param defines the list of defines
  46117. * @param lightIndex defines the index of the light for the effect
  46118. */
  46119. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46120. }
  46121. }
  46122. declare module BABYLON {
  46123. /**
  46124. * Class containing static functions to help procedurally build meshes
  46125. */
  46126. export class HemisphereBuilder {
  46127. /**
  46128. * Creates a hemisphere mesh
  46129. * @param name defines the name of the mesh
  46130. * @param options defines the options used to create the mesh
  46131. * @param scene defines the hosting scene
  46132. * @returns the hemisphere mesh
  46133. */
  46134. static CreateHemisphere(name: string, options: {
  46135. segments?: number;
  46136. diameter?: number;
  46137. sideOrientation?: number;
  46138. }, scene: any): Mesh;
  46139. }
  46140. }
  46141. declare module BABYLON {
  46142. /**
  46143. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46144. * These values define a cone of light starting from the position, emitting toward the direction.
  46145. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46146. * and the exponent defines the speed of the decay of the light with distance (reach).
  46147. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46148. */
  46149. export class SpotLight extends ShadowLight {
  46150. private _angle;
  46151. private _innerAngle;
  46152. private _cosHalfAngle;
  46153. private _lightAngleScale;
  46154. private _lightAngleOffset;
  46155. /**
  46156. * Gets the cone angle of the spot light in Radians.
  46157. */
  46158. /**
  46159. * Sets the cone angle of the spot light in Radians.
  46160. */
  46161. angle: number;
  46162. /**
  46163. * Only used in gltf falloff mode, this defines the angle where
  46164. * the directional falloff will start before cutting at angle which could be seen
  46165. * as outer angle.
  46166. */
  46167. /**
  46168. * Only used in gltf falloff mode, this defines the angle where
  46169. * the directional falloff will start before cutting at angle which could be seen
  46170. * as outer angle.
  46171. */
  46172. innerAngle: number;
  46173. private _shadowAngleScale;
  46174. /**
  46175. * Allows scaling the angle of the light for shadow generation only.
  46176. */
  46177. /**
  46178. * Allows scaling the angle of the light for shadow generation only.
  46179. */
  46180. shadowAngleScale: number;
  46181. /**
  46182. * The light decay speed with the distance from the emission spot.
  46183. */
  46184. exponent: number;
  46185. private _projectionTextureMatrix;
  46186. /**
  46187. * Allows reading the projecton texture
  46188. */
  46189. readonly projectionTextureMatrix: Matrix;
  46190. protected _projectionTextureLightNear: number;
  46191. /**
  46192. * Gets the near clip of the Spotlight for texture projection.
  46193. */
  46194. /**
  46195. * Sets the near clip of the Spotlight for texture projection.
  46196. */
  46197. projectionTextureLightNear: number;
  46198. protected _projectionTextureLightFar: number;
  46199. /**
  46200. * Gets the far clip of the Spotlight for texture projection.
  46201. */
  46202. /**
  46203. * Sets the far clip of the Spotlight for texture projection.
  46204. */
  46205. projectionTextureLightFar: number;
  46206. protected _projectionTextureUpDirection: Vector3;
  46207. /**
  46208. * Gets the Up vector of the Spotlight for texture projection.
  46209. */
  46210. /**
  46211. * Sets the Up vector of the Spotlight for texture projection.
  46212. */
  46213. projectionTextureUpDirection: Vector3;
  46214. private _projectionTexture;
  46215. /**
  46216. * Gets the projection texture of the light.
  46217. */
  46218. /**
  46219. * Sets the projection texture of the light.
  46220. */
  46221. projectionTexture: Nullable<BaseTexture>;
  46222. private _projectionTextureViewLightDirty;
  46223. private _projectionTextureProjectionLightDirty;
  46224. private _projectionTextureDirty;
  46225. private _projectionTextureViewTargetVector;
  46226. private _projectionTextureViewLightMatrix;
  46227. private _projectionTextureProjectionLightMatrix;
  46228. private _projectionTextureScalingMatrix;
  46229. /**
  46230. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46231. * It can cast shadows.
  46232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46233. * @param name The light friendly name
  46234. * @param position The position of the spot light in the scene
  46235. * @param direction The direction of the light in the scene
  46236. * @param angle The cone angle of the light in Radians
  46237. * @param exponent The light decay speed with the distance from the emission spot
  46238. * @param scene The scene the lights belongs to
  46239. */
  46240. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46241. /**
  46242. * Returns the string "SpotLight".
  46243. * @returns the class name
  46244. */
  46245. getClassName(): string;
  46246. /**
  46247. * Returns the integer 2.
  46248. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46249. */
  46250. getTypeID(): number;
  46251. /**
  46252. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46253. */
  46254. protected _setDirection(value: Vector3): void;
  46255. /**
  46256. * Overrides the position setter to recompute the projection texture view light Matrix.
  46257. */
  46258. protected _setPosition(value: Vector3): void;
  46259. /**
  46260. * 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.
  46261. * Returns the SpotLight.
  46262. */
  46263. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46264. protected _computeProjectionTextureViewLightMatrix(): void;
  46265. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46266. /**
  46267. * Main function for light texture projection matrix computing.
  46268. */
  46269. protected _computeProjectionTextureMatrix(): void;
  46270. protected _buildUniformLayout(): void;
  46271. private _computeAngleValues;
  46272. /**
  46273. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46274. * @param effect The effect to update
  46275. * @param lightIndex The index of the light in the effect to update
  46276. * @returns The spot light
  46277. */
  46278. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46279. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46280. /**
  46281. * Disposes the light and the associated resources.
  46282. */
  46283. dispose(): void;
  46284. /**
  46285. * Prepares the list of defines specific to the light type.
  46286. * @param defines the list of defines
  46287. * @param lightIndex defines the index of the light for the effect
  46288. */
  46289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46290. }
  46291. }
  46292. declare module BABYLON {
  46293. /**
  46294. * Gizmo that enables viewing a light
  46295. */
  46296. export class LightGizmo extends Gizmo {
  46297. private _lightMesh;
  46298. private _material;
  46299. private cachedPosition;
  46300. private cachedForward;
  46301. /**
  46302. * Creates a LightGizmo
  46303. * @param gizmoLayer The utility layer the gizmo will be added to
  46304. */
  46305. constructor(gizmoLayer?: UtilityLayerRenderer);
  46306. private _light;
  46307. /**
  46308. * The light that the gizmo is attached to
  46309. */
  46310. light: Nullable<Light>;
  46311. /**
  46312. * Gets the material used to render the light gizmo
  46313. */
  46314. readonly material: StandardMaterial;
  46315. /**
  46316. * @hidden
  46317. * Updates the gizmo to match the attached mesh's position/rotation
  46318. */
  46319. protected _update(): void;
  46320. private static _Scale;
  46321. /**
  46322. * Creates the lines for a light mesh
  46323. */
  46324. private static _createLightLines;
  46325. /**
  46326. * Disposes of the light gizmo
  46327. */
  46328. dispose(): void;
  46329. private static _CreateHemisphericLightMesh;
  46330. private static _CreatePointLightMesh;
  46331. private static _CreateSpotLightMesh;
  46332. private static _CreateDirectionalLightMesh;
  46333. }
  46334. }
  46335. declare module BABYLON {
  46336. /** @hidden */
  46337. export var backgroundFragmentDeclaration: {
  46338. name: string;
  46339. shader: string;
  46340. };
  46341. }
  46342. declare module BABYLON {
  46343. /** @hidden */
  46344. export var backgroundUboDeclaration: {
  46345. name: string;
  46346. shader: string;
  46347. };
  46348. }
  46349. declare module BABYLON {
  46350. /** @hidden */
  46351. export var backgroundPixelShader: {
  46352. name: string;
  46353. shader: string;
  46354. };
  46355. }
  46356. declare module BABYLON {
  46357. /** @hidden */
  46358. export var backgroundVertexDeclaration: {
  46359. name: string;
  46360. shader: string;
  46361. };
  46362. }
  46363. declare module BABYLON {
  46364. /** @hidden */
  46365. export var backgroundVertexShader: {
  46366. name: string;
  46367. shader: string;
  46368. };
  46369. }
  46370. declare module BABYLON {
  46371. /**
  46372. * Background material used to create an efficient environement around your scene.
  46373. */
  46374. export class BackgroundMaterial extends PushMaterial {
  46375. /**
  46376. * Standard reflectance value at parallel view angle.
  46377. */
  46378. static StandardReflectance0: number;
  46379. /**
  46380. * Standard reflectance value at grazing angle.
  46381. */
  46382. static StandardReflectance90: number;
  46383. protected _primaryColor: Color3;
  46384. /**
  46385. * Key light Color (multiply against the environement texture)
  46386. */
  46387. primaryColor: Color3;
  46388. protected __perceptualColor: Nullable<Color3>;
  46389. /**
  46390. * Experimental Internal Use Only.
  46391. *
  46392. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46393. * This acts as a helper to set the primary color to a more "human friendly" value.
  46394. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46395. * output color as close as possible from the chosen value.
  46396. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46397. * part of lighting setup.)
  46398. */
  46399. _perceptualColor: Nullable<Color3>;
  46400. protected _primaryColorShadowLevel: float;
  46401. /**
  46402. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46403. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46404. */
  46405. primaryColorShadowLevel: float;
  46406. protected _primaryColorHighlightLevel: float;
  46407. /**
  46408. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46409. * The primary color is used at the level chosen to define what the white area would look.
  46410. */
  46411. primaryColorHighlightLevel: float;
  46412. protected _reflectionTexture: Nullable<BaseTexture>;
  46413. /**
  46414. * Reflection Texture used in the material.
  46415. * Should be author in a specific way for the best result (refer to the documentation).
  46416. */
  46417. reflectionTexture: Nullable<BaseTexture>;
  46418. protected _reflectionBlur: float;
  46419. /**
  46420. * Reflection Texture level of blur.
  46421. *
  46422. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46423. * texture twice.
  46424. */
  46425. reflectionBlur: float;
  46426. protected _diffuseTexture: Nullable<BaseTexture>;
  46427. /**
  46428. * Diffuse Texture used in the material.
  46429. * Should be author in a specific way for the best result (refer to the documentation).
  46430. */
  46431. diffuseTexture: Nullable<BaseTexture>;
  46432. protected _shadowLights: Nullable<IShadowLight[]>;
  46433. /**
  46434. * Specify the list of lights casting shadow on the material.
  46435. * All scene shadow lights will be included if null.
  46436. */
  46437. shadowLights: Nullable<IShadowLight[]>;
  46438. protected _shadowLevel: float;
  46439. /**
  46440. * Helps adjusting the shadow to a softer level if required.
  46441. * 0 means black shadows and 1 means no shadows.
  46442. */
  46443. shadowLevel: float;
  46444. protected _sceneCenter: Vector3;
  46445. /**
  46446. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46447. * It is usually zero but might be interesting to modify according to your setup.
  46448. */
  46449. sceneCenter: Vector3;
  46450. protected _opacityFresnel: boolean;
  46451. /**
  46452. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46453. * This helps ensuring a nice transition when the camera goes under the ground.
  46454. */
  46455. opacityFresnel: boolean;
  46456. protected _reflectionFresnel: boolean;
  46457. /**
  46458. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46459. * This helps adding a mirror texture on the ground.
  46460. */
  46461. reflectionFresnel: boolean;
  46462. protected _reflectionFalloffDistance: number;
  46463. /**
  46464. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46465. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46466. */
  46467. reflectionFalloffDistance: number;
  46468. protected _reflectionAmount: number;
  46469. /**
  46470. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46471. */
  46472. reflectionAmount: number;
  46473. protected _reflectionReflectance0: number;
  46474. /**
  46475. * This specifies the weight of the reflection at grazing angle.
  46476. */
  46477. reflectionReflectance0: number;
  46478. protected _reflectionReflectance90: number;
  46479. /**
  46480. * This specifies the weight of the reflection at a perpendicular point of view.
  46481. */
  46482. reflectionReflectance90: number;
  46483. /**
  46484. * Sets the reflection reflectance fresnel values according to the default standard
  46485. * empirically know to work well :-)
  46486. */
  46487. reflectionStandardFresnelWeight: number;
  46488. protected _useRGBColor: boolean;
  46489. /**
  46490. * Helps to directly use the maps channels instead of their level.
  46491. */
  46492. useRGBColor: boolean;
  46493. protected _enableNoise: boolean;
  46494. /**
  46495. * This helps reducing the banding effect that could occur on the background.
  46496. */
  46497. enableNoise: boolean;
  46498. /**
  46499. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46500. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46501. * Recommended to be keep at 1.0 except for special cases.
  46502. */
  46503. fovMultiplier: number;
  46504. private _fovMultiplier;
  46505. /**
  46506. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46507. */
  46508. useEquirectangularFOV: boolean;
  46509. private _maxSimultaneousLights;
  46510. /**
  46511. * Number of Simultaneous lights allowed on the material.
  46512. */
  46513. maxSimultaneousLights: int;
  46514. /**
  46515. * Default configuration related to image processing available in the Background Material.
  46516. */
  46517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46518. /**
  46519. * Keep track of the image processing observer to allow dispose and replace.
  46520. */
  46521. private _imageProcessingObserver;
  46522. /**
  46523. * Attaches a new image processing configuration to the PBR Material.
  46524. * @param configuration (if null the scene configuration will be use)
  46525. */
  46526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46527. /**
  46528. * Gets the image processing configuration used either in this material.
  46529. */
  46530. /**
  46531. * Sets the Default image processing configuration used either in the this material.
  46532. *
  46533. * If sets to null, the scene one is in use.
  46534. */
  46535. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46536. /**
  46537. * Gets wether the color curves effect is enabled.
  46538. */
  46539. /**
  46540. * Sets wether the color curves effect is enabled.
  46541. */
  46542. cameraColorCurvesEnabled: boolean;
  46543. /**
  46544. * Gets wether the color grading effect is enabled.
  46545. */
  46546. /**
  46547. * Gets wether the color grading effect is enabled.
  46548. */
  46549. cameraColorGradingEnabled: boolean;
  46550. /**
  46551. * Gets wether tonemapping is enabled or not.
  46552. */
  46553. /**
  46554. * Sets wether tonemapping is enabled or not
  46555. */
  46556. cameraToneMappingEnabled: boolean;
  46557. /**
  46558. * The camera exposure used on this material.
  46559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46560. * This corresponds to a photographic exposure.
  46561. */
  46562. /**
  46563. * The camera exposure used on this material.
  46564. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46565. * This corresponds to a photographic exposure.
  46566. */
  46567. cameraExposure: float;
  46568. /**
  46569. * Gets The camera contrast used on this material.
  46570. */
  46571. /**
  46572. * Sets The camera contrast used on this material.
  46573. */
  46574. cameraContrast: float;
  46575. /**
  46576. * Gets the Color Grading 2D Lookup Texture.
  46577. */
  46578. /**
  46579. * Sets the Color Grading 2D Lookup Texture.
  46580. */
  46581. cameraColorGradingTexture: Nullable<BaseTexture>;
  46582. /**
  46583. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46584. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46585. * 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;
  46586. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46587. */
  46588. /**
  46589. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46590. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46591. * 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;
  46592. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46593. */
  46594. cameraColorCurves: Nullable<ColorCurves>;
  46595. /**
  46596. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46597. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46598. */
  46599. switchToBGR: boolean;
  46600. private _renderTargets;
  46601. private _reflectionControls;
  46602. private _white;
  46603. private _primaryShadowColor;
  46604. private _primaryHighlightColor;
  46605. /**
  46606. * Instantiates a Background Material in the given scene
  46607. * @param name The friendly name of the material
  46608. * @param scene The scene to add the material to
  46609. */
  46610. constructor(name: string, scene: Scene);
  46611. /**
  46612. * Gets a boolean indicating that current material needs to register RTT
  46613. */
  46614. readonly hasRenderTargetTextures: boolean;
  46615. /**
  46616. * The entire material has been created in order to prevent overdraw.
  46617. * @returns false
  46618. */
  46619. needAlphaTesting(): boolean;
  46620. /**
  46621. * The entire material has been created in order to prevent overdraw.
  46622. * @returns true if blending is enable
  46623. */
  46624. needAlphaBlending(): boolean;
  46625. /**
  46626. * Checks wether the material is ready to be rendered for a given mesh.
  46627. * @param mesh The mesh to render
  46628. * @param subMesh The submesh to check against
  46629. * @param useInstances Specify wether or not the material is used with instances
  46630. * @returns true if all the dependencies are ready (Textures, Effects...)
  46631. */
  46632. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46633. /**
  46634. * Compute the primary color according to the chosen perceptual color.
  46635. */
  46636. private _computePrimaryColorFromPerceptualColor;
  46637. /**
  46638. * Compute the highlights and shadow colors according to their chosen levels.
  46639. */
  46640. private _computePrimaryColors;
  46641. /**
  46642. * Build the uniform buffer used in the material.
  46643. */
  46644. buildUniformLayout(): void;
  46645. /**
  46646. * Unbind the material.
  46647. */
  46648. unbind(): void;
  46649. /**
  46650. * Bind only the world matrix to the material.
  46651. * @param world The world matrix to bind.
  46652. */
  46653. bindOnlyWorldMatrix(world: Matrix): void;
  46654. /**
  46655. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46656. * @param world The world matrix to bind.
  46657. * @param subMesh The submesh to bind for.
  46658. */
  46659. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46660. /**
  46661. * Checks to see if a texture is used in the material.
  46662. * @param texture - Base texture to use.
  46663. * @returns - Boolean specifying if a texture is used in the material.
  46664. */
  46665. hasTexture(texture: BaseTexture): boolean;
  46666. /**
  46667. * Dispose the material.
  46668. * @param forceDisposeEffect Force disposal of the associated effect.
  46669. * @param forceDisposeTextures Force disposal of the associated textures.
  46670. */
  46671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46672. /**
  46673. * Clones the material.
  46674. * @param name The cloned name.
  46675. * @returns The cloned material.
  46676. */
  46677. clone(name: string): BackgroundMaterial;
  46678. /**
  46679. * Serializes the current material to its JSON representation.
  46680. * @returns The JSON representation.
  46681. */
  46682. serialize(): any;
  46683. /**
  46684. * Gets the class name of the material
  46685. * @returns "BackgroundMaterial"
  46686. */
  46687. getClassName(): string;
  46688. /**
  46689. * Parse a JSON input to create back a background material.
  46690. * @param source The JSON data to parse
  46691. * @param scene The scene to create the parsed material in
  46692. * @param rootUrl The root url of the assets the material depends upon
  46693. * @returns the instantiated BackgroundMaterial.
  46694. */
  46695. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46696. }
  46697. }
  46698. declare module BABYLON {
  46699. /**
  46700. * Represents the different options available during the creation of
  46701. * a Environment helper.
  46702. *
  46703. * This can control the default ground, skybox and image processing setup of your scene.
  46704. */
  46705. export interface IEnvironmentHelperOptions {
  46706. /**
  46707. * Specifies wether or not to create a ground.
  46708. * True by default.
  46709. */
  46710. createGround: boolean;
  46711. /**
  46712. * Specifies the ground size.
  46713. * 15 by default.
  46714. */
  46715. groundSize: number;
  46716. /**
  46717. * The texture used on the ground for the main color.
  46718. * Comes from the BabylonJS CDN by default.
  46719. *
  46720. * Remarks: Can be either a texture or a url.
  46721. */
  46722. groundTexture: string | BaseTexture;
  46723. /**
  46724. * The color mixed in the ground texture by default.
  46725. * BabylonJS clearColor by default.
  46726. */
  46727. groundColor: Color3;
  46728. /**
  46729. * Specifies the ground opacity.
  46730. * 1 by default.
  46731. */
  46732. groundOpacity: number;
  46733. /**
  46734. * Enables the ground to receive shadows.
  46735. * True by default.
  46736. */
  46737. enableGroundShadow: boolean;
  46738. /**
  46739. * Helps preventing the shadow to be fully black on the ground.
  46740. * 0.5 by default.
  46741. */
  46742. groundShadowLevel: number;
  46743. /**
  46744. * Creates a mirror texture attach to the ground.
  46745. * false by default.
  46746. */
  46747. enableGroundMirror: boolean;
  46748. /**
  46749. * Specifies the ground mirror size ratio.
  46750. * 0.3 by default as the default kernel is 64.
  46751. */
  46752. groundMirrorSizeRatio: number;
  46753. /**
  46754. * Specifies the ground mirror blur kernel size.
  46755. * 64 by default.
  46756. */
  46757. groundMirrorBlurKernel: number;
  46758. /**
  46759. * Specifies the ground mirror visibility amount.
  46760. * 1 by default
  46761. */
  46762. groundMirrorAmount: number;
  46763. /**
  46764. * Specifies the ground mirror reflectance weight.
  46765. * This uses the standard weight of the background material to setup the fresnel effect
  46766. * of the mirror.
  46767. * 1 by default.
  46768. */
  46769. groundMirrorFresnelWeight: number;
  46770. /**
  46771. * Specifies the ground mirror Falloff distance.
  46772. * This can helps reducing the size of the reflection.
  46773. * 0 by Default.
  46774. */
  46775. groundMirrorFallOffDistance: number;
  46776. /**
  46777. * Specifies the ground mirror texture type.
  46778. * Unsigned Int by Default.
  46779. */
  46780. groundMirrorTextureType: number;
  46781. /**
  46782. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46783. * the shown objects.
  46784. */
  46785. groundYBias: number;
  46786. /**
  46787. * Specifies wether or not to create a skybox.
  46788. * True by default.
  46789. */
  46790. createSkybox: boolean;
  46791. /**
  46792. * Specifies the skybox size.
  46793. * 20 by default.
  46794. */
  46795. skyboxSize: number;
  46796. /**
  46797. * The texture used on the skybox for the main color.
  46798. * Comes from the BabylonJS CDN by default.
  46799. *
  46800. * Remarks: Can be either a texture or a url.
  46801. */
  46802. skyboxTexture: string | BaseTexture;
  46803. /**
  46804. * The color mixed in the skybox texture by default.
  46805. * BabylonJS clearColor by default.
  46806. */
  46807. skyboxColor: Color3;
  46808. /**
  46809. * The background rotation around the Y axis of the scene.
  46810. * This helps aligning the key lights of your scene with the background.
  46811. * 0 by default.
  46812. */
  46813. backgroundYRotation: number;
  46814. /**
  46815. * Compute automatically the size of the elements to best fit with the scene.
  46816. */
  46817. sizeAuto: boolean;
  46818. /**
  46819. * Default position of the rootMesh if autoSize is not true.
  46820. */
  46821. rootPosition: Vector3;
  46822. /**
  46823. * Sets up the image processing in the scene.
  46824. * true by default.
  46825. */
  46826. setupImageProcessing: boolean;
  46827. /**
  46828. * The texture used as your environment texture in the scene.
  46829. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46830. *
  46831. * Remarks: Can be either a texture or a url.
  46832. */
  46833. environmentTexture: string | BaseTexture;
  46834. /**
  46835. * The value of the exposure to apply to the scene.
  46836. * 0.6 by default if setupImageProcessing is true.
  46837. */
  46838. cameraExposure: number;
  46839. /**
  46840. * The value of the contrast to apply to the scene.
  46841. * 1.6 by default if setupImageProcessing is true.
  46842. */
  46843. cameraContrast: number;
  46844. /**
  46845. * Specifies wether or not tonemapping should be enabled in the scene.
  46846. * true by default if setupImageProcessing is true.
  46847. */
  46848. toneMappingEnabled: boolean;
  46849. }
  46850. /**
  46851. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46852. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46853. * It also helps with the default setup of your imageProcessing configuration.
  46854. */
  46855. export class EnvironmentHelper {
  46856. /**
  46857. * Default ground texture URL.
  46858. */
  46859. private static _groundTextureCDNUrl;
  46860. /**
  46861. * Default skybox texture URL.
  46862. */
  46863. private static _skyboxTextureCDNUrl;
  46864. /**
  46865. * Default environment texture URL.
  46866. */
  46867. private static _environmentTextureCDNUrl;
  46868. /**
  46869. * Creates the default options for the helper.
  46870. */
  46871. private static _getDefaultOptions;
  46872. private _rootMesh;
  46873. /**
  46874. * Gets the root mesh created by the helper.
  46875. */
  46876. readonly rootMesh: Mesh;
  46877. private _skybox;
  46878. /**
  46879. * Gets the skybox created by the helper.
  46880. */
  46881. readonly skybox: Nullable<Mesh>;
  46882. private _skyboxTexture;
  46883. /**
  46884. * Gets the skybox texture created by the helper.
  46885. */
  46886. readonly skyboxTexture: Nullable<BaseTexture>;
  46887. private _skyboxMaterial;
  46888. /**
  46889. * Gets the skybox material created by the helper.
  46890. */
  46891. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46892. private _ground;
  46893. /**
  46894. * Gets the ground mesh created by the helper.
  46895. */
  46896. readonly ground: Nullable<Mesh>;
  46897. private _groundTexture;
  46898. /**
  46899. * Gets the ground texture created by the helper.
  46900. */
  46901. readonly groundTexture: Nullable<BaseTexture>;
  46902. private _groundMirror;
  46903. /**
  46904. * Gets the ground mirror created by the helper.
  46905. */
  46906. readonly groundMirror: Nullable<MirrorTexture>;
  46907. /**
  46908. * Gets the ground mirror render list to helps pushing the meshes
  46909. * you wish in the ground reflection.
  46910. */
  46911. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46912. private _groundMaterial;
  46913. /**
  46914. * Gets the ground material created by the helper.
  46915. */
  46916. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46917. /**
  46918. * Stores the creation options.
  46919. */
  46920. private readonly _scene;
  46921. private _options;
  46922. /**
  46923. * This observable will be notified with any error during the creation of the environment,
  46924. * mainly texture creation errors.
  46925. */
  46926. onErrorObservable: Observable<{
  46927. message?: string;
  46928. exception?: any;
  46929. }>;
  46930. /**
  46931. * constructor
  46932. * @param options Defines the options we want to customize the helper
  46933. * @param scene The scene to add the material to
  46934. */
  46935. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46936. /**
  46937. * Updates the background according to the new options
  46938. * @param options
  46939. */
  46940. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46941. /**
  46942. * Sets the primary color of all the available elements.
  46943. * @param color the main color to affect to the ground and the background
  46944. */
  46945. setMainColor(color: Color3): void;
  46946. /**
  46947. * Setup the image processing according to the specified options.
  46948. */
  46949. private _setupImageProcessing;
  46950. /**
  46951. * Setup the environment texture according to the specified options.
  46952. */
  46953. private _setupEnvironmentTexture;
  46954. /**
  46955. * Setup the background according to the specified options.
  46956. */
  46957. private _setupBackground;
  46958. /**
  46959. * Get the scene sizes according to the setup.
  46960. */
  46961. private _getSceneSize;
  46962. /**
  46963. * Setup the ground according to the specified options.
  46964. */
  46965. private _setupGround;
  46966. /**
  46967. * Setup the ground material according to the specified options.
  46968. */
  46969. private _setupGroundMaterial;
  46970. /**
  46971. * Setup the ground diffuse texture according to the specified options.
  46972. */
  46973. private _setupGroundDiffuseTexture;
  46974. /**
  46975. * Setup the ground mirror texture according to the specified options.
  46976. */
  46977. private _setupGroundMirrorTexture;
  46978. /**
  46979. * Setup the ground to receive the mirror texture.
  46980. */
  46981. private _setupMirrorInGroundMaterial;
  46982. /**
  46983. * Setup the skybox according to the specified options.
  46984. */
  46985. private _setupSkybox;
  46986. /**
  46987. * Setup the skybox material according to the specified options.
  46988. */
  46989. private _setupSkyboxMaterial;
  46990. /**
  46991. * Setup the skybox reflection texture according to the specified options.
  46992. */
  46993. private _setupSkyboxReflectionTexture;
  46994. private _errorHandler;
  46995. /**
  46996. * Dispose all the elements created by the Helper.
  46997. */
  46998. dispose(): void;
  46999. }
  47000. }
  47001. declare module BABYLON {
  47002. /**
  47003. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47004. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47005. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47006. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47007. */
  47008. export class PhotoDome extends TransformNode {
  47009. /**
  47010. * Define the image as a Monoscopic panoramic 360 image.
  47011. */
  47012. static readonly MODE_MONOSCOPIC: number;
  47013. /**
  47014. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47015. */
  47016. static readonly MODE_TOPBOTTOM: number;
  47017. /**
  47018. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47019. */
  47020. static readonly MODE_SIDEBYSIDE: number;
  47021. private _useDirectMapping;
  47022. /**
  47023. * The texture being displayed on the sphere
  47024. */
  47025. protected _photoTexture: Texture;
  47026. /**
  47027. * Gets or sets the texture being displayed on the sphere
  47028. */
  47029. photoTexture: Texture;
  47030. /**
  47031. * Observable raised when an error occured while loading the 360 image
  47032. */
  47033. onLoadErrorObservable: Observable<string>;
  47034. /**
  47035. * The skybox material
  47036. */
  47037. protected _material: BackgroundMaterial;
  47038. /**
  47039. * The surface used for the skybox
  47040. */
  47041. protected _mesh: Mesh;
  47042. /**
  47043. * Gets the mesh used for the skybox.
  47044. */
  47045. readonly mesh: Mesh;
  47046. /**
  47047. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47048. * Also see the options.resolution property.
  47049. */
  47050. fovMultiplier: number;
  47051. private _imageMode;
  47052. /**
  47053. * Gets or set the current video mode for the video. It can be:
  47054. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47055. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47056. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47057. */
  47058. imageMode: number;
  47059. /**
  47060. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47061. * @param name Element's name, child elements will append suffixes for their own names.
  47062. * @param urlsOfPhoto defines the url of the photo to display
  47063. * @param options defines an object containing optional or exposed sub element properties
  47064. * @param onError defines a callback called when an error occured while loading the texture
  47065. */
  47066. constructor(name: string, urlOfPhoto: string, options: {
  47067. resolution?: number;
  47068. size?: number;
  47069. useDirectMapping?: boolean;
  47070. faceForward?: boolean;
  47071. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47072. private _onBeforeCameraRenderObserver;
  47073. private _changeImageMode;
  47074. /**
  47075. * Releases resources associated with this node.
  47076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47078. */
  47079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47080. }
  47081. }
  47082. declare module BABYLON {
  47083. /**
  47084. * Class used to host RGBD texture specific utilities
  47085. */
  47086. export class RGBDTextureTools {
  47087. /**
  47088. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47089. * @param texture the texture to expand.
  47090. */
  47091. static ExpandRGBDTexture(texture: Texture): void;
  47092. }
  47093. }
  47094. declare module BABYLON {
  47095. /**
  47096. * Class used to host texture specific utilities
  47097. */
  47098. export class BRDFTextureTools {
  47099. /**
  47100. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47101. * @param scene defines the hosting scene
  47102. * @returns the environment BRDF texture
  47103. */
  47104. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47105. private static _environmentBRDFBase64Texture;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. /**
  47110. * @hidden
  47111. */
  47112. export interface IMaterialClearCoatDefines {
  47113. CLEARCOAT: boolean;
  47114. CLEARCOAT_DEFAULTIOR: boolean;
  47115. CLEARCOAT_TEXTURE: boolean;
  47116. CLEARCOAT_TEXTUREDIRECTUV: number;
  47117. CLEARCOAT_BUMP: boolean;
  47118. CLEARCOAT_BUMPDIRECTUV: number;
  47119. CLEARCOAT_TINT: boolean;
  47120. CLEARCOAT_TINT_TEXTURE: boolean;
  47121. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47122. /** @hidden */
  47123. _areTexturesDirty: boolean;
  47124. }
  47125. /**
  47126. * Define the code related to the clear coat parameters of the pbr material.
  47127. */
  47128. export class PBRClearCoatConfiguration {
  47129. /**
  47130. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47131. * The default fits with a polyurethane material.
  47132. */
  47133. private static readonly _DefaultIndexOfRefraction;
  47134. private _isEnabled;
  47135. /**
  47136. * Defines if the clear coat is enabled in the material.
  47137. */
  47138. isEnabled: boolean;
  47139. /**
  47140. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47141. */
  47142. intensity: number;
  47143. /**
  47144. * Defines the clear coat layer roughness.
  47145. */
  47146. roughness: number;
  47147. private _indexOfRefraction;
  47148. /**
  47149. * Defines the index of refraction of the clear coat.
  47150. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47151. * The default fits with a polyurethane material.
  47152. * Changing the default value is more performance intensive.
  47153. */
  47154. indexOfRefraction: number;
  47155. private _texture;
  47156. /**
  47157. * Stores the clear coat values in a texture.
  47158. */
  47159. texture: Nullable<BaseTexture>;
  47160. private _bumpTexture;
  47161. /**
  47162. * Define the clear coat specific bump texture.
  47163. */
  47164. bumpTexture: Nullable<BaseTexture>;
  47165. private _isTintEnabled;
  47166. /**
  47167. * Defines if the clear coat tint is enabled in the material.
  47168. */
  47169. isTintEnabled: boolean;
  47170. /**
  47171. * Defines the clear coat tint of the material.
  47172. * This is only use if tint is enabled
  47173. */
  47174. tintColor: Color3;
  47175. /**
  47176. * Defines the distance at which the tint color should be found in the
  47177. * clear coat media.
  47178. * This is only use if tint is enabled
  47179. */
  47180. tintColorAtDistance: number;
  47181. /**
  47182. * Defines the clear coat layer thickness.
  47183. * This is only use if tint is enabled
  47184. */
  47185. tintThickness: number;
  47186. private _tintTexture;
  47187. /**
  47188. * Stores the clear tint values in a texture.
  47189. * rgb is tint
  47190. * a is a thickness factor
  47191. */
  47192. tintTexture: Nullable<BaseTexture>;
  47193. /** @hidden */
  47194. private _internalMarkAllSubMeshesAsTexturesDirty;
  47195. /** @hidden */
  47196. _markAllSubMeshesAsTexturesDirty(): void;
  47197. /**
  47198. * Instantiate a new istance of clear coat configuration.
  47199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47200. */
  47201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47202. /**
  47203. * Gets wehter the submesh is ready to be used or not.
  47204. * @param defines the list of "defines" to update.
  47205. * @param scene defines the scene the material belongs to.
  47206. * @param engine defines the engine the material belongs to.
  47207. * @param disableBumpMap defines wether the material disables bump or not.
  47208. * @returns - boolean indicating that the submesh is ready or not.
  47209. */
  47210. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47211. /**
  47212. * Checks to see if a texture is used in the material.
  47213. * @param defines the list of "defines" to update.
  47214. * @param scene defines the scene to the material belongs to.
  47215. */
  47216. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47217. /**
  47218. * Binds the material data.
  47219. * @param uniformBuffer defines the Uniform buffer to fill in.
  47220. * @param scene defines the scene the material belongs to.
  47221. * @param engine defines the engine the material belongs to.
  47222. * @param disableBumpMap defines wether the material disables bump or not.
  47223. * @param isFrozen defines wether the material is frozen or not.
  47224. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47225. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47226. */
  47227. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47228. /**
  47229. * Checks to see if a texture is used in the material.
  47230. * @param texture - Base texture to use.
  47231. * @returns - Boolean specifying if a texture is used in the material.
  47232. */
  47233. hasTexture(texture: BaseTexture): boolean;
  47234. /**
  47235. * Returns an array of the actively used textures.
  47236. * @param activeTextures Array of BaseTextures
  47237. */
  47238. getActiveTextures(activeTextures: BaseTexture[]): void;
  47239. /**
  47240. * Returns the animatable textures.
  47241. * @param animatables Array of animatable textures.
  47242. */
  47243. getAnimatables(animatables: IAnimatable[]): void;
  47244. /**
  47245. * Disposes the resources of the material.
  47246. * @param forceDisposeTextures - Forces the disposal of all textures.
  47247. */
  47248. dispose(forceDisposeTextures?: boolean): void;
  47249. /**
  47250. * Get the current class name of the texture useful for serialization or dynamic coding.
  47251. * @returns "PBRClearCoatConfiguration"
  47252. */
  47253. getClassName(): string;
  47254. /**
  47255. * Add fallbacks to the effect fallbacks list.
  47256. * @param defines defines the Base texture to use.
  47257. * @param fallbacks defines the current fallback list.
  47258. * @param currentRank defines the current fallback rank.
  47259. * @returns the new fallback rank.
  47260. */
  47261. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47262. /**
  47263. * Add the required uniforms to the current list.
  47264. * @param uniforms defines the current uniform list.
  47265. */
  47266. static AddUniforms(uniforms: string[]): void;
  47267. /**
  47268. * Add the required samplers to the current list.
  47269. * @param samplers defines the current sampler list.
  47270. */
  47271. static AddSamplers(samplers: string[]): void;
  47272. /**
  47273. * Add the required uniforms to the current buffer.
  47274. * @param uniformBuffer defines the current uniform buffer.
  47275. */
  47276. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47277. /**
  47278. * Makes a duplicate of the current configuration into another one.
  47279. * @param clearCoatConfiguration define the config where to copy the info
  47280. */
  47281. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47282. /**
  47283. * Serializes this clear coat configuration.
  47284. * @returns - An object with the serialized config.
  47285. */
  47286. serialize(): any;
  47287. /**
  47288. * Parses a anisotropy Configuration from a serialized object.
  47289. * @param source - Serialized object.
  47290. * @param scene Defines the scene we are parsing for
  47291. * @param rootUrl Defines the rootUrl to load from
  47292. */
  47293. parse(source: any, scene: Scene, rootUrl: string): void;
  47294. }
  47295. }
  47296. declare module BABYLON {
  47297. /**
  47298. * @hidden
  47299. */
  47300. export interface IMaterialAnisotropicDefines {
  47301. ANISOTROPIC: boolean;
  47302. ANISOTROPIC_TEXTURE: boolean;
  47303. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47304. MAINUV1: boolean;
  47305. _areTexturesDirty: boolean;
  47306. _needUVs: boolean;
  47307. }
  47308. /**
  47309. * Define the code related to the anisotropic parameters of the pbr material.
  47310. */
  47311. export class PBRAnisotropicConfiguration {
  47312. private _isEnabled;
  47313. /**
  47314. * Defines if the anisotropy is enabled in the material.
  47315. */
  47316. isEnabled: boolean;
  47317. /**
  47318. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47319. */
  47320. intensity: number;
  47321. /**
  47322. * Defines if the effect is along the tangents, bitangents or in between.
  47323. * By default, the effect is "strectching" the highlights along the tangents.
  47324. */
  47325. direction: Vector2;
  47326. private _texture;
  47327. /**
  47328. * Stores the anisotropy values in a texture.
  47329. * rg is direction (like normal from -1 to 1)
  47330. * b is a intensity
  47331. */
  47332. texture: Nullable<BaseTexture>;
  47333. /** @hidden */
  47334. private _internalMarkAllSubMeshesAsTexturesDirty;
  47335. /** @hidden */
  47336. _markAllSubMeshesAsTexturesDirty(): void;
  47337. /**
  47338. * Instantiate a new istance of anisotropy configuration.
  47339. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47340. */
  47341. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47342. /**
  47343. * Specifies that the submesh is ready to be used.
  47344. * @param defines the list of "defines" to update.
  47345. * @param scene defines the scene the material belongs to.
  47346. * @returns - boolean indicating that the submesh is ready or not.
  47347. */
  47348. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47349. /**
  47350. * Checks to see if a texture is used in the material.
  47351. * @param defines the list of "defines" to update.
  47352. * @param mesh the mesh we are preparing the defines for.
  47353. * @param scene defines the scene the material belongs to.
  47354. */
  47355. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47356. /**
  47357. * Binds the material data.
  47358. * @param uniformBuffer defines the Uniform buffer to fill in.
  47359. * @param scene defines the scene the material belongs to.
  47360. * @param isFrozen defines wether the material is frozen or not.
  47361. */
  47362. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47363. /**
  47364. * Checks to see if a texture is used in the material.
  47365. * @param texture - Base texture to use.
  47366. * @returns - Boolean specifying if a texture is used in the material.
  47367. */
  47368. hasTexture(texture: BaseTexture): boolean;
  47369. /**
  47370. * Returns an array of the actively used textures.
  47371. * @param activeTextures Array of BaseTextures
  47372. */
  47373. getActiveTextures(activeTextures: BaseTexture[]): void;
  47374. /**
  47375. * Returns the animatable textures.
  47376. * @param animatables Array of animatable textures.
  47377. */
  47378. getAnimatables(animatables: IAnimatable[]): void;
  47379. /**
  47380. * Disposes the resources of the material.
  47381. * @param forceDisposeTextures - Forces the disposal of all textures.
  47382. */
  47383. dispose(forceDisposeTextures?: boolean): void;
  47384. /**
  47385. * Get the current class name of the texture useful for serialization or dynamic coding.
  47386. * @returns "PBRAnisotropicConfiguration"
  47387. */
  47388. getClassName(): string;
  47389. /**
  47390. * Add fallbacks to the effect fallbacks list.
  47391. * @param defines defines the Base texture to use.
  47392. * @param fallbacks defines the current fallback list.
  47393. * @param currentRank defines the current fallback rank.
  47394. * @returns the new fallback rank.
  47395. */
  47396. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47397. /**
  47398. * Add the required uniforms to the current list.
  47399. * @param uniforms defines the current uniform list.
  47400. */
  47401. static AddUniforms(uniforms: string[]): void;
  47402. /**
  47403. * Add the required uniforms to the current buffer.
  47404. * @param uniformBuffer defines the current uniform buffer.
  47405. */
  47406. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47407. /**
  47408. * Add the required samplers to the current list.
  47409. * @param samplers defines the current sampler list.
  47410. */
  47411. static AddSamplers(samplers: string[]): void;
  47412. /**
  47413. * Makes a duplicate of the current configuration into another one.
  47414. * @param anisotropicConfiguration define the config where to copy the info
  47415. */
  47416. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47417. /**
  47418. * Serializes this anisotropy configuration.
  47419. * @returns - An object with the serialized config.
  47420. */
  47421. serialize(): any;
  47422. /**
  47423. * Parses a anisotropy Configuration from a serialized object.
  47424. * @param source - Serialized object.
  47425. * @param scene Defines the scene we are parsing for
  47426. * @param rootUrl Defines the rootUrl to load from
  47427. */
  47428. parse(source: any, scene: Scene, rootUrl: string): void;
  47429. }
  47430. }
  47431. declare module BABYLON {
  47432. /**
  47433. * @hidden
  47434. */
  47435. export interface IMaterialBRDFDefines {
  47436. BRDF_V_HEIGHT_CORRELATED: boolean;
  47437. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47438. SPHERICAL_HARMONICS: boolean;
  47439. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47440. /** @hidden */
  47441. _areMiscDirty: boolean;
  47442. }
  47443. /**
  47444. * Define the code related to the BRDF parameters of the pbr material.
  47445. */
  47446. export class PBRBRDFConfiguration {
  47447. /**
  47448. * Default value used for the energy conservation.
  47449. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47450. */
  47451. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47452. /**
  47453. * Default value used for the Smith Visibility Height Correlated mode.
  47454. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47455. */
  47456. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47457. /**
  47458. * Default value used for the IBL diffuse part.
  47459. * This can help switching back to the polynomials mode globally which is a tiny bit
  47460. * less GPU intensive at the drawback of a lower quality.
  47461. */
  47462. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47463. /**
  47464. * Default value used for activating energy conservation for the specular workflow.
  47465. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47466. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47467. */
  47468. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47469. private _useEnergyConservation;
  47470. /**
  47471. * Defines if the material uses energy conservation.
  47472. */
  47473. useEnergyConservation: boolean;
  47474. private _useSmithVisibilityHeightCorrelated;
  47475. /**
  47476. * LEGACY Mode set to false
  47477. * Defines if the material uses height smith correlated visibility term.
  47478. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47479. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47480. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47481. * Not relying on height correlated will also disable energy conservation.
  47482. */
  47483. useSmithVisibilityHeightCorrelated: boolean;
  47484. private _useSphericalHarmonics;
  47485. /**
  47486. * LEGACY Mode set to false
  47487. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47488. * diffuse part of the IBL.
  47489. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47490. * to the ground truth.
  47491. */
  47492. useSphericalHarmonics: boolean;
  47493. private _useSpecularGlossinessInputEnergyConservation;
  47494. /**
  47495. * Defines if the material uses energy conservation, when the specular workflow is active.
  47496. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47497. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47498. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47499. */
  47500. useSpecularGlossinessInputEnergyConservation: boolean;
  47501. /** @hidden */
  47502. private _internalMarkAllSubMeshesAsMiscDirty;
  47503. /** @hidden */
  47504. _markAllSubMeshesAsMiscDirty(): void;
  47505. /**
  47506. * Instantiate a new istance of clear coat configuration.
  47507. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47508. */
  47509. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47510. /**
  47511. * Checks to see if a texture is used in the material.
  47512. * @param defines the list of "defines" to update.
  47513. */
  47514. prepareDefines(defines: IMaterialBRDFDefines): void;
  47515. /**
  47516. * Get the current class name of the texture useful for serialization or dynamic coding.
  47517. * @returns "PBRClearCoatConfiguration"
  47518. */
  47519. getClassName(): string;
  47520. /**
  47521. * Makes a duplicate of the current configuration into another one.
  47522. * @param brdfConfiguration define the config where to copy the info
  47523. */
  47524. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47525. /**
  47526. * Serializes this BRDF configuration.
  47527. * @returns - An object with the serialized config.
  47528. */
  47529. serialize(): any;
  47530. /**
  47531. * Parses a anisotropy Configuration from a serialized object.
  47532. * @param source - Serialized object.
  47533. * @param scene Defines the scene we are parsing for
  47534. * @param rootUrl Defines the rootUrl to load from
  47535. */
  47536. parse(source: any, scene: Scene, rootUrl: string): void;
  47537. }
  47538. }
  47539. declare module BABYLON {
  47540. /**
  47541. * @hidden
  47542. */
  47543. export interface IMaterialSheenDefines {
  47544. SHEEN: boolean;
  47545. SHEEN_TEXTURE: boolean;
  47546. SHEEN_TEXTUREDIRECTUV: number;
  47547. SHEEN_LINKWITHALBEDO: boolean;
  47548. /** @hidden */
  47549. _areTexturesDirty: boolean;
  47550. }
  47551. /**
  47552. * Define the code related to the Sheen parameters of the pbr material.
  47553. */
  47554. export class PBRSheenConfiguration {
  47555. private _isEnabled;
  47556. /**
  47557. * Defines if the material uses sheen.
  47558. */
  47559. isEnabled: boolean;
  47560. private _linkSheenWithAlbedo;
  47561. /**
  47562. * Defines if the sheen is linked to the sheen color.
  47563. */
  47564. linkSheenWithAlbedo: boolean;
  47565. /**
  47566. * Defines the sheen intensity.
  47567. */
  47568. intensity: number;
  47569. /**
  47570. * Defines the sheen color.
  47571. */
  47572. color: Color3;
  47573. private _texture;
  47574. /**
  47575. * Stores the sheen tint values in a texture.
  47576. * rgb is tint
  47577. * a is a intensity
  47578. */
  47579. texture: Nullable<BaseTexture>;
  47580. /** @hidden */
  47581. private _internalMarkAllSubMeshesAsTexturesDirty;
  47582. /** @hidden */
  47583. _markAllSubMeshesAsTexturesDirty(): void;
  47584. /**
  47585. * Instantiate a new istance of clear coat configuration.
  47586. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47587. */
  47588. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47589. /**
  47590. * Specifies that the submesh is ready to be used.
  47591. * @param defines the list of "defines" to update.
  47592. * @param scene defines the scene the material belongs to.
  47593. * @returns - boolean indicating that the submesh is ready or not.
  47594. */
  47595. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47596. /**
  47597. * Checks to see if a texture is used in the material.
  47598. * @param defines the list of "defines" to update.
  47599. * @param scene defines the scene the material belongs to.
  47600. */
  47601. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47602. /**
  47603. * Binds the material data.
  47604. * @param uniformBuffer defines the Uniform buffer to fill in.
  47605. * @param scene defines the scene the material belongs to.
  47606. * @param isFrozen defines wether the material is frozen or not.
  47607. */
  47608. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47609. /**
  47610. * Checks to see if a texture is used in the material.
  47611. * @param texture - Base texture to use.
  47612. * @returns - Boolean specifying if a texture is used in the material.
  47613. */
  47614. hasTexture(texture: BaseTexture): boolean;
  47615. /**
  47616. * Returns an array of the actively used textures.
  47617. * @param activeTextures Array of BaseTextures
  47618. */
  47619. getActiveTextures(activeTextures: BaseTexture[]): void;
  47620. /**
  47621. * Returns the animatable textures.
  47622. * @param animatables Array of animatable textures.
  47623. */
  47624. getAnimatables(animatables: IAnimatable[]): void;
  47625. /**
  47626. * Disposes the resources of the material.
  47627. * @param forceDisposeTextures - Forces the disposal of all textures.
  47628. */
  47629. dispose(forceDisposeTextures?: boolean): void;
  47630. /**
  47631. * Get the current class name of the texture useful for serialization or dynamic coding.
  47632. * @returns "PBRSheenConfiguration"
  47633. */
  47634. getClassName(): string;
  47635. /**
  47636. * Add fallbacks to the effect fallbacks list.
  47637. * @param defines defines the Base texture to use.
  47638. * @param fallbacks defines the current fallback list.
  47639. * @param currentRank defines the current fallback rank.
  47640. * @returns the new fallback rank.
  47641. */
  47642. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47643. /**
  47644. * Add the required uniforms to the current list.
  47645. * @param uniforms defines the current uniform list.
  47646. */
  47647. static AddUniforms(uniforms: string[]): void;
  47648. /**
  47649. * Add the required uniforms to the current buffer.
  47650. * @param uniformBuffer defines the current uniform buffer.
  47651. */
  47652. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47653. /**
  47654. * Add the required samplers to the current list.
  47655. * @param samplers defines the current sampler list.
  47656. */
  47657. static AddSamplers(samplers: string[]): void;
  47658. /**
  47659. * Makes a duplicate of the current configuration into another one.
  47660. * @param sheenConfiguration define the config where to copy the info
  47661. */
  47662. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47663. /**
  47664. * Serializes this BRDF configuration.
  47665. * @returns - An object with the serialized config.
  47666. */
  47667. serialize(): any;
  47668. /**
  47669. * Parses a anisotropy Configuration from a serialized object.
  47670. * @param source - Serialized object.
  47671. * @param scene Defines the scene we are parsing for
  47672. * @param rootUrl Defines the rootUrl to load from
  47673. */
  47674. parse(source: any, scene: Scene, rootUrl: string): void;
  47675. }
  47676. }
  47677. declare module BABYLON {
  47678. /**
  47679. * @hidden
  47680. */
  47681. export interface IMaterialSubSurfaceDefines {
  47682. SUBSURFACE: boolean;
  47683. SS_REFRACTION: boolean;
  47684. SS_TRANSLUCENCY: boolean;
  47685. SS_SCATERRING: boolean;
  47686. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47687. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47688. SS_REFRACTIONMAP_3D: boolean;
  47689. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47690. SS_LODINREFRACTIONALPHA: boolean;
  47691. SS_GAMMAREFRACTION: boolean;
  47692. SS_RGBDREFRACTION: boolean;
  47693. SS_LINEARSPECULARREFRACTION: boolean;
  47694. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47695. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47696. /** @hidden */
  47697. _areTexturesDirty: boolean;
  47698. }
  47699. /**
  47700. * Define the code related to the sub surface parameters of the pbr material.
  47701. */
  47702. export class PBRSubSurfaceConfiguration {
  47703. private _isRefractionEnabled;
  47704. /**
  47705. * Defines if the refraction is enabled in the material.
  47706. */
  47707. isRefractionEnabled: boolean;
  47708. private _isTranslucencyEnabled;
  47709. /**
  47710. * Defines if the translucency is enabled in the material.
  47711. */
  47712. isTranslucencyEnabled: boolean;
  47713. private _isScatteringEnabled;
  47714. /**
  47715. * Defines the refraction intensity of the material.
  47716. * The refraction when enabled replaces the Diffuse part of the material.
  47717. * The intensity helps transitionning between diffuse and refraction.
  47718. */
  47719. refractionIntensity: number;
  47720. /**
  47721. * Defines the translucency intensity of the material.
  47722. * When translucency has been enabled, this defines how much of the "translucency"
  47723. * is addded to the diffuse part of the material.
  47724. */
  47725. translucencyIntensity: number;
  47726. /**
  47727. * Defines the scattering intensity of the material.
  47728. * When scattering has been enabled, this defines how much of the "scattered light"
  47729. * is addded to the diffuse part of the material.
  47730. */
  47731. scatteringIntensity: number;
  47732. private _thicknessTexture;
  47733. /**
  47734. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47735. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47736. * 0 would mean minimumThickness
  47737. * 1 would mean maximumThickness
  47738. * The other channels might be use as a mask to vary the different effects intensity.
  47739. */
  47740. thicknessTexture: Nullable<BaseTexture>;
  47741. private _refractionTexture;
  47742. /**
  47743. * Defines the texture to use for refraction.
  47744. */
  47745. refractionTexture: Nullable<BaseTexture>;
  47746. private _indexOfRefraction;
  47747. /**
  47748. * Defines the index of refraction used in the material.
  47749. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47750. */
  47751. indexOfRefraction: number;
  47752. private _invertRefractionY;
  47753. /**
  47754. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47755. */
  47756. invertRefractionY: boolean;
  47757. private _linkRefractionWithTransparency;
  47758. /**
  47759. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47760. * Materials half opaque for instance using refraction could benefit from this control.
  47761. */
  47762. linkRefractionWithTransparency: boolean;
  47763. /**
  47764. * Defines the minimum thickness stored in the thickness map.
  47765. * If no thickness map is defined, this value will be used to simulate thickness.
  47766. */
  47767. minimumThickness: number;
  47768. /**
  47769. * Defines the maximum thickness stored in the thickness map.
  47770. */
  47771. maximumThickness: number;
  47772. /**
  47773. * Defines the volume tint of the material.
  47774. * This is used for both translucency and scattering.
  47775. */
  47776. tintColor: Color3;
  47777. /**
  47778. * Defines the distance at which the tint color should be found in the media.
  47779. * This is used for refraction only.
  47780. */
  47781. tintColorAtDistance: number;
  47782. /**
  47783. * Defines how far each channel transmit through the media.
  47784. * It is defined as a color to simplify it selection.
  47785. */
  47786. diffusionDistance: Color3;
  47787. private _useMaskFromThicknessTexture;
  47788. /**
  47789. * Stores the intensity of the different subsurface effects in the thickness texture.
  47790. * * the green channel is the translucency intensity.
  47791. * * the blue channel is the scattering intensity.
  47792. * * the alpha channel is the refraction intensity.
  47793. */
  47794. useMaskFromThicknessTexture: boolean;
  47795. /** @hidden */
  47796. private _internalMarkAllSubMeshesAsTexturesDirty;
  47797. /** @hidden */
  47798. _markAllSubMeshesAsTexturesDirty(): void;
  47799. /**
  47800. * Instantiate a new istance of sub surface configuration.
  47801. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47802. */
  47803. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47804. /**
  47805. * Gets wehter the submesh is ready to be used or not.
  47806. * @param defines the list of "defines" to update.
  47807. * @param scene defines the scene the material belongs to.
  47808. * @returns - boolean indicating that the submesh is ready or not.
  47809. */
  47810. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47811. /**
  47812. * Checks to see if a texture is used in the material.
  47813. * @param defines the list of "defines" to update.
  47814. * @param scene defines the scene to the material belongs to.
  47815. */
  47816. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47817. /**
  47818. * Binds the material data.
  47819. * @param uniformBuffer defines the Uniform buffer to fill in.
  47820. * @param scene defines the scene the material belongs to.
  47821. * @param engine defines the engine the material belongs to.
  47822. * @param isFrozen defines wether the material is frozen or not.
  47823. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47824. */
  47825. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47826. /**
  47827. * Unbinds the material from the mesh.
  47828. * @param activeEffect defines the effect that should be unbound from.
  47829. * @returns true if unbound, otherwise false
  47830. */
  47831. unbind(activeEffect: Effect): boolean;
  47832. /**
  47833. * Returns the texture used for refraction or null if none is used.
  47834. * @param scene defines the scene the material belongs to.
  47835. * @returns - Refraction texture if present. If no refraction texture and refraction
  47836. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47837. */
  47838. private _getRefractionTexture;
  47839. /**
  47840. * Returns true if alpha blending should be disabled.
  47841. */
  47842. readonly disableAlphaBlending: boolean;
  47843. /**
  47844. * Fills the list of render target textures.
  47845. * @param renderTargets the list of render targets to update
  47846. */
  47847. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47848. /**
  47849. * Checks to see if a texture is used in the material.
  47850. * @param texture - Base texture to use.
  47851. * @returns - Boolean specifying if a texture is used in the material.
  47852. */
  47853. hasTexture(texture: BaseTexture): boolean;
  47854. /**
  47855. * Gets a boolean indicating that current material needs to register RTT
  47856. * @returns true if this uses a render target otherwise false.
  47857. */
  47858. hasRenderTargetTextures(): boolean;
  47859. /**
  47860. * Returns an array of the actively used textures.
  47861. * @param activeTextures Array of BaseTextures
  47862. */
  47863. getActiveTextures(activeTextures: BaseTexture[]): void;
  47864. /**
  47865. * Returns the animatable textures.
  47866. * @param animatables Array of animatable textures.
  47867. */
  47868. getAnimatables(animatables: IAnimatable[]): void;
  47869. /**
  47870. * Disposes the resources of the material.
  47871. * @param forceDisposeTextures - Forces the disposal of all textures.
  47872. */
  47873. dispose(forceDisposeTextures?: boolean): void;
  47874. /**
  47875. * Get the current class name of the texture useful for serialization or dynamic coding.
  47876. * @returns "PBRSubSurfaceConfiguration"
  47877. */
  47878. getClassName(): string;
  47879. /**
  47880. * Add fallbacks to the effect fallbacks list.
  47881. * @param defines defines the Base texture to use.
  47882. * @param fallbacks defines the current fallback list.
  47883. * @param currentRank defines the current fallback rank.
  47884. * @returns the new fallback rank.
  47885. */
  47886. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47887. /**
  47888. * Add the required uniforms to the current list.
  47889. * @param uniforms defines the current uniform list.
  47890. */
  47891. static AddUniforms(uniforms: string[]): void;
  47892. /**
  47893. * Add the required samplers to the current list.
  47894. * @param samplers defines the current sampler list.
  47895. */
  47896. static AddSamplers(samplers: string[]): void;
  47897. /**
  47898. * Add the required uniforms to the current buffer.
  47899. * @param uniformBuffer defines the current uniform buffer.
  47900. */
  47901. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47902. /**
  47903. * Makes a duplicate of the current configuration into another one.
  47904. * @param configuration define the config where to copy the info
  47905. */
  47906. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47907. /**
  47908. * Serializes this Sub Surface configuration.
  47909. * @returns - An object with the serialized config.
  47910. */
  47911. serialize(): any;
  47912. /**
  47913. * Parses a anisotropy Configuration from a serialized object.
  47914. * @param source - Serialized object.
  47915. * @param scene Defines the scene we are parsing for
  47916. * @param rootUrl Defines the rootUrl to load from
  47917. */
  47918. parse(source: any, scene: Scene, rootUrl: string): void;
  47919. }
  47920. }
  47921. declare module BABYLON {
  47922. /** @hidden */
  47923. export var pbrFragmentDeclaration: {
  47924. name: string;
  47925. shader: string;
  47926. };
  47927. }
  47928. declare module BABYLON {
  47929. /** @hidden */
  47930. export var pbrUboDeclaration: {
  47931. name: string;
  47932. shader: string;
  47933. };
  47934. }
  47935. declare module BABYLON {
  47936. /** @hidden */
  47937. export var pbrFragmentExtraDeclaration: {
  47938. name: string;
  47939. shader: string;
  47940. };
  47941. }
  47942. declare module BABYLON {
  47943. /** @hidden */
  47944. export var pbrFragmentSamplersDeclaration: {
  47945. name: string;
  47946. shader: string;
  47947. };
  47948. }
  47949. declare module BABYLON {
  47950. /** @hidden */
  47951. export var pbrHelperFunctions: {
  47952. name: string;
  47953. shader: string;
  47954. };
  47955. }
  47956. declare module BABYLON {
  47957. /** @hidden */
  47958. export var harmonicsFunctions: {
  47959. name: string;
  47960. shader: string;
  47961. };
  47962. }
  47963. declare module BABYLON {
  47964. /** @hidden */
  47965. export var pbrDirectLightingSetupFunctions: {
  47966. name: string;
  47967. shader: string;
  47968. };
  47969. }
  47970. declare module BABYLON {
  47971. /** @hidden */
  47972. export var pbrDirectLightingFalloffFunctions: {
  47973. name: string;
  47974. shader: string;
  47975. };
  47976. }
  47977. declare module BABYLON {
  47978. /** @hidden */
  47979. export var pbrBRDFFunctions: {
  47980. name: string;
  47981. shader: string;
  47982. };
  47983. }
  47984. declare module BABYLON {
  47985. /** @hidden */
  47986. export var pbrDirectLightingFunctions: {
  47987. name: string;
  47988. shader: string;
  47989. };
  47990. }
  47991. declare module BABYLON {
  47992. /** @hidden */
  47993. export var pbrIBLFunctions: {
  47994. name: string;
  47995. shader: string;
  47996. };
  47997. }
  47998. declare module BABYLON {
  47999. /** @hidden */
  48000. export var pbrDebug: {
  48001. name: string;
  48002. shader: string;
  48003. };
  48004. }
  48005. declare module BABYLON {
  48006. /** @hidden */
  48007. export var pbrPixelShader: {
  48008. name: string;
  48009. shader: string;
  48010. };
  48011. }
  48012. declare module BABYLON {
  48013. /** @hidden */
  48014. export var pbrVertexDeclaration: {
  48015. name: string;
  48016. shader: string;
  48017. };
  48018. }
  48019. declare module BABYLON {
  48020. /** @hidden */
  48021. export var pbrVertexShader: {
  48022. name: string;
  48023. shader: string;
  48024. };
  48025. }
  48026. declare module BABYLON {
  48027. /**
  48028. * Manages the defines for the PBR Material.
  48029. * @hidden
  48030. */
  48031. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48032. PBR: boolean;
  48033. MAINUV1: boolean;
  48034. MAINUV2: boolean;
  48035. UV1: boolean;
  48036. UV2: boolean;
  48037. ALBEDO: boolean;
  48038. ALBEDODIRECTUV: number;
  48039. VERTEXCOLOR: boolean;
  48040. AMBIENT: boolean;
  48041. AMBIENTDIRECTUV: number;
  48042. AMBIENTINGRAYSCALE: boolean;
  48043. OPACITY: boolean;
  48044. VERTEXALPHA: boolean;
  48045. OPACITYDIRECTUV: number;
  48046. OPACITYRGB: boolean;
  48047. ALPHATEST: boolean;
  48048. DEPTHPREPASS: boolean;
  48049. ALPHABLEND: boolean;
  48050. ALPHAFROMALBEDO: boolean;
  48051. ALPHATESTVALUE: string;
  48052. SPECULAROVERALPHA: boolean;
  48053. RADIANCEOVERALPHA: boolean;
  48054. ALPHAFRESNEL: boolean;
  48055. LINEARALPHAFRESNEL: boolean;
  48056. PREMULTIPLYALPHA: boolean;
  48057. EMISSIVE: boolean;
  48058. EMISSIVEDIRECTUV: number;
  48059. REFLECTIVITY: boolean;
  48060. REFLECTIVITYDIRECTUV: number;
  48061. SPECULARTERM: boolean;
  48062. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48063. MICROSURFACEAUTOMATIC: boolean;
  48064. LODBASEDMICROSFURACE: boolean;
  48065. MICROSURFACEMAP: boolean;
  48066. MICROSURFACEMAPDIRECTUV: number;
  48067. METALLICWORKFLOW: boolean;
  48068. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48069. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48070. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48071. AOSTOREINMETALMAPRED: boolean;
  48072. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48073. ENVIRONMENTBRDF: boolean;
  48074. ENVIRONMENTBRDF_RGBD: boolean;
  48075. NORMAL: boolean;
  48076. TANGENT: boolean;
  48077. BUMP: boolean;
  48078. BUMPDIRECTUV: number;
  48079. OBJECTSPACE_NORMALMAP: boolean;
  48080. PARALLAX: boolean;
  48081. PARALLAXOCCLUSION: boolean;
  48082. NORMALXYSCALE: boolean;
  48083. LIGHTMAP: boolean;
  48084. LIGHTMAPDIRECTUV: number;
  48085. USELIGHTMAPASSHADOWMAP: boolean;
  48086. GAMMALIGHTMAP: boolean;
  48087. RGBDLIGHTMAP: boolean;
  48088. REFLECTION: boolean;
  48089. REFLECTIONMAP_3D: boolean;
  48090. REFLECTIONMAP_SPHERICAL: boolean;
  48091. REFLECTIONMAP_PLANAR: boolean;
  48092. REFLECTIONMAP_CUBIC: boolean;
  48093. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48094. REFLECTIONMAP_PROJECTION: boolean;
  48095. REFLECTIONMAP_SKYBOX: boolean;
  48096. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48097. REFLECTIONMAP_EXPLICIT: boolean;
  48098. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48099. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48100. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48101. INVERTCUBICMAP: boolean;
  48102. USESPHERICALFROMREFLECTIONMAP: boolean;
  48103. USEIRRADIANCEMAP: boolean;
  48104. SPHERICAL_HARMONICS: boolean;
  48105. USESPHERICALINVERTEX: boolean;
  48106. REFLECTIONMAP_OPPOSITEZ: boolean;
  48107. LODINREFLECTIONALPHA: boolean;
  48108. GAMMAREFLECTION: boolean;
  48109. RGBDREFLECTION: boolean;
  48110. LINEARSPECULARREFLECTION: boolean;
  48111. RADIANCEOCCLUSION: boolean;
  48112. HORIZONOCCLUSION: boolean;
  48113. INSTANCES: boolean;
  48114. NUM_BONE_INFLUENCERS: number;
  48115. BonesPerMesh: number;
  48116. BONETEXTURE: boolean;
  48117. NONUNIFORMSCALING: boolean;
  48118. MORPHTARGETS: boolean;
  48119. MORPHTARGETS_NORMAL: boolean;
  48120. MORPHTARGETS_TANGENT: boolean;
  48121. MORPHTARGETS_UV: boolean;
  48122. NUM_MORPH_INFLUENCERS: number;
  48123. IMAGEPROCESSING: boolean;
  48124. VIGNETTE: boolean;
  48125. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48126. VIGNETTEBLENDMODEOPAQUE: boolean;
  48127. TONEMAPPING: boolean;
  48128. TONEMAPPING_ACES: boolean;
  48129. CONTRAST: boolean;
  48130. COLORCURVES: boolean;
  48131. COLORGRADING: boolean;
  48132. COLORGRADING3D: boolean;
  48133. SAMPLER3DGREENDEPTH: boolean;
  48134. SAMPLER3DBGRMAP: boolean;
  48135. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48136. EXPOSURE: boolean;
  48137. MULTIVIEW: boolean;
  48138. USEPHYSICALLIGHTFALLOFF: boolean;
  48139. USEGLTFLIGHTFALLOFF: boolean;
  48140. TWOSIDEDLIGHTING: boolean;
  48141. SHADOWFLOAT: boolean;
  48142. CLIPPLANE: boolean;
  48143. CLIPPLANE2: boolean;
  48144. CLIPPLANE3: boolean;
  48145. CLIPPLANE4: boolean;
  48146. POINTSIZE: boolean;
  48147. FOG: boolean;
  48148. LOGARITHMICDEPTH: boolean;
  48149. FORCENORMALFORWARD: boolean;
  48150. SPECULARAA: boolean;
  48151. CLEARCOAT: boolean;
  48152. CLEARCOAT_DEFAULTIOR: boolean;
  48153. CLEARCOAT_TEXTURE: boolean;
  48154. CLEARCOAT_TEXTUREDIRECTUV: number;
  48155. CLEARCOAT_BUMP: boolean;
  48156. CLEARCOAT_BUMPDIRECTUV: number;
  48157. CLEARCOAT_TINT: boolean;
  48158. CLEARCOAT_TINT_TEXTURE: boolean;
  48159. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48160. ANISOTROPIC: boolean;
  48161. ANISOTROPIC_TEXTURE: boolean;
  48162. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48163. BRDF_V_HEIGHT_CORRELATED: boolean;
  48164. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48165. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48166. SHEEN: boolean;
  48167. SHEEN_TEXTURE: boolean;
  48168. SHEEN_TEXTUREDIRECTUV: number;
  48169. SHEEN_LINKWITHALBEDO: boolean;
  48170. SUBSURFACE: boolean;
  48171. SS_REFRACTION: boolean;
  48172. SS_TRANSLUCENCY: boolean;
  48173. SS_SCATERRING: boolean;
  48174. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48175. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48176. SS_REFRACTIONMAP_3D: boolean;
  48177. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48178. SS_LODINREFRACTIONALPHA: boolean;
  48179. SS_GAMMAREFRACTION: boolean;
  48180. SS_RGBDREFRACTION: boolean;
  48181. SS_LINEARSPECULARREFRACTION: boolean;
  48182. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48183. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48184. UNLIT: boolean;
  48185. DEBUGMODE: number;
  48186. /**
  48187. * Initializes the PBR Material defines.
  48188. */
  48189. constructor();
  48190. /**
  48191. * Resets the PBR Material defines.
  48192. */
  48193. reset(): void;
  48194. }
  48195. /**
  48196. * The Physically based material base class of BJS.
  48197. *
  48198. * This offers the main features of a standard PBR material.
  48199. * For more information, please refer to the documentation :
  48200. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48201. */
  48202. export abstract class PBRBaseMaterial extends PushMaterial {
  48203. /**
  48204. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48205. */
  48206. static readonly PBRMATERIAL_OPAQUE: number;
  48207. /**
  48208. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48209. */
  48210. static readonly PBRMATERIAL_ALPHATEST: number;
  48211. /**
  48212. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48213. */
  48214. static readonly PBRMATERIAL_ALPHABLEND: number;
  48215. /**
  48216. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48217. * They are also discarded below the alpha cutoff threshold to improve performances.
  48218. */
  48219. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48220. /**
  48221. * Defines the default value of how much AO map is occluding the analytical lights
  48222. * (point spot...).
  48223. */
  48224. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48225. /**
  48226. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48227. */
  48228. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48229. /**
  48230. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48231. * to enhance interoperability with other engines.
  48232. */
  48233. static readonly LIGHTFALLOFF_GLTF: number;
  48234. /**
  48235. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48236. * to enhance interoperability with other materials.
  48237. */
  48238. static readonly LIGHTFALLOFF_STANDARD: number;
  48239. /**
  48240. * Intensity of the direct lights e.g. the four lights available in your scene.
  48241. * This impacts both the direct diffuse and specular highlights.
  48242. */
  48243. protected _directIntensity: number;
  48244. /**
  48245. * Intensity of the emissive part of the material.
  48246. * This helps controlling the emissive effect without modifying the emissive color.
  48247. */
  48248. protected _emissiveIntensity: number;
  48249. /**
  48250. * Intensity of the environment e.g. how much the environment will light the object
  48251. * either through harmonics for rough material or through the refelction for shiny ones.
  48252. */
  48253. protected _environmentIntensity: number;
  48254. /**
  48255. * This is a special control allowing the reduction of the specular highlights coming from the
  48256. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48257. */
  48258. protected _specularIntensity: number;
  48259. /**
  48260. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48261. */
  48262. private _lightingInfos;
  48263. /**
  48264. * Debug Control allowing disabling the bump map on this material.
  48265. */
  48266. protected _disableBumpMap: boolean;
  48267. /**
  48268. * AKA Diffuse Texture in standard nomenclature.
  48269. */
  48270. protected _albedoTexture: Nullable<BaseTexture>;
  48271. /**
  48272. * AKA Occlusion Texture in other nomenclature.
  48273. */
  48274. protected _ambientTexture: Nullable<BaseTexture>;
  48275. /**
  48276. * AKA Occlusion Texture Intensity in other nomenclature.
  48277. */
  48278. protected _ambientTextureStrength: number;
  48279. /**
  48280. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48281. * 1 means it completely occludes it
  48282. * 0 mean it has no impact
  48283. */
  48284. protected _ambientTextureImpactOnAnalyticalLights: number;
  48285. /**
  48286. * Stores the alpha values in a texture.
  48287. */
  48288. protected _opacityTexture: Nullable<BaseTexture>;
  48289. /**
  48290. * Stores the reflection values in a texture.
  48291. */
  48292. protected _reflectionTexture: Nullable<BaseTexture>;
  48293. /**
  48294. * Stores the emissive values in a texture.
  48295. */
  48296. protected _emissiveTexture: Nullable<BaseTexture>;
  48297. /**
  48298. * AKA Specular texture in other nomenclature.
  48299. */
  48300. protected _reflectivityTexture: Nullable<BaseTexture>;
  48301. /**
  48302. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48303. */
  48304. protected _metallicTexture: Nullable<BaseTexture>;
  48305. /**
  48306. * Specifies the metallic scalar of the metallic/roughness workflow.
  48307. * Can also be used to scale the metalness values of the metallic texture.
  48308. */
  48309. protected _metallic: Nullable<number>;
  48310. /**
  48311. * Specifies the roughness scalar of the metallic/roughness workflow.
  48312. * Can also be used to scale the roughness values of the metallic texture.
  48313. */
  48314. protected _roughness: Nullable<number>;
  48315. /**
  48316. * Specifies the an F0 factor to help configuring the material F0.
  48317. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48318. * to 0.5 the previously hard coded value stays the same.
  48319. * Can also be used to scale the F0 values of the metallic texture.
  48320. */
  48321. protected _metallicF0Factor: number;
  48322. /**
  48323. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48324. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48325. * your expectation as it multiplies with the texture data.
  48326. */
  48327. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48328. /**
  48329. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48330. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48331. */
  48332. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48333. /**
  48334. * Stores surface normal data used to displace a mesh in a texture.
  48335. */
  48336. protected _bumpTexture: Nullable<BaseTexture>;
  48337. /**
  48338. * Stores the pre-calculated light information of a mesh in a texture.
  48339. */
  48340. protected _lightmapTexture: Nullable<BaseTexture>;
  48341. /**
  48342. * The color of a material in ambient lighting.
  48343. */
  48344. protected _ambientColor: Color3;
  48345. /**
  48346. * AKA Diffuse Color in other nomenclature.
  48347. */
  48348. protected _albedoColor: Color3;
  48349. /**
  48350. * AKA Specular Color in other nomenclature.
  48351. */
  48352. protected _reflectivityColor: Color3;
  48353. /**
  48354. * The color applied when light is reflected from a material.
  48355. */
  48356. protected _reflectionColor: Color3;
  48357. /**
  48358. * The color applied when light is emitted from a material.
  48359. */
  48360. protected _emissiveColor: Color3;
  48361. /**
  48362. * AKA Glossiness in other nomenclature.
  48363. */
  48364. protected _microSurface: number;
  48365. /**
  48366. * Specifies that the material will use the light map as a show map.
  48367. */
  48368. protected _useLightmapAsShadowmap: boolean;
  48369. /**
  48370. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48371. * makes the reflect vector face the model (under horizon).
  48372. */
  48373. protected _useHorizonOcclusion: boolean;
  48374. /**
  48375. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48376. * too much the area relying on ambient texture to define their ambient occlusion.
  48377. */
  48378. protected _useRadianceOcclusion: boolean;
  48379. /**
  48380. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48381. */
  48382. protected _useAlphaFromAlbedoTexture: boolean;
  48383. /**
  48384. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48385. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48386. */
  48387. protected _useSpecularOverAlpha: boolean;
  48388. /**
  48389. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48390. */
  48391. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48392. /**
  48393. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48394. */
  48395. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48396. /**
  48397. * Specifies if the metallic texture contains the roughness information in its green channel.
  48398. */
  48399. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48400. /**
  48401. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48402. */
  48403. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48404. /**
  48405. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48406. */
  48407. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48408. /**
  48409. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48410. */
  48411. protected _useAmbientInGrayScale: boolean;
  48412. /**
  48413. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48414. * The material will try to infer what glossiness each pixel should be.
  48415. */
  48416. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48417. /**
  48418. * Defines the falloff type used in this material.
  48419. * It by default is Physical.
  48420. */
  48421. protected _lightFalloff: number;
  48422. /**
  48423. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48424. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48425. */
  48426. protected _useRadianceOverAlpha: boolean;
  48427. /**
  48428. * Allows using an object space normal map (instead of tangent space).
  48429. */
  48430. protected _useObjectSpaceNormalMap: boolean;
  48431. /**
  48432. * Allows using the bump map in parallax mode.
  48433. */
  48434. protected _useParallax: boolean;
  48435. /**
  48436. * Allows using the bump map in parallax occlusion mode.
  48437. */
  48438. protected _useParallaxOcclusion: boolean;
  48439. /**
  48440. * Controls the scale bias of the parallax mode.
  48441. */
  48442. protected _parallaxScaleBias: number;
  48443. /**
  48444. * If sets to true, disables all the lights affecting the material.
  48445. */
  48446. protected _disableLighting: boolean;
  48447. /**
  48448. * Number of Simultaneous lights allowed on the material.
  48449. */
  48450. protected _maxSimultaneousLights: number;
  48451. /**
  48452. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48453. */
  48454. protected _invertNormalMapX: boolean;
  48455. /**
  48456. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48457. */
  48458. protected _invertNormalMapY: boolean;
  48459. /**
  48460. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48461. */
  48462. protected _twoSidedLighting: boolean;
  48463. /**
  48464. * Defines the alpha limits in alpha test mode.
  48465. */
  48466. protected _alphaCutOff: number;
  48467. /**
  48468. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48469. */
  48470. protected _forceAlphaTest: boolean;
  48471. /**
  48472. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48473. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48474. */
  48475. protected _useAlphaFresnel: boolean;
  48476. /**
  48477. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48478. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48479. */
  48480. protected _useLinearAlphaFresnel: boolean;
  48481. /**
  48482. * The transparency mode of the material.
  48483. */
  48484. protected _transparencyMode: Nullable<number>;
  48485. /**
  48486. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48487. * from cos thetav and roughness:
  48488. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48489. */
  48490. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48491. /**
  48492. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48493. */
  48494. protected _forceIrradianceInFragment: boolean;
  48495. /**
  48496. * Force normal to face away from face.
  48497. */
  48498. protected _forceNormalForward: boolean;
  48499. /**
  48500. * Enables specular anti aliasing in the PBR shader.
  48501. * It will both interacts on the Geometry for analytical and IBL lighting.
  48502. * It also prefilter the roughness map based on the bump values.
  48503. */
  48504. protected _enableSpecularAntiAliasing: boolean;
  48505. /**
  48506. * Default configuration related to image processing available in the PBR Material.
  48507. */
  48508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48509. /**
  48510. * Keep track of the image processing observer to allow dispose and replace.
  48511. */
  48512. private _imageProcessingObserver;
  48513. /**
  48514. * Attaches a new image processing configuration to the PBR Material.
  48515. * @param configuration
  48516. */
  48517. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48518. /**
  48519. * Stores the available render targets.
  48520. */
  48521. private _renderTargets;
  48522. /**
  48523. * Sets the global ambient color for the material used in lighting calculations.
  48524. */
  48525. private _globalAmbientColor;
  48526. /**
  48527. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48528. */
  48529. private _useLogarithmicDepth;
  48530. /**
  48531. * If set to true, no lighting calculations will be applied.
  48532. */
  48533. private _unlit;
  48534. private _debugMode;
  48535. /**
  48536. * @hidden
  48537. * This is reserved for the inspector.
  48538. * Defines the material debug mode.
  48539. * It helps seeing only some components of the material while troubleshooting.
  48540. */
  48541. debugMode: number;
  48542. /**
  48543. * @hidden
  48544. * This is reserved for the inspector.
  48545. * Specify from where on screen the debug mode should start.
  48546. * The value goes from -1 (full screen) to 1 (not visible)
  48547. * It helps with side by side comparison against the final render
  48548. * This defaults to -1
  48549. */
  48550. private debugLimit;
  48551. /**
  48552. * @hidden
  48553. * This is reserved for the inspector.
  48554. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48555. * You can use the factor to better multiply the final value.
  48556. */
  48557. private debugFactor;
  48558. /**
  48559. * Defines the clear coat layer parameters for the material.
  48560. */
  48561. readonly clearCoat: PBRClearCoatConfiguration;
  48562. /**
  48563. * Defines the anisotropic parameters for the material.
  48564. */
  48565. readonly anisotropy: PBRAnisotropicConfiguration;
  48566. /**
  48567. * Defines the BRDF parameters for the material.
  48568. */
  48569. readonly brdf: PBRBRDFConfiguration;
  48570. /**
  48571. * Defines the Sheen parameters for the material.
  48572. */
  48573. readonly sheen: PBRSheenConfiguration;
  48574. /**
  48575. * Defines the SubSurface parameters for the material.
  48576. */
  48577. readonly subSurface: PBRSubSurfaceConfiguration;
  48578. /**
  48579. * Custom callback helping to override the default shader used in the material.
  48580. */
  48581. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48582. protected _rebuildInParallel: boolean;
  48583. /**
  48584. * Instantiates a new PBRMaterial instance.
  48585. *
  48586. * @param name The material name
  48587. * @param scene The scene the material will be use in.
  48588. */
  48589. constructor(name: string, scene: Scene);
  48590. /**
  48591. * Gets a boolean indicating that current material needs to register RTT
  48592. */
  48593. readonly hasRenderTargetTextures: boolean;
  48594. /**
  48595. * Gets the name of the material class.
  48596. */
  48597. getClassName(): string;
  48598. /**
  48599. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48600. */
  48601. /**
  48602. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48603. */
  48604. useLogarithmicDepth: boolean;
  48605. /**
  48606. * Gets the current transparency mode.
  48607. */
  48608. /**
  48609. * Sets the transparency mode of the material.
  48610. *
  48611. * | Value | Type | Description |
  48612. * | ----- | ----------------------------------- | ----------- |
  48613. * | 0 | OPAQUE | |
  48614. * | 1 | ALPHATEST | |
  48615. * | 2 | ALPHABLEND | |
  48616. * | 3 | ALPHATESTANDBLEND | |
  48617. *
  48618. */
  48619. transparencyMode: Nullable<number>;
  48620. /**
  48621. * Returns true if alpha blending should be disabled.
  48622. */
  48623. private readonly _disableAlphaBlending;
  48624. /**
  48625. * Specifies whether or not this material should be rendered in alpha blend mode.
  48626. */
  48627. needAlphaBlending(): boolean;
  48628. /**
  48629. * Specifies if the mesh will require alpha blending.
  48630. * @param mesh - BJS mesh.
  48631. */
  48632. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48633. /**
  48634. * Specifies whether or not this material should be rendered in alpha test mode.
  48635. */
  48636. needAlphaTesting(): boolean;
  48637. /**
  48638. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48639. */
  48640. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48641. /**
  48642. * Gets the texture used for the alpha test.
  48643. */
  48644. getAlphaTestTexture(): Nullable<BaseTexture>;
  48645. /**
  48646. * Specifies that the submesh is ready to be used.
  48647. * @param mesh - BJS mesh.
  48648. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48649. * @param useInstances - Specifies that instances should be used.
  48650. * @returns - boolean indicating that the submesh is ready or not.
  48651. */
  48652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48653. /**
  48654. * Specifies if the material uses metallic roughness workflow.
  48655. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48656. */
  48657. isMetallicWorkflow(): boolean;
  48658. private _prepareEffect;
  48659. private _prepareDefines;
  48660. /**
  48661. * Force shader compilation
  48662. */
  48663. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48664. /**
  48665. * Initializes the uniform buffer layout for the shader.
  48666. */
  48667. buildUniformLayout(): void;
  48668. /**
  48669. * Unbinds the material from the mesh
  48670. */
  48671. unbind(): void;
  48672. /**
  48673. * Binds the submesh data.
  48674. * @param world - The world matrix.
  48675. * @param mesh - The BJS mesh.
  48676. * @param subMesh - A submesh of the BJS mesh.
  48677. */
  48678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48679. /**
  48680. * Returns the animatable textures.
  48681. * @returns - Array of animatable textures.
  48682. */
  48683. getAnimatables(): IAnimatable[];
  48684. /**
  48685. * Returns the texture used for reflections.
  48686. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48687. */
  48688. private _getReflectionTexture;
  48689. /**
  48690. * Returns an array of the actively used textures.
  48691. * @returns - Array of BaseTextures
  48692. */
  48693. getActiveTextures(): BaseTexture[];
  48694. /**
  48695. * Checks to see if a texture is used in the material.
  48696. * @param texture - Base texture to use.
  48697. * @returns - Boolean specifying if a texture is used in the material.
  48698. */
  48699. hasTexture(texture: BaseTexture): boolean;
  48700. /**
  48701. * Disposes the resources of the material.
  48702. * @param forceDisposeEffect - Forces the disposal of effects.
  48703. * @param forceDisposeTextures - Forces the disposal of all textures.
  48704. */
  48705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48706. }
  48707. }
  48708. declare module BABYLON {
  48709. /**
  48710. * The Physically based material of BJS.
  48711. *
  48712. * This offers the main features of a standard PBR material.
  48713. * For more information, please refer to the documentation :
  48714. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48715. */
  48716. export class PBRMaterial extends PBRBaseMaterial {
  48717. /**
  48718. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48719. */
  48720. static readonly PBRMATERIAL_OPAQUE: number;
  48721. /**
  48722. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48723. */
  48724. static readonly PBRMATERIAL_ALPHATEST: number;
  48725. /**
  48726. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48727. */
  48728. static readonly PBRMATERIAL_ALPHABLEND: number;
  48729. /**
  48730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48731. * They are also discarded below the alpha cutoff threshold to improve performances.
  48732. */
  48733. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48734. /**
  48735. * Defines the default value of how much AO map is occluding the analytical lights
  48736. * (point spot...).
  48737. */
  48738. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48739. /**
  48740. * Intensity of the direct lights e.g. the four lights available in your scene.
  48741. * This impacts both the direct diffuse and specular highlights.
  48742. */
  48743. directIntensity: number;
  48744. /**
  48745. * Intensity of the emissive part of the material.
  48746. * This helps controlling the emissive effect without modifying the emissive color.
  48747. */
  48748. emissiveIntensity: number;
  48749. /**
  48750. * Intensity of the environment e.g. how much the environment will light the object
  48751. * either through harmonics for rough material or through the refelction for shiny ones.
  48752. */
  48753. environmentIntensity: number;
  48754. /**
  48755. * This is a special control allowing the reduction of the specular highlights coming from the
  48756. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48757. */
  48758. specularIntensity: number;
  48759. /**
  48760. * Debug Control allowing disabling the bump map on this material.
  48761. */
  48762. disableBumpMap: boolean;
  48763. /**
  48764. * AKA Diffuse Texture in standard nomenclature.
  48765. */
  48766. albedoTexture: BaseTexture;
  48767. /**
  48768. * AKA Occlusion Texture in other nomenclature.
  48769. */
  48770. ambientTexture: BaseTexture;
  48771. /**
  48772. * AKA Occlusion Texture Intensity in other nomenclature.
  48773. */
  48774. ambientTextureStrength: number;
  48775. /**
  48776. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48777. * 1 means it completely occludes it
  48778. * 0 mean it has no impact
  48779. */
  48780. ambientTextureImpactOnAnalyticalLights: number;
  48781. /**
  48782. * Stores the alpha values in a texture.
  48783. */
  48784. opacityTexture: BaseTexture;
  48785. /**
  48786. * Stores the reflection values in a texture.
  48787. */
  48788. reflectionTexture: Nullable<BaseTexture>;
  48789. /**
  48790. * Stores the emissive values in a texture.
  48791. */
  48792. emissiveTexture: BaseTexture;
  48793. /**
  48794. * AKA Specular texture in other nomenclature.
  48795. */
  48796. reflectivityTexture: BaseTexture;
  48797. /**
  48798. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48799. */
  48800. metallicTexture: BaseTexture;
  48801. /**
  48802. * Specifies the metallic scalar of the metallic/roughness workflow.
  48803. * Can also be used to scale the metalness values of the metallic texture.
  48804. */
  48805. metallic: Nullable<number>;
  48806. /**
  48807. * Specifies the roughness scalar of the metallic/roughness workflow.
  48808. * Can also be used to scale the roughness values of the metallic texture.
  48809. */
  48810. roughness: Nullable<number>;
  48811. /**
  48812. * Specifies the an F0 factor to help configuring the material F0.
  48813. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48814. * to 0.5 the previously hard coded value stays the same.
  48815. * Can also be used to scale the F0 values of the metallic texture.
  48816. */
  48817. metallicF0Factor: number;
  48818. /**
  48819. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48820. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48821. * your expectation as it multiplies with the texture data.
  48822. */
  48823. useMetallicF0FactorFromMetallicTexture: boolean;
  48824. /**
  48825. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48826. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48827. */
  48828. microSurfaceTexture: BaseTexture;
  48829. /**
  48830. * Stores surface normal data used to displace a mesh in a texture.
  48831. */
  48832. bumpTexture: BaseTexture;
  48833. /**
  48834. * Stores the pre-calculated light information of a mesh in a texture.
  48835. */
  48836. lightmapTexture: BaseTexture;
  48837. /**
  48838. * Stores the refracted light information in a texture.
  48839. */
  48840. refractionTexture: Nullable<BaseTexture>;
  48841. /**
  48842. * The color of a material in ambient lighting.
  48843. */
  48844. ambientColor: Color3;
  48845. /**
  48846. * AKA Diffuse Color in other nomenclature.
  48847. */
  48848. albedoColor: Color3;
  48849. /**
  48850. * AKA Specular Color in other nomenclature.
  48851. */
  48852. reflectivityColor: Color3;
  48853. /**
  48854. * The color reflected from the material.
  48855. */
  48856. reflectionColor: Color3;
  48857. /**
  48858. * The color emitted from the material.
  48859. */
  48860. emissiveColor: Color3;
  48861. /**
  48862. * AKA Glossiness in other nomenclature.
  48863. */
  48864. microSurface: number;
  48865. /**
  48866. * source material index of refraction (IOR)' / 'destination material IOR.
  48867. */
  48868. indexOfRefraction: number;
  48869. /**
  48870. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48871. */
  48872. invertRefractionY: boolean;
  48873. /**
  48874. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48875. * Materials half opaque for instance using refraction could benefit from this control.
  48876. */
  48877. linkRefractionWithTransparency: boolean;
  48878. /**
  48879. * If true, the light map contains occlusion information instead of lighting info.
  48880. */
  48881. useLightmapAsShadowmap: boolean;
  48882. /**
  48883. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48884. */
  48885. useAlphaFromAlbedoTexture: boolean;
  48886. /**
  48887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48888. */
  48889. forceAlphaTest: boolean;
  48890. /**
  48891. * Defines the alpha limits in alpha test mode.
  48892. */
  48893. alphaCutOff: number;
  48894. /**
  48895. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48896. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48897. */
  48898. useSpecularOverAlpha: boolean;
  48899. /**
  48900. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48901. */
  48902. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48903. /**
  48904. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48905. */
  48906. useRoughnessFromMetallicTextureAlpha: boolean;
  48907. /**
  48908. * Specifies if the metallic texture contains the roughness information in its green channel.
  48909. */
  48910. useRoughnessFromMetallicTextureGreen: boolean;
  48911. /**
  48912. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48913. */
  48914. useMetallnessFromMetallicTextureBlue: boolean;
  48915. /**
  48916. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48917. */
  48918. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48919. /**
  48920. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48921. */
  48922. useAmbientInGrayScale: boolean;
  48923. /**
  48924. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48925. * The material will try to infer what glossiness each pixel should be.
  48926. */
  48927. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48928. /**
  48929. * BJS is using an harcoded light falloff based on a manually sets up range.
  48930. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48931. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48932. */
  48933. /**
  48934. * BJS is using an harcoded light falloff based on a manually sets up range.
  48935. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48936. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48937. */
  48938. usePhysicalLightFalloff: boolean;
  48939. /**
  48940. * In order to support the falloff compatibility with gltf, a special mode has been added
  48941. * to reproduce the gltf light falloff.
  48942. */
  48943. /**
  48944. * In order to support the falloff compatibility with gltf, a special mode has been added
  48945. * to reproduce the gltf light falloff.
  48946. */
  48947. useGLTFLightFalloff: boolean;
  48948. /**
  48949. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48950. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48951. */
  48952. useRadianceOverAlpha: boolean;
  48953. /**
  48954. * Allows using an object space normal map (instead of tangent space).
  48955. */
  48956. useObjectSpaceNormalMap: boolean;
  48957. /**
  48958. * Allows using the bump map in parallax mode.
  48959. */
  48960. useParallax: boolean;
  48961. /**
  48962. * Allows using the bump map in parallax occlusion mode.
  48963. */
  48964. useParallaxOcclusion: boolean;
  48965. /**
  48966. * Controls the scale bias of the parallax mode.
  48967. */
  48968. parallaxScaleBias: number;
  48969. /**
  48970. * If sets to true, disables all the lights affecting the material.
  48971. */
  48972. disableLighting: boolean;
  48973. /**
  48974. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48975. */
  48976. forceIrradianceInFragment: boolean;
  48977. /**
  48978. * Number of Simultaneous lights allowed on the material.
  48979. */
  48980. maxSimultaneousLights: number;
  48981. /**
  48982. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48983. */
  48984. invertNormalMapX: boolean;
  48985. /**
  48986. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48987. */
  48988. invertNormalMapY: boolean;
  48989. /**
  48990. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48991. */
  48992. twoSidedLighting: boolean;
  48993. /**
  48994. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48995. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48996. */
  48997. useAlphaFresnel: boolean;
  48998. /**
  48999. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49000. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49001. */
  49002. useLinearAlphaFresnel: boolean;
  49003. /**
  49004. * Let user defines the brdf lookup texture used for IBL.
  49005. * A default 8bit version is embedded but you could point at :
  49006. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49007. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49008. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49009. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49010. */
  49011. environmentBRDFTexture: Nullable<BaseTexture>;
  49012. /**
  49013. * Force normal to face away from face.
  49014. */
  49015. forceNormalForward: boolean;
  49016. /**
  49017. * Enables specular anti aliasing in the PBR shader.
  49018. * It will both interacts on the Geometry for analytical and IBL lighting.
  49019. * It also prefilter the roughness map based on the bump values.
  49020. */
  49021. enableSpecularAntiAliasing: boolean;
  49022. /**
  49023. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49024. * makes the reflect vector face the model (under horizon).
  49025. */
  49026. useHorizonOcclusion: boolean;
  49027. /**
  49028. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49029. * too much the area relying on ambient texture to define their ambient occlusion.
  49030. */
  49031. useRadianceOcclusion: boolean;
  49032. /**
  49033. * If set to true, no lighting calculations will be applied.
  49034. */
  49035. unlit: boolean;
  49036. /**
  49037. * Gets the image processing configuration used either in this material.
  49038. */
  49039. /**
  49040. * Sets the Default image processing configuration used either in the this material.
  49041. *
  49042. * If sets to null, the scene one is in use.
  49043. */
  49044. imageProcessingConfiguration: ImageProcessingConfiguration;
  49045. /**
  49046. * Gets wether the color curves effect is enabled.
  49047. */
  49048. /**
  49049. * Sets wether the color curves effect is enabled.
  49050. */
  49051. cameraColorCurvesEnabled: boolean;
  49052. /**
  49053. * Gets wether the color grading effect is enabled.
  49054. */
  49055. /**
  49056. * Gets wether the color grading effect is enabled.
  49057. */
  49058. cameraColorGradingEnabled: boolean;
  49059. /**
  49060. * Gets wether tonemapping is enabled or not.
  49061. */
  49062. /**
  49063. * Sets wether tonemapping is enabled or not
  49064. */
  49065. cameraToneMappingEnabled: boolean;
  49066. /**
  49067. * The camera exposure used on this material.
  49068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49069. * This corresponds to a photographic exposure.
  49070. */
  49071. /**
  49072. * The camera exposure used on this material.
  49073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49074. * This corresponds to a photographic exposure.
  49075. */
  49076. cameraExposure: number;
  49077. /**
  49078. * Gets The camera contrast used on this material.
  49079. */
  49080. /**
  49081. * Sets The camera contrast used on this material.
  49082. */
  49083. cameraContrast: number;
  49084. /**
  49085. * Gets the Color Grading 2D Lookup Texture.
  49086. */
  49087. /**
  49088. * Sets the Color Grading 2D Lookup Texture.
  49089. */
  49090. cameraColorGradingTexture: Nullable<BaseTexture>;
  49091. /**
  49092. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49093. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49094. * 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;
  49095. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49096. */
  49097. /**
  49098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49100. * 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;
  49101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49102. */
  49103. cameraColorCurves: Nullable<ColorCurves>;
  49104. /**
  49105. * Instantiates a new PBRMaterial instance.
  49106. *
  49107. * @param name The material name
  49108. * @param scene The scene the material will be use in.
  49109. */
  49110. constructor(name: string, scene: Scene);
  49111. /**
  49112. * Returns the name of this material class.
  49113. */
  49114. getClassName(): string;
  49115. /**
  49116. * Makes a duplicate of the current material.
  49117. * @param name - name to use for the new material.
  49118. */
  49119. clone(name: string): PBRMaterial;
  49120. /**
  49121. * Serializes this PBR Material.
  49122. * @returns - An object with the serialized material.
  49123. */
  49124. serialize(): any;
  49125. /**
  49126. * Parses a PBR Material from a serialized object.
  49127. * @param source - Serialized object.
  49128. * @param scene - BJS scene instance.
  49129. * @param rootUrl - url for the scene object
  49130. * @returns - PBRMaterial
  49131. */
  49132. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49133. }
  49134. }
  49135. declare module BABYLON {
  49136. /**
  49137. * Direct draw surface info
  49138. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49139. */
  49140. export interface DDSInfo {
  49141. /**
  49142. * Width of the texture
  49143. */
  49144. width: number;
  49145. /**
  49146. * Width of the texture
  49147. */
  49148. height: number;
  49149. /**
  49150. * Number of Mipmaps for the texture
  49151. * @see https://en.wikipedia.org/wiki/Mipmap
  49152. */
  49153. mipmapCount: number;
  49154. /**
  49155. * If the textures format is a known fourCC format
  49156. * @see https://www.fourcc.org/
  49157. */
  49158. isFourCC: boolean;
  49159. /**
  49160. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49161. */
  49162. isRGB: boolean;
  49163. /**
  49164. * If the texture is a lumincance format
  49165. */
  49166. isLuminance: boolean;
  49167. /**
  49168. * If this is a cube texture
  49169. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49170. */
  49171. isCube: boolean;
  49172. /**
  49173. * If the texture is a compressed format eg. FOURCC_DXT1
  49174. */
  49175. isCompressed: boolean;
  49176. /**
  49177. * The dxgiFormat of the texture
  49178. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49179. */
  49180. dxgiFormat: number;
  49181. /**
  49182. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49183. */
  49184. textureType: number;
  49185. /**
  49186. * Sphericle polynomial created for the dds texture
  49187. */
  49188. sphericalPolynomial?: SphericalPolynomial;
  49189. }
  49190. /**
  49191. * Class used to provide DDS decompression tools
  49192. */
  49193. export class DDSTools {
  49194. /**
  49195. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49196. */
  49197. static StoreLODInAlphaChannel: boolean;
  49198. /**
  49199. * Gets DDS information from an array buffer
  49200. * @param arrayBuffer defines the array buffer to read data from
  49201. * @returns the DDS information
  49202. */
  49203. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49204. private static _FloatView;
  49205. private static _Int32View;
  49206. private static _ToHalfFloat;
  49207. private static _FromHalfFloat;
  49208. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49209. private static _GetHalfFloatRGBAArrayBuffer;
  49210. private static _GetFloatRGBAArrayBuffer;
  49211. private static _GetFloatAsUIntRGBAArrayBuffer;
  49212. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49213. private static _GetRGBAArrayBuffer;
  49214. private static _ExtractLongWordOrder;
  49215. private static _GetRGBArrayBuffer;
  49216. private static _GetLuminanceArrayBuffer;
  49217. /**
  49218. * Uploads DDS Levels to a Babylon Texture
  49219. * @hidden
  49220. */
  49221. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49222. }
  49223. interface ThinEngine {
  49224. /**
  49225. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49226. * @param rootUrl defines the url where the file to load is located
  49227. * @param scene defines the current scene
  49228. * @param lodScale defines scale to apply to the mip map selection
  49229. * @param lodOffset defines offset to apply to the mip map selection
  49230. * @param onLoad defines an optional callback raised when the texture is loaded
  49231. * @param onError defines an optional callback raised if there is an issue to load the texture
  49232. * @param format defines the format of the data
  49233. * @param forcedExtension defines the extension to use to pick the right loader
  49234. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49235. * @returns the cube texture as an InternalTexture
  49236. */
  49237. 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;
  49238. }
  49239. }
  49240. declare module BABYLON {
  49241. /**
  49242. * Implementation of the DDS Texture Loader.
  49243. * @hidden
  49244. */
  49245. export class _DDSTextureLoader implements IInternalTextureLoader {
  49246. /**
  49247. * Defines wether the loader supports cascade loading the different faces.
  49248. */
  49249. readonly supportCascades: boolean;
  49250. /**
  49251. * This returns if the loader support the current file information.
  49252. * @param extension defines the file extension of the file being loaded
  49253. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49254. * @param fallback defines the fallback internal texture if any
  49255. * @param isBase64 defines whether the texture is encoded as a base64
  49256. * @param isBuffer defines whether the texture data are stored as a buffer
  49257. * @returns true if the loader can load the specified file
  49258. */
  49259. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49260. /**
  49261. * Transform the url before loading if required.
  49262. * @param rootUrl the url of the texture
  49263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49264. * @returns the transformed texture
  49265. */
  49266. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49267. /**
  49268. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49269. * @param rootUrl the url of the texture
  49270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49271. * @returns the fallback texture
  49272. */
  49273. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49274. /**
  49275. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49276. * @param data contains the texture data
  49277. * @param texture defines the BabylonJS internal texture
  49278. * @param createPolynomials will be true if polynomials have been requested
  49279. * @param onLoad defines the callback to trigger once the texture is ready
  49280. * @param onError defines the callback to trigger in case of error
  49281. */
  49282. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49283. /**
  49284. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49285. * @param data contains the texture data
  49286. * @param texture defines the BabylonJS internal texture
  49287. * @param callback defines the method to call once ready to upload
  49288. */
  49289. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49290. }
  49291. }
  49292. declare module BABYLON {
  49293. /**
  49294. * Implementation of the ENV Texture Loader.
  49295. * @hidden
  49296. */
  49297. export class _ENVTextureLoader implements IInternalTextureLoader {
  49298. /**
  49299. * Defines wether the loader supports cascade loading the different faces.
  49300. */
  49301. readonly supportCascades: boolean;
  49302. /**
  49303. * This returns if the loader support the current file information.
  49304. * @param extension defines the file extension of the file being loaded
  49305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49306. * @param fallback defines the fallback internal texture if any
  49307. * @param isBase64 defines whether the texture is encoded as a base64
  49308. * @param isBuffer defines whether the texture data are stored as a buffer
  49309. * @returns true if the loader can load the specified file
  49310. */
  49311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49312. /**
  49313. * Transform the url before loading if required.
  49314. * @param rootUrl the url of the texture
  49315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49316. * @returns the transformed texture
  49317. */
  49318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49319. /**
  49320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49321. * @param rootUrl the url of the texture
  49322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49323. * @returns the fallback texture
  49324. */
  49325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49326. /**
  49327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49328. * @param data contains the texture data
  49329. * @param texture defines the BabylonJS internal texture
  49330. * @param createPolynomials will be true if polynomials have been requested
  49331. * @param onLoad defines the callback to trigger once the texture is ready
  49332. * @param onError defines the callback to trigger in case of error
  49333. */
  49334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49335. /**
  49336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49337. * @param data contains the texture data
  49338. * @param texture defines the BabylonJS internal texture
  49339. * @param callback defines the method to call once ready to upload
  49340. */
  49341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49342. }
  49343. }
  49344. declare module BABYLON {
  49345. /**
  49346. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49347. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49348. */
  49349. export class KhronosTextureContainer {
  49350. /** contents of the KTX container file */
  49351. arrayBuffer: any;
  49352. private static HEADER_LEN;
  49353. private static COMPRESSED_2D;
  49354. private static COMPRESSED_3D;
  49355. private static TEX_2D;
  49356. private static TEX_3D;
  49357. /**
  49358. * Gets the openGL type
  49359. */
  49360. glType: number;
  49361. /**
  49362. * Gets the openGL type size
  49363. */
  49364. glTypeSize: number;
  49365. /**
  49366. * Gets the openGL format
  49367. */
  49368. glFormat: number;
  49369. /**
  49370. * Gets the openGL internal format
  49371. */
  49372. glInternalFormat: number;
  49373. /**
  49374. * Gets the base internal format
  49375. */
  49376. glBaseInternalFormat: number;
  49377. /**
  49378. * Gets image width in pixel
  49379. */
  49380. pixelWidth: number;
  49381. /**
  49382. * Gets image height in pixel
  49383. */
  49384. pixelHeight: number;
  49385. /**
  49386. * Gets image depth in pixels
  49387. */
  49388. pixelDepth: number;
  49389. /**
  49390. * Gets the number of array elements
  49391. */
  49392. numberOfArrayElements: number;
  49393. /**
  49394. * Gets the number of faces
  49395. */
  49396. numberOfFaces: number;
  49397. /**
  49398. * Gets the number of mipmap levels
  49399. */
  49400. numberOfMipmapLevels: number;
  49401. /**
  49402. * Gets the bytes of key value data
  49403. */
  49404. bytesOfKeyValueData: number;
  49405. /**
  49406. * Gets the load type
  49407. */
  49408. loadType: number;
  49409. /**
  49410. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49411. */
  49412. isInvalid: boolean;
  49413. /**
  49414. * Creates a new KhronosTextureContainer
  49415. * @param arrayBuffer contents of the KTX container file
  49416. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49417. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49418. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49419. */
  49420. constructor(
  49421. /** contents of the KTX container file */
  49422. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49423. /**
  49424. * Uploads KTX content to a Babylon Texture.
  49425. * It is assumed that the texture has already been created & is currently bound
  49426. * @hidden
  49427. */
  49428. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49429. private _upload2DCompressedLevels;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * Implementation of the KTX Texture Loader.
  49435. * @hidden
  49436. */
  49437. export class _KTXTextureLoader implements IInternalTextureLoader {
  49438. /**
  49439. * Defines wether the loader supports cascade loading the different faces.
  49440. */
  49441. readonly supportCascades: boolean;
  49442. /**
  49443. * This returns if the loader support the current file information.
  49444. * @param extension defines the file extension of the file being loaded
  49445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49446. * @param fallback defines the fallback internal texture if any
  49447. * @param isBase64 defines whether the texture is encoded as a base64
  49448. * @param isBuffer defines whether the texture data are stored as a buffer
  49449. * @returns true if the loader can load the specified file
  49450. */
  49451. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49452. /**
  49453. * Transform the url before loading if required.
  49454. * @param rootUrl the url of the texture
  49455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49456. * @returns the transformed texture
  49457. */
  49458. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49459. /**
  49460. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49461. * @param rootUrl the url of the texture
  49462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49463. * @returns the fallback texture
  49464. */
  49465. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49466. /**
  49467. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49468. * @param data contains the texture data
  49469. * @param texture defines the BabylonJS internal texture
  49470. * @param createPolynomials will be true if polynomials have been requested
  49471. * @param onLoad defines the callback to trigger once the texture is ready
  49472. * @param onError defines the callback to trigger in case of error
  49473. */
  49474. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49475. /**
  49476. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49477. * @param data contains the texture data
  49478. * @param texture defines the BabylonJS internal texture
  49479. * @param callback defines the method to call once ready to upload
  49480. */
  49481. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49482. }
  49483. }
  49484. declare module BABYLON {
  49485. /**
  49486. * Options for the default xr helper
  49487. */
  49488. export class WebXRDefaultExperienceOptions {
  49489. /**
  49490. * Floor meshes that should be used for teleporting
  49491. */
  49492. floorMeshes: Array<AbstractMesh>;
  49493. /**
  49494. * Enable or disable default UI to enter XR
  49495. */
  49496. disableDefaultUI: boolean;
  49497. }
  49498. /**
  49499. * Default experience which provides a similar setup to the previous webVRExperience
  49500. */
  49501. export class WebXRDefaultExperience {
  49502. /**
  49503. * Base experience
  49504. */
  49505. baseExperience: WebXRExperienceHelper;
  49506. /**
  49507. * Input experience extension
  49508. */
  49509. input: WebXRInput;
  49510. /**
  49511. * Loads the controller models
  49512. */
  49513. controllerModelLoader: WebXRControllerModelLoader;
  49514. /**
  49515. * Enables laser pointer and selection
  49516. */
  49517. pointerSelection: WebXRControllerPointerSelection;
  49518. /**
  49519. * Enables teleportation
  49520. */
  49521. teleportation: WebXRControllerTeleportation;
  49522. /**
  49523. * Enables ui for enetering/exiting xr
  49524. */
  49525. enterExitUI: WebXREnterExitUI;
  49526. /**
  49527. * Default target xr should render to
  49528. */
  49529. renderTarget: WebXRRenderTarget;
  49530. /**
  49531. * Creates the default xr experience
  49532. * @param scene scene
  49533. * @param options options for basic configuration
  49534. * @returns resulting WebXRDefaultExperience
  49535. */
  49536. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49537. private constructor();
  49538. /**
  49539. * DIsposes of the experience helper
  49540. */
  49541. dispose(): void;
  49542. }
  49543. }
  49544. declare module BABYLON {
  49545. /** @hidden */
  49546. export var _forceSceneHelpersToBundle: boolean;
  49547. interface Scene {
  49548. /**
  49549. * Creates a default light for the scene.
  49550. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49551. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49552. */
  49553. createDefaultLight(replace?: boolean): void;
  49554. /**
  49555. * Creates a default camera for the scene.
  49556. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49557. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49558. * @param replace has default false, when true replaces the active camera in the scene
  49559. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49560. */
  49561. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49562. /**
  49563. * Creates a default camera and a default light.
  49564. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49565. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49566. * @param replace has the default false, when true replaces the active camera/light in the scene
  49567. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49568. */
  49569. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49570. /**
  49571. * Creates a new sky box
  49572. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49573. * @param environmentTexture defines the texture to use as environment texture
  49574. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49575. * @param scale defines the overall scale of the skybox
  49576. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49577. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49578. * @returns a new mesh holding the sky box
  49579. */
  49580. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49581. /**
  49582. * Creates a new environment
  49583. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49584. * @param options defines the options you can use to configure the environment
  49585. * @returns the new EnvironmentHelper
  49586. */
  49587. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49588. /**
  49589. * Creates a new VREXperienceHelper
  49590. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49591. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49592. * @returns a new VREXperienceHelper
  49593. */
  49594. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49595. /**
  49596. * Creates a new WebXRDefaultExperience
  49597. * @see http://doc.babylonjs.com/how_to/webxr
  49598. * @param options experience options
  49599. * @returns a promise for a new WebXRDefaultExperience
  49600. */
  49601. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49607. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49608. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49609. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49610. */
  49611. export class VideoDome extends TransformNode {
  49612. /**
  49613. * Define the video source as a Monoscopic panoramic 360 video.
  49614. */
  49615. static readonly MODE_MONOSCOPIC: number;
  49616. /**
  49617. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49618. */
  49619. static readonly MODE_TOPBOTTOM: number;
  49620. /**
  49621. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49622. */
  49623. static readonly MODE_SIDEBYSIDE: number;
  49624. private _halfDome;
  49625. private _useDirectMapping;
  49626. /**
  49627. * The video texture being displayed on the sphere
  49628. */
  49629. protected _videoTexture: VideoTexture;
  49630. /**
  49631. * Gets the video texture being displayed on the sphere
  49632. */
  49633. readonly videoTexture: VideoTexture;
  49634. /**
  49635. * The skybox material
  49636. */
  49637. protected _material: BackgroundMaterial;
  49638. /**
  49639. * The surface used for the skybox
  49640. */
  49641. protected _mesh: Mesh;
  49642. /**
  49643. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49644. */
  49645. private _halfDomeMask;
  49646. /**
  49647. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49648. * Also see the options.resolution property.
  49649. */
  49650. fovMultiplier: number;
  49651. private _videoMode;
  49652. /**
  49653. * Gets or set the current video mode for the video. It can be:
  49654. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49655. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49656. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49657. */
  49658. videoMode: number;
  49659. /**
  49660. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49661. *
  49662. */
  49663. /**
  49664. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49665. */
  49666. halfDome: boolean;
  49667. /**
  49668. * Oberserver used in Stereoscopic VR Mode.
  49669. */
  49670. private _onBeforeCameraRenderObserver;
  49671. /**
  49672. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49673. * @param name Element's name, child elements will append suffixes for their own names.
  49674. * @param urlsOrVideo defines the url(s) or the video element to use
  49675. * @param options An object containing optional or exposed sub element properties
  49676. */
  49677. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49678. resolution?: number;
  49679. clickToPlay?: boolean;
  49680. autoPlay?: boolean;
  49681. loop?: boolean;
  49682. size?: number;
  49683. poster?: string;
  49684. faceForward?: boolean;
  49685. useDirectMapping?: boolean;
  49686. halfDomeMode?: boolean;
  49687. }, scene: Scene);
  49688. private _changeVideoMode;
  49689. /**
  49690. * Releases resources associated with this node.
  49691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49693. */
  49694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49695. }
  49696. }
  49697. declare module BABYLON {
  49698. /**
  49699. * This class can be used to get instrumentation data from a Babylon engine
  49700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49701. */
  49702. export class EngineInstrumentation implements IDisposable {
  49703. /**
  49704. * Define the instrumented engine.
  49705. */
  49706. engine: Engine;
  49707. private _captureGPUFrameTime;
  49708. private _gpuFrameTimeToken;
  49709. private _gpuFrameTime;
  49710. private _captureShaderCompilationTime;
  49711. private _shaderCompilationTime;
  49712. private _onBeginFrameObserver;
  49713. private _onEndFrameObserver;
  49714. private _onBeforeShaderCompilationObserver;
  49715. private _onAfterShaderCompilationObserver;
  49716. /**
  49717. * Gets the perf counter used for GPU frame time
  49718. */
  49719. readonly gpuFrameTimeCounter: PerfCounter;
  49720. /**
  49721. * Gets the GPU frame time capture status
  49722. */
  49723. /**
  49724. * Enable or disable the GPU frame time capture
  49725. */
  49726. captureGPUFrameTime: boolean;
  49727. /**
  49728. * Gets the perf counter used for shader compilation time
  49729. */
  49730. readonly shaderCompilationTimeCounter: PerfCounter;
  49731. /**
  49732. * Gets the shader compilation time capture status
  49733. */
  49734. /**
  49735. * Enable or disable the shader compilation time capture
  49736. */
  49737. captureShaderCompilationTime: boolean;
  49738. /**
  49739. * Instantiates a new engine instrumentation.
  49740. * This class can be used to get instrumentation data from a Babylon engine
  49741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49742. * @param engine Defines the engine to instrument
  49743. */
  49744. constructor(
  49745. /**
  49746. * Define the instrumented engine.
  49747. */
  49748. engine: Engine);
  49749. /**
  49750. * Dispose and release associated resources.
  49751. */
  49752. dispose(): void;
  49753. }
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * This class can be used to get instrumentation data from a Babylon engine
  49758. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49759. */
  49760. export class SceneInstrumentation implements IDisposable {
  49761. /**
  49762. * Defines the scene to instrument
  49763. */
  49764. scene: Scene;
  49765. private _captureActiveMeshesEvaluationTime;
  49766. private _activeMeshesEvaluationTime;
  49767. private _captureRenderTargetsRenderTime;
  49768. private _renderTargetsRenderTime;
  49769. private _captureFrameTime;
  49770. private _frameTime;
  49771. private _captureRenderTime;
  49772. private _renderTime;
  49773. private _captureInterFrameTime;
  49774. private _interFrameTime;
  49775. private _captureParticlesRenderTime;
  49776. private _particlesRenderTime;
  49777. private _captureSpritesRenderTime;
  49778. private _spritesRenderTime;
  49779. private _capturePhysicsTime;
  49780. private _physicsTime;
  49781. private _captureAnimationsTime;
  49782. private _animationsTime;
  49783. private _captureCameraRenderTime;
  49784. private _cameraRenderTime;
  49785. private _onBeforeActiveMeshesEvaluationObserver;
  49786. private _onAfterActiveMeshesEvaluationObserver;
  49787. private _onBeforeRenderTargetsRenderObserver;
  49788. private _onAfterRenderTargetsRenderObserver;
  49789. private _onAfterRenderObserver;
  49790. private _onBeforeDrawPhaseObserver;
  49791. private _onAfterDrawPhaseObserver;
  49792. private _onBeforeAnimationsObserver;
  49793. private _onBeforeParticlesRenderingObserver;
  49794. private _onAfterParticlesRenderingObserver;
  49795. private _onBeforeSpritesRenderingObserver;
  49796. private _onAfterSpritesRenderingObserver;
  49797. private _onBeforePhysicsObserver;
  49798. private _onAfterPhysicsObserver;
  49799. private _onAfterAnimationsObserver;
  49800. private _onBeforeCameraRenderObserver;
  49801. private _onAfterCameraRenderObserver;
  49802. /**
  49803. * Gets the perf counter used for active meshes evaluation time
  49804. */
  49805. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49806. /**
  49807. * Gets the active meshes evaluation time capture status
  49808. */
  49809. /**
  49810. * Enable or disable the active meshes evaluation time capture
  49811. */
  49812. captureActiveMeshesEvaluationTime: boolean;
  49813. /**
  49814. * Gets the perf counter used for render targets render time
  49815. */
  49816. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49817. /**
  49818. * Gets the render targets render time capture status
  49819. */
  49820. /**
  49821. * Enable or disable the render targets render time capture
  49822. */
  49823. captureRenderTargetsRenderTime: boolean;
  49824. /**
  49825. * Gets the perf counter used for particles render time
  49826. */
  49827. readonly particlesRenderTimeCounter: PerfCounter;
  49828. /**
  49829. * Gets the particles render time capture status
  49830. */
  49831. /**
  49832. * Enable or disable the particles render time capture
  49833. */
  49834. captureParticlesRenderTime: boolean;
  49835. /**
  49836. * Gets the perf counter used for sprites render time
  49837. */
  49838. readonly spritesRenderTimeCounter: PerfCounter;
  49839. /**
  49840. * Gets the sprites render time capture status
  49841. */
  49842. /**
  49843. * Enable or disable the sprites render time capture
  49844. */
  49845. captureSpritesRenderTime: boolean;
  49846. /**
  49847. * Gets the perf counter used for physics time
  49848. */
  49849. readonly physicsTimeCounter: PerfCounter;
  49850. /**
  49851. * Gets the physics time capture status
  49852. */
  49853. /**
  49854. * Enable or disable the physics time capture
  49855. */
  49856. capturePhysicsTime: boolean;
  49857. /**
  49858. * Gets the perf counter used for animations time
  49859. */
  49860. readonly animationsTimeCounter: PerfCounter;
  49861. /**
  49862. * Gets the animations time capture status
  49863. */
  49864. /**
  49865. * Enable or disable the animations time capture
  49866. */
  49867. captureAnimationsTime: boolean;
  49868. /**
  49869. * Gets the perf counter used for frame time capture
  49870. */
  49871. readonly frameTimeCounter: PerfCounter;
  49872. /**
  49873. * Gets the frame time capture status
  49874. */
  49875. /**
  49876. * Enable or disable the frame time capture
  49877. */
  49878. captureFrameTime: boolean;
  49879. /**
  49880. * Gets the perf counter used for inter-frames time capture
  49881. */
  49882. readonly interFrameTimeCounter: PerfCounter;
  49883. /**
  49884. * Gets the inter-frames time capture status
  49885. */
  49886. /**
  49887. * Enable or disable the inter-frames time capture
  49888. */
  49889. captureInterFrameTime: boolean;
  49890. /**
  49891. * Gets the perf counter used for render time capture
  49892. */
  49893. readonly renderTimeCounter: PerfCounter;
  49894. /**
  49895. * Gets the render time capture status
  49896. */
  49897. /**
  49898. * Enable or disable the render time capture
  49899. */
  49900. captureRenderTime: boolean;
  49901. /**
  49902. * Gets the perf counter used for camera render time capture
  49903. */
  49904. readonly cameraRenderTimeCounter: PerfCounter;
  49905. /**
  49906. * Gets the camera render time capture status
  49907. */
  49908. /**
  49909. * Enable or disable the camera render time capture
  49910. */
  49911. captureCameraRenderTime: boolean;
  49912. /**
  49913. * Gets the perf counter used for draw calls
  49914. */
  49915. readonly drawCallsCounter: PerfCounter;
  49916. /**
  49917. * Instantiates a new scene instrumentation.
  49918. * This class can be used to get instrumentation data from a Babylon engine
  49919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49920. * @param scene Defines the scene to instrument
  49921. */
  49922. constructor(
  49923. /**
  49924. * Defines the scene to instrument
  49925. */
  49926. scene: Scene);
  49927. /**
  49928. * Dispose and release associated resources.
  49929. */
  49930. dispose(): void;
  49931. }
  49932. }
  49933. declare module BABYLON {
  49934. /** @hidden */
  49935. export var glowMapGenerationPixelShader: {
  49936. name: string;
  49937. shader: string;
  49938. };
  49939. }
  49940. declare module BABYLON {
  49941. /** @hidden */
  49942. export var glowMapGenerationVertexShader: {
  49943. name: string;
  49944. shader: string;
  49945. };
  49946. }
  49947. declare module BABYLON {
  49948. /**
  49949. * Effect layer options. This helps customizing the behaviour
  49950. * of the effect layer.
  49951. */
  49952. export interface IEffectLayerOptions {
  49953. /**
  49954. * Multiplication factor apply to the canvas size to compute the render target size
  49955. * used to generated the objects (the smaller the faster).
  49956. */
  49957. mainTextureRatio: number;
  49958. /**
  49959. * Enforces a fixed size texture to ensure effect stability across devices.
  49960. */
  49961. mainTextureFixedSize?: number;
  49962. /**
  49963. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49964. */
  49965. alphaBlendingMode: number;
  49966. /**
  49967. * The camera attached to the layer.
  49968. */
  49969. camera: Nullable<Camera>;
  49970. /**
  49971. * The rendering group to draw the layer in.
  49972. */
  49973. renderingGroupId: number;
  49974. }
  49975. /**
  49976. * The effect layer Helps adding post process effect blended with the main pass.
  49977. *
  49978. * This can be for instance use to generate glow or higlight effects on the scene.
  49979. *
  49980. * The effect layer class can not be used directly and is intented to inherited from to be
  49981. * customized per effects.
  49982. */
  49983. export abstract class EffectLayer {
  49984. private _vertexBuffers;
  49985. private _indexBuffer;
  49986. private _cachedDefines;
  49987. private _effectLayerMapGenerationEffect;
  49988. private _effectLayerOptions;
  49989. private _mergeEffect;
  49990. protected _scene: Scene;
  49991. protected _engine: Engine;
  49992. protected _maxSize: number;
  49993. protected _mainTextureDesiredSize: ISize;
  49994. protected _mainTexture: RenderTargetTexture;
  49995. protected _shouldRender: boolean;
  49996. protected _postProcesses: PostProcess[];
  49997. protected _textures: BaseTexture[];
  49998. protected _emissiveTextureAndColor: {
  49999. texture: Nullable<BaseTexture>;
  50000. color: Color4;
  50001. };
  50002. /**
  50003. * The name of the layer
  50004. */
  50005. name: string;
  50006. /**
  50007. * The clear color of the texture used to generate the glow map.
  50008. */
  50009. neutralColor: Color4;
  50010. /**
  50011. * Specifies wether the highlight layer is enabled or not.
  50012. */
  50013. isEnabled: boolean;
  50014. /**
  50015. * Gets the camera attached to the layer.
  50016. */
  50017. readonly camera: Nullable<Camera>;
  50018. /**
  50019. * Gets the rendering group id the layer should render in.
  50020. */
  50021. renderingGroupId: number;
  50022. /**
  50023. * An event triggered when the effect layer has been disposed.
  50024. */
  50025. onDisposeObservable: Observable<EffectLayer>;
  50026. /**
  50027. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50028. */
  50029. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50030. /**
  50031. * An event triggered when the generated texture is being merged in the scene.
  50032. */
  50033. onBeforeComposeObservable: Observable<EffectLayer>;
  50034. /**
  50035. * An event triggered when the mesh is rendered into the effect render target.
  50036. */
  50037. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50038. /**
  50039. * An event triggered after the mesh has been rendered into the effect render target.
  50040. */
  50041. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50042. /**
  50043. * An event triggered when the generated texture has been merged in the scene.
  50044. */
  50045. onAfterComposeObservable: Observable<EffectLayer>;
  50046. /**
  50047. * An event triggered when the efffect layer changes its size.
  50048. */
  50049. onSizeChangedObservable: Observable<EffectLayer>;
  50050. /** @hidden */
  50051. static _SceneComponentInitialization: (scene: Scene) => void;
  50052. /**
  50053. * Instantiates a new effect Layer and references it in the scene.
  50054. * @param name The name of the layer
  50055. * @param scene The scene to use the layer in
  50056. */
  50057. constructor(
  50058. /** The Friendly of the effect in the scene */
  50059. name: string, scene: Scene);
  50060. /**
  50061. * Get the effect name of the layer.
  50062. * @return The effect name
  50063. */
  50064. abstract getEffectName(): string;
  50065. /**
  50066. * Checks for the readiness of the element composing the layer.
  50067. * @param subMesh the mesh to check for
  50068. * @param useInstances specify wether or not to use instances to render the mesh
  50069. * @return true if ready otherwise, false
  50070. */
  50071. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50072. /**
  50073. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50074. * @returns true if the effect requires stencil during the main canvas render pass.
  50075. */
  50076. abstract needStencil(): boolean;
  50077. /**
  50078. * Create the merge effect. This is the shader use to blit the information back
  50079. * to the main canvas at the end of the scene rendering.
  50080. * @returns The effect containing the shader used to merge the effect on the main canvas
  50081. */
  50082. protected abstract _createMergeEffect(): Effect;
  50083. /**
  50084. * Creates the render target textures and post processes used in the effect layer.
  50085. */
  50086. protected abstract _createTextureAndPostProcesses(): void;
  50087. /**
  50088. * Implementation specific of rendering the generating effect on the main canvas.
  50089. * @param effect The effect used to render through
  50090. */
  50091. protected abstract _internalRender(effect: Effect): void;
  50092. /**
  50093. * Sets the required values for both the emissive texture and and the main color.
  50094. */
  50095. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50096. /**
  50097. * Free any resources and references associated to a mesh.
  50098. * Internal use
  50099. * @param mesh The mesh to free.
  50100. */
  50101. abstract _disposeMesh(mesh: Mesh): void;
  50102. /**
  50103. * Serializes this layer (Glow or Highlight for example)
  50104. * @returns a serialized layer object
  50105. */
  50106. abstract serialize?(): any;
  50107. /**
  50108. * Initializes the effect layer with the required options.
  50109. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50110. */
  50111. protected _init(options: Partial<IEffectLayerOptions>): void;
  50112. /**
  50113. * Generates the index buffer of the full screen quad blending to the main canvas.
  50114. */
  50115. private _generateIndexBuffer;
  50116. /**
  50117. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50118. */
  50119. private _generateVertexBuffer;
  50120. /**
  50121. * Sets the main texture desired size which is the closest power of two
  50122. * of the engine canvas size.
  50123. */
  50124. private _setMainTextureSize;
  50125. /**
  50126. * Creates the main texture for the effect layer.
  50127. */
  50128. protected _createMainTexture(): void;
  50129. /**
  50130. * Adds specific effects defines.
  50131. * @param defines The defines to add specifics to.
  50132. */
  50133. protected _addCustomEffectDefines(defines: string[]): void;
  50134. /**
  50135. * Checks for the readiness of the element composing the layer.
  50136. * @param subMesh the mesh to check for
  50137. * @param useInstances specify wether or not to use instances to render the mesh
  50138. * @param emissiveTexture the associated emissive texture used to generate the glow
  50139. * @return true if ready otherwise, false
  50140. */
  50141. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50142. /**
  50143. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50144. */
  50145. render(): void;
  50146. /**
  50147. * Determine if a given mesh will be used in the current effect.
  50148. * @param mesh mesh to test
  50149. * @returns true if the mesh will be used
  50150. */
  50151. hasMesh(mesh: AbstractMesh): boolean;
  50152. /**
  50153. * Returns true if the layer contains information to display, otherwise false.
  50154. * @returns true if the glow layer should be rendered
  50155. */
  50156. shouldRender(): boolean;
  50157. /**
  50158. * Returns true if the mesh should render, otherwise false.
  50159. * @param mesh The mesh to render
  50160. * @returns true if it should render otherwise false
  50161. */
  50162. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50163. /**
  50164. * Returns true if the mesh can be rendered, otherwise false.
  50165. * @param mesh The mesh to render
  50166. * @param material The material used on the mesh
  50167. * @returns true if it can be rendered otherwise false
  50168. */
  50169. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50170. /**
  50171. * Returns true if the mesh should render, otherwise false.
  50172. * @param mesh The mesh to render
  50173. * @returns true if it should render otherwise false
  50174. */
  50175. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50176. /**
  50177. * Renders the submesh passed in parameter to the generation map.
  50178. */
  50179. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50180. /**
  50181. * Defines wether the current material of the mesh should be use to render the effect.
  50182. * @param mesh defines the current mesh to render
  50183. */
  50184. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50185. /**
  50186. * Rebuild the required buffers.
  50187. * @hidden Internal use only.
  50188. */
  50189. _rebuild(): void;
  50190. /**
  50191. * Dispose only the render target textures and post process.
  50192. */
  50193. private _disposeTextureAndPostProcesses;
  50194. /**
  50195. * Dispose the highlight layer and free resources.
  50196. */
  50197. dispose(): void;
  50198. /**
  50199. * Gets the class name of the effect layer
  50200. * @returns the string with the class name of the effect layer
  50201. */
  50202. getClassName(): string;
  50203. /**
  50204. * Creates an effect layer from parsed effect layer data
  50205. * @param parsedEffectLayer defines effect layer data
  50206. * @param scene defines the current scene
  50207. * @param rootUrl defines the root URL containing the effect layer information
  50208. * @returns a parsed effect Layer
  50209. */
  50210. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50211. }
  50212. }
  50213. declare module BABYLON {
  50214. interface AbstractScene {
  50215. /**
  50216. * The list of effect layers (highlights/glow) added to the scene
  50217. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50218. * @see http://doc.babylonjs.com/how_to/glow_layer
  50219. */
  50220. effectLayers: Array<EffectLayer>;
  50221. /**
  50222. * Removes the given effect layer from this scene.
  50223. * @param toRemove defines the effect layer to remove
  50224. * @returns the index of the removed effect layer
  50225. */
  50226. removeEffectLayer(toRemove: EffectLayer): number;
  50227. /**
  50228. * Adds the given effect layer to this scene
  50229. * @param newEffectLayer defines the effect layer to add
  50230. */
  50231. addEffectLayer(newEffectLayer: EffectLayer): void;
  50232. }
  50233. /**
  50234. * Defines the layer scene component responsible to manage any effect layers
  50235. * in a given scene.
  50236. */
  50237. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50238. /**
  50239. * The component name helpfull to identify the component in the list of scene components.
  50240. */
  50241. readonly name: string;
  50242. /**
  50243. * The scene the component belongs to.
  50244. */
  50245. scene: Scene;
  50246. private _engine;
  50247. private _renderEffects;
  50248. private _needStencil;
  50249. private _previousStencilState;
  50250. /**
  50251. * Creates a new instance of the component for the given scene
  50252. * @param scene Defines the scene to register the component in
  50253. */
  50254. constructor(scene: Scene);
  50255. /**
  50256. * Registers the component in a given scene
  50257. */
  50258. register(): void;
  50259. /**
  50260. * Rebuilds the elements related to this component in case of
  50261. * context lost for instance.
  50262. */
  50263. rebuild(): void;
  50264. /**
  50265. * Serializes the component data to the specified json object
  50266. * @param serializationObject The object to serialize to
  50267. */
  50268. serialize(serializationObject: any): void;
  50269. /**
  50270. * Adds all the elements from the container to the scene
  50271. * @param container the container holding the elements
  50272. */
  50273. addFromContainer(container: AbstractScene): void;
  50274. /**
  50275. * Removes all the elements in the container from the scene
  50276. * @param container contains the elements to remove
  50277. * @param dispose if the removed element should be disposed (default: false)
  50278. */
  50279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50280. /**
  50281. * Disposes the component and the associated ressources.
  50282. */
  50283. dispose(): void;
  50284. private _isReadyForMesh;
  50285. private _renderMainTexture;
  50286. private _setStencil;
  50287. private _setStencilBack;
  50288. private _draw;
  50289. private _drawCamera;
  50290. private _drawRenderingGroup;
  50291. }
  50292. }
  50293. declare module BABYLON {
  50294. /** @hidden */
  50295. export var glowMapMergePixelShader: {
  50296. name: string;
  50297. shader: string;
  50298. };
  50299. }
  50300. declare module BABYLON {
  50301. /** @hidden */
  50302. export var glowMapMergeVertexShader: {
  50303. name: string;
  50304. shader: string;
  50305. };
  50306. }
  50307. declare module BABYLON {
  50308. interface AbstractScene {
  50309. /**
  50310. * Return a the first highlight layer of the scene with a given name.
  50311. * @param name The name of the highlight layer to look for.
  50312. * @return The highlight layer if found otherwise null.
  50313. */
  50314. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50315. }
  50316. /**
  50317. * Glow layer options. This helps customizing the behaviour
  50318. * of the glow layer.
  50319. */
  50320. export interface IGlowLayerOptions {
  50321. /**
  50322. * Multiplication factor apply to the canvas size to compute the render target size
  50323. * used to generated the glowing objects (the smaller the faster).
  50324. */
  50325. mainTextureRatio: number;
  50326. /**
  50327. * Enforces a fixed size texture to ensure resize independant blur.
  50328. */
  50329. mainTextureFixedSize?: number;
  50330. /**
  50331. * How big is the kernel of the blur texture.
  50332. */
  50333. blurKernelSize: number;
  50334. /**
  50335. * The camera attached to the layer.
  50336. */
  50337. camera: Nullable<Camera>;
  50338. /**
  50339. * Enable MSAA by chosing the number of samples.
  50340. */
  50341. mainTextureSamples?: number;
  50342. /**
  50343. * The rendering group to draw the layer in.
  50344. */
  50345. renderingGroupId: number;
  50346. }
  50347. /**
  50348. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50349. *
  50350. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50351. *
  50352. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50353. */
  50354. export class GlowLayer extends EffectLayer {
  50355. /**
  50356. * Effect Name of the layer.
  50357. */
  50358. static readonly EffectName: string;
  50359. /**
  50360. * The default blur kernel size used for the glow.
  50361. */
  50362. static DefaultBlurKernelSize: number;
  50363. /**
  50364. * The default texture size ratio used for the glow.
  50365. */
  50366. static DefaultTextureRatio: number;
  50367. /**
  50368. * Sets the kernel size of the blur.
  50369. */
  50370. /**
  50371. * Gets the kernel size of the blur.
  50372. */
  50373. blurKernelSize: number;
  50374. /**
  50375. * Sets the glow intensity.
  50376. */
  50377. /**
  50378. * Gets the glow intensity.
  50379. */
  50380. intensity: number;
  50381. private _options;
  50382. private _intensity;
  50383. private _horizontalBlurPostprocess1;
  50384. private _verticalBlurPostprocess1;
  50385. private _horizontalBlurPostprocess2;
  50386. private _verticalBlurPostprocess2;
  50387. private _blurTexture1;
  50388. private _blurTexture2;
  50389. private _postProcesses1;
  50390. private _postProcesses2;
  50391. private _includedOnlyMeshes;
  50392. private _excludedMeshes;
  50393. private _meshesUsingTheirOwnMaterials;
  50394. /**
  50395. * Callback used to let the user override the color selection on a per mesh basis
  50396. */
  50397. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50398. /**
  50399. * Callback used to let the user override the texture selection on a per mesh basis
  50400. */
  50401. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50402. /**
  50403. * Instantiates a new glow Layer and references it to the scene.
  50404. * @param name The name of the layer
  50405. * @param scene The scene to use the layer in
  50406. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50407. */
  50408. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50409. /**
  50410. * Get the effect name of the layer.
  50411. * @return The effect name
  50412. */
  50413. getEffectName(): string;
  50414. /**
  50415. * Create the merge effect. This is the shader use to blit the information back
  50416. * to the main canvas at the end of the scene rendering.
  50417. */
  50418. protected _createMergeEffect(): Effect;
  50419. /**
  50420. * Creates the render target textures and post processes used in the glow layer.
  50421. */
  50422. protected _createTextureAndPostProcesses(): void;
  50423. /**
  50424. * Checks for the readiness of the element composing the layer.
  50425. * @param subMesh the mesh to check for
  50426. * @param useInstances specify wether or not to use instances to render the mesh
  50427. * @param emissiveTexture the associated emissive texture used to generate the glow
  50428. * @return true if ready otherwise, false
  50429. */
  50430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50431. /**
  50432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50433. */
  50434. needStencil(): boolean;
  50435. /**
  50436. * Returns true if the mesh can be rendered, otherwise false.
  50437. * @param mesh The mesh to render
  50438. * @param material The material used on the mesh
  50439. * @returns true if it can be rendered otherwise false
  50440. */
  50441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50442. /**
  50443. * Implementation specific of rendering the generating effect on the main canvas.
  50444. * @param effect The effect used to render through
  50445. */
  50446. protected _internalRender(effect: Effect): void;
  50447. /**
  50448. * Sets the required values for both the emissive texture and and the main color.
  50449. */
  50450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50451. /**
  50452. * Returns true if the mesh should render, otherwise false.
  50453. * @param mesh The mesh to render
  50454. * @returns true if it should render otherwise false
  50455. */
  50456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50457. /**
  50458. * Adds specific effects defines.
  50459. * @param defines The defines to add specifics to.
  50460. */
  50461. protected _addCustomEffectDefines(defines: string[]): void;
  50462. /**
  50463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50464. * @param mesh The mesh to exclude from the glow layer
  50465. */
  50466. addExcludedMesh(mesh: Mesh): void;
  50467. /**
  50468. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50469. * @param mesh The mesh to remove
  50470. */
  50471. removeExcludedMesh(mesh: Mesh): void;
  50472. /**
  50473. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50474. * @param mesh The mesh to include in the glow layer
  50475. */
  50476. addIncludedOnlyMesh(mesh: Mesh): void;
  50477. /**
  50478. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50479. * @param mesh The mesh to remove
  50480. */
  50481. removeIncludedOnlyMesh(mesh: Mesh): void;
  50482. /**
  50483. * Determine if a given mesh will be used in the glow layer
  50484. * @param mesh The mesh to test
  50485. * @returns true if the mesh will be highlighted by the current glow layer
  50486. */
  50487. hasMesh(mesh: AbstractMesh): boolean;
  50488. /**
  50489. * Defines wether the current material of the mesh should be use to render the effect.
  50490. * @param mesh defines the current mesh to render
  50491. */
  50492. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50493. /**
  50494. * Add a mesh to be rendered through its own material and not with emissive only.
  50495. * @param mesh The mesh for which we need to use its material
  50496. */
  50497. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50498. /**
  50499. * Remove a mesh from being rendered through its own material and not with emissive only.
  50500. * @param mesh The mesh for which we need to not use its material
  50501. */
  50502. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50503. /**
  50504. * Free any resources and references associated to a mesh.
  50505. * Internal use
  50506. * @param mesh The mesh to free.
  50507. * @hidden
  50508. */
  50509. _disposeMesh(mesh: Mesh): void;
  50510. /**
  50511. * Gets the class name of the effect layer
  50512. * @returns the string with the class name of the effect layer
  50513. */
  50514. getClassName(): string;
  50515. /**
  50516. * Serializes this glow layer
  50517. * @returns a serialized glow layer object
  50518. */
  50519. serialize(): any;
  50520. /**
  50521. * Creates a Glow Layer from parsed glow layer data
  50522. * @param parsedGlowLayer defines glow layer data
  50523. * @param scene defines the current scene
  50524. * @param rootUrl defines the root URL containing the glow layer information
  50525. * @returns a parsed Glow Layer
  50526. */
  50527. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50528. }
  50529. }
  50530. declare module BABYLON {
  50531. /** @hidden */
  50532. export var glowBlurPostProcessPixelShader: {
  50533. name: string;
  50534. shader: string;
  50535. };
  50536. }
  50537. declare module BABYLON {
  50538. interface AbstractScene {
  50539. /**
  50540. * Return a the first highlight layer of the scene with a given name.
  50541. * @param name The name of the highlight layer to look for.
  50542. * @return The highlight layer if found otherwise null.
  50543. */
  50544. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50545. }
  50546. /**
  50547. * Highlight layer options. This helps customizing the behaviour
  50548. * of the highlight layer.
  50549. */
  50550. export interface IHighlightLayerOptions {
  50551. /**
  50552. * Multiplication factor apply to the canvas size to compute the render target size
  50553. * used to generated the glowing objects (the smaller the faster).
  50554. */
  50555. mainTextureRatio: number;
  50556. /**
  50557. * Enforces a fixed size texture to ensure resize independant blur.
  50558. */
  50559. mainTextureFixedSize?: number;
  50560. /**
  50561. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50562. * of the picture to blur (the smaller the faster).
  50563. */
  50564. blurTextureSizeRatio: number;
  50565. /**
  50566. * How big in texel of the blur texture is the vertical blur.
  50567. */
  50568. blurVerticalSize: number;
  50569. /**
  50570. * How big in texel of the blur texture is the horizontal blur.
  50571. */
  50572. blurHorizontalSize: number;
  50573. /**
  50574. * Alpha blending mode used to apply the blur. Default is combine.
  50575. */
  50576. alphaBlendingMode: number;
  50577. /**
  50578. * The camera attached to the layer.
  50579. */
  50580. camera: Nullable<Camera>;
  50581. /**
  50582. * Should we display highlight as a solid stroke?
  50583. */
  50584. isStroke?: boolean;
  50585. /**
  50586. * The rendering group to draw the layer in.
  50587. */
  50588. renderingGroupId: number;
  50589. }
  50590. /**
  50591. * The highlight layer Helps adding a glow effect around a mesh.
  50592. *
  50593. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50594. * glowy meshes to your scene.
  50595. *
  50596. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50597. */
  50598. export class HighlightLayer extends EffectLayer {
  50599. name: string;
  50600. /**
  50601. * Effect Name of the highlight layer.
  50602. */
  50603. static readonly EffectName: string;
  50604. /**
  50605. * The neutral color used during the preparation of the glow effect.
  50606. * This is black by default as the blend operation is a blend operation.
  50607. */
  50608. static NeutralColor: Color4;
  50609. /**
  50610. * Stencil value used for glowing meshes.
  50611. */
  50612. static GlowingMeshStencilReference: number;
  50613. /**
  50614. * Stencil value used for the other meshes in the scene.
  50615. */
  50616. static NormalMeshStencilReference: number;
  50617. /**
  50618. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50619. */
  50620. innerGlow: boolean;
  50621. /**
  50622. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50623. */
  50624. outerGlow: boolean;
  50625. /**
  50626. * Specifies the horizontal size of the blur.
  50627. */
  50628. /**
  50629. * Gets the horizontal size of the blur.
  50630. */
  50631. blurHorizontalSize: number;
  50632. /**
  50633. * Specifies the vertical size of the blur.
  50634. */
  50635. /**
  50636. * Gets the vertical size of the blur.
  50637. */
  50638. blurVerticalSize: number;
  50639. /**
  50640. * An event triggered when the highlight layer is being blurred.
  50641. */
  50642. onBeforeBlurObservable: Observable<HighlightLayer>;
  50643. /**
  50644. * An event triggered when the highlight layer has been blurred.
  50645. */
  50646. onAfterBlurObservable: Observable<HighlightLayer>;
  50647. private _instanceGlowingMeshStencilReference;
  50648. private _options;
  50649. private _downSamplePostprocess;
  50650. private _horizontalBlurPostprocess;
  50651. private _verticalBlurPostprocess;
  50652. private _blurTexture;
  50653. private _meshes;
  50654. private _excludedMeshes;
  50655. /**
  50656. * Instantiates a new highlight Layer and references it to the scene..
  50657. * @param name The name of the layer
  50658. * @param scene The scene to use the layer in
  50659. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50660. */
  50661. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50662. /**
  50663. * Get the effect name of the layer.
  50664. * @return The effect name
  50665. */
  50666. getEffectName(): string;
  50667. /**
  50668. * Create the merge effect. This is the shader use to blit the information back
  50669. * to the main canvas at the end of the scene rendering.
  50670. */
  50671. protected _createMergeEffect(): Effect;
  50672. /**
  50673. * Creates the render target textures and post processes used in the highlight layer.
  50674. */
  50675. protected _createTextureAndPostProcesses(): void;
  50676. /**
  50677. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50678. */
  50679. needStencil(): boolean;
  50680. /**
  50681. * Checks for the readiness of the element composing the layer.
  50682. * @param subMesh the mesh to check for
  50683. * @param useInstances specify wether or not to use instances to render the mesh
  50684. * @param emissiveTexture the associated emissive texture used to generate the glow
  50685. * @return true if ready otherwise, false
  50686. */
  50687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50688. /**
  50689. * Implementation specific of rendering the generating effect on the main canvas.
  50690. * @param effect The effect used to render through
  50691. */
  50692. protected _internalRender(effect: Effect): void;
  50693. /**
  50694. * Returns true if the layer contains information to display, otherwise false.
  50695. */
  50696. shouldRender(): boolean;
  50697. /**
  50698. * Returns true if the mesh should render, otherwise false.
  50699. * @param mesh The mesh to render
  50700. * @returns true if it should render otherwise false
  50701. */
  50702. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50703. /**
  50704. * Sets the required values for both the emissive texture and and the main color.
  50705. */
  50706. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50707. /**
  50708. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50709. * @param mesh The mesh to exclude from the highlight layer
  50710. */
  50711. addExcludedMesh(mesh: Mesh): void;
  50712. /**
  50713. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50714. * @param mesh The mesh to highlight
  50715. */
  50716. removeExcludedMesh(mesh: Mesh): void;
  50717. /**
  50718. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50719. * @param mesh mesh to test
  50720. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50721. */
  50722. hasMesh(mesh: AbstractMesh): boolean;
  50723. /**
  50724. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50725. * @param mesh The mesh to highlight
  50726. * @param color The color of the highlight
  50727. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50728. */
  50729. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50730. /**
  50731. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50732. * @param mesh The mesh to highlight
  50733. */
  50734. removeMesh(mesh: Mesh): void;
  50735. /**
  50736. * Force the stencil to the normal expected value for none glowing parts
  50737. */
  50738. private _defaultStencilReference;
  50739. /**
  50740. * Free any resources and references associated to a mesh.
  50741. * Internal use
  50742. * @param mesh The mesh to free.
  50743. * @hidden
  50744. */
  50745. _disposeMesh(mesh: Mesh): void;
  50746. /**
  50747. * Dispose the highlight layer and free resources.
  50748. */
  50749. dispose(): void;
  50750. /**
  50751. * Gets the class name of the effect layer
  50752. * @returns the string with the class name of the effect layer
  50753. */
  50754. getClassName(): string;
  50755. /**
  50756. * Serializes this Highlight layer
  50757. * @returns a serialized Highlight layer object
  50758. */
  50759. serialize(): any;
  50760. /**
  50761. * Creates a Highlight layer from parsed Highlight layer data
  50762. * @param parsedHightlightLayer defines the Highlight layer data
  50763. * @param scene defines the current scene
  50764. * @param rootUrl defines the root URL containing the Highlight layer information
  50765. * @returns a parsed Highlight layer
  50766. */
  50767. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50768. }
  50769. }
  50770. declare module BABYLON {
  50771. interface AbstractScene {
  50772. /**
  50773. * The list of layers (background and foreground) of the scene
  50774. */
  50775. layers: Array<Layer>;
  50776. }
  50777. /**
  50778. * Defines the layer scene component responsible to manage any layers
  50779. * in a given scene.
  50780. */
  50781. export class LayerSceneComponent implements ISceneComponent {
  50782. /**
  50783. * The component name helpfull to identify the component in the list of scene components.
  50784. */
  50785. readonly name: string;
  50786. /**
  50787. * The scene the component belongs to.
  50788. */
  50789. scene: Scene;
  50790. private _engine;
  50791. /**
  50792. * Creates a new instance of the component for the given scene
  50793. * @param scene Defines the scene to register the component in
  50794. */
  50795. constructor(scene: Scene);
  50796. /**
  50797. * Registers the component in a given scene
  50798. */
  50799. register(): void;
  50800. /**
  50801. * Rebuilds the elements related to this component in case of
  50802. * context lost for instance.
  50803. */
  50804. rebuild(): void;
  50805. /**
  50806. * Disposes the component and the associated ressources.
  50807. */
  50808. dispose(): void;
  50809. private _draw;
  50810. private _drawCameraPredicate;
  50811. private _drawCameraBackground;
  50812. private _drawCameraForeground;
  50813. private _drawRenderTargetPredicate;
  50814. private _drawRenderTargetBackground;
  50815. private _drawRenderTargetForeground;
  50816. /**
  50817. * Adds all the elements from the container to the scene
  50818. * @param container the container holding the elements
  50819. */
  50820. addFromContainer(container: AbstractScene): void;
  50821. /**
  50822. * Removes all the elements in the container from the scene
  50823. * @param container contains the elements to remove
  50824. * @param dispose if the removed element should be disposed (default: false)
  50825. */
  50826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50827. }
  50828. }
  50829. declare module BABYLON {
  50830. /** @hidden */
  50831. export var layerPixelShader: {
  50832. name: string;
  50833. shader: string;
  50834. };
  50835. }
  50836. declare module BABYLON {
  50837. /** @hidden */
  50838. export var layerVertexShader: {
  50839. name: string;
  50840. shader: string;
  50841. };
  50842. }
  50843. declare module BABYLON {
  50844. /**
  50845. * This represents a full screen 2d layer.
  50846. * This can be useful to display a picture in the background of your scene for instance.
  50847. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50848. */
  50849. export class Layer {
  50850. /**
  50851. * Define the name of the layer.
  50852. */
  50853. name: string;
  50854. /**
  50855. * Define the texture the layer should display.
  50856. */
  50857. texture: Nullable<Texture>;
  50858. /**
  50859. * Is the layer in background or foreground.
  50860. */
  50861. isBackground: boolean;
  50862. /**
  50863. * Define the color of the layer (instead of texture).
  50864. */
  50865. color: Color4;
  50866. /**
  50867. * Define the scale of the layer in order to zoom in out of the texture.
  50868. */
  50869. scale: Vector2;
  50870. /**
  50871. * Define an offset for the layer in order to shift the texture.
  50872. */
  50873. offset: Vector2;
  50874. /**
  50875. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50876. */
  50877. alphaBlendingMode: number;
  50878. /**
  50879. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50880. * Alpha test will not mix with the background color in case of transparency.
  50881. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50882. */
  50883. alphaTest: boolean;
  50884. /**
  50885. * Define a mask to restrict the layer to only some of the scene cameras.
  50886. */
  50887. layerMask: number;
  50888. /**
  50889. * Define the list of render target the layer is visible into.
  50890. */
  50891. renderTargetTextures: RenderTargetTexture[];
  50892. /**
  50893. * Define if the layer is only used in renderTarget or if it also
  50894. * renders in the main frame buffer of the canvas.
  50895. */
  50896. renderOnlyInRenderTargetTextures: boolean;
  50897. private _scene;
  50898. private _vertexBuffers;
  50899. private _indexBuffer;
  50900. private _effect;
  50901. private _alphaTestEffect;
  50902. /**
  50903. * An event triggered when the layer is disposed.
  50904. */
  50905. onDisposeObservable: Observable<Layer>;
  50906. private _onDisposeObserver;
  50907. /**
  50908. * Back compatibility with callback before the onDisposeObservable existed.
  50909. * The set callback will be triggered when the layer has been disposed.
  50910. */
  50911. onDispose: () => void;
  50912. /**
  50913. * An event triggered before rendering the scene
  50914. */
  50915. onBeforeRenderObservable: Observable<Layer>;
  50916. private _onBeforeRenderObserver;
  50917. /**
  50918. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50919. * The set callback will be triggered just before rendering the layer.
  50920. */
  50921. onBeforeRender: () => void;
  50922. /**
  50923. * An event triggered after rendering the scene
  50924. */
  50925. onAfterRenderObservable: Observable<Layer>;
  50926. private _onAfterRenderObserver;
  50927. /**
  50928. * Back compatibility with callback before the onAfterRenderObservable existed.
  50929. * The set callback will be triggered just after rendering the layer.
  50930. */
  50931. onAfterRender: () => void;
  50932. /**
  50933. * Instantiates a new layer.
  50934. * This represents a full screen 2d layer.
  50935. * This can be useful to display a picture in the background of your scene for instance.
  50936. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50937. * @param name Define the name of the layer in the scene
  50938. * @param imgUrl Define the url of the texture to display in the layer
  50939. * @param scene Define the scene the layer belongs to
  50940. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50941. * @param color Defines a color for the layer
  50942. */
  50943. constructor(
  50944. /**
  50945. * Define the name of the layer.
  50946. */
  50947. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50948. private _createIndexBuffer;
  50949. /** @hidden */
  50950. _rebuild(): void;
  50951. /**
  50952. * Renders the layer in the scene.
  50953. */
  50954. render(): void;
  50955. /**
  50956. * Disposes and releases the associated ressources.
  50957. */
  50958. dispose(): void;
  50959. }
  50960. }
  50961. declare module BABYLON {
  50962. /** @hidden */
  50963. export var lensFlarePixelShader: {
  50964. name: string;
  50965. shader: string;
  50966. };
  50967. }
  50968. declare module BABYLON {
  50969. /** @hidden */
  50970. export var lensFlareVertexShader: {
  50971. name: string;
  50972. shader: string;
  50973. };
  50974. }
  50975. declare module BABYLON {
  50976. /**
  50977. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50978. * It is usually composed of several `lensFlare`.
  50979. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50980. */
  50981. export class LensFlareSystem {
  50982. /**
  50983. * Define the name of the lens flare system
  50984. */
  50985. name: string;
  50986. /**
  50987. * List of lens flares used in this system.
  50988. */
  50989. lensFlares: LensFlare[];
  50990. /**
  50991. * Define a limit from the border the lens flare can be visible.
  50992. */
  50993. borderLimit: number;
  50994. /**
  50995. * Define a viewport border we do not want to see the lens flare in.
  50996. */
  50997. viewportBorder: number;
  50998. /**
  50999. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51000. */
  51001. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51002. /**
  51003. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51004. */
  51005. layerMask: number;
  51006. /**
  51007. * Define the id of the lens flare system in the scene.
  51008. * (equal to name by default)
  51009. */
  51010. id: string;
  51011. private _scene;
  51012. private _emitter;
  51013. private _vertexBuffers;
  51014. private _indexBuffer;
  51015. private _effect;
  51016. private _positionX;
  51017. private _positionY;
  51018. private _isEnabled;
  51019. /** @hidden */
  51020. static _SceneComponentInitialization: (scene: Scene) => void;
  51021. /**
  51022. * Instantiates a lens flare system.
  51023. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51024. * It is usually composed of several `lensFlare`.
  51025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51026. * @param name Define the name of the lens flare system in the scene
  51027. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51028. * @param scene Define the scene the lens flare system belongs to
  51029. */
  51030. constructor(
  51031. /**
  51032. * Define the name of the lens flare system
  51033. */
  51034. name: string, emitter: any, scene: Scene);
  51035. /**
  51036. * Define if the lens flare system is enabled.
  51037. */
  51038. isEnabled: boolean;
  51039. /**
  51040. * Get the scene the effects belongs to.
  51041. * @returns the scene holding the lens flare system
  51042. */
  51043. getScene(): Scene;
  51044. /**
  51045. * Get the emitter of the lens flare system.
  51046. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51047. * @returns the emitter of the lens flare system
  51048. */
  51049. getEmitter(): any;
  51050. /**
  51051. * Set the emitter of the lens flare system.
  51052. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51053. * @param newEmitter Define the new emitter of the system
  51054. */
  51055. setEmitter(newEmitter: any): void;
  51056. /**
  51057. * Get the lens flare system emitter position.
  51058. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51059. * @returns the position
  51060. */
  51061. getEmitterPosition(): Vector3;
  51062. /**
  51063. * @hidden
  51064. */
  51065. computeEffectivePosition(globalViewport: Viewport): boolean;
  51066. /** @hidden */
  51067. _isVisible(): boolean;
  51068. /**
  51069. * @hidden
  51070. */
  51071. render(): boolean;
  51072. /**
  51073. * Dispose and release the lens flare with its associated resources.
  51074. */
  51075. dispose(): void;
  51076. /**
  51077. * Parse a lens flare system from a JSON repressentation
  51078. * @param parsedLensFlareSystem Define the JSON to parse
  51079. * @param scene Define the scene the parsed system should be instantiated in
  51080. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51081. * @returns the parsed system
  51082. */
  51083. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51084. /**
  51085. * Serialize the current Lens Flare System into a JSON representation.
  51086. * @returns the serialized JSON
  51087. */
  51088. serialize(): any;
  51089. }
  51090. }
  51091. declare module BABYLON {
  51092. /**
  51093. * This represents one of the lens effect in a `lensFlareSystem`.
  51094. * It controls one of the indiviual texture used in the effect.
  51095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51096. */
  51097. export class LensFlare {
  51098. /**
  51099. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51100. */
  51101. size: number;
  51102. /**
  51103. * 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.
  51104. */
  51105. position: number;
  51106. /**
  51107. * Define the lens color.
  51108. */
  51109. color: Color3;
  51110. /**
  51111. * Define the lens texture.
  51112. */
  51113. texture: Nullable<Texture>;
  51114. /**
  51115. * Define the alpha mode to render this particular lens.
  51116. */
  51117. alphaMode: number;
  51118. private _system;
  51119. /**
  51120. * Creates a new Lens Flare.
  51121. * This represents one of the lens effect in a `lensFlareSystem`.
  51122. * It controls one of the indiviual texture used in the effect.
  51123. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51124. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51125. * @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.
  51126. * @param color Define the lens color
  51127. * @param imgUrl Define the lens texture url
  51128. * @param system Define the `lensFlareSystem` this flare is part of
  51129. * @returns The newly created Lens Flare
  51130. */
  51131. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51132. /**
  51133. * Instantiates a new Lens Flare.
  51134. * This represents one of the lens effect in a `lensFlareSystem`.
  51135. * It controls one of the indiviual texture used in the effect.
  51136. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51137. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51138. * @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.
  51139. * @param color Define the lens color
  51140. * @param imgUrl Define the lens texture url
  51141. * @param system Define the `lensFlareSystem` this flare is part of
  51142. */
  51143. constructor(
  51144. /**
  51145. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51146. */
  51147. size: number,
  51148. /**
  51149. * 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.
  51150. */
  51151. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51152. /**
  51153. * Dispose and release the lens flare with its associated resources.
  51154. */
  51155. dispose(): void;
  51156. }
  51157. }
  51158. declare module BABYLON {
  51159. interface AbstractScene {
  51160. /**
  51161. * The list of lens flare system added to the scene
  51162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51163. */
  51164. lensFlareSystems: Array<LensFlareSystem>;
  51165. /**
  51166. * Removes the given lens flare system from this scene.
  51167. * @param toRemove The lens flare system to remove
  51168. * @returns The index of the removed lens flare system
  51169. */
  51170. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51171. /**
  51172. * Adds the given lens flare system to this scene
  51173. * @param newLensFlareSystem The lens flare system to add
  51174. */
  51175. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51176. /**
  51177. * Gets a lens flare system using its name
  51178. * @param name defines the name to look for
  51179. * @returns the lens flare system or null if not found
  51180. */
  51181. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51182. /**
  51183. * Gets a lens flare system using its id
  51184. * @param id defines the id to look for
  51185. * @returns the lens flare system or null if not found
  51186. */
  51187. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51188. }
  51189. /**
  51190. * Defines the lens flare scene component responsible to manage any lens flares
  51191. * in a given scene.
  51192. */
  51193. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51194. /**
  51195. * The component name helpfull to identify the component in the list of scene components.
  51196. */
  51197. readonly name: string;
  51198. /**
  51199. * The scene the component belongs to.
  51200. */
  51201. scene: Scene;
  51202. /**
  51203. * Creates a new instance of the component for the given scene
  51204. * @param scene Defines the scene to register the component in
  51205. */
  51206. constructor(scene: Scene);
  51207. /**
  51208. * Registers the component in a given scene
  51209. */
  51210. register(): void;
  51211. /**
  51212. * Rebuilds the elements related to this component in case of
  51213. * context lost for instance.
  51214. */
  51215. rebuild(): void;
  51216. /**
  51217. * Adds all the elements from the container to the scene
  51218. * @param container the container holding the elements
  51219. */
  51220. addFromContainer(container: AbstractScene): void;
  51221. /**
  51222. * Removes all the elements in the container from the scene
  51223. * @param container contains the elements to remove
  51224. * @param dispose if the removed element should be disposed (default: false)
  51225. */
  51226. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51227. /**
  51228. * Serializes the component data to the specified json object
  51229. * @param serializationObject The object to serialize to
  51230. */
  51231. serialize(serializationObject: any): void;
  51232. /**
  51233. * Disposes the component and the associated ressources.
  51234. */
  51235. dispose(): void;
  51236. private _draw;
  51237. }
  51238. }
  51239. declare module BABYLON {
  51240. /**
  51241. * Defines the shadow generator component responsible to manage any shadow generators
  51242. * in a given scene.
  51243. */
  51244. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51245. /**
  51246. * The component name helpfull to identify the component in the list of scene components.
  51247. */
  51248. readonly name: string;
  51249. /**
  51250. * The scene the component belongs to.
  51251. */
  51252. scene: Scene;
  51253. /**
  51254. * Creates a new instance of the component for the given scene
  51255. * @param scene Defines the scene to register the component in
  51256. */
  51257. constructor(scene: Scene);
  51258. /**
  51259. * Registers the component in a given scene
  51260. */
  51261. register(): void;
  51262. /**
  51263. * Rebuilds the elements related to this component in case of
  51264. * context lost for instance.
  51265. */
  51266. rebuild(): void;
  51267. /**
  51268. * Serializes the component data to the specified json object
  51269. * @param serializationObject The object to serialize to
  51270. */
  51271. serialize(serializationObject: any): void;
  51272. /**
  51273. * Adds all the elements from the container to the scene
  51274. * @param container the container holding the elements
  51275. */
  51276. addFromContainer(container: AbstractScene): void;
  51277. /**
  51278. * Removes all the elements in the container from the scene
  51279. * @param container contains the elements to remove
  51280. * @param dispose if the removed element should be disposed (default: false)
  51281. */
  51282. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51283. /**
  51284. * Rebuilds the elements related to this component in case of
  51285. * context lost for instance.
  51286. */
  51287. dispose(): void;
  51288. private _gatherRenderTargets;
  51289. }
  51290. }
  51291. declare module BABYLON {
  51292. /**
  51293. * A point light is a light defined by an unique point in world space.
  51294. * The light is emitted in every direction from this point.
  51295. * A good example of a point light is a standard light bulb.
  51296. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51297. */
  51298. export class PointLight extends ShadowLight {
  51299. private _shadowAngle;
  51300. /**
  51301. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51302. * This specifies what angle the shadow will use to be created.
  51303. *
  51304. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51305. */
  51306. /**
  51307. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51308. * This specifies what angle the shadow will use to be created.
  51309. *
  51310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51311. */
  51312. shadowAngle: number;
  51313. /**
  51314. * Gets the direction if it has been set.
  51315. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51316. */
  51317. /**
  51318. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51319. */
  51320. direction: Vector3;
  51321. /**
  51322. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51323. * A PointLight emits the light in every direction.
  51324. * It can cast shadows.
  51325. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51326. * ```javascript
  51327. * var pointLight = new PointLight("pl", camera.position, scene);
  51328. * ```
  51329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51330. * @param name The light friendly name
  51331. * @param position The position of the point light in the scene
  51332. * @param scene The scene the lights belongs to
  51333. */
  51334. constructor(name: string, position: Vector3, scene: Scene);
  51335. /**
  51336. * Returns the string "PointLight"
  51337. * @returns the class name
  51338. */
  51339. getClassName(): string;
  51340. /**
  51341. * Returns the integer 0.
  51342. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51343. */
  51344. getTypeID(): number;
  51345. /**
  51346. * Specifies wether or not the shadowmap should be a cube texture.
  51347. * @returns true if the shadowmap needs to be a cube texture.
  51348. */
  51349. needCube(): boolean;
  51350. /**
  51351. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51352. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51353. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51354. */
  51355. getShadowDirection(faceIndex?: number): Vector3;
  51356. /**
  51357. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51358. * - fov = PI / 2
  51359. * - aspect ratio : 1.0
  51360. * - z-near and far equal to the active camera minZ and maxZ.
  51361. * Returns the PointLight.
  51362. */
  51363. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51364. protected _buildUniformLayout(): void;
  51365. /**
  51366. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51367. * @param effect The effect to update
  51368. * @param lightIndex The index of the light in the effect to update
  51369. * @returns The point light
  51370. */
  51371. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51373. /**
  51374. * Prepares the list of defines specific to the light type.
  51375. * @param defines the list of defines
  51376. * @param lightIndex defines the index of the light for the effect
  51377. */
  51378. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51379. }
  51380. }
  51381. declare module BABYLON {
  51382. /**
  51383. * Header information of HDR texture files.
  51384. */
  51385. export interface HDRInfo {
  51386. /**
  51387. * The height of the texture in pixels.
  51388. */
  51389. height: number;
  51390. /**
  51391. * The width of the texture in pixels.
  51392. */
  51393. width: number;
  51394. /**
  51395. * The index of the beginning of the data in the binary file.
  51396. */
  51397. dataPosition: number;
  51398. }
  51399. /**
  51400. * This groups tools to convert HDR texture to native colors array.
  51401. */
  51402. export class HDRTools {
  51403. private static Ldexp;
  51404. private static Rgbe2float;
  51405. private static readStringLine;
  51406. /**
  51407. * Reads header information from an RGBE texture stored in a native array.
  51408. * More information on this format are available here:
  51409. * https://en.wikipedia.org/wiki/RGBE_image_format
  51410. *
  51411. * @param uint8array The binary file stored in native array.
  51412. * @return The header information.
  51413. */
  51414. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51415. /**
  51416. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51417. * This RGBE texture needs to store the information as a panorama.
  51418. *
  51419. * More information on this format are available here:
  51420. * https://en.wikipedia.org/wiki/RGBE_image_format
  51421. *
  51422. * @param buffer The binary file stored in an array buffer.
  51423. * @param size The expected size of the extracted cubemap.
  51424. * @return The Cube Map information.
  51425. */
  51426. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51427. /**
  51428. * Returns the pixels data extracted from an RGBE texture.
  51429. * This pixels will be stored left to right up to down in the R G B order in one array.
  51430. *
  51431. * More information on this format are available here:
  51432. * https://en.wikipedia.org/wiki/RGBE_image_format
  51433. *
  51434. * @param uint8array The binary file stored in an array buffer.
  51435. * @param hdrInfo The header information of the file.
  51436. * @return The pixels data in RGB right to left up to down order.
  51437. */
  51438. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51439. private static RGBE_ReadPixels_RLE;
  51440. }
  51441. }
  51442. declare module BABYLON {
  51443. /**
  51444. * This represents a texture coming from an HDR input.
  51445. *
  51446. * The only supported format is currently panorama picture stored in RGBE format.
  51447. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51448. */
  51449. export class HDRCubeTexture extends BaseTexture {
  51450. private static _facesMapping;
  51451. private _generateHarmonics;
  51452. private _noMipmap;
  51453. private _textureMatrix;
  51454. private _size;
  51455. private _onLoad;
  51456. private _onError;
  51457. /**
  51458. * The texture URL.
  51459. */
  51460. url: string;
  51461. /**
  51462. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51463. */
  51464. coordinatesMode: number;
  51465. protected _isBlocking: boolean;
  51466. /**
  51467. * Sets wether or not the texture is blocking during loading.
  51468. */
  51469. /**
  51470. * Gets wether or not the texture is blocking during loading.
  51471. */
  51472. isBlocking: boolean;
  51473. protected _rotationY: number;
  51474. /**
  51475. * Sets texture matrix rotation angle around Y axis in radians.
  51476. */
  51477. /**
  51478. * Gets texture matrix rotation angle around Y axis radians.
  51479. */
  51480. rotationY: number;
  51481. /**
  51482. * Gets or sets the center of the bounding box associated with the cube texture
  51483. * It must define where the camera used to render the texture was set
  51484. */
  51485. boundingBoxPosition: Vector3;
  51486. private _boundingBoxSize;
  51487. /**
  51488. * Gets or sets the size of the bounding box associated with the cube texture
  51489. * When defined, the cubemap will switch to local mode
  51490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51491. * @example https://www.babylonjs-playground.com/#RNASML
  51492. */
  51493. boundingBoxSize: Vector3;
  51494. /**
  51495. * Instantiates an HDRTexture from the following parameters.
  51496. *
  51497. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51498. * @param scene The scene the texture will be used in
  51499. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51500. * @param noMipmap Forces to not generate the mipmap if true
  51501. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51502. * @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)
  51503. * @param reserved Reserved flag for internal use.
  51504. */
  51505. 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>);
  51506. /**
  51507. * Get the current class name of the texture useful for serialization or dynamic coding.
  51508. * @returns "HDRCubeTexture"
  51509. */
  51510. getClassName(): string;
  51511. /**
  51512. * Occurs when the file is raw .hdr file.
  51513. */
  51514. private loadTexture;
  51515. clone(): HDRCubeTexture;
  51516. delayLoad(): void;
  51517. /**
  51518. * Get the texture reflection matrix used to rotate/transform the reflection.
  51519. * @returns the reflection matrix
  51520. */
  51521. getReflectionTextureMatrix(): Matrix;
  51522. /**
  51523. * Set the texture reflection matrix used to rotate/transform the reflection.
  51524. * @param value Define the reflection matrix to set
  51525. */
  51526. setReflectionTextureMatrix(value: Matrix): void;
  51527. /**
  51528. * Parses a JSON representation of an HDR Texture in order to create the texture
  51529. * @param parsedTexture Define the JSON representation
  51530. * @param scene Define the scene the texture should be created in
  51531. * @param rootUrl Define the root url in case we need to load relative dependencies
  51532. * @returns the newly created texture after parsing
  51533. */
  51534. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51535. serialize(): any;
  51536. }
  51537. }
  51538. declare module BABYLON {
  51539. /**
  51540. * Class used to control physics engine
  51541. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51542. */
  51543. export class PhysicsEngine implements IPhysicsEngine {
  51544. private _physicsPlugin;
  51545. /**
  51546. * Global value used to control the smallest number supported by the simulation
  51547. */
  51548. static Epsilon: number;
  51549. private _impostors;
  51550. private _joints;
  51551. /**
  51552. * Gets the gravity vector used by the simulation
  51553. */
  51554. gravity: Vector3;
  51555. /**
  51556. * Factory used to create the default physics plugin.
  51557. * @returns The default physics plugin
  51558. */
  51559. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51560. /**
  51561. * Creates a new Physics Engine
  51562. * @param gravity defines the gravity vector used by the simulation
  51563. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51564. */
  51565. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51566. /**
  51567. * Sets the gravity vector used by the simulation
  51568. * @param gravity defines the gravity vector to use
  51569. */
  51570. setGravity(gravity: Vector3): void;
  51571. /**
  51572. * Set the time step of the physics engine.
  51573. * Default is 1/60.
  51574. * To slow it down, enter 1/600 for example.
  51575. * To speed it up, 1/30
  51576. * @param newTimeStep defines the new timestep to apply to this world.
  51577. */
  51578. setTimeStep(newTimeStep?: number): void;
  51579. /**
  51580. * Get the time step of the physics engine.
  51581. * @returns the current time step
  51582. */
  51583. getTimeStep(): number;
  51584. /**
  51585. * Release all resources
  51586. */
  51587. dispose(): void;
  51588. /**
  51589. * Gets the name of the current physics plugin
  51590. * @returns the name of the plugin
  51591. */
  51592. getPhysicsPluginName(): string;
  51593. /**
  51594. * Adding a new impostor for the impostor tracking.
  51595. * This will be done by the impostor itself.
  51596. * @param impostor the impostor to add
  51597. */
  51598. addImpostor(impostor: PhysicsImpostor): void;
  51599. /**
  51600. * Remove an impostor from the engine.
  51601. * This impostor and its mesh will not longer be updated by the physics engine.
  51602. * @param impostor the impostor to remove
  51603. */
  51604. removeImpostor(impostor: PhysicsImpostor): void;
  51605. /**
  51606. * Add a joint to the physics engine
  51607. * @param mainImpostor defines the main impostor to which the joint is added.
  51608. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51609. * @param joint defines the joint that will connect both impostors.
  51610. */
  51611. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51612. /**
  51613. * Removes a joint from the simulation
  51614. * @param mainImpostor defines the impostor used with the joint
  51615. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51616. * @param joint defines the joint to remove
  51617. */
  51618. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51619. /**
  51620. * Called by the scene. No need to call it.
  51621. * @param delta defines the timespam between frames
  51622. */
  51623. _step(delta: number): void;
  51624. /**
  51625. * Gets the current plugin used to run the simulation
  51626. * @returns current plugin
  51627. */
  51628. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51629. /**
  51630. * Gets the list of physic impostors
  51631. * @returns an array of PhysicsImpostor
  51632. */
  51633. getImpostors(): Array<PhysicsImpostor>;
  51634. /**
  51635. * Gets the impostor for a physics enabled object
  51636. * @param object defines the object impersonated by the impostor
  51637. * @returns the PhysicsImpostor or null if not found
  51638. */
  51639. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51640. /**
  51641. * Gets the impostor for a physics body object
  51642. * @param body defines physics body used by the impostor
  51643. * @returns the PhysicsImpostor or null if not found
  51644. */
  51645. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51646. /**
  51647. * Does a raycast in the physics world
  51648. * @param from when should the ray start?
  51649. * @param to when should the ray end?
  51650. * @returns PhysicsRaycastResult
  51651. */
  51652. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51653. }
  51654. }
  51655. declare module BABYLON {
  51656. /** @hidden */
  51657. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51658. private _useDeltaForWorldStep;
  51659. world: any;
  51660. name: string;
  51661. private _physicsMaterials;
  51662. private _fixedTimeStep;
  51663. private _cannonRaycastResult;
  51664. private _raycastResult;
  51665. private _physicsBodysToRemoveAfterStep;
  51666. BJSCANNON: any;
  51667. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51668. setGravity(gravity: Vector3): void;
  51669. setTimeStep(timeStep: number): void;
  51670. getTimeStep(): number;
  51671. executeStep(delta: number): void;
  51672. private _removeMarkedPhysicsBodiesFromWorld;
  51673. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51674. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51675. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51676. private _processChildMeshes;
  51677. removePhysicsBody(impostor: PhysicsImpostor): void;
  51678. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51679. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51680. private _addMaterial;
  51681. private _checkWithEpsilon;
  51682. private _createShape;
  51683. private _createHeightmap;
  51684. private _minus90X;
  51685. private _plus90X;
  51686. private _tmpPosition;
  51687. private _tmpDeltaPosition;
  51688. private _tmpUnityRotation;
  51689. private _updatePhysicsBodyTransformation;
  51690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51692. isSupported(): boolean;
  51693. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51694. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51695. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51696. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51698. getBodyMass(impostor: PhysicsImpostor): number;
  51699. getBodyFriction(impostor: PhysicsImpostor): number;
  51700. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51701. getBodyRestitution(impostor: PhysicsImpostor): number;
  51702. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51703. sleepBody(impostor: PhysicsImpostor): void;
  51704. wakeUpBody(impostor: PhysicsImpostor): void;
  51705. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51706. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51707. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51708. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51709. getRadius(impostor: PhysicsImpostor): number;
  51710. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51711. dispose(): void;
  51712. private _extendNamespace;
  51713. /**
  51714. * Does a raycast in the physics world
  51715. * @param from when should the ray start?
  51716. * @param to when should the ray end?
  51717. * @returns PhysicsRaycastResult
  51718. */
  51719. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51720. }
  51721. }
  51722. declare module BABYLON {
  51723. /** @hidden */
  51724. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51725. world: any;
  51726. name: string;
  51727. BJSOIMO: any;
  51728. private _raycastResult;
  51729. constructor(iterations?: number, oimoInjection?: any);
  51730. setGravity(gravity: Vector3): void;
  51731. setTimeStep(timeStep: number): void;
  51732. getTimeStep(): number;
  51733. private _tmpImpostorsArray;
  51734. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51735. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51736. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51737. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51738. private _tmpPositionVector;
  51739. removePhysicsBody(impostor: PhysicsImpostor): void;
  51740. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51741. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51742. isSupported(): boolean;
  51743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51744. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51745. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51746. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51747. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51748. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51749. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51750. getBodyMass(impostor: PhysicsImpostor): number;
  51751. getBodyFriction(impostor: PhysicsImpostor): number;
  51752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51753. getBodyRestitution(impostor: PhysicsImpostor): number;
  51754. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51755. sleepBody(impostor: PhysicsImpostor): void;
  51756. wakeUpBody(impostor: PhysicsImpostor): void;
  51757. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51758. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51759. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51760. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51761. getRadius(impostor: PhysicsImpostor): number;
  51762. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51763. dispose(): void;
  51764. /**
  51765. * Does a raycast in the physics world
  51766. * @param from when should the ray start?
  51767. * @param to when should the ray end?
  51768. * @returns PhysicsRaycastResult
  51769. */
  51770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51771. }
  51772. }
  51773. declare module BABYLON {
  51774. /**
  51775. * Class containing static functions to help procedurally build meshes
  51776. */
  51777. export class RibbonBuilder {
  51778. /**
  51779. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51780. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51781. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51782. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51783. * * 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
  51784. * * 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
  51785. * * 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
  51786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51787. * * 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
  51788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51789. * * 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
  51790. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51791. * * 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
  51792. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51794. * @param name defines the name of the mesh
  51795. * @param options defines the options used to create the mesh
  51796. * @param scene defines the hosting scene
  51797. * @returns the ribbon mesh
  51798. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51800. */
  51801. static CreateRibbon(name: string, options: {
  51802. pathArray: Vector3[][];
  51803. closeArray?: boolean;
  51804. closePath?: boolean;
  51805. offset?: number;
  51806. updatable?: boolean;
  51807. sideOrientation?: number;
  51808. frontUVs?: Vector4;
  51809. backUVs?: Vector4;
  51810. instance?: Mesh;
  51811. invertUV?: boolean;
  51812. uvs?: Vector2[];
  51813. colors?: Color4[];
  51814. }, scene?: Nullable<Scene>): Mesh;
  51815. }
  51816. }
  51817. declare module BABYLON {
  51818. /**
  51819. * Class containing static functions to help procedurally build meshes
  51820. */
  51821. export class ShapeBuilder {
  51822. /**
  51823. * 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.
  51824. * * 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.
  51825. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51826. * * 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.
  51827. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51828. * * 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
  51829. * * 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
  51830. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51832. * * 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
  51833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51835. * @param name defines the name of the mesh
  51836. * @param options defines the options used to create the mesh
  51837. * @param scene defines the hosting scene
  51838. * @returns the extruded shape mesh
  51839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51841. */
  51842. static ExtrudeShape(name: string, options: {
  51843. shape: Vector3[];
  51844. path: Vector3[];
  51845. scale?: number;
  51846. rotation?: number;
  51847. cap?: number;
  51848. updatable?: boolean;
  51849. sideOrientation?: number;
  51850. frontUVs?: Vector4;
  51851. backUVs?: Vector4;
  51852. instance?: Mesh;
  51853. invertUV?: boolean;
  51854. }, scene?: Nullable<Scene>): Mesh;
  51855. /**
  51856. * Creates an custom extruded shape mesh.
  51857. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51858. * * 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.
  51859. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51860. * * 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
  51861. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51862. * * 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
  51863. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51864. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51865. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51866. * * 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
  51867. * * 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
  51868. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51870. * * 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
  51871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51873. * @param name defines the name of the mesh
  51874. * @param options defines the options used to create the mesh
  51875. * @param scene defines the hosting scene
  51876. * @returns the custom extruded shape mesh
  51877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51880. */
  51881. static ExtrudeShapeCustom(name: string, options: {
  51882. shape: Vector3[];
  51883. path: Vector3[];
  51884. scaleFunction?: any;
  51885. rotationFunction?: any;
  51886. ribbonCloseArray?: boolean;
  51887. ribbonClosePath?: boolean;
  51888. cap?: number;
  51889. updatable?: boolean;
  51890. sideOrientation?: number;
  51891. frontUVs?: Vector4;
  51892. backUVs?: Vector4;
  51893. instance?: Mesh;
  51894. invertUV?: boolean;
  51895. }, scene?: Nullable<Scene>): Mesh;
  51896. private static _ExtrudeShapeGeneric;
  51897. }
  51898. }
  51899. declare module BABYLON {
  51900. /**
  51901. * AmmoJS Physics plugin
  51902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51903. * @see https://github.com/kripken/ammo.js/
  51904. */
  51905. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51906. private _useDeltaForWorldStep;
  51907. /**
  51908. * Reference to the Ammo library
  51909. */
  51910. bjsAMMO: any;
  51911. /**
  51912. * Created ammoJS world which physics bodies are added to
  51913. */
  51914. world: any;
  51915. /**
  51916. * Name of the plugin
  51917. */
  51918. name: string;
  51919. private _timeStep;
  51920. private _fixedTimeStep;
  51921. private _maxSteps;
  51922. private _tmpQuaternion;
  51923. private _tmpAmmoTransform;
  51924. private _tmpAmmoQuaternion;
  51925. private _tmpAmmoConcreteContactResultCallback;
  51926. private _collisionConfiguration;
  51927. private _dispatcher;
  51928. private _overlappingPairCache;
  51929. private _solver;
  51930. private _softBodySolver;
  51931. private _tmpAmmoVectorA;
  51932. private _tmpAmmoVectorB;
  51933. private _tmpAmmoVectorC;
  51934. private _tmpAmmoVectorD;
  51935. private _tmpContactCallbackResult;
  51936. private _tmpAmmoVectorRCA;
  51937. private _tmpAmmoVectorRCB;
  51938. private _raycastResult;
  51939. private static readonly DISABLE_COLLISION_FLAG;
  51940. private static readonly KINEMATIC_FLAG;
  51941. private static readonly DISABLE_DEACTIVATION_FLAG;
  51942. /**
  51943. * Initializes the ammoJS plugin
  51944. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51945. * @param ammoInjection can be used to inject your own ammo reference
  51946. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51947. */
  51948. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51949. /**
  51950. * Sets the gravity of the physics world (m/(s^2))
  51951. * @param gravity Gravity to set
  51952. */
  51953. setGravity(gravity: Vector3): void;
  51954. /**
  51955. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51956. * @param timeStep timestep to use in seconds
  51957. */
  51958. setTimeStep(timeStep: number): void;
  51959. /**
  51960. * 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)
  51961. * @param fixedTimeStep fixedTimeStep to use in seconds
  51962. */
  51963. setFixedTimeStep(fixedTimeStep: number): void;
  51964. /**
  51965. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51966. * @param maxSteps the maximum number of steps by the physics engine per frame
  51967. */
  51968. setMaxSteps(maxSteps: number): void;
  51969. /**
  51970. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51971. * @returns the current timestep in seconds
  51972. */
  51973. getTimeStep(): number;
  51974. private _isImpostorInContact;
  51975. private _isImpostorPairInContact;
  51976. private _stepSimulation;
  51977. /**
  51978. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51979. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51980. * After the step the babylon meshes are set to the position of the physics imposters
  51981. * @param delta amount of time to step forward
  51982. * @param impostors array of imposters to update before/after the step
  51983. */
  51984. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51985. /**
  51986. * Update babylon mesh to match physics world object
  51987. * @param impostor imposter to match
  51988. */
  51989. private _afterSoftStep;
  51990. /**
  51991. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51992. * @param impostor imposter to match
  51993. */
  51994. private _ropeStep;
  51995. /**
  51996. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51997. * @param impostor imposter to match
  51998. */
  51999. private _softbodyOrClothStep;
  52000. private _tmpVector;
  52001. private _tmpMatrix;
  52002. /**
  52003. * Applies an impulse on the imposter
  52004. * @param impostor imposter to apply impulse to
  52005. * @param force amount of force to be applied to the imposter
  52006. * @param contactPoint the location to apply the impulse on the imposter
  52007. */
  52008. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52009. /**
  52010. * Applies a force on the imposter
  52011. * @param impostor imposter to apply force
  52012. * @param force amount of force to be applied to the imposter
  52013. * @param contactPoint the location to apply the force on the imposter
  52014. */
  52015. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52016. /**
  52017. * Creates a physics body using the plugin
  52018. * @param impostor the imposter to create the physics body on
  52019. */
  52020. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52021. /**
  52022. * Removes the physics body from the imposter and disposes of the body's memory
  52023. * @param impostor imposter to remove the physics body from
  52024. */
  52025. removePhysicsBody(impostor: PhysicsImpostor): void;
  52026. /**
  52027. * Generates a joint
  52028. * @param impostorJoint the imposter joint to create the joint with
  52029. */
  52030. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52031. /**
  52032. * Removes a joint
  52033. * @param impostorJoint the imposter joint to remove the joint from
  52034. */
  52035. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52036. private _addMeshVerts;
  52037. /**
  52038. * Initialise the soft body vertices to match its object's (mesh) vertices
  52039. * Softbody vertices (nodes) are in world space and to match this
  52040. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52041. * @param impostor to create the softbody for
  52042. */
  52043. private _softVertexData;
  52044. /**
  52045. * Create an impostor's soft body
  52046. * @param impostor to create the softbody for
  52047. */
  52048. private _createSoftbody;
  52049. /**
  52050. * Create cloth for an impostor
  52051. * @param impostor to create the softbody for
  52052. */
  52053. private _createCloth;
  52054. /**
  52055. * Create rope for an impostor
  52056. * @param impostor to create the softbody for
  52057. */
  52058. private _createRope;
  52059. private _addHullVerts;
  52060. private _createShape;
  52061. /**
  52062. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52063. * @param impostor imposter containing the physics body and babylon object
  52064. */
  52065. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52066. /**
  52067. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52068. * @param impostor imposter containing the physics body and babylon object
  52069. * @param newPosition new position
  52070. * @param newRotation new rotation
  52071. */
  52072. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52073. /**
  52074. * If this plugin is supported
  52075. * @returns true if its supported
  52076. */
  52077. isSupported(): boolean;
  52078. /**
  52079. * Sets the linear velocity of the physics body
  52080. * @param impostor imposter to set the velocity on
  52081. * @param velocity velocity to set
  52082. */
  52083. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52084. /**
  52085. * Sets the angular velocity of the physics body
  52086. * @param impostor imposter to set the velocity on
  52087. * @param velocity velocity to set
  52088. */
  52089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52090. /**
  52091. * gets the linear velocity
  52092. * @param impostor imposter to get linear velocity from
  52093. * @returns linear velocity
  52094. */
  52095. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52096. /**
  52097. * gets the angular velocity
  52098. * @param impostor imposter to get angular velocity from
  52099. * @returns angular velocity
  52100. */
  52101. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52102. /**
  52103. * Sets the mass of physics body
  52104. * @param impostor imposter to set the mass on
  52105. * @param mass mass to set
  52106. */
  52107. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52108. /**
  52109. * Gets the mass of the physics body
  52110. * @param impostor imposter to get the mass from
  52111. * @returns mass
  52112. */
  52113. getBodyMass(impostor: PhysicsImpostor): number;
  52114. /**
  52115. * Gets friction of the impostor
  52116. * @param impostor impostor to get friction from
  52117. * @returns friction value
  52118. */
  52119. getBodyFriction(impostor: PhysicsImpostor): number;
  52120. /**
  52121. * Sets friction of the impostor
  52122. * @param impostor impostor to set friction on
  52123. * @param friction friction value
  52124. */
  52125. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52126. /**
  52127. * Gets restitution of the impostor
  52128. * @param impostor impostor to get restitution from
  52129. * @returns restitution value
  52130. */
  52131. getBodyRestitution(impostor: PhysicsImpostor): number;
  52132. /**
  52133. * Sets resitution of the impostor
  52134. * @param impostor impostor to set resitution on
  52135. * @param restitution resitution value
  52136. */
  52137. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52138. /**
  52139. * Gets pressure inside the impostor
  52140. * @param impostor impostor to get pressure from
  52141. * @returns pressure value
  52142. */
  52143. getBodyPressure(impostor: PhysicsImpostor): number;
  52144. /**
  52145. * Sets pressure inside a soft body impostor
  52146. * Cloth and rope must remain 0 pressure
  52147. * @param impostor impostor to set pressure on
  52148. * @param pressure pressure value
  52149. */
  52150. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52151. /**
  52152. * Gets stiffness of the impostor
  52153. * @param impostor impostor to get stiffness from
  52154. * @returns pressure value
  52155. */
  52156. getBodyStiffness(impostor: PhysicsImpostor): number;
  52157. /**
  52158. * Sets stiffness of the impostor
  52159. * @param impostor impostor to set stiffness on
  52160. * @param stiffness stiffness value from 0 to 1
  52161. */
  52162. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52163. /**
  52164. * Gets velocityIterations of the impostor
  52165. * @param impostor impostor to get velocity iterations from
  52166. * @returns velocityIterations value
  52167. */
  52168. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52169. /**
  52170. * Sets velocityIterations of the impostor
  52171. * @param impostor impostor to set velocity iterations on
  52172. * @param velocityIterations velocityIterations value
  52173. */
  52174. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52175. /**
  52176. * Gets positionIterations of the impostor
  52177. * @param impostor impostor to get position iterations from
  52178. * @returns positionIterations value
  52179. */
  52180. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52181. /**
  52182. * Sets positionIterations of the impostor
  52183. * @param impostor impostor to set position on
  52184. * @param positionIterations positionIterations value
  52185. */
  52186. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52187. /**
  52188. * Append an anchor to a cloth object
  52189. * @param impostor is the cloth impostor to add anchor to
  52190. * @param otherImpostor is the rigid impostor to anchor to
  52191. * @param width ratio across width from 0 to 1
  52192. * @param height ratio up height from 0 to 1
  52193. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52194. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52195. */
  52196. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52197. /**
  52198. * Append an hook to a rope object
  52199. * @param impostor is the rope impostor to add hook to
  52200. * @param otherImpostor is the rigid impostor to hook to
  52201. * @param length ratio along the rope from 0 to 1
  52202. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52203. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52204. */
  52205. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52206. /**
  52207. * Sleeps the physics body and stops it from being active
  52208. * @param impostor impostor to sleep
  52209. */
  52210. sleepBody(impostor: PhysicsImpostor): void;
  52211. /**
  52212. * Activates the physics body
  52213. * @param impostor impostor to activate
  52214. */
  52215. wakeUpBody(impostor: PhysicsImpostor): void;
  52216. /**
  52217. * Updates the distance parameters of the joint
  52218. * @param joint joint to update
  52219. * @param maxDistance maximum distance of the joint
  52220. * @param minDistance minimum distance of the joint
  52221. */
  52222. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52223. /**
  52224. * Sets a motor on the joint
  52225. * @param joint joint to set motor on
  52226. * @param speed speed of the motor
  52227. * @param maxForce maximum force of the motor
  52228. * @param motorIndex index of the motor
  52229. */
  52230. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52231. /**
  52232. * Sets the motors limit
  52233. * @param joint joint to set limit on
  52234. * @param upperLimit upper limit
  52235. * @param lowerLimit lower limit
  52236. */
  52237. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52238. /**
  52239. * Syncs the position and rotation of a mesh with the impostor
  52240. * @param mesh mesh to sync
  52241. * @param impostor impostor to update the mesh with
  52242. */
  52243. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52244. /**
  52245. * Gets the radius of the impostor
  52246. * @param impostor impostor to get radius from
  52247. * @returns the radius
  52248. */
  52249. getRadius(impostor: PhysicsImpostor): number;
  52250. /**
  52251. * Gets the box size of the impostor
  52252. * @param impostor impostor to get box size from
  52253. * @param result the resulting box size
  52254. */
  52255. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52256. /**
  52257. * Disposes of the impostor
  52258. */
  52259. dispose(): void;
  52260. /**
  52261. * Does a raycast in the physics world
  52262. * @param from when should the ray start?
  52263. * @param to when should the ray end?
  52264. * @returns PhysicsRaycastResult
  52265. */
  52266. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52267. }
  52268. }
  52269. declare module BABYLON {
  52270. interface AbstractScene {
  52271. /**
  52272. * The list of reflection probes added to the scene
  52273. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52274. */
  52275. reflectionProbes: Array<ReflectionProbe>;
  52276. /**
  52277. * Removes the given reflection probe from this scene.
  52278. * @param toRemove The reflection probe to remove
  52279. * @returns The index of the removed reflection probe
  52280. */
  52281. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52282. /**
  52283. * Adds the given reflection probe to this scene.
  52284. * @param newReflectionProbe The reflection probe to add
  52285. */
  52286. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52287. }
  52288. /**
  52289. * Class used to generate realtime reflection / refraction cube textures
  52290. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52291. */
  52292. export class ReflectionProbe {
  52293. /** defines the name of the probe */
  52294. name: string;
  52295. private _scene;
  52296. private _renderTargetTexture;
  52297. private _projectionMatrix;
  52298. private _viewMatrix;
  52299. private _target;
  52300. private _add;
  52301. private _attachedMesh;
  52302. private _invertYAxis;
  52303. /** Gets or sets probe position (center of the cube map) */
  52304. position: Vector3;
  52305. /**
  52306. * Creates a new reflection probe
  52307. * @param name defines the name of the probe
  52308. * @param size defines the texture resolution (for each face)
  52309. * @param scene defines the hosting scene
  52310. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52311. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52312. */
  52313. constructor(
  52314. /** defines the name of the probe */
  52315. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52316. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52317. samples: number;
  52318. /** Gets or sets the refresh rate to use (on every frame by default) */
  52319. refreshRate: number;
  52320. /**
  52321. * Gets the hosting scene
  52322. * @returns a Scene
  52323. */
  52324. getScene(): Scene;
  52325. /** Gets the internal CubeTexture used to render to */
  52326. readonly cubeTexture: RenderTargetTexture;
  52327. /** Gets the list of meshes to render */
  52328. readonly renderList: Nullable<AbstractMesh[]>;
  52329. /**
  52330. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52331. * @param mesh defines the mesh to attach to
  52332. */
  52333. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52334. /**
  52335. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52336. * @param renderingGroupId The rendering group id corresponding to its index
  52337. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52338. */
  52339. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52340. /**
  52341. * Clean all associated resources
  52342. */
  52343. dispose(): void;
  52344. /**
  52345. * Converts the reflection probe information to a readable string for debug purpose.
  52346. * @param fullDetails Supports for multiple levels of logging within scene loading
  52347. * @returns the human readable reflection probe info
  52348. */
  52349. toString(fullDetails?: boolean): string;
  52350. /**
  52351. * Get the class name of the relfection probe.
  52352. * @returns "ReflectionProbe"
  52353. */
  52354. getClassName(): string;
  52355. /**
  52356. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52357. * @returns The JSON representation of the texture
  52358. */
  52359. serialize(): any;
  52360. /**
  52361. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52362. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52363. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52364. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52365. * @returns The parsed reflection probe if successful
  52366. */
  52367. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52368. }
  52369. }
  52370. declare module BABYLON {
  52371. /** @hidden */
  52372. export var _BabylonLoaderRegistered: boolean;
  52373. /**
  52374. * Helps setting up some configuration for the babylon file loader.
  52375. */
  52376. export class BabylonFileLoaderConfiguration {
  52377. /**
  52378. * The loader does not allow injecting custom physix engine into the plugins.
  52379. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52380. * So you could set this variable to your engine import to make it work.
  52381. */
  52382. static LoaderInjectedPhysicsEngine: any;
  52383. }
  52384. }
  52385. declare module BABYLON {
  52386. /**
  52387. * The Physically based simple base material of BJS.
  52388. *
  52389. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52390. * It is used as the base class for both the specGloss and metalRough conventions.
  52391. */
  52392. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52393. /**
  52394. * Number of Simultaneous lights allowed on the material.
  52395. */
  52396. maxSimultaneousLights: number;
  52397. /**
  52398. * If sets to true, disables all the lights affecting the material.
  52399. */
  52400. disableLighting: boolean;
  52401. /**
  52402. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52403. */
  52404. environmentTexture: BaseTexture;
  52405. /**
  52406. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52407. */
  52408. invertNormalMapX: boolean;
  52409. /**
  52410. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52411. */
  52412. invertNormalMapY: boolean;
  52413. /**
  52414. * Normal map used in the model.
  52415. */
  52416. normalTexture: BaseTexture;
  52417. /**
  52418. * Emissivie color used to self-illuminate the model.
  52419. */
  52420. emissiveColor: Color3;
  52421. /**
  52422. * Emissivie texture used to self-illuminate the model.
  52423. */
  52424. emissiveTexture: BaseTexture;
  52425. /**
  52426. * Occlusion Channel Strenght.
  52427. */
  52428. occlusionStrength: number;
  52429. /**
  52430. * Occlusion Texture of the material (adding extra occlusion effects).
  52431. */
  52432. occlusionTexture: BaseTexture;
  52433. /**
  52434. * Defines the alpha limits in alpha test mode.
  52435. */
  52436. alphaCutOff: number;
  52437. /**
  52438. * Gets the current double sided mode.
  52439. */
  52440. /**
  52441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52442. */
  52443. doubleSided: boolean;
  52444. /**
  52445. * Stores the pre-calculated light information of a mesh in a texture.
  52446. */
  52447. lightmapTexture: BaseTexture;
  52448. /**
  52449. * If true, the light map contains occlusion information instead of lighting info.
  52450. */
  52451. useLightmapAsShadowmap: boolean;
  52452. /**
  52453. * Instantiates a new PBRMaterial instance.
  52454. *
  52455. * @param name The material name
  52456. * @param scene The scene the material will be use in.
  52457. */
  52458. constructor(name: string, scene: Scene);
  52459. getClassName(): string;
  52460. }
  52461. }
  52462. declare module BABYLON {
  52463. /**
  52464. * The PBR material of BJS following the metal roughness convention.
  52465. *
  52466. * This fits to the PBR convention in the GLTF definition:
  52467. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52468. */
  52469. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52470. /**
  52471. * The base color has two different interpretations depending on the value of metalness.
  52472. * When the material is a metal, the base color is the specific measured reflectance value
  52473. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52474. * of the material.
  52475. */
  52476. baseColor: Color3;
  52477. /**
  52478. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52479. * well as opacity information in the alpha channel.
  52480. */
  52481. baseTexture: BaseTexture;
  52482. /**
  52483. * Specifies the metallic scalar value of the material.
  52484. * Can also be used to scale the metalness values of the metallic texture.
  52485. */
  52486. metallic: number;
  52487. /**
  52488. * Specifies the roughness scalar value of the material.
  52489. * Can also be used to scale the roughness values of the metallic texture.
  52490. */
  52491. roughness: number;
  52492. /**
  52493. * Texture containing both the metallic value in the B channel and the
  52494. * roughness value in the G channel to keep better precision.
  52495. */
  52496. metallicRoughnessTexture: BaseTexture;
  52497. /**
  52498. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52499. *
  52500. * @param name The material name
  52501. * @param scene The scene the material will be use in.
  52502. */
  52503. constructor(name: string, scene: Scene);
  52504. /**
  52505. * Return the currrent class name of the material.
  52506. */
  52507. getClassName(): string;
  52508. /**
  52509. * Makes a duplicate of the current material.
  52510. * @param name - name to use for the new material.
  52511. */
  52512. clone(name: string): PBRMetallicRoughnessMaterial;
  52513. /**
  52514. * Serialize the material to a parsable JSON object.
  52515. */
  52516. serialize(): any;
  52517. /**
  52518. * Parses a JSON object correponding to the serialize function.
  52519. */
  52520. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52521. }
  52522. }
  52523. declare module BABYLON {
  52524. /**
  52525. * The PBR material of BJS following the specular glossiness convention.
  52526. *
  52527. * This fits to the PBR convention in the GLTF definition:
  52528. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52529. */
  52530. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52531. /**
  52532. * Specifies the diffuse color of the material.
  52533. */
  52534. diffuseColor: Color3;
  52535. /**
  52536. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52537. * channel.
  52538. */
  52539. diffuseTexture: BaseTexture;
  52540. /**
  52541. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52542. */
  52543. specularColor: Color3;
  52544. /**
  52545. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52546. */
  52547. glossiness: number;
  52548. /**
  52549. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52550. */
  52551. specularGlossinessTexture: BaseTexture;
  52552. /**
  52553. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52554. *
  52555. * @param name The material name
  52556. * @param scene The scene the material will be use in.
  52557. */
  52558. constructor(name: string, scene: Scene);
  52559. /**
  52560. * Return the currrent class name of the material.
  52561. */
  52562. getClassName(): string;
  52563. /**
  52564. * Makes a duplicate of the current material.
  52565. * @param name - name to use for the new material.
  52566. */
  52567. clone(name: string): PBRSpecularGlossinessMaterial;
  52568. /**
  52569. * Serialize the material to a parsable JSON object.
  52570. */
  52571. serialize(): any;
  52572. /**
  52573. * Parses a JSON object correponding to the serialize function.
  52574. */
  52575. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52576. }
  52577. }
  52578. declare module BABYLON {
  52579. /**
  52580. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52581. * It can help converting any input color in a desired output one. This can then be used to create effects
  52582. * from sepia, black and white to sixties or futuristic rendering...
  52583. *
  52584. * The only supported format is currently 3dl.
  52585. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52586. */
  52587. export class ColorGradingTexture extends BaseTexture {
  52588. /**
  52589. * The current texture matrix. (will always be identity in color grading texture)
  52590. */
  52591. private _textureMatrix;
  52592. /**
  52593. * The texture URL.
  52594. */
  52595. url: string;
  52596. /**
  52597. * Empty line regex stored for GC.
  52598. */
  52599. private static _noneEmptyLineRegex;
  52600. private _engine;
  52601. /**
  52602. * Instantiates a ColorGradingTexture from the following parameters.
  52603. *
  52604. * @param url The location of the color gradind data (currently only supporting 3dl)
  52605. * @param scene The scene the texture will be used in
  52606. */
  52607. constructor(url: string, scene: Scene);
  52608. /**
  52609. * Returns the texture matrix used in most of the material.
  52610. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52611. */
  52612. getTextureMatrix(): Matrix;
  52613. /**
  52614. * Occurs when the file being loaded is a .3dl LUT file.
  52615. */
  52616. private load3dlTexture;
  52617. /**
  52618. * Starts the loading process of the texture.
  52619. */
  52620. private loadTexture;
  52621. /**
  52622. * Clones the color gradind texture.
  52623. */
  52624. clone(): ColorGradingTexture;
  52625. /**
  52626. * Called during delayed load for textures.
  52627. */
  52628. delayLoad(): void;
  52629. /**
  52630. * Parses a color grading texture serialized by Babylon.
  52631. * @param parsedTexture The texture information being parsedTexture
  52632. * @param scene The scene to load the texture in
  52633. * @param rootUrl The root url of the data assets to load
  52634. * @return A color gradind texture
  52635. */
  52636. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52637. /**
  52638. * Serializes the LUT texture to json format.
  52639. */
  52640. serialize(): any;
  52641. }
  52642. }
  52643. declare module BABYLON {
  52644. /**
  52645. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52646. */
  52647. export class EquiRectangularCubeTexture extends BaseTexture {
  52648. /** The six faces of the cube. */
  52649. private static _FacesMapping;
  52650. private _noMipmap;
  52651. private _onLoad;
  52652. private _onError;
  52653. /** The size of the cubemap. */
  52654. private _size;
  52655. /** The buffer of the image. */
  52656. private _buffer;
  52657. /** The width of the input image. */
  52658. private _width;
  52659. /** The height of the input image. */
  52660. private _height;
  52661. /** The URL to the image. */
  52662. url: string;
  52663. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52664. coordinatesMode: number;
  52665. /**
  52666. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52667. * @param url The location of the image
  52668. * @param scene The scene the texture will be used in
  52669. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52670. * @param noMipmap Forces to not generate the mipmap if true
  52671. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52672. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52673. * @param onLoad — defines a callback called when texture is loaded
  52674. * @param onError — defines a callback called if there is an error
  52675. */
  52676. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52677. /**
  52678. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52679. */
  52680. private loadImage;
  52681. /**
  52682. * Convert the image buffer into a cubemap and create a CubeTexture.
  52683. */
  52684. private loadTexture;
  52685. /**
  52686. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52687. * @param buffer The ArrayBuffer that should be converted.
  52688. * @returns The buffer as Float32Array.
  52689. */
  52690. private getFloat32ArrayFromArrayBuffer;
  52691. /**
  52692. * Get the current class name of the texture useful for serialization or dynamic coding.
  52693. * @returns "EquiRectangularCubeTexture"
  52694. */
  52695. getClassName(): string;
  52696. /**
  52697. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52698. * @returns A clone of the current EquiRectangularCubeTexture.
  52699. */
  52700. clone(): EquiRectangularCubeTexture;
  52701. }
  52702. }
  52703. declare module BABYLON {
  52704. /**
  52705. * Based on jsTGALoader - Javascript loader for TGA file
  52706. * By Vincent Thibault
  52707. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52708. */
  52709. export class TGATools {
  52710. private static _TYPE_INDEXED;
  52711. private static _TYPE_RGB;
  52712. private static _TYPE_GREY;
  52713. private static _TYPE_RLE_INDEXED;
  52714. private static _TYPE_RLE_RGB;
  52715. private static _TYPE_RLE_GREY;
  52716. private static _ORIGIN_MASK;
  52717. private static _ORIGIN_SHIFT;
  52718. private static _ORIGIN_BL;
  52719. private static _ORIGIN_BR;
  52720. private static _ORIGIN_UL;
  52721. private static _ORIGIN_UR;
  52722. /**
  52723. * Gets the header of a TGA file
  52724. * @param data defines the TGA data
  52725. * @returns the header
  52726. */
  52727. static GetTGAHeader(data: Uint8Array): any;
  52728. /**
  52729. * Uploads TGA content to a Babylon Texture
  52730. * @hidden
  52731. */
  52732. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52733. /** @hidden */
  52734. 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;
  52735. /** @hidden */
  52736. 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;
  52737. /** @hidden */
  52738. 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;
  52739. /** @hidden */
  52740. 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;
  52741. /** @hidden */
  52742. 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;
  52743. /** @hidden */
  52744. 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;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /**
  52749. * Implementation of the TGA Texture Loader.
  52750. * @hidden
  52751. */
  52752. export class _TGATextureLoader implements IInternalTextureLoader {
  52753. /**
  52754. * Defines wether the loader supports cascade loading the different faces.
  52755. */
  52756. readonly supportCascades: boolean;
  52757. /**
  52758. * This returns if the loader support the current file information.
  52759. * @param extension defines the file extension of the file being loaded
  52760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52761. * @param fallback defines the fallback internal texture if any
  52762. * @param isBase64 defines whether the texture is encoded as a base64
  52763. * @param isBuffer defines whether the texture data are stored as a buffer
  52764. * @returns true if the loader can load the specified file
  52765. */
  52766. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52767. /**
  52768. * Transform the url before loading if required.
  52769. * @param rootUrl the url of the texture
  52770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52771. * @returns the transformed texture
  52772. */
  52773. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52774. /**
  52775. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52776. * @param rootUrl the url of the texture
  52777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52778. * @returns the fallback texture
  52779. */
  52780. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52781. /**
  52782. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52783. * @param data contains the texture data
  52784. * @param texture defines the BabylonJS internal texture
  52785. * @param createPolynomials will be true if polynomials have been requested
  52786. * @param onLoad defines the callback to trigger once the texture is ready
  52787. * @param onError defines the callback to trigger in case of error
  52788. */
  52789. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52790. /**
  52791. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52792. * @param data contains the texture data
  52793. * @param texture defines the BabylonJS internal texture
  52794. * @param callback defines the method to call once ready to upload
  52795. */
  52796. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52797. }
  52798. }
  52799. declare module BABYLON {
  52800. /**
  52801. * Info about the .basis files
  52802. */
  52803. class BasisFileInfo {
  52804. /**
  52805. * If the file has alpha
  52806. */
  52807. hasAlpha: boolean;
  52808. /**
  52809. * Info about each image of the basis file
  52810. */
  52811. images: Array<{
  52812. levels: Array<{
  52813. width: number;
  52814. height: number;
  52815. transcodedPixels: ArrayBufferView;
  52816. }>;
  52817. }>;
  52818. }
  52819. /**
  52820. * Result of transcoding a basis file
  52821. */
  52822. class TranscodeResult {
  52823. /**
  52824. * Info about the .basis file
  52825. */
  52826. fileInfo: BasisFileInfo;
  52827. /**
  52828. * Format to use when loading the file
  52829. */
  52830. format: number;
  52831. }
  52832. /**
  52833. * Configuration options for the Basis transcoder
  52834. */
  52835. export class BasisTranscodeConfiguration {
  52836. /**
  52837. * Supported compression formats used to determine the supported output format of the transcoder
  52838. */
  52839. supportedCompressionFormats?: {
  52840. /**
  52841. * etc1 compression format
  52842. */
  52843. etc1?: boolean;
  52844. /**
  52845. * s3tc compression format
  52846. */
  52847. s3tc?: boolean;
  52848. /**
  52849. * pvrtc compression format
  52850. */
  52851. pvrtc?: boolean;
  52852. /**
  52853. * etc2 compression format
  52854. */
  52855. etc2?: boolean;
  52856. };
  52857. /**
  52858. * If mipmap levels should be loaded for transcoded images (Default: true)
  52859. */
  52860. loadMipmapLevels?: boolean;
  52861. /**
  52862. * Index of a single image to load (Default: all images)
  52863. */
  52864. loadSingleImage?: number;
  52865. }
  52866. /**
  52867. * Used to load .Basis files
  52868. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52869. */
  52870. export class BasisTools {
  52871. private static _IgnoreSupportedFormats;
  52872. /**
  52873. * URL to use when loading the basis transcoder
  52874. */
  52875. static JSModuleURL: string;
  52876. /**
  52877. * URL to use when loading the wasm module for the transcoder
  52878. */
  52879. static WasmModuleURL: string;
  52880. /**
  52881. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52882. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52883. * @returns internal format corresponding to the Basis format
  52884. */
  52885. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52886. private static _WorkerPromise;
  52887. private static _Worker;
  52888. private static _actionId;
  52889. private static _CreateWorkerAsync;
  52890. /**
  52891. * Transcodes a loaded image file to compressed pixel data
  52892. * @param imageData image data to transcode
  52893. * @param config configuration options for the transcoding
  52894. * @returns a promise resulting in the transcoded image
  52895. */
  52896. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52897. /**
  52898. * Loads a texture from the transcode result
  52899. * @param texture texture load to
  52900. * @param transcodeResult the result of transcoding the basis file to load from
  52901. */
  52902. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52903. }
  52904. }
  52905. declare module BABYLON {
  52906. /**
  52907. * Loader for .basis file format
  52908. */
  52909. export class _BasisTextureLoader implements IInternalTextureLoader {
  52910. /**
  52911. * Defines whether the loader supports cascade loading the different faces.
  52912. */
  52913. readonly supportCascades: boolean;
  52914. /**
  52915. * This returns if the loader support the current file information.
  52916. * @param extension defines the file extension of the file being loaded
  52917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52918. * @param fallback defines the fallback internal texture if any
  52919. * @param isBase64 defines whether the texture is encoded as a base64
  52920. * @param isBuffer defines whether the texture data are stored as a buffer
  52921. * @returns true if the loader can load the specified file
  52922. */
  52923. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52924. /**
  52925. * Transform the url before loading if required.
  52926. * @param rootUrl the url of the texture
  52927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52928. * @returns the transformed texture
  52929. */
  52930. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52931. /**
  52932. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52933. * @param rootUrl the url of the texture
  52934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52935. * @returns the fallback texture
  52936. */
  52937. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52938. /**
  52939. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52940. * @param data contains the texture data
  52941. * @param texture defines the BabylonJS internal texture
  52942. * @param createPolynomials will be true if polynomials have been requested
  52943. * @param onLoad defines the callback to trigger once the texture is ready
  52944. * @param onError defines the callback to trigger in case of error
  52945. */
  52946. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52947. /**
  52948. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52949. * @param data contains the texture data
  52950. * @param texture defines the BabylonJS internal texture
  52951. * @param callback defines the method to call once ready to upload
  52952. */
  52953. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52954. }
  52955. }
  52956. declare module BABYLON {
  52957. /**
  52958. * 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.
  52959. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52960. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52961. */
  52962. export class CustomProceduralTexture extends ProceduralTexture {
  52963. private _animate;
  52964. private _time;
  52965. private _config;
  52966. private _texturePath;
  52967. /**
  52968. * Instantiates a new Custom Procedural Texture.
  52969. * 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.
  52970. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52971. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52972. * @param name Define the name of the texture
  52973. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52974. * @param size Define the size of the texture to create
  52975. * @param scene Define the scene the texture belongs to
  52976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52977. * @param generateMipMaps Define if the texture should creates mip maps or not
  52978. */
  52979. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52980. private _loadJson;
  52981. /**
  52982. * Is the texture ready to be used ? (rendered at least once)
  52983. * @returns true if ready, otherwise, false.
  52984. */
  52985. isReady(): boolean;
  52986. /**
  52987. * Render the texture to its associated render target.
  52988. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52989. */
  52990. render(useCameraPostProcess?: boolean): void;
  52991. /**
  52992. * Update the list of dependant textures samplers in the shader.
  52993. */
  52994. updateTextures(): void;
  52995. /**
  52996. * Update the uniform values of the procedural texture in the shader.
  52997. */
  52998. updateShaderUniforms(): void;
  52999. /**
  53000. * Define if the texture animates or not.
  53001. */
  53002. animate: boolean;
  53003. }
  53004. }
  53005. declare module BABYLON {
  53006. /** @hidden */
  53007. export var noisePixelShader: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module BABYLON {
  53013. /**
  53014. * Class used to generate noise procedural textures
  53015. */
  53016. export class NoiseProceduralTexture extends ProceduralTexture {
  53017. private _time;
  53018. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53019. brightness: number;
  53020. /** Defines the number of octaves to process */
  53021. octaves: number;
  53022. /** Defines the level of persistence (0.8 by default) */
  53023. persistence: number;
  53024. /** Gets or sets animation speed factor (default is 1) */
  53025. animationSpeedFactor: number;
  53026. /**
  53027. * Creates a new NoiseProceduralTexture
  53028. * @param name defines the name fo the texture
  53029. * @param size defines the size of the texture (default is 256)
  53030. * @param scene defines the hosting scene
  53031. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53032. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53033. */
  53034. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53035. private _updateShaderUniforms;
  53036. protected _getDefines(): string;
  53037. /** Generate the current state of the procedural texture */
  53038. render(useCameraPostProcess?: boolean): void;
  53039. /**
  53040. * Serializes this noise procedural texture
  53041. * @returns a serialized noise procedural texture object
  53042. */
  53043. serialize(): any;
  53044. /**
  53045. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53046. * @param parsedTexture defines parsed texture data
  53047. * @param scene defines the current scene
  53048. * @param rootUrl defines the root URL containing noise procedural texture information
  53049. * @returns a parsed NoiseProceduralTexture
  53050. */
  53051. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53052. }
  53053. }
  53054. declare module BABYLON {
  53055. /**
  53056. * Raw cube texture where the raw buffers are passed in
  53057. */
  53058. export class RawCubeTexture extends CubeTexture {
  53059. /**
  53060. * Creates a cube texture where the raw buffers are passed in.
  53061. * @param scene defines the scene the texture is attached to
  53062. * @param data defines the array of data to use to create each face
  53063. * @param size defines the size of the textures
  53064. * @param format defines the format of the data
  53065. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53066. * @param generateMipMaps defines if the engine should generate the mip levels
  53067. * @param invertY defines if data must be stored with Y axis inverted
  53068. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53069. * @param compression defines the compression used (null by default)
  53070. */
  53071. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53072. /**
  53073. * Updates the raw cube texture.
  53074. * @param data defines the data to store
  53075. * @param format defines the data format
  53076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53077. * @param invertY defines if data must be stored with Y axis inverted
  53078. * @param compression defines the compression used (null by default)
  53079. * @param level defines which level of the texture to update
  53080. */
  53081. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53082. /**
  53083. * Updates a raw cube texture with RGBD encoded data.
  53084. * @param data defines the array of data [mipmap][face] to use to create each face
  53085. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53086. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53087. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53088. * @returns a promsie that resolves when the operation is complete
  53089. */
  53090. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53091. /**
  53092. * Clones the raw cube texture.
  53093. * @return a new cube texture
  53094. */
  53095. clone(): CubeTexture;
  53096. /** @hidden */
  53097. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53098. }
  53099. }
  53100. declare module BABYLON {
  53101. /**
  53102. * Class used to store 3D textures containing user data
  53103. */
  53104. export class RawTexture3D extends Texture {
  53105. /** Gets or sets the texture format to use */
  53106. format: number;
  53107. private _engine;
  53108. /**
  53109. * Create a new RawTexture3D
  53110. * @param data defines the data of the texture
  53111. * @param width defines the width of the texture
  53112. * @param height defines the height of the texture
  53113. * @param depth defines the depth of the texture
  53114. * @param format defines the texture format to use
  53115. * @param scene defines the hosting scene
  53116. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53117. * @param invertY defines if texture must be stored with Y axis inverted
  53118. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53119. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53120. */
  53121. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53122. /** Gets or sets the texture format to use */
  53123. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53124. /**
  53125. * Update the texture with new data
  53126. * @param data defines the data to store in the texture
  53127. */
  53128. update(data: ArrayBufferView): void;
  53129. }
  53130. }
  53131. declare module BABYLON {
  53132. /**
  53133. * Class used to store 2D array textures containing user data
  53134. */
  53135. export class RawTexture2DArray extends Texture {
  53136. /** Gets or sets the texture format to use */
  53137. format: number;
  53138. private _engine;
  53139. /**
  53140. * Create a new RawTexture2DArray
  53141. * @param data defines the data of the texture
  53142. * @param width defines the width of the texture
  53143. * @param height defines the height of the texture
  53144. * @param depth defines the number of layers of the texture
  53145. * @param format defines the texture format to use
  53146. * @param scene defines the hosting scene
  53147. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53148. * @param invertY defines if texture must be stored with Y axis inverted
  53149. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53150. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53151. */
  53152. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53153. /** Gets or sets the texture format to use */
  53154. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53155. /**
  53156. * Update the texture with new data
  53157. * @param data defines the data to store in the texture
  53158. */
  53159. update(data: ArrayBufferView): void;
  53160. }
  53161. }
  53162. declare module BABYLON {
  53163. /**
  53164. * Creates a refraction texture used by refraction channel of the standard material.
  53165. * It is like a mirror but to see through a material.
  53166. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53167. */
  53168. export class RefractionTexture extends RenderTargetTexture {
  53169. /**
  53170. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53171. * 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.
  53172. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53173. */
  53174. refractionPlane: Plane;
  53175. /**
  53176. * Define how deep under the surface we should see.
  53177. */
  53178. depth: number;
  53179. /**
  53180. * Creates a refraction texture used by refraction channel of the standard material.
  53181. * It is like a mirror but to see through a material.
  53182. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53183. * @param name Define the texture name
  53184. * @param size Define the size of the underlying texture
  53185. * @param scene Define the scene the refraction belongs to
  53186. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53187. */
  53188. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53189. /**
  53190. * Clone the refraction texture.
  53191. * @returns the cloned texture
  53192. */
  53193. clone(): RefractionTexture;
  53194. /**
  53195. * Serialize the texture to a JSON representation you could use in Parse later on
  53196. * @returns the serialized JSON representation
  53197. */
  53198. serialize(): any;
  53199. }
  53200. }
  53201. declare module BABYLON {
  53202. /**
  53203. * Defines the options related to the creation of an HtmlElementTexture
  53204. */
  53205. export interface IHtmlElementTextureOptions {
  53206. /**
  53207. * Defines wether mip maps should be created or not.
  53208. */
  53209. generateMipMaps?: boolean;
  53210. /**
  53211. * Defines the sampling mode of the texture.
  53212. */
  53213. samplingMode?: number;
  53214. /**
  53215. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53216. */
  53217. engine: Nullable<ThinEngine>;
  53218. /**
  53219. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53220. */
  53221. scene: Nullable<Scene>;
  53222. }
  53223. /**
  53224. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53225. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53226. * is automatically managed.
  53227. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53228. * in your application.
  53229. *
  53230. * As the update is not automatic, you need to call them manually.
  53231. */
  53232. export class HtmlElementTexture extends BaseTexture {
  53233. /**
  53234. * The texture URL.
  53235. */
  53236. element: HTMLVideoElement | HTMLCanvasElement;
  53237. private static readonly DefaultOptions;
  53238. private _textureMatrix;
  53239. private _engine;
  53240. private _isVideo;
  53241. private _generateMipMaps;
  53242. private _samplingMode;
  53243. /**
  53244. * Instantiates a HtmlElementTexture from the following parameters.
  53245. *
  53246. * @param name Defines the name of the texture
  53247. * @param element Defines the video or canvas the texture is filled with
  53248. * @param options Defines the other none mandatory texture creation options
  53249. */
  53250. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53251. private _createInternalTexture;
  53252. /**
  53253. * Returns the texture matrix used in most of the material.
  53254. */
  53255. getTextureMatrix(): Matrix;
  53256. /**
  53257. * Updates the content of the texture.
  53258. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53259. */
  53260. update(invertY?: Nullable<boolean>): void;
  53261. }
  53262. }
  53263. declare module BABYLON {
  53264. /**
  53265. * Enum used to define the target of a block
  53266. */
  53267. export enum NodeMaterialBlockTargets {
  53268. /** Vertex shader */
  53269. Vertex = 1,
  53270. /** Fragment shader */
  53271. Fragment = 2,
  53272. /** Neutral */
  53273. Neutral = 4,
  53274. /** Vertex and Fragment */
  53275. VertexAndFragment = 3
  53276. }
  53277. }
  53278. declare module BABYLON {
  53279. /**
  53280. * Defines the kind of connection point for node based material
  53281. */
  53282. export enum NodeMaterialBlockConnectionPointTypes {
  53283. /** Float */
  53284. Float = 1,
  53285. /** Int */
  53286. Int = 2,
  53287. /** Vector2 */
  53288. Vector2 = 4,
  53289. /** Vector3 */
  53290. Vector3 = 8,
  53291. /** Vector4 */
  53292. Vector4 = 16,
  53293. /** Color3 */
  53294. Color3 = 32,
  53295. /** Color4 */
  53296. Color4 = 64,
  53297. /** Matrix */
  53298. Matrix = 128,
  53299. /** Detect type based on connection */
  53300. AutoDetect = 1024,
  53301. /** Output type that will be defined by input type */
  53302. BasedOnInput = 2048
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53308. */
  53309. export enum NodeMaterialBlockConnectionPointMode {
  53310. /** Value is an uniform */
  53311. Uniform = 0,
  53312. /** Value is a mesh attribute */
  53313. Attribute = 1,
  53314. /** Value is a varying between vertex and fragment shaders */
  53315. Varying = 2,
  53316. /** Mode is undefined */
  53317. Undefined = 3
  53318. }
  53319. }
  53320. declare module BABYLON {
  53321. /**
  53322. * Enum used to define system values e.g. values automatically provided by the system
  53323. */
  53324. export enum NodeMaterialSystemValues {
  53325. /** World */
  53326. World = 1,
  53327. /** View */
  53328. View = 2,
  53329. /** Projection */
  53330. Projection = 3,
  53331. /** ViewProjection */
  53332. ViewProjection = 4,
  53333. /** WorldView */
  53334. WorldView = 5,
  53335. /** WorldViewProjection */
  53336. WorldViewProjection = 6,
  53337. /** CameraPosition */
  53338. CameraPosition = 7,
  53339. /** Fog Color */
  53340. FogColor = 8,
  53341. /** Delta time */
  53342. DeltaTime = 9
  53343. }
  53344. }
  53345. declare module BABYLON {
  53346. /**
  53347. * Root class for all node material optimizers
  53348. */
  53349. export class NodeMaterialOptimizer {
  53350. /**
  53351. * Function used to optimize a NodeMaterial graph
  53352. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53353. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53354. */
  53355. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53356. }
  53357. }
  53358. declare module BABYLON {
  53359. /**
  53360. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53361. */
  53362. export class TransformBlock extends NodeMaterialBlock {
  53363. /**
  53364. * Defines the value to use to complement W value to transform it to a Vector4
  53365. */
  53366. complementW: number;
  53367. /**
  53368. * Defines the value to use to complement z value to transform it to a Vector4
  53369. */
  53370. complementZ: number;
  53371. /**
  53372. * Creates a new TransformBlock
  53373. * @param name defines the block name
  53374. */
  53375. constructor(name: string);
  53376. /**
  53377. * Gets the current class name
  53378. * @returns the class name
  53379. */
  53380. getClassName(): string;
  53381. /**
  53382. * Gets the vector input
  53383. */
  53384. readonly vector: NodeMaterialConnectionPoint;
  53385. /**
  53386. * Gets the output component
  53387. */
  53388. readonly output: NodeMaterialConnectionPoint;
  53389. /**
  53390. * Gets the matrix transform input
  53391. */
  53392. readonly transform: NodeMaterialConnectionPoint;
  53393. protected _buildBlock(state: NodeMaterialBuildState): this;
  53394. serialize(): any;
  53395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53396. protected _dumpPropertiesCode(): string;
  53397. }
  53398. }
  53399. declare module BABYLON {
  53400. /**
  53401. * Block used to output the vertex position
  53402. */
  53403. export class VertexOutputBlock extends NodeMaterialBlock {
  53404. /**
  53405. * Creates a new VertexOutputBlock
  53406. * @param name defines the block name
  53407. */
  53408. constructor(name: string);
  53409. /**
  53410. * Gets the current class name
  53411. * @returns the class name
  53412. */
  53413. getClassName(): string;
  53414. /**
  53415. * Gets the vector input component
  53416. */
  53417. readonly vector: NodeMaterialConnectionPoint;
  53418. protected _buildBlock(state: NodeMaterialBuildState): this;
  53419. }
  53420. }
  53421. declare module BABYLON {
  53422. /**
  53423. * Block used to output the final color
  53424. */
  53425. export class FragmentOutputBlock extends NodeMaterialBlock {
  53426. /**
  53427. * Create a new FragmentOutputBlock
  53428. * @param name defines the block name
  53429. */
  53430. constructor(name: string);
  53431. /**
  53432. * Gets the current class name
  53433. * @returns the class name
  53434. */
  53435. getClassName(): string;
  53436. /**
  53437. * Gets the rgba input component
  53438. */
  53439. readonly rgba: NodeMaterialConnectionPoint;
  53440. /**
  53441. * Gets the rgb input component
  53442. */
  53443. readonly rgb: NodeMaterialConnectionPoint;
  53444. /**
  53445. * Gets the a input component
  53446. */
  53447. readonly a: NodeMaterialConnectionPoint;
  53448. protected _buildBlock(state: NodeMaterialBuildState): this;
  53449. }
  53450. }
  53451. declare module BABYLON {
  53452. /**
  53453. * Block used to read a reflection texture from a sampler
  53454. */
  53455. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53456. private _define3DName;
  53457. private _defineCubicName;
  53458. private _defineExplicitName;
  53459. private _defineProjectionName;
  53460. private _defineLocalCubicName;
  53461. private _defineSphericalName;
  53462. private _definePlanarName;
  53463. private _defineEquirectangularName;
  53464. private _defineMirroredEquirectangularFixedName;
  53465. private _defineEquirectangularFixedName;
  53466. private _defineSkyboxName;
  53467. private _cubeSamplerName;
  53468. private _2DSamplerName;
  53469. private _positionUVWName;
  53470. private _directionWName;
  53471. private _reflectionCoordsName;
  53472. private _reflection2DCoordsName;
  53473. private _reflectionColorName;
  53474. private _reflectionMatrixName;
  53475. /**
  53476. * Gets or sets the texture associated with the node
  53477. */
  53478. texture: Nullable<BaseTexture>;
  53479. /**
  53480. * Create a new TextureBlock
  53481. * @param name defines the block name
  53482. */
  53483. constructor(name: string);
  53484. /**
  53485. * Gets the current class name
  53486. * @returns the class name
  53487. */
  53488. getClassName(): string;
  53489. /**
  53490. * Gets the world position input component
  53491. */
  53492. readonly position: NodeMaterialConnectionPoint;
  53493. /**
  53494. * Gets the world position input component
  53495. */
  53496. readonly worldPosition: NodeMaterialConnectionPoint;
  53497. /**
  53498. * Gets the world normal input component
  53499. */
  53500. readonly worldNormal: NodeMaterialConnectionPoint;
  53501. /**
  53502. * Gets the world input component
  53503. */
  53504. readonly world: NodeMaterialConnectionPoint;
  53505. /**
  53506. * Gets the camera (or eye) position component
  53507. */
  53508. readonly cameraPosition: NodeMaterialConnectionPoint;
  53509. /**
  53510. * Gets the view input component
  53511. */
  53512. readonly view: NodeMaterialConnectionPoint;
  53513. /**
  53514. * Gets the rgb output component
  53515. */
  53516. readonly rgb: NodeMaterialConnectionPoint;
  53517. /**
  53518. * Gets the r output component
  53519. */
  53520. readonly r: NodeMaterialConnectionPoint;
  53521. /**
  53522. * Gets the g output component
  53523. */
  53524. readonly g: NodeMaterialConnectionPoint;
  53525. /**
  53526. * Gets the b output component
  53527. */
  53528. readonly b: NodeMaterialConnectionPoint;
  53529. autoConfigure(material: NodeMaterial): void;
  53530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53531. isReady(): boolean;
  53532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53533. private _injectVertexCode;
  53534. private _writeOutput;
  53535. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53536. protected _dumpPropertiesCode(): string;
  53537. serialize(): any;
  53538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53539. }
  53540. }
  53541. declare module BABYLON {
  53542. /**
  53543. * Interface used to configure the node material editor
  53544. */
  53545. export interface INodeMaterialEditorOptions {
  53546. /** Define the URl to load node editor script */
  53547. editorURL?: string;
  53548. }
  53549. /** @hidden */
  53550. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53551. /** BONES */
  53552. NUM_BONE_INFLUENCERS: number;
  53553. BonesPerMesh: number;
  53554. BONETEXTURE: boolean;
  53555. /** MORPH TARGETS */
  53556. MORPHTARGETS: boolean;
  53557. MORPHTARGETS_NORMAL: boolean;
  53558. MORPHTARGETS_TANGENT: boolean;
  53559. MORPHTARGETS_UV: boolean;
  53560. NUM_MORPH_INFLUENCERS: number;
  53561. /** IMAGE PROCESSING */
  53562. IMAGEPROCESSING: boolean;
  53563. VIGNETTE: boolean;
  53564. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53565. VIGNETTEBLENDMODEOPAQUE: boolean;
  53566. TONEMAPPING: boolean;
  53567. TONEMAPPING_ACES: boolean;
  53568. CONTRAST: boolean;
  53569. EXPOSURE: boolean;
  53570. COLORCURVES: boolean;
  53571. COLORGRADING: boolean;
  53572. COLORGRADING3D: boolean;
  53573. SAMPLER3DGREENDEPTH: boolean;
  53574. SAMPLER3DBGRMAP: boolean;
  53575. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53576. /** MISC. */
  53577. BUMPDIRECTUV: number;
  53578. constructor();
  53579. setValue(name: string, value: boolean): void;
  53580. }
  53581. /**
  53582. * Class used to configure NodeMaterial
  53583. */
  53584. export interface INodeMaterialOptions {
  53585. /**
  53586. * Defines if blocks should emit comments
  53587. */
  53588. emitComments: boolean;
  53589. }
  53590. /**
  53591. * Class used to create a node based material built by assembling shader blocks
  53592. */
  53593. export class NodeMaterial extends PushMaterial {
  53594. private static _BuildIdGenerator;
  53595. private _options;
  53596. private _vertexCompilationState;
  53597. private _fragmentCompilationState;
  53598. private _sharedData;
  53599. private _buildId;
  53600. private _buildWasSuccessful;
  53601. private _cachedWorldViewMatrix;
  53602. private _cachedWorldViewProjectionMatrix;
  53603. private _optimizers;
  53604. private _animationFrame;
  53605. /** Define the URl to load node editor script */
  53606. static EditorURL: string;
  53607. private BJSNODEMATERIALEDITOR;
  53608. /** Get the inspector from bundle or global */
  53609. private _getGlobalNodeMaterialEditor;
  53610. /**
  53611. * 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)
  53612. */
  53613. ignoreAlpha: boolean;
  53614. /**
  53615. * Defines the maximum number of lights that can be used in the material
  53616. */
  53617. maxSimultaneousLights: number;
  53618. /**
  53619. * Observable raised when the material is built
  53620. */
  53621. onBuildObservable: Observable<NodeMaterial>;
  53622. /**
  53623. * Gets or sets the root nodes of the material vertex shader
  53624. */
  53625. _vertexOutputNodes: NodeMaterialBlock[];
  53626. /**
  53627. * Gets or sets the root nodes of the material fragment (pixel) shader
  53628. */
  53629. _fragmentOutputNodes: NodeMaterialBlock[];
  53630. /** Gets or sets options to control the node material overall behavior */
  53631. options: INodeMaterialOptions;
  53632. /**
  53633. * Default configuration related to image processing available in the standard Material.
  53634. */
  53635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53636. /**
  53637. * Gets the image processing configuration used either in this material.
  53638. */
  53639. /**
  53640. * Sets the Default image processing configuration used either in the this material.
  53641. *
  53642. * If sets to null, the scene one is in use.
  53643. */
  53644. imageProcessingConfiguration: ImageProcessingConfiguration;
  53645. /**
  53646. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53647. */
  53648. attachedBlocks: NodeMaterialBlock[];
  53649. /**
  53650. * Create a new node based material
  53651. * @param name defines the material name
  53652. * @param scene defines the hosting scene
  53653. * @param options defines creation option
  53654. */
  53655. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53656. /**
  53657. * Gets the current class name of the material e.g. "NodeMaterial"
  53658. * @returns the class name
  53659. */
  53660. getClassName(): string;
  53661. /**
  53662. * Keep track of the image processing observer to allow dispose and replace.
  53663. */
  53664. private _imageProcessingObserver;
  53665. /**
  53666. * Attaches a new image processing configuration to the Standard Material.
  53667. * @param configuration
  53668. */
  53669. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53670. /**
  53671. * Get a block by its name
  53672. * @param name defines the name of the block to retrieve
  53673. * @returns the required block or null if not found
  53674. */
  53675. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53676. /**
  53677. * Get a block by its name
  53678. * @param predicate defines the predicate used to find the good candidate
  53679. * @returns the required block or null if not found
  53680. */
  53681. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53682. /**
  53683. * Get an input block by its name
  53684. * @param predicate defines the predicate used to find the good candidate
  53685. * @returns the required input block or null if not found
  53686. */
  53687. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53688. /**
  53689. * Gets the list of input blocks attached to this material
  53690. * @returns an array of InputBlocks
  53691. */
  53692. getInputBlocks(): InputBlock[];
  53693. /**
  53694. * Adds a new optimizer to the list of optimizers
  53695. * @param optimizer defines the optimizers to add
  53696. * @returns the current material
  53697. */
  53698. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53699. /**
  53700. * Remove an optimizer from the list of optimizers
  53701. * @param optimizer defines the optimizers to remove
  53702. * @returns the current material
  53703. */
  53704. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53705. /**
  53706. * Add a new block to the list of output nodes
  53707. * @param node defines the node to add
  53708. * @returns the current material
  53709. */
  53710. addOutputNode(node: NodeMaterialBlock): this;
  53711. /**
  53712. * Remove a block from the list of root nodes
  53713. * @param node defines the node to remove
  53714. * @returns the current material
  53715. */
  53716. removeOutputNode(node: NodeMaterialBlock): this;
  53717. private _addVertexOutputNode;
  53718. private _removeVertexOutputNode;
  53719. private _addFragmentOutputNode;
  53720. private _removeFragmentOutputNode;
  53721. /**
  53722. * Specifies if the material will require alpha blending
  53723. * @returns a boolean specifying if alpha blending is needed
  53724. */
  53725. needAlphaBlending(): boolean;
  53726. /**
  53727. * Specifies if this material should be rendered in alpha test mode
  53728. * @returns a boolean specifying if an alpha test is needed.
  53729. */
  53730. needAlphaTesting(): boolean;
  53731. private _initializeBlock;
  53732. private _resetDualBlocks;
  53733. /**
  53734. * Build the material and generates the inner effect
  53735. * @param verbose defines if the build should log activity
  53736. */
  53737. build(verbose?: boolean): void;
  53738. /**
  53739. * Runs an otpimization phase to try to improve the shader code
  53740. */
  53741. optimize(): void;
  53742. private _prepareDefinesForAttributes;
  53743. /**
  53744. * Get if the submesh is ready to be used and all its information available.
  53745. * Child classes can use it to update shaders
  53746. * @param mesh defines the mesh to check
  53747. * @param subMesh defines which submesh to check
  53748. * @param useInstances specifies that instances should be used
  53749. * @returns a boolean indicating that the submesh is ready or not
  53750. */
  53751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53752. /**
  53753. * Get a string representing the shaders built by the current node graph
  53754. */
  53755. readonly compiledShaders: string;
  53756. /**
  53757. * Binds the world matrix to the material
  53758. * @param world defines the world transformation matrix
  53759. */
  53760. bindOnlyWorldMatrix(world: Matrix): void;
  53761. /**
  53762. * Binds the submesh to this material by preparing the effect and shader to draw
  53763. * @param world defines the world transformation matrix
  53764. * @param mesh defines the mesh containing the submesh
  53765. * @param subMesh defines the submesh to bind the material to
  53766. */
  53767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53768. /**
  53769. * Gets the active textures from the material
  53770. * @returns an array of textures
  53771. */
  53772. getActiveTextures(): BaseTexture[];
  53773. /**
  53774. * Gets the list of texture blocks
  53775. * @returns an array of texture blocks
  53776. */
  53777. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53778. /**
  53779. * Specifies if the material uses a texture
  53780. * @param texture defines the texture to check against the material
  53781. * @returns a boolean specifying if the material uses the texture
  53782. */
  53783. hasTexture(texture: BaseTexture): boolean;
  53784. /**
  53785. * Disposes the material
  53786. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53787. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53788. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53789. */
  53790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53791. /** Creates the node editor window. */
  53792. private _createNodeEditor;
  53793. /**
  53794. * Launch the node material editor
  53795. * @param config Define the configuration of the editor
  53796. * @return a promise fulfilled when the node editor is visible
  53797. */
  53798. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53799. /**
  53800. * Clear the current material
  53801. */
  53802. clear(): void;
  53803. /**
  53804. * Clear the current material and set it to a default state
  53805. */
  53806. setToDefault(): void;
  53807. /**
  53808. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53809. * @param url defines the url to load from
  53810. * @returns a promise that will fullfil when the material is fully loaded
  53811. */
  53812. loadAsync(url: string): Promise<void>;
  53813. private _gatherBlocks;
  53814. /**
  53815. * Generate a string containing the code declaration required to create an equivalent of this material
  53816. * @returns a string
  53817. */
  53818. generateCode(): string;
  53819. /**
  53820. * Serializes this material in a JSON representation
  53821. * @returns the serialized material object
  53822. */
  53823. serialize(): any;
  53824. private _restoreConnections;
  53825. /**
  53826. * Clear the current graph and load a new one from a serialization object
  53827. * @param source defines the JSON representation of the material
  53828. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53829. */
  53830. loadFromSerialization(source: any, rootUrl?: string): void;
  53831. /**
  53832. * Creates a node material from parsed material data
  53833. * @param source defines the JSON representation of the material
  53834. * @param scene defines the hosting scene
  53835. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53836. * @returns a new node material
  53837. */
  53838. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53839. /**
  53840. * Creates a new node material set to default basic configuration
  53841. * @param name defines the name of the material
  53842. * @param scene defines the hosting scene
  53843. * @returns a new NodeMaterial
  53844. */
  53845. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53846. }
  53847. }
  53848. declare module BABYLON {
  53849. /**
  53850. * Block used to read a texture from a sampler
  53851. */
  53852. export class TextureBlock extends NodeMaterialBlock {
  53853. private _defineName;
  53854. private _linearDefineName;
  53855. private _samplerName;
  53856. private _transformedUVName;
  53857. private _textureTransformName;
  53858. private _textureInfoName;
  53859. private _mainUVName;
  53860. private _mainUVDefineName;
  53861. /**
  53862. * Gets or sets the texture associated with the node
  53863. */
  53864. texture: Nullable<Texture>;
  53865. /**
  53866. * Create a new TextureBlock
  53867. * @param name defines the block name
  53868. */
  53869. constructor(name: string);
  53870. /**
  53871. * Gets the current class name
  53872. * @returns the class name
  53873. */
  53874. getClassName(): string;
  53875. /**
  53876. * Gets the uv input component
  53877. */
  53878. readonly uv: NodeMaterialConnectionPoint;
  53879. /**
  53880. * Gets the rgba output component
  53881. */
  53882. readonly rgba: NodeMaterialConnectionPoint;
  53883. /**
  53884. * Gets the rgb output component
  53885. */
  53886. readonly rgb: NodeMaterialConnectionPoint;
  53887. /**
  53888. * Gets the r output component
  53889. */
  53890. readonly r: NodeMaterialConnectionPoint;
  53891. /**
  53892. * Gets the g output component
  53893. */
  53894. readonly g: NodeMaterialConnectionPoint;
  53895. /**
  53896. * Gets the b output component
  53897. */
  53898. readonly b: NodeMaterialConnectionPoint;
  53899. /**
  53900. * Gets the a output component
  53901. */
  53902. readonly a: NodeMaterialConnectionPoint;
  53903. readonly target: NodeMaterialBlockTargets;
  53904. autoConfigure(material: NodeMaterial): void;
  53905. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53907. isReady(): boolean;
  53908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53909. private readonly _isMixed;
  53910. private _injectVertexCode;
  53911. private _writeOutput;
  53912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53913. protected _dumpPropertiesCode(): string;
  53914. serialize(): any;
  53915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53916. }
  53917. }
  53918. declare module BABYLON {
  53919. /**
  53920. * Class used to store shared data between 2 NodeMaterialBuildState
  53921. */
  53922. export class NodeMaterialBuildStateSharedData {
  53923. /**
  53924. * Gets the list of emitted varyings
  53925. */
  53926. temps: string[];
  53927. /**
  53928. * Gets the list of emitted varyings
  53929. */
  53930. varyings: string[];
  53931. /**
  53932. * Gets the varying declaration string
  53933. */
  53934. varyingDeclaration: string;
  53935. /**
  53936. * Input blocks
  53937. */
  53938. inputBlocks: InputBlock[];
  53939. /**
  53940. * Input blocks
  53941. */
  53942. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53943. /**
  53944. * Bindable blocks (Blocks that need to set data to the effect)
  53945. */
  53946. bindableBlocks: NodeMaterialBlock[];
  53947. /**
  53948. * List of blocks that can provide a compilation fallback
  53949. */
  53950. blocksWithFallbacks: NodeMaterialBlock[];
  53951. /**
  53952. * List of blocks that can provide a define update
  53953. */
  53954. blocksWithDefines: NodeMaterialBlock[];
  53955. /**
  53956. * List of blocks that can provide a repeatable content
  53957. */
  53958. repeatableContentBlocks: NodeMaterialBlock[];
  53959. /**
  53960. * List of blocks that can provide a dynamic list of uniforms
  53961. */
  53962. dynamicUniformBlocks: NodeMaterialBlock[];
  53963. /**
  53964. * List of blocks that can block the isReady function for the material
  53965. */
  53966. blockingBlocks: NodeMaterialBlock[];
  53967. /**
  53968. * Gets the list of animated inputs
  53969. */
  53970. animatedInputs: InputBlock[];
  53971. /**
  53972. * Build Id used to avoid multiple recompilations
  53973. */
  53974. buildId: number;
  53975. /** List of emitted variables */
  53976. variableNames: {
  53977. [key: string]: number;
  53978. };
  53979. /** List of emitted defines */
  53980. defineNames: {
  53981. [key: string]: number;
  53982. };
  53983. /** Should emit comments? */
  53984. emitComments: boolean;
  53985. /** Emit build activity */
  53986. verbose: boolean;
  53987. /** Gets or sets the hosting scene */
  53988. scene: Scene;
  53989. /**
  53990. * Gets the compilation hints emitted at compilation time
  53991. */
  53992. hints: {
  53993. needWorldViewMatrix: boolean;
  53994. needWorldViewProjectionMatrix: boolean;
  53995. needAlphaBlending: boolean;
  53996. needAlphaTesting: boolean;
  53997. };
  53998. /**
  53999. * List of compilation checks
  54000. */
  54001. checks: {
  54002. emitVertex: boolean;
  54003. emitFragment: boolean;
  54004. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54005. };
  54006. /** Creates a new shared data */
  54007. constructor();
  54008. /**
  54009. * Emits console errors and exceptions if there is a failing check
  54010. */
  54011. emitErrors(): void;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /**
  54016. * Class used to store node based material build state
  54017. */
  54018. export class NodeMaterialBuildState {
  54019. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54020. supportUniformBuffers: boolean;
  54021. /**
  54022. * Gets the list of emitted attributes
  54023. */
  54024. attributes: string[];
  54025. /**
  54026. * Gets the list of emitted uniforms
  54027. */
  54028. uniforms: string[];
  54029. /**
  54030. * Gets the list of emitted constants
  54031. */
  54032. constants: string[];
  54033. /**
  54034. * Gets the list of emitted samplers
  54035. */
  54036. samplers: string[];
  54037. /**
  54038. * Gets the list of emitted functions
  54039. */
  54040. functions: {
  54041. [key: string]: string;
  54042. };
  54043. /**
  54044. * Gets the list of emitted extensions
  54045. */
  54046. extensions: {
  54047. [key: string]: string;
  54048. };
  54049. /**
  54050. * Gets the target of the compilation state
  54051. */
  54052. target: NodeMaterialBlockTargets;
  54053. /**
  54054. * Gets the list of emitted counters
  54055. */
  54056. counters: {
  54057. [key: string]: number;
  54058. };
  54059. /**
  54060. * Shared data between multiple NodeMaterialBuildState instances
  54061. */
  54062. sharedData: NodeMaterialBuildStateSharedData;
  54063. /** @hidden */
  54064. _vertexState: NodeMaterialBuildState;
  54065. /** @hidden */
  54066. _attributeDeclaration: string;
  54067. /** @hidden */
  54068. _uniformDeclaration: string;
  54069. /** @hidden */
  54070. _constantDeclaration: string;
  54071. /** @hidden */
  54072. _samplerDeclaration: string;
  54073. /** @hidden */
  54074. _varyingTransfer: string;
  54075. private _repeatableContentAnchorIndex;
  54076. /** @hidden */
  54077. _builtCompilationString: string;
  54078. /**
  54079. * Gets the emitted compilation strings
  54080. */
  54081. compilationString: string;
  54082. /**
  54083. * Finalize the compilation strings
  54084. * @param state defines the current compilation state
  54085. */
  54086. finalize(state: NodeMaterialBuildState): void;
  54087. /** @hidden */
  54088. readonly _repeatableContentAnchor: string;
  54089. /** @hidden */
  54090. _getFreeVariableName(prefix: string): string;
  54091. /** @hidden */
  54092. _getFreeDefineName(prefix: string): string;
  54093. /** @hidden */
  54094. _excludeVariableName(name: string): void;
  54095. /** @hidden */
  54096. _emit2DSampler(name: string): void;
  54097. /** @hidden */
  54098. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54099. /** @hidden */
  54100. _emitExtension(name: string, extension: string): void;
  54101. /** @hidden */
  54102. _emitFunction(name: string, code: string, comments: string): void;
  54103. /** @hidden */
  54104. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54105. replaceStrings?: {
  54106. search: RegExp;
  54107. replace: string;
  54108. }[];
  54109. repeatKey?: string;
  54110. }): string;
  54111. /** @hidden */
  54112. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54113. repeatKey?: string;
  54114. removeAttributes?: boolean;
  54115. removeUniforms?: boolean;
  54116. removeVaryings?: boolean;
  54117. removeIfDef?: boolean;
  54118. replaceStrings?: {
  54119. search: RegExp;
  54120. replace: string;
  54121. }[];
  54122. }, storeKey?: string): void;
  54123. /** @hidden */
  54124. _registerTempVariable(name: string): boolean;
  54125. /** @hidden */
  54126. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54127. /** @hidden */
  54128. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54129. /** @hidden */
  54130. _emitFloat(value: number): string;
  54131. }
  54132. }
  54133. declare module BABYLON {
  54134. /**
  54135. * Defines a block that can be used inside a node based material
  54136. */
  54137. export class NodeMaterialBlock {
  54138. private _buildId;
  54139. private _buildTarget;
  54140. private _target;
  54141. private _isFinalMerger;
  54142. private _isInput;
  54143. protected _isUnique: boolean;
  54144. /** @hidden */
  54145. _codeVariableName: string;
  54146. /** @hidden */
  54147. _inputs: NodeMaterialConnectionPoint[];
  54148. /** @hidden */
  54149. _outputs: NodeMaterialConnectionPoint[];
  54150. /** @hidden */
  54151. _preparationId: number;
  54152. /**
  54153. * Gets or sets the name of the block
  54154. */
  54155. name: string;
  54156. /**
  54157. * Gets or sets the unique id of the node
  54158. */
  54159. uniqueId: number;
  54160. /**
  54161. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54162. */
  54163. readonly isUnique: boolean;
  54164. /**
  54165. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54166. */
  54167. readonly isFinalMerger: boolean;
  54168. /**
  54169. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54170. */
  54171. readonly isInput: boolean;
  54172. /**
  54173. * Gets or sets the build Id
  54174. */
  54175. buildId: number;
  54176. /**
  54177. * Gets or sets the target of the block
  54178. */
  54179. target: NodeMaterialBlockTargets;
  54180. /**
  54181. * Gets the list of input points
  54182. */
  54183. readonly inputs: NodeMaterialConnectionPoint[];
  54184. /** Gets the list of output points */
  54185. readonly outputs: NodeMaterialConnectionPoint[];
  54186. /**
  54187. * Find an input by its name
  54188. * @param name defines the name of the input to look for
  54189. * @returns the input or null if not found
  54190. */
  54191. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54192. /**
  54193. * Find an output by its name
  54194. * @param name defines the name of the outputto look for
  54195. * @returns the output or null if not found
  54196. */
  54197. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54198. /**
  54199. * Creates a new NodeMaterialBlock
  54200. * @param name defines the block name
  54201. * @param target defines the target of that block (Vertex by default)
  54202. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54203. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54204. */
  54205. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54206. /**
  54207. * Initialize the block and prepare the context for build
  54208. * @param state defines the state that will be used for the build
  54209. */
  54210. initialize(state: NodeMaterialBuildState): void;
  54211. /**
  54212. * Bind data to effect. Will only be called for blocks with isBindable === true
  54213. * @param effect defines the effect to bind data to
  54214. * @param nodeMaterial defines the hosting NodeMaterial
  54215. * @param mesh defines the mesh that will be rendered
  54216. */
  54217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54218. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54219. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54220. protected _writeFloat(value: number): string;
  54221. /**
  54222. * Gets the current class name e.g. "NodeMaterialBlock"
  54223. * @returns the class name
  54224. */
  54225. getClassName(): string;
  54226. /**
  54227. * Register a new input. Must be called inside a block constructor
  54228. * @param name defines the connection point name
  54229. * @param type defines the connection point type
  54230. * @param isOptional defines a boolean indicating that this input can be omitted
  54231. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54232. * @returns the current block
  54233. */
  54234. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54235. /**
  54236. * Register a new output. Must be called inside a block constructor
  54237. * @param name defines the connection point name
  54238. * @param type defines the connection point type
  54239. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54240. * @returns the current block
  54241. */
  54242. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54243. /**
  54244. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54245. * @param forOutput defines an optional connection point to check compatibility with
  54246. * @returns the first available input or null
  54247. */
  54248. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54249. /**
  54250. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54251. * @param forBlock defines an optional block to check compatibility with
  54252. * @returns the first available input or null
  54253. */
  54254. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54255. /**
  54256. * Gets the sibling of the given output
  54257. * @param current defines the current output
  54258. * @returns the next output in the list or null
  54259. */
  54260. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54261. /**
  54262. * Connect current block with another block
  54263. * @param other defines the block to connect with
  54264. * @param options define the various options to help pick the right connections
  54265. * @returns the current block
  54266. */
  54267. connectTo(other: NodeMaterialBlock, options?: {
  54268. input?: string;
  54269. output?: string;
  54270. outputSwizzle?: string;
  54271. }): this | undefined;
  54272. protected _buildBlock(state: NodeMaterialBuildState): void;
  54273. /**
  54274. * Add uniforms, samplers and uniform buffers at compilation time
  54275. * @param state defines the state to update
  54276. * @param nodeMaterial defines the node material requesting the update
  54277. * @param defines defines the material defines to update
  54278. * @param uniformBuffers defines the list of uniform buffer names
  54279. */
  54280. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54281. /**
  54282. * Add potential fallbacks if shader compilation fails
  54283. * @param mesh defines the mesh to be rendered
  54284. * @param fallbacks defines the current prioritized list of fallbacks
  54285. */
  54286. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54287. /**
  54288. * Initialize defines for shader compilation
  54289. * @param mesh defines the mesh to be rendered
  54290. * @param nodeMaterial defines the node material requesting the update
  54291. * @param defines defines the material defines to update
  54292. * @param useInstances specifies that instances should be used
  54293. */
  54294. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54295. /**
  54296. * Update defines for shader compilation
  54297. * @param mesh defines the mesh to be rendered
  54298. * @param nodeMaterial defines the node material requesting the update
  54299. * @param defines defines the material defines to update
  54300. * @param useInstances specifies that instances should be used
  54301. */
  54302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54303. /**
  54304. * Lets the block try to connect some inputs automatically
  54305. * @param material defines the hosting NodeMaterial
  54306. */
  54307. autoConfigure(material: NodeMaterial): void;
  54308. /**
  54309. * Function called when a block is declared as repeatable content generator
  54310. * @param vertexShaderState defines the current compilation state for the vertex shader
  54311. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54312. * @param mesh defines the mesh to be rendered
  54313. * @param defines defines the material defines to update
  54314. */
  54315. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54316. /**
  54317. * Checks if the block is ready
  54318. * @param mesh defines the mesh to be rendered
  54319. * @param nodeMaterial defines the node material requesting the update
  54320. * @param defines defines the material defines to update
  54321. * @param useInstances specifies that instances should be used
  54322. * @returns true if the block is ready
  54323. */
  54324. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54325. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54326. private _processBuild;
  54327. /**
  54328. * Compile the current node and generate the shader code
  54329. * @param state defines the current compilation state (uniforms, samplers, current string)
  54330. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54331. * @returns true if already built
  54332. */
  54333. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54334. protected _inputRename(name: string): string;
  54335. protected _outputRename(name: string): string;
  54336. protected _dumpPropertiesCode(): string;
  54337. /** @hidden */
  54338. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54339. /** @hidden */
  54340. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54341. /**
  54342. * Clone the current block to a new identical block
  54343. * @param scene defines the hosting scene
  54344. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54345. * @returns a copy of the current block
  54346. */
  54347. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54348. /**
  54349. * Serializes this block in a JSON representation
  54350. * @returns the serialized block object
  54351. */
  54352. serialize(): any;
  54353. /** @hidden */
  54354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54355. /**
  54356. * Release resources
  54357. */
  54358. dispose(): void;
  54359. }
  54360. }
  54361. declare module BABYLON {
  54362. /**
  54363. * Enum defining the type of animations supported by InputBlock
  54364. */
  54365. export enum AnimatedInputBlockTypes {
  54366. /** No animation */
  54367. None = 0,
  54368. /** Time based animation. Will only work for floats */
  54369. Time = 1
  54370. }
  54371. }
  54372. declare module BABYLON {
  54373. /**
  54374. * Block used to expose an input value
  54375. */
  54376. export class InputBlock extends NodeMaterialBlock {
  54377. private _mode;
  54378. private _associatedVariableName;
  54379. private _storedValue;
  54380. private _valueCallback;
  54381. private _type;
  54382. private _animationType;
  54383. /** Gets or set a value used to limit the range of float values */
  54384. min: number;
  54385. /** Gets or set a value used to limit the range of float values */
  54386. max: number;
  54387. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54388. matrixMode: number;
  54389. /** @hidden */
  54390. _systemValue: Nullable<NodeMaterialSystemValues>;
  54391. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54392. visibleInInspector: boolean;
  54393. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54394. isConstant: boolean;
  54395. /**
  54396. * Gets or sets the connection point type (default is float)
  54397. */
  54398. readonly type: NodeMaterialBlockConnectionPointTypes;
  54399. /**
  54400. * Creates a new InputBlock
  54401. * @param name defines the block name
  54402. * @param target defines the target of that block (Vertex by default)
  54403. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54404. */
  54405. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54406. /**
  54407. * Gets the output component
  54408. */
  54409. readonly output: NodeMaterialConnectionPoint;
  54410. /**
  54411. * Set the source of this connection point to a vertex attribute
  54412. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54413. * @returns the current connection point
  54414. */
  54415. setAsAttribute(attributeName?: string): InputBlock;
  54416. /**
  54417. * Set the source of this connection point to a system value
  54418. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54419. * @returns the current connection point
  54420. */
  54421. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54422. /**
  54423. * Gets or sets the value of that point.
  54424. * Please note that this value will be ignored if valueCallback is defined
  54425. */
  54426. value: any;
  54427. /**
  54428. * Gets or sets a callback used to get the value of that point.
  54429. * Please note that setting this value will force the connection point to ignore the value property
  54430. */
  54431. valueCallback: () => any;
  54432. /**
  54433. * Gets or sets the associated variable name in the shader
  54434. */
  54435. associatedVariableName: string;
  54436. /** Gets or sets the type of animation applied to the input */
  54437. animationType: AnimatedInputBlockTypes;
  54438. /**
  54439. * Gets a boolean indicating that this connection point not defined yet
  54440. */
  54441. readonly isUndefined: boolean;
  54442. /**
  54443. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54444. * In this case the connection point name must be the name of the uniform to use.
  54445. * Can only be set on inputs
  54446. */
  54447. isUniform: boolean;
  54448. /**
  54449. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54450. * In this case the connection point name must be the name of the attribute to use
  54451. * Can only be set on inputs
  54452. */
  54453. isAttribute: boolean;
  54454. /**
  54455. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54456. * Can only be set on exit points
  54457. */
  54458. isVarying: boolean;
  54459. /**
  54460. * Gets a boolean indicating that the current connection point is a system value
  54461. */
  54462. readonly isSystemValue: boolean;
  54463. /**
  54464. * Gets or sets the current well known value or null if not defined as a system value
  54465. */
  54466. systemValue: Nullable<NodeMaterialSystemValues>;
  54467. /**
  54468. * Gets the current class name
  54469. * @returns the class name
  54470. */
  54471. getClassName(): string;
  54472. /**
  54473. * Animate the input if animationType !== None
  54474. * @param scene defines the rendering scene
  54475. */
  54476. animate(scene: Scene): void;
  54477. private _emitDefine;
  54478. initialize(state: NodeMaterialBuildState): void;
  54479. /**
  54480. * Set the input block to its default value (based on its type)
  54481. */
  54482. setDefaultValue(): void;
  54483. private _emitConstant;
  54484. private _emit;
  54485. /** @hidden */
  54486. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54487. /** @hidden */
  54488. _transmit(effect: Effect, scene: Scene): void;
  54489. protected _buildBlock(state: NodeMaterialBuildState): void;
  54490. protected _dumpPropertiesCode(): string;
  54491. serialize(): any;
  54492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54493. }
  54494. }
  54495. declare module BABYLON {
  54496. /**
  54497. * Enum used to define the compatibility state between two connection points
  54498. */
  54499. export enum NodeMaterialConnectionPointCompatibilityStates {
  54500. /** Points are compatibles */
  54501. Compatible = 0,
  54502. /** Points are incompatible because of their types */
  54503. TypeIncompatible = 1,
  54504. /** Points are incompatible because of their targets (vertex vs fragment) */
  54505. TargetIncompatible = 2
  54506. }
  54507. /**
  54508. * Defines a connection point for a block
  54509. */
  54510. export class NodeMaterialConnectionPoint {
  54511. /** @hidden */
  54512. _ownerBlock: NodeMaterialBlock;
  54513. /** @hidden */
  54514. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54515. private _endpoints;
  54516. private _associatedVariableName;
  54517. /** @hidden */
  54518. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54519. /** @hidden */
  54520. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54521. private _type;
  54522. /** @hidden */
  54523. _enforceAssociatedVariableName: boolean;
  54524. /**
  54525. * Gets or sets the additional types supported by this connection point
  54526. */
  54527. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54528. /**
  54529. * Gets or sets the additional types excluded by this connection point
  54530. */
  54531. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54532. /**
  54533. * Observable triggered when this point is connected
  54534. */
  54535. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54536. /**
  54537. * Gets or sets the associated variable name in the shader
  54538. */
  54539. associatedVariableName: string;
  54540. /**
  54541. * Gets or sets the connection point type (default is float)
  54542. */
  54543. type: NodeMaterialBlockConnectionPointTypes;
  54544. /**
  54545. * Gets or sets the connection point name
  54546. */
  54547. name: string;
  54548. /**
  54549. * Gets or sets a boolean indicating that this connection point can be omitted
  54550. */
  54551. isOptional: boolean;
  54552. /**
  54553. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54554. */
  54555. define: string;
  54556. /** @hidden */
  54557. _prioritizeVertex: boolean;
  54558. private _target;
  54559. /** Gets or sets the target of that connection point */
  54560. target: NodeMaterialBlockTargets;
  54561. /**
  54562. * Gets a boolean indicating that the current point is connected
  54563. */
  54564. readonly isConnected: boolean;
  54565. /**
  54566. * Gets a boolean indicating that the current point is connected to an input block
  54567. */
  54568. readonly isConnectedToInputBlock: boolean;
  54569. /**
  54570. * Gets a the connected input block (if any)
  54571. */
  54572. readonly connectInputBlock: Nullable<InputBlock>;
  54573. /** Get the other side of the connection (if any) */
  54574. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54575. /** Get the block that owns this connection point */
  54576. readonly ownerBlock: NodeMaterialBlock;
  54577. /** Get the block connected on the other side of this connection (if any) */
  54578. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54579. /** Get the block connected on the endpoints of this connection (if any) */
  54580. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54581. /** Gets the list of connected endpoints */
  54582. readonly endpoints: NodeMaterialConnectionPoint[];
  54583. /** Gets a boolean indicating if that output point is connected to at least one input */
  54584. readonly hasEndpoints: boolean;
  54585. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54586. readonly isConnectedInVertexShader: boolean;
  54587. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54588. readonly isConnectedInFragmentShader: boolean;
  54589. /**
  54590. * Creates a new connection point
  54591. * @param name defines the connection point name
  54592. * @param ownerBlock defines the block hosting this connection point
  54593. */
  54594. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54595. /**
  54596. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54597. * @returns the class name
  54598. */
  54599. getClassName(): string;
  54600. /**
  54601. * Gets a boolean indicating if the current point can be connected to another point
  54602. * @param connectionPoint defines the other connection point
  54603. * @returns a boolean
  54604. */
  54605. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54606. /**
  54607. * Gets a number indicating if the current point can be connected to another point
  54608. * @param connectionPoint defines the other connection point
  54609. * @returns a number defining the compatibility state
  54610. */
  54611. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  54612. /**
  54613. * Connect this point to another connection point
  54614. * @param connectionPoint defines the other connection point
  54615. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54616. * @returns the current connection point
  54617. */
  54618. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54619. /**
  54620. * Disconnect this point from one of his endpoint
  54621. * @param endpoint defines the other connection point
  54622. * @returns the current connection point
  54623. */
  54624. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54625. /**
  54626. * Serializes this point in a JSON representation
  54627. * @returns the serialized point object
  54628. */
  54629. serialize(): any;
  54630. /**
  54631. * Release resources
  54632. */
  54633. dispose(): void;
  54634. }
  54635. }
  54636. declare module BABYLON {
  54637. /**
  54638. * Block used to add support for vertex skinning (bones)
  54639. */
  54640. export class BonesBlock extends NodeMaterialBlock {
  54641. /**
  54642. * Creates a new BonesBlock
  54643. * @param name defines the block name
  54644. */
  54645. constructor(name: string);
  54646. /**
  54647. * Initialize the block and prepare the context for build
  54648. * @param state defines the state that will be used for the build
  54649. */
  54650. initialize(state: NodeMaterialBuildState): void;
  54651. /**
  54652. * Gets the current class name
  54653. * @returns the class name
  54654. */
  54655. getClassName(): string;
  54656. /**
  54657. * Gets the matrix indices input component
  54658. */
  54659. readonly matricesIndices: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the matrix weights input component
  54662. */
  54663. readonly matricesWeights: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the extra matrix indices input component
  54666. */
  54667. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the extra matrix weights input component
  54670. */
  54671. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the world input component
  54674. */
  54675. readonly world: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the output component
  54678. */
  54679. readonly output: NodeMaterialConnectionPoint;
  54680. autoConfigure(material: NodeMaterial): void;
  54681. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54684. protected _buildBlock(state: NodeMaterialBuildState): this;
  54685. }
  54686. }
  54687. declare module BABYLON {
  54688. /**
  54689. * Block used to add support for instances
  54690. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54691. */
  54692. export class InstancesBlock extends NodeMaterialBlock {
  54693. /**
  54694. * Creates a new InstancesBlock
  54695. * @param name defines the block name
  54696. */
  54697. constructor(name: string);
  54698. /**
  54699. * Gets the current class name
  54700. * @returns the class name
  54701. */
  54702. getClassName(): string;
  54703. /**
  54704. * Gets the first world row input component
  54705. */
  54706. readonly world0: NodeMaterialConnectionPoint;
  54707. /**
  54708. * Gets the second world row input component
  54709. */
  54710. readonly world1: NodeMaterialConnectionPoint;
  54711. /**
  54712. * Gets the third world row input component
  54713. */
  54714. readonly world2: NodeMaterialConnectionPoint;
  54715. /**
  54716. * Gets the forth world row input component
  54717. */
  54718. readonly world3: NodeMaterialConnectionPoint;
  54719. /**
  54720. * Gets the world input component
  54721. */
  54722. readonly world: NodeMaterialConnectionPoint;
  54723. /**
  54724. * Gets the output component
  54725. */
  54726. readonly output: NodeMaterialConnectionPoint;
  54727. autoConfigure(material: NodeMaterial): void;
  54728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54729. protected _buildBlock(state: NodeMaterialBuildState): this;
  54730. }
  54731. }
  54732. declare module BABYLON {
  54733. /**
  54734. * Block used to add morph targets support to vertex shader
  54735. */
  54736. export class MorphTargetsBlock extends NodeMaterialBlock {
  54737. private _repeatableContentAnchor;
  54738. private _repeatebleContentGenerated;
  54739. /**
  54740. * Create a new MorphTargetsBlock
  54741. * @param name defines the block name
  54742. */
  54743. constructor(name: string);
  54744. /**
  54745. * Gets the current class name
  54746. * @returns the class name
  54747. */
  54748. getClassName(): string;
  54749. /**
  54750. * Gets the position input component
  54751. */
  54752. readonly position: NodeMaterialConnectionPoint;
  54753. /**
  54754. * Gets the normal input component
  54755. */
  54756. readonly normal: NodeMaterialConnectionPoint;
  54757. /**
  54758. * Gets the tangent input component
  54759. */
  54760. readonly tangent: NodeMaterialConnectionPoint;
  54761. /**
  54762. * Gets the tangent input component
  54763. */
  54764. readonly uv: NodeMaterialConnectionPoint;
  54765. /**
  54766. * Gets the position output component
  54767. */
  54768. readonly positionOutput: NodeMaterialConnectionPoint;
  54769. /**
  54770. * Gets the normal output component
  54771. */
  54772. readonly normalOutput: NodeMaterialConnectionPoint;
  54773. /**
  54774. * Gets the tangent output component
  54775. */
  54776. readonly tangentOutput: NodeMaterialConnectionPoint;
  54777. /**
  54778. * Gets the tangent output component
  54779. */
  54780. readonly uvOutput: NodeMaterialConnectionPoint;
  54781. initialize(state: NodeMaterialBuildState): void;
  54782. autoConfigure(material: NodeMaterial): void;
  54783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54785. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54786. protected _buildBlock(state: NodeMaterialBuildState): this;
  54787. }
  54788. }
  54789. declare module BABYLON {
  54790. /**
  54791. * Block used to get data information from a light
  54792. */
  54793. export class LightInformationBlock extends NodeMaterialBlock {
  54794. private _lightDataUniformName;
  54795. private _lightColorUniformName;
  54796. private _lightTypeDefineName;
  54797. /**
  54798. * Gets or sets the light associated with this block
  54799. */
  54800. light: Nullable<Light>;
  54801. /**
  54802. * Creates a new LightInformationBlock
  54803. * @param name defines the block name
  54804. */
  54805. constructor(name: string);
  54806. /**
  54807. * Gets the current class name
  54808. * @returns the class name
  54809. */
  54810. getClassName(): string;
  54811. /**
  54812. * Gets the world position input component
  54813. */
  54814. readonly worldPosition: NodeMaterialConnectionPoint;
  54815. /**
  54816. * Gets the direction output component
  54817. */
  54818. readonly direction: NodeMaterialConnectionPoint;
  54819. /**
  54820. * Gets the direction output component
  54821. */
  54822. readonly color: NodeMaterialConnectionPoint;
  54823. /**
  54824. * Gets the direction output component
  54825. */
  54826. readonly intensity: NodeMaterialConnectionPoint;
  54827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54829. protected _buildBlock(state: NodeMaterialBuildState): this;
  54830. serialize(): any;
  54831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54832. }
  54833. }
  54834. declare module BABYLON {
  54835. /**
  54836. * Block used to add image processing support to fragment shader
  54837. */
  54838. export class ImageProcessingBlock extends NodeMaterialBlock {
  54839. /**
  54840. * Create a new ImageProcessingBlock
  54841. * @param name defines the block name
  54842. */
  54843. constructor(name: string);
  54844. /**
  54845. * Gets the current class name
  54846. * @returns the class name
  54847. */
  54848. getClassName(): string;
  54849. /**
  54850. * Gets the color input component
  54851. */
  54852. readonly color: NodeMaterialConnectionPoint;
  54853. /**
  54854. * Gets the output component
  54855. */
  54856. readonly output: NodeMaterialConnectionPoint;
  54857. /**
  54858. * Initialize the block and prepare the context for build
  54859. * @param state defines the state that will be used for the build
  54860. */
  54861. initialize(state: NodeMaterialBuildState): void;
  54862. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54865. protected _buildBlock(state: NodeMaterialBuildState): this;
  54866. }
  54867. }
  54868. declare module BABYLON {
  54869. /**
  54870. * Block used to pertub normals based on a normal map
  54871. */
  54872. export class PerturbNormalBlock extends NodeMaterialBlock {
  54873. private _tangentSpaceParameterName;
  54874. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54875. invertX: boolean;
  54876. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54877. invertY: boolean;
  54878. /**
  54879. * Create a new PerturbNormalBlock
  54880. * @param name defines the block name
  54881. */
  54882. constructor(name: string);
  54883. /**
  54884. * Gets the current class name
  54885. * @returns the class name
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Gets the world position input component
  54890. */
  54891. readonly worldPosition: NodeMaterialConnectionPoint;
  54892. /**
  54893. * Gets the world normal input component
  54894. */
  54895. readonly worldNormal: NodeMaterialConnectionPoint;
  54896. /**
  54897. * Gets the uv input component
  54898. */
  54899. readonly uv: NodeMaterialConnectionPoint;
  54900. /**
  54901. * Gets the normal map color input component
  54902. */
  54903. readonly normalMapColor: NodeMaterialConnectionPoint;
  54904. /**
  54905. * Gets the strength input component
  54906. */
  54907. readonly strength: NodeMaterialConnectionPoint;
  54908. /**
  54909. * Gets the output component
  54910. */
  54911. readonly output: NodeMaterialConnectionPoint;
  54912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54914. autoConfigure(material: NodeMaterial): void;
  54915. protected _buildBlock(state: NodeMaterialBuildState): this;
  54916. protected _dumpPropertiesCode(): string;
  54917. serialize(): any;
  54918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54919. }
  54920. }
  54921. declare module BABYLON {
  54922. /**
  54923. * Block used to discard a pixel if a value is smaller than a cutoff
  54924. */
  54925. export class DiscardBlock extends NodeMaterialBlock {
  54926. /**
  54927. * Create a new DiscardBlock
  54928. * @param name defines the block name
  54929. */
  54930. constructor(name: string);
  54931. /**
  54932. * Gets the current class name
  54933. * @returns the class name
  54934. */
  54935. getClassName(): string;
  54936. /**
  54937. * Gets the color input component
  54938. */
  54939. readonly value: NodeMaterialConnectionPoint;
  54940. /**
  54941. * Gets the cutoff input component
  54942. */
  54943. readonly cutoff: NodeMaterialConnectionPoint;
  54944. protected _buildBlock(state: NodeMaterialBuildState): this;
  54945. }
  54946. }
  54947. declare module BABYLON {
  54948. /**
  54949. * Block used to test if the fragment shader is front facing
  54950. */
  54951. export class FrontFacingBlock extends NodeMaterialBlock {
  54952. /**
  54953. * Creates a new FrontFacingBlock
  54954. * @param name defines the block name
  54955. */
  54956. constructor(name: string);
  54957. /**
  54958. * Gets the current class name
  54959. * @returns the class name
  54960. */
  54961. getClassName(): string;
  54962. /**
  54963. * Gets the output component
  54964. */
  54965. readonly output: NodeMaterialConnectionPoint;
  54966. protected _buildBlock(state: NodeMaterialBuildState): this;
  54967. }
  54968. }
  54969. declare module BABYLON {
  54970. /**
  54971. * Block used to add support for scene fog
  54972. */
  54973. export class FogBlock extends NodeMaterialBlock {
  54974. private _fogDistanceName;
  54975. private _fogParameters;
  54976. /**
  54977. * Create a new FogBlock
  54978. * @param name defines the block name
  54979. */
  54980. constructor(name: string);
  54981. /**
  54982. * Gets the current class name
  54983. * @returns the class name
  54984. */
  54985. getClassName(): string;
  54986. /**
  54987. * Gets the world position input component
  54988. */
  54989. readonly worldPosition: NodeMaterialConnectionPoint;
  54990. /**
  54991. * Gets the view input component
  54992. */
  54993. readonly view: NodeMaterialConnectionPoint;
  54994. /**
  54995. * Gets the color input component
  54996. */
  54997. readonly input: NodeMaterialConnectionPoint;
  54998. /**
  54999. * Gets the fog color input component
  55000. */
  55001. readonly fogColor: NodeMaterialConnectionPoint;
  55002. /**
  55003. * Gets the output component
  55004. */
  55005. readonly output: NodeMaterialConnectionPoint;
  55006. autoConfigure(material: NodeMaterial): void;
  55007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55008. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55009. protected _buildBlock(state: NodeMaterialBuildState): this;
  55010. }
  55011. }
  55012. declare module BABYLON {
  55013. /**
  55014. * Block used to add light in the fragment shader
  55015. */
  55016. export class LightBlock extends NodeMaterialBlock {
  55017. private _lightId;
  55018. /**
  55019. * Gets or sets the light associated with this block
  55020. */
  55021. light: Nullable<Light>;
  55022. /**
  55023. * Create a new LightBlock
  55024. * @param name defines the block name
  55025. */
  55026. constructor(name: string);
  55027. /**
  55028. * Gets the current class name
  55029. * @returns the class name
  55030. */
  55031. getClassName(): string;
  55032. /**
  55033. * Gets the world position input component
  55034. */
  55035. readonly worldPosition: NodeMaterialConnectionPoint;
  55036. /**
  55037. * Gets the world normal input component
  55038. */
  55039. readonly worldNormal: NodeMaterialConnectionPoint;
  55040. /**
  55041. * Gets the camera (or eye) position component
  55042. */
  55043. readonly cameraPosition: NodeMaterialConnectionPoint;
  55044. /**
  55045. * Gets the glossiness component
  55046. */
  55047. readonly glossiness: NodeMaterialConnectionPoint;
  55048. /**
  55049. * Gets the glossinness power component
  55050. */
  55051. readonly glossPower: NodeMaterialConnectionPoint;
  55052. /**
  55053. * Gets the diffuse color component
  55054. */
  55055. readonly diffuseColor: NodeMaterialConnectionPoint;
  55056. /**
  55057. * Gets the specular color component
  55058. */
  55059. readonly specularColor: NodeMaterialConnectionPoint;
  55060. /**
  55061. * Gets the diffuse output component
  55062. */
  55063. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55064. /**
  55065. * Gets the specular output component
  55066. */
  55067. readonly specularOutput: NodeMaterialConnectionPoint;
  55068. autoConfigure(material: NodeMaterial): void;
  55069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55070. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55072. private _injectVertexCode;
  55073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55074. serialize(): any;
  55075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55076. }
  55077. }
  55078. declare module BABYLON {
  55079. /**
  55080. * Block used to multiply 2 values
  55081. */
  55082. export class MultiplyBlock extends NodeMaterialBlock {
  55083. /**
  55084. * Creates a new MultiplyBlock
  55085. * @param name defines the block name
  55086. */
  55087. constructor(name: string);
  55088. /**
  55089. * Gets the current class name
  55090. * @returns the class name
  55091. */
  55092. getClassName(): string;
  55093. /**
  55094. * Gets the left operand input component
  55095. */
  55096. readonly left: NodeMaterialConnectionPoint;
  55097. /**
  55098. * Gets the right operand input component
  55099. */
  55100. readonly right: NodeMaterialConnectionPoint;
  55101. /**
  55102. * Gets the output component
  55103. */
  55104. readonly output: NodeMaterialConnectionPoint;
  55105. protected _buildBlock(state: NodeMaterialBuildState): this;
  55106. }
  55107. }
  55108. declare module BABYLON {
  55109. /**
  55110. * Block used to add 2 vectors
  55111. */
  55112. export class AddBlock extends NodeMaterialBlock {
  55113. /**
  55114. * Creates a new AddBlock
  55115. * @param name defines the block name
  55116. */
  55117. constructor(name: string);
  55118. /**
  55119. * Gets the current class name
  55120. * @returns the class name
  55121. */
  55122. getClassName(): string;
  55123. /**
  55124. * Gets the left operand input component
  55125. */
  55126. readonly left: NodeMaterialConnectionPoint;
  55127. /**
  55128. * Gets the right operand input component
  55129. */
  55130. readonly right: NodeMaterialConnectionPoint;
  55131. /**
  55132. * Gets the output component
  55133. */
  55134. readonly output: NodeMaterialConnectionPoint;
  55135. protected _buildBlock(state: NodeMaterialBuildState): this;
  55136. }
  55137. }
  55138. declare module BABYLON {
  55139. /**
  55140. * Block used to scale a vector by a float
  55141. */
  55142. export class ScaleBlock extends NodeMaterialBlock {
  55143. /**
  55144. * Creates a new ScaleBlock
  55145. * @param name defines the block name
  55146. */
  55147. constructor(name: string);
  55148. /**
  55149. * Gets the current class name
  55150. * @returns the class name
  55151. */
  55152. getClassName(): string;
  55153. /**
  55154. * Gets the input component
  55155. */
  55156. readonly input: NodeMaterialConnectionPoint;
  55157. /**
  55158. * Gets the factor input component
  55159. */
  55160. readonly factor: NodeMaterialConnectionPoint;
  55161. /**
  55162. * Gets the output component
  55163. */
  55164. readonly output: NodeMaterialConnectionPoint;
  55165. protected _buildBlock(state: NodeMaterialBuildState): this;
  55166. }
  55167. }
  55168. declare module BABYLON {
  55169. /**
  55170. * Block used to clamp a float
  55171. */
  55172. export class ClampBlock extends NodeMaterialBlock {
  55173. /** Gets or sets the minimum range */
  55174. minimum: number;
  55175. /** Gets or sets the maximum range */
  55176. maximum: number;
  55177. /**
  55178. * Creates a new ClampBlock
  55179. * @param name defines the block name
  55180. */
  55181. constructor(name: string);
  55182. /**
  55183. * Gets the current class name
  55184. * @returns the class name
  55185. */
  55186. getClassName(): string;
  55187. /**
  55188. * Gets the value input component
  55189. */
  55190. readonly value: NodeMaterialConnectionPoint;
  55191. /**
  55192. * Gets the output component
  55193. */
  55194. readonly output: NodeMaterialConnectionPoint;
  55195. protected _buildBlock(state: NodeMaterialBuildState): this;
  55196. protected _dumpPropertiesCode(): string;
  55197. serialize(): any;
  55198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55199. }
  55200. }
  55201. declare module BABYLON {
  55202. /**
  55203. * Block used to apply a cross product between 2 vectors
  55204. */
  55205. export class CrossBlock extends NodeMaterialBlock {
  55206. /**
  55207. * Creates a new CrossBlock
  55208. * @param name defines the block name
  55209. */
  55210. constructor(name: string);
  55211. /**
  55212. * Gets the current class name
  55213. * @returns the class name
  55214. */
  55215. getClassName(): string;
  55216. /**
  55217. * Gets the left operand input component
  55218. */
  55219. readonly left: NodeMaterialConnectionPoint;
  55220. /**
  55221. * Gets the right operand input component
  55222. */
  55223. readonly right: NodeMaterialConnectionPoint;
  55224. /**
  55225. * Gets the output component
  55226. */
  55227. readonly output: NodeMaterialConnectionPoint;
  55228. protected _buildBlock(state: NodeMaterialBuildState): this;
  55229. }
  55230. }
  55231. declare module BABYLON {
  55232. /**
  55233. * Block used to apply a dot product between 2 vectors
  55234. */
  55235. export class DotBlock extends NodeMaterialBlock {
  55236. /**
  55237. * Creates a new DotBlock
  55238. * @param name defines the block name
  55239. */
  55240. constructor(name: string);
  55241. /**
  55242. * Gets the current class name
  55243. * @returns the class name
  55244. */
  55245. getClassName(): string;
  55246. /**
  55247. * Gets the left operand input component
  55248. */
  55249. readonly left: NodeMaterialConnectionPoint;
  55250. /**
  55251. * Gets the right operand input component
  55252. */
  55253. readonly right: NodeMaterialConnectionPoint;
  55254. /**
  55255. * Gets the output component
  55256. */
  55257. readonly output: NodeMaterialConnectionPoint;
  55258. protected _buildBlock(state: NodeMaterialBuildState): this;
  55259. }
  55260. }
  55261. declare module BABYLON {
  55262. /**
  55263. * Block used to remap a float from a range to a new one
  55264. */
  55265. export class RemapBlock extends NodeMaterialBlock {
  55266. /**
  55267. * Gets or sets the source range
  55268. */
  55269. sourceRange: Vector2;
  55270. /**
  55271. * Gets or sets the target range
  55272. */
  55273. targetRange: Vector2;
  55274. /**
  55275. * Creates a new RemapBlock
  55276. * @param name defines the block name
  55277. */
  55278. constructor(name: string);
  55279. /**
  55280. * Gets the current class name
  55281. * @returns the class name
  55282. */
  55283. getClassName(): string;
  55284. /**
  55285. * Gets the input component
  55286. */
  55287. readonly input: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the source min input component
  55290. */
  55291. readonly sourceMin: NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the source max input component
  55294. */
  55295. readonly sourceMax: NodeMaterialConnectionPoint;
  55296. /**
  55297. * Gets the target min input component
  55298. */
  55299. readonly targetMin: NodeMaterialConnectionPoint;
  55300. /**
  55301. * Gets the target max input component
  55302. */
  55303. readonly targetMax: NodeMaterialConnectionPoint;
  55304. /**
  55305. * Gets the output component
  55306. */
  55307. readonly output: NodeMaterialConnectionPoint;
  55308. protected _buildBlock(state: NodeMaterialBuildState): this;
  55309. protected _dumpPropertiesCode(): string;
  55310. serialize(): any;
  55311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * Block used to normalize a vector
  55317. */
  55318. export class NormalizeBlock extends NodeMaterialBlock {
  55319. /**
  55320. * Creates a new NormalizeBlock
  55321. * @param name defines the block name
  55322. */
  55323. constructor(name: string);
  55324. /**
  55325. * Gets the current class name
  55326. * @returns the class name
  55327. */
  55328. getClassName(): string;
  55329. /**
  55330. * Gets the input component
  55331. */
  55332. readonly input: NodeMaterialConnectionPoint;
  55333. /**
  55334. * Gets the output component
  55335. */
  55336. readonly output: NodeMaterialConnectionPoint;
  55337. protected _buildBlock(state: NodeMaterialBuildState): this;
  55338. }
  55339. }
  55340. declare module BABYLON {
  55341. /**
  55342. * Operations supported by the Trigonometry block
  55343. */
  55344. export enum TrigonometryBlockOperations {
  55345. /** Cos */
  55346. Cos = 0,
  55347. /** Sin */
  55348. Sin = 1,
  55349. /** Abs */
  55350. Abs = 2,
  55351. /** Exp */
  55352. Exp = 3,
  55353. /** Exp2 */
  55354. Exp2 = 4,
  55355. /** Round */
  55356. Round = 5,
  55357. /** Floor */
  55358. Floor = 6,
  55359. /** Ceiling */
  55360. Ceiling = 7,
  55361. /** Square root */
  55362. Sqrt = 8,
  55363. /** Log */
  55364. Log = 9,
  55365. /** Tangent */
  55366. Tan = 10,
  55367. /** Arc tangent */
  55368. ArcTan = 11,
  55369. /** Arc cosinus */
  55370. ArcCos = 12,
  55371. /** Arc sinus */
  55372. ArcSin = 13,
  55373. /** Fraction */
  55374. Fract = 14,
  55375. /** Sign */
  55376. Sign = 15,
  55377. /** To radians (from degrees) */
  55378. Radians = 16,
  55379. /** To degrees (from radians) */
  55380. Degrees = 17
  55381. }
  55382. /**
  55383. * Block used to apply trigonometry operation to floats
  55384. */
  55385. export class TrigonometryBlock extends NodeMaterialBlock {
  55386. /**
  55387. * Gets or sets the operation applied by the block
  55388. */
  55389. operation: TrigonometryBlockOperations;
  55390. /**
  55391. * Creates a new TrigonometryBlock
  55392. * @param name defines the block name
  55393. */
  55394. constructor(name: string);
  55395. /**
  55396. * Gets the current class name
  55397. * @returns the class name
  55398. */
  55399. getClassName(): string;
  55400. /**
  55401. * Gets the input component
  55402. */
  55403. readonly input: NodeMaterialConnectionPoint;
  55404. /**
  55405. * Gets the output component
  55406. */
  55407. readonly output: NodeMaterialConnectionPoint;
  55408. protected _buildBlock(state: NodeMaterialBuildState): this;
  55409. serialize(): any;
  55410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55411. }
  55412. }
  55413. declare module BABYLON {
  55414. /**
  55415. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55416. */
  55417. export class ColorMergerBlock extends NodeMaterialBlock {
  55418. /**
  55419. * Create a new ColorMergerBlock
  55420. * @param name defines the block name
  55421. */
  55422. constructor(name: string);
  55423. /**
  55424. * Gets the current class name
  55425. * @returns the class name
  55426. */
  55427. getClassName(): string;
  55428. /**
  55429. * Gets the r component (input)
  55430. */
  55431. readonly r: NodeMaterialConnectionPoint;
  55432. /**
  55433. * Gets the g component (input)
  55434. */
  55435. readonly g: NodeMaterialConnectionPoint;
  55436. /**
  55437. * Gets the b component (input)
  55438. */
  55439. readonly b: NodeMaterialConnectionPoint;
  55440. /**
  55441. * Gets the a component (input)
  55442. */
  55443. readonly a: NodeMaterialConnectionPoint;
  55444. /**
  55445. * Gets the rgba component (output)
  55446. */
  55447. readonly rgba: NodeMaterialConnectionPoint;
  55448. /**
  55449. * Gets the rgb component (output)
  55450. */
  55451. readonly rgb: NodeMaterialConnectionPoint;
  55452. protected _buildBlock(state: NodeMaterialBuildState): this;
  55453. }
  55454. }
  55455. declare module BABYLON {
  55456. /**
  55457. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55458. */
  55459. export class VectorMergerBlock extends NodeMaterialBlock {
  55460. /**
  55461. * Create a new VectorMergerBlock
  55462. * @param name defines the block name
  55463. */
  55464. constructor(name: string);
  55465. /**
  55466. * Gets the current class name
  55467. * @returns the class name
  55468. */
  55469. getClassName(): string;
  55470. /**
  55471. * Gets the x component (input)
  55472. */
  55473. readonly x: NodeMaterialConnectionPoint;
  55474. /**
  55475. * Gets the y component (input)
  55476. */
  55477. readonly y: NodeMaterialConnectionPoint;
  55478. /**
  55479. * Gets the z component (input)
  55480. */
  55481. readonly z: NodeMaterialConnectionPoint;
  55482. /**
  55483. * Gets the w component (input)
  55484. */
  55485. readonly w: NodeMaterialConnectionPoint;
  55486. /**
  55487. * Gets the xyzw component (output)
  55488. */
  55489. readonly xyzw: NodeMaterialConnectionPoint;
  55490. /**
  55491. * Gets the xyz component (output)
  55492. */
  55493. readonly xyz: NodeMaterialConnectionPoint;
  55494. /**
  55495. * Gets the xy component (output)
  55496. */
  55497. readonly xy: NodeMaterialConnectionPoint;
  55498. protected _buildBlock(state: NodeMaterialBuildState): this;
  55499. }
  55500. }
  55501. declare module BABYLON {
  55502. /**
  55503. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55504. */
  55505. export class ColorSplitterBlock extends NodeMaterialBlock {
  55506. /**
  55507. * Create a new ColorSplitterBlock
  55508. * @param name defines the block name
  55509. */
  55510. constructor(name: string);
  55511. /**
  55512. * Gets the current class name
  55513. * @returns the class name
  55514. */
  55515. getClassName(): string;
  55516. /**
  55517. * Gets the rgba component (input)
  55518. */
  55519. readonly rgba: NodeMaterialConnectionPoint;
  55520. /**
  55521. * Gets the rgb component (input)
  55522. */
  55523. readonly rgbIn: NodeMaterialConnectionPoint;
  55524. /**
  55525. * Gets the rgb component (output)
  55526. */
  55527. readonly rgbOut: NodeMaterialConnectionPoint;
  55528. /**
  55529. * Gets the r component (output)
  55530. */
  55531. readonly r: NodeMaterialConnectionPoint;
  55532. /**
  55533. * Gets the g component (output)
  55534. */
  55535. readonly g: NodeMaterialConnectionPoint;
  55536. /**
  55537. * Gets the b component (output)
  55538. */
  55539. readonly b: NodeMaterialConnectionPoint;
  55540. /**
  55541. * Gets the a component (output)
  55542. */
  55543. readonly a: NodeMaterialConnectionPoint;
  55544. protected _inputRename(name: string): string;
  55545. protected _outputRename(name: string): string;
  55546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55547. }
  55548. }
  55549. declare module BABYLON {
  55550. /**
  55551. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55552. */
  55553. export class VectorSplitterBlock extends NodeMaterialBlock {
  55554. /**
  55555. * Create a new VectorSplitterBlock
  55556. * @param name defines the block name
  55557. */
  55558. constructor(name: string);
  55559. /**
  55560. * Gets the current class name
  55561. * @returns the class name
  55562. */
  55563. getClassName(): string;
  55564. /**
  55565. * Gets the xyzw component (input)
  55566. */
  55567. readonly xyzw: NodeMaterialConnectionPoint;
  55568. /**
  55569. * Gets the xyz component (input)
  55570. */
  55571. readonly xyzIn: NodeMaterialConnectionPoint;
  55572. /**
  55573. * Gets the xy component (input)
  55574. */
  55575. readonly xyIn: NodeMaterialConnectionPoint;
  55576. /**
  55577. * Gets the xyz component (output)
  55578. */
  55579. readonly xyzOut: NodeMaterialConnectionPoint;
  55580. /**
  55581. * Gets the xy component (output)
  55582. */
  55583. readonly xyOut: NodeMaterialConnectionPoint;
  55584. /**
  55585. * Gets the x component (output)
  55586. */
  55587. readonly x: NodeMaterialConnectionPoint;
  55588. /**
  55589. * Gets the y component (output)
  55590. */
  55591. readonly y: NodeMaterialConnectionPoint;
  55592. /**
  55593. * Gets the z component (output)
  55594. */
  55595. readonly z: NodeMaterialConnectionPoint;
  55596. /**
  55597. * Gets the w component (output)
  55598. */
  55599. readonly w: NodeMaterialConnectionPoint;
  55600. protected _inputRename(name: string): string;
  55601. protected _outputRename(name: string): string;
  55602. protected _buildBlock(state: NodeMaterialBuildState): this;
  55603. }
  55604. }
  55605. declare module BABYLON {
  55606. /**
  55607. * Block used to lerp between 2 values
  55608. */
  55609. export class LerpBlock extends NodeMaterialBlock {
  55610. /**
  55611. * Creates a new LerpBlock
  55612. * @param name defines the block name
  55613. */
  55614. constructor(name: string);
  55615. /**
  55616. * Gets the current class name
  55617. * @returns the class name
  55618. */
  55619. getClassName(): string;
  55620. /**
  55621. * Gets the left operand input component
  55622. */
  55623. readonly left: NodeMaterialConnectionPoint;
  55624. /**
  55625. * Gets the right operand input component
  55626. */
  55627. readonly right: NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the gradient operand input component
  55630. */
  55631. readonly gradient: NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the output component
  55634. */
  55635. readonly output: NodeMaterialConnectionPoint;
  55636. protected _buildBlock(state: NodeMaterialBuildState): this;
  55637. }
  55638. }
  55639. declare module BABYLON {
  55640. /**
  55641. * Block used to divide 2 vectors
  55642. */
  55643. export class DivideBlock extends NodeMaterialBlock {
  55644. /**
  55645. * Creates a new DivideBlock
  55646. * @param name defines the block name
  55647. */
  55648. constructor(name: string);
  55649. /**
  55650. * Gets the current class name
  55651. * @returns the class name
  55652. */
  55653. getClassName(): string;
  55654. /**
  55655. * Gets the left operand input component
  55656. */
  55657. readonly left: NodeMaterialConnectionPoint;
  55658. /**
  55659. * Gets the right operand input component
  55660. */
  55661. readonly right: NodeMaterialConnectionPoint;
  55662. /**
  55663. * Gets the output component
  55664. */
  55665. readonly output: NodeMaterialConnectionPoint;
  55666. protected _buildBlock(state: NodeMaterialBuildState): this;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /**
  55671. * Block used to subtract 2 vectors
  55672. */
  55673. export class SubtractBlock extends NodeMaterialBlock {
  55674. /**
  55675. * Creates a new SubtractBlock
  55676. * @param name defines the block name
  55677. */
  55678. constructor(name: string);
  55679. /**
  55680. * Gets the current class name
  55681. * @returns the class name
  55682. */
  55683. getClassName(): string;
  55684. /**
  55685. * Gets the left operand input component
  55686. */
  55687. readonly left: NodeMaterialConnectionPoint;
  55688. /**
  55689. * Gets the right operand input component
  55690. */
  55691. readonly right: NodeMaterialConnectionPoint;
  55692. /**
  55693. * Gets the output component
  55694. */
  55695. readonly output: NodeMaterialConnectionPoint;
  55696. protected _buildBlock(state: NodeMaterialBuildState): this;
  55697. }
  55698. }
  55699. declare module BABYLON {
  55700. /**
  55701. * Block used to step a value
  55702. */
  55703. export class StepBlock extends NodeMaterialBlock {
  55704. /**
  55705. * Creates a new StepBlock
  55706. * @param name defines the block name
  55707. */
  55708. constructor(name: string);
  55709. /**
  55710. * Gets the current class name
  55711. * @returns the class name
  55712. */
  55713. getClassName(): string;
  55714. /**
  55715. * Gets the value operand input component
  55716. */
  55717. readonly value: NodeMaterialConnectionPoint;
  55718. /**
  55719. * Gets the edge operand input component
  55720. */
  55721. readonly edge: NodeMaterialConnectionPoint;
  55722. /**
  55723. * Gets the output component
  55724. */
  55725. readonly output: NodeMaterialConnectionPoint;
  55726. protected _buildBlock(state: NodeMaterialBuildState): this;
  55727. }
  55728. }
  55729. declare module BABYLON {
  55730. /**
  55731. * Block used to get the opposite (1 - x) of a value
  55732. */
  55733. export class OneMinusBlock extends NodeMaterialBlock {
  55734. /**
  55735. * Creates a new OneMinusBlock
  55736. * @param name defines the block name
  55737. */
  55738. constructor(name: string);
  55739. /**
  55740. * Gets the current class name
  55741. * @returns the class name
  55742. */
  55743. getClassName(): string;
  55744. /**
  55745. * Gets the input component
  55746. */
  55747. readonly input: NodeMaterialConnectionPoint;
  55748. /**
  55749. * Gets the output component
  55750. */
  55751. readonly output: NodeMaterialConnectionPoint;
  55752. protected _buildBlock(state: NodeMaterialBuildState): this;
  55753. }
  55754. }
  55755. declare module BABYLON {
  55756. /**
  55757. * Block used to get the view direction
  55758. */
  55759. export class ViewDirectionBlock extends NodeMaterialBlock {
  55760. /**
  55761. * Creates a new ViewDirectionBlock
  55762. * @param name defines the block name
  55763. */
  55764. constructor(name: string);
  55765. /**
  55766. * Gets the current class name
  55767. * @returns the class name
  55768. */
  55769. getClassName(): string;
  55770. /**
  55771. * Gets the world position component
  55772. */
  55773. readonly worldPosition: NodeMaterialConnectionPoint;
  55774. /**
  55775. * Gets the camera position component
  55776. */
  55777. readonly cameraPosition: NodeMaterialConnectionPoint;
  55778. /**
  55779. * Gets the output component
  55780. */
  55781. readonly output: NodeMaterialConnectionPoint;
  55782. autoConfigure(material: NodeMaterial): void;
  55783. protected _buildBlock(state: NodeMaterialBuildState): this;
  55784. }
  55785. }
  55786. declare module BABYLON {
  55787. /**
  55788. * Block used to compute fresnel value
  55789. */
  55790. export class FresnelBlock extends NodeMaterialBlock {
  55791. /**
  55792. * Create a new FresnelBlock
  55793. * @param name defines the block name
  55794. */
  55795. constructor(name: string);
  55796. /**
  55797. * Gets the current class name
  55798. * @returns the class name
  55799. */
  55800. getClassName(): string;
  55801. /**
  55802. * Gets the world normal input component
  55803. */
  55804. readonly worldNormal: NodeMaterialConnectionPoint;
  55805. /**
  55806. * Gets the view direction input component
  55807. */
  55808. readonly viewDirection: NodeMaterialConnectionPoint;
  55809. /**
  55810. * Gets the bias input component
  55811. */
  55812. readonly bias: NodeMaterialConnectionPoint;
  55813. /**
  55814. * Gets the camera (or eye) position component
  55815. */
  55816. readonly power: NodeMaterialConnectionPoint;
  55817. /**
  55818. * Gets the fresnel output component
  55819. */
  55820. readonly fresnel: NodeMaterialConnectionPoint;
  55821. autoConfigure(material: NodeMaterial): void;
  55822. protected _buildBlock(state: NodeMaterialBuildState): this;
  55823. }
  55824. }
  55825. declare module BABYLON {
  55826. /**
  55827. * Block used to get the max of 2 values
  55828. */
  55829. export class MaxBlock extends NodeMaterialBlock {
  55830. /**
  55831. * Creates a new MaxBlock
  55832. * @param name defines the block name
  55833. */
  55834. constructor(name: string);
  55835. /**
  55836. * Gets the current class name
  55837. * @returns the class name
  55838. */
  55839. getClassName(): string;
  55840. /**
  55841. * Gets the left operand input component
  55842. */
  55843. readonly left: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the right operand input component
  55846. */
  55847. readonly right: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the output component
  55850. */
  55851. readonly output: NodeMaterialConnectionPoint;
  55852. protected _buildBlock(state: NodeMaterialBuildState): this;
  55853. }
  55854. }
  55855. declare module BABYLON {
  55856. /**
  55857. * Block used to get the min of 2 values
  55858. */
  55859. export class MinBlock extends NodeMaterialBlock {
  55860. /**
  55861. * Creates a new MinBlock
  55862. * @param name defines the block name
  55863. */
  55864. constructor(name: string);
  55865. /**
  55866. * Gets the current class name
  55867. * @returns the class name
  55868. */
  55869. getClassName(): string;
  55870. /**
  55871. * Gets the left operand input component
  55872. */
  55873. readonly left: NodeMaterialConnectionPoint;
  55874. /**
  55875. * Gets the right operand input component
  55876. */
  55877. readonly right: NodeMaterialConnectionPoint;
  55878. /**
  55879. * Gets the output component
  55880. */
  55881. readonly output: NodeMaterialConnectionPoint;
  55882. protected _buildBlock(state: NodeMaterialBuildState): this;
  55883. }
  55884. }
  55885. declare module BABYLON {
  55886. /**
  55887. * Block used to get the distance between 2 values
  55888. */
  55889. export class DistanceBlock extends NodeMaterialBlock {
  55890. /**
  55891. * Creates a new DistanceBlock
  55892. * @param name defines the block name
  55893. */
  55894. constructor(name: string);
  55895. /**
  55896. * Gets the current class name
  55897. * @returns the class name
  55898. */
  55899. getClassName(): string;
  55900. /**
  55901. * Gets the left operand input component
  55902. */
  55903. readonly left: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the right operand input component
  55906. */
  55907. readonly right: NodeMaterialConnectionPoint;
  55908. /**
  55909. * Gets the output component
  55910. */
  55911. readonly output: NodeMaterialConnectionPoint;
  55912. protected _buildBlock(state: NodeMaterialBuildState): this;
  55913. }
  55914. }
  55915. declare module BABYLON {
  55916. /**
  55917. * Block used to get the length of a vector
  55918. */
  55919. export class LengthBlock extends NodeMaterialBlock {
  55920. /**
  55921. * Creates a new LengthBlock
  55922. * @param name defines the block name
  55923. */
  55924. constructor(name: string);
  55925. /**
  55926. * Gets the current class name
  55927. * @returns the class name
  55928. */
  55929. getClassName(): string;
  55930. /**
  55931. * Gets the value input component
  55932. */
  55933. readonly value: NodeMaterialConnectionPoint;
  55934. /**
  55935. * Gets the output component
  55936. */
  55937. readonly output: NodeMaterialConnectionPoint;
  55938. protected _buildBlock(state: NodeMaterialBuildState): this;
  55939. }
  55940. }
  55941. declare module BABYLON {
  55942. /**
  55943. * Block used to get negative version of a value (i.e. x * -1)
  55944. */
  55945. export class NegateBlock extends NodeMaterialBlock {
  55946. /**
  55947. * Creates a new NegateBlock
  55948. * @param name defines the block name
  55949. */
  55950. constructor(name: string);
  55951. /**
  55952. * Gets the current class name
  55953. * @returns the class name
  55954. */
  55955. getClassName(): string;
  55956. /**
  55957. * Gets the value input component
  55958. */
  55959. readonly value: NodeMaterialConnectionPoint;
  55960. /**
  55961. * Gets the output component
  55962. */
  55963. readonly output: NodeMaterialConnectionPoint;
  55964. protected _buildBlock(state: NodeMaterialBuildState): this;
  55965. }
  55966. }
  55967. declare module BABYLON {
  55968. /**
  55969. * Block used to get the value of the first parameter raised to the power of the second
  55970. */
  55971. export class PowBlock extends NodeMaterialBlock {
  55972. /**
  55973. * Creates a new PowBlock
  55974. * @param name defines the block name
  55975. */
  55976. constructor(name: string);
  55977. /**
  55978. * Gets the current class name
  55979. * @returns the class name
  55980. */
  55981. getClassName(): string;
  55982. /**
  55983. * Gets the value operand input component
  55984. */
  55985. readonly value: NodeMaterialConnectionPoint;
  55986. /**
  55987. * Gets the power operand input component
  55988. */
  55989. readonly power: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the output component
  55992. */
  55993. readonly output: NodeMaterialConnectionPoint;
  55994. protected _buildBlock(state: NodeMaterialBuildState): this;
  55995. }
  55996. }
  55997. declare module BABYLON {
  55998. /**
  55999. * Block used to get a random number
  56000. */
  56001. export class RandomNumberBlock extends NodeMaterialBlock {
  56002. /**
  56003. * Creates a new RandomNumberBlock
  56004. * @param name defines the block name
  56005. */
  56006. constructor(name: string);
  56007. /**
  56008. * Gets the current class name
  56009. * @returns the class name
  56010. */
  56011. getClassName(): string;
  56012. /**
  56013. * Gets the seed input component
  56014. */
  56015. readonly seed: NodeMaterialConnectionPoint;
  56016. /**
  56017. * Gets the output component
  56018. */
  56019. readonly output: NodeMaterialConnectionPoint;
  56020. protected _buildBlock(state: NodeMaterialBuildState): this;
  56021. }
  56022. }
  56023. declare module BABYLON {
  56024. /**
  56025. * Block used to compute arc tangent of 2 values
  56026. */
  56027. export class ArcTan2Block extends NodeMaterialBlock {
  56028. /**
  56029. * Creates a new ArcTan2Block
  56030. * @param name defines the block name
  56031. */
  56032. constructor(name: string);
  56033. /**
  56034. * Gets the current class name
  56035. * @returns the class name
  56036. */
  56037. getClassName(): string;
  56038. /**
  56039. * Gets the x operand input component
  56040. */
  56041. readonly x: NodeMaterialConnectionPoint;
  56042. /**
  56043. * Gets the y operand input component
  56044. */
  56045. readonly y: NodeMaterialConnectionPoint;
  56046. /**
  56047. * Gets the output component
  56048. */
  56049. readonly output: NodeMaterialConnectionPoint;
  56050. protected _buildBlock(state: NodeMaterialBuildState): this;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Block used to smooth step a value
  56056. */
  56057. export class SmoothStepBlock extends NodeMaterialBlock {
  56058. /**
  56059. * Creates a new SmoothStepBlock
  56060. * @param name defines the block name
  56061. */
  56062. constructor(name: string);
  56063. /**
  56064. * Gets the current class name
  56065. * @returns the class name
  56066. */
  56067. getClassName(): string;
  56068. /**
  56069. * Gets the value operand input component
  56070. */
  56071. readonly value: NodeMaterialConnectionPoint;
  56072. /**
  56073. * Gets the first edge operand input component
  56074. */
  56075. readonly edge0: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the second edge operand input component
  56078. */
  56079. readonly edge1: NodeMaterialConnectionPoint;
  56080. /**
  56081. * Gets the output component
  56082. */
  56083. readonly output: NodeMaterialConnectionPoint;
  56084. protected _buildBlock(state: NodeMaterialBuildState): this;
  56085. }
  56086. }
  56087. declare module BABYLON {
  56088. /**
  56089. * Block used to get the reciprocal (1 / x) of a value
  56090. */
  56091. export class ReciprocalBlock extends NodeMaterialBlock {
  56092. /**
  56093. * Creates a new ReciprocalBlock
  56094. * @param name defines the block name
  56095. */
  56096. constructor(name: string);
  56097. /**
  56098. * Gets the current class name
  56099. * @returns the class name
  56100. */
  56101. getClassName(): string;
  56102. /**
  56103. * Gets the input component
  56104. */
  56105. readonly input: NodeMaterialConnectionPoint;
  56106. /**
  56107. * Gets the output component
  56108. */
  56109. readonly output: NodeMaterialConnectionPoint;
  56110. protected _buildBlock(state: NodeMaterialBuildState): this;
  56111. }
  56112. }
  56113. declare module BABYLON {
  56114. /**
  56115. * Block used to replace a color by another one
  56116. */
  56117. export class ReplaceColorBlock extends NodeMaterialBlock {
  56118. /**
  56119. * Creates a new ReplaceColorBlock
  56120. * @param name defines the block name
  56121. */
  56122. constructor(name: string);
  56123. /**
  56124. * Gets the current class name
  56125. * @returns the class name
  56126. */
  56127. getClassName(): string;
  56128. /**
  56129. * Gets the value input component
  56130. */
  56131. readonly value: NodeMaterialConnectionPoint;
  56132. /**
  56133. * Gets the reference input component
  56134. */
  56135. readonly reference: NodeMaterialConnectionPoint;
  56136. /**
  56137. * Gets the distance input component
  56138. */
  56139. readonly distance: NodeMaterialConnectionPoint;
  56140. /**
  56141. * Gets the replacement input component
  56142. */
  56143. readonly replacement: NodeMaterialConnectionPoint;
  56144. /**
  56145. * Gets the output component
  56146. */
  56147. readonly output: NodeMaterialConnectionPoint;
  56148. protected _buildBlock(state: NodeMaterialBuildState): this;
  56149. }
  56150. }
  56151. declare module BABYLON {
  56152. /**
  56153. * Block used to posterize a value
  56154. * @see https://en.wikipedia.org/wiki/Posterization
  56155. */
  56156. export class PosterizeBlock extends NodeMaterialBlock {
  56157. /**
  56158. * Creates a new PosterizeBlock
  56159. * @param name defines the block name
  56160. */
  56161. constructor(name: string);
  56162. /**
  56163. * Gets the current class name
  56164. * @returns the class name
  56165. */
  56166. getClassName(): string;
  56167. /**
  56168. * Gets the value input component
  56169. */
  56170. readonly value: NodeMaterialConnectionPoint;
  56171. /**
  56172. * Gets the steps input component
  56173. */
  56174. readonly steps: NodeMaterialConnectionPoint;
  56175. /**
  56176. * Gets the output component
  56177. */
  56178. readonly output: NodeMaterialConnectionPoint;
  56179. protected _buildBlock(state: NodeMaterialBuildState): this;
  56180. }
  56181. }
  56182. declare module BABYLON {
  56183. /**
  56184. * Operations supported by the Wave block
  56185. */
  56186. export enum WaveBlockKind {
  56187. /** SawTooth */
  56188. SawTooth = 0,
  56189. /** Square */
  56190. Square = 1,
  56191. /** Triangle */
  56192. Triangle = 2
  56193. }
  56194. /**
  56195. * Block used to apply wave operation to floats
  56196. */
  56197. export class WaveBlock extends NodeMaterialBlock {
  56198. /**
  56199. * Gets or sets the kibnd of wave to be applied by the block
  56200. */
  56201. kind: WaveBlockKind;
  56202. /**
  56203. * Creates a new WaveBlock
  56204. * @param name defines the block name
  56205. */
  56206. constructor(name: string);
  56207. /**
  56208. * Gets the current class name
  56209. * @returns the class name
  56210. */
  56211. getClassName(): string;
  56212. /**
  56213. * Gets the input component
  56214. */
  56215. readonly input: NodeMaterialConnectionPoint;
  56216. /**
  56217. * Gets the output component
  56218. */
  56219. readonly output: NodeMaterialConnectionPoint;
  56220. protected _buildBlock(state: NodeMaterialBuildState): this;
  56221. serialize(): any;
  56222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56223. }
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * Class used to store a color step for the GradientBlock
  56228. */
  56229. export class GradientBlockColorStep {
  56230. /**
  56231. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56232. */
  56233. step: number;
  56234. /**
  56235. * Gets or sets the color associated with this step
  56236. */
  56237. color: Color3;
  56238. /**
  56239. * Creates a new GradientBlockColorStep
  56240. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56241. * @param color defines the color associated with this step
  56242. */
  56243. constructor(
  56244. /**
  56245. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56246. */
  56247. step: number,
  56248. /**
  56249. * Gets or sets the color associated with this step
  56250. */
  56251. color: Color3);
  56252. }
  56253. /**
  56254. * Block used to return a color from a gradient based on an input value between 0 and 1
  56255. */
  56256. export class GradientBlock extends NodeMaterialBlock {
  56257. /**
  56258. * Gets or sets the list of color steps
  56259. */
  56260. colorSteps: GradientBlockColorStep[];
  56261. /**
  56262. * Creates a new GradientBlock
  56263. * @param name defines the block name
  56264. */
  56265. constructor(name: string);
  56266. /**
  56267. * Gets the current class name
  56268. * @returns the class name
  56269. */
  56270. getClassName(): string;
  56271. /**
  56272. * Gets the gradient input component
  56273. */
  56274. readonly gradient: NodeMaterialConnectionPoint;
  56275. /**
  56276. * Gets the output component
  56277. */
  56278. readonly output: NodeMaterialConnectionPoint;
  56279. private _writeColorConstant;
  56280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56281. serialize(): any;
  56282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56283. protected _dumpPropertiesCode(): string;
  56284. }
  56285. }
  56286. declare module BABYLON {
  56287. /**
  56288. * Block used to normalize lerp between 2 values
  56289. */
  56290. export class NLerpBlock extends NodeMaterialBlock {
  56291. /**
  56292. * Creates a new NLerpBlock
  56293. * @param name defines the block name
  56294. */
  56295. constructor(name: string);
  56296. /**
  56297. * Gets the current class name
  56298. * @returns the class name
  56299. */
  56300. getClassName(): string;
  56301. /**
  56302. * Gets the left operand input component
  56303. */
  56304. readonly left: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the right operand input component
  56307. */
  56308. readonly right: NodeMaterialConnectionPoint;
  56309. /**
  56310. * Gets the gradient operand input component
  56311. */
  56312. readonly gradient: NodeMaterialConnectionPoint;
  56313. /**
  56314. * Gets the output component
  56315. */
  56316. readonly output: NodeMaterialConnectionPoint;
  56317. protected _buildBlock(state: NodeMaterialBuildState): this;
  56318. }
  56319. }
  56320. declare module BABYLON {
  56321. /**
  56322. * Effect Render Options
  56323. */
  56324. export interface IEffectRendererOptions {
  56325. /**
  56326. * Defines the vertices positions.
  56327. */
  56328. positions?: number[];
  56329. /**
  56330. * Defines the indices.
  56331. */
  56332. indices?: number[];
  56333. }
  56334. /**
  56335. * Helper class to render one or more effects
  56336. */
  56337. export class EffectRenderer {
  56338. private engine;
  56339. private static _DefaultOptions;
  56340. private _vertexBuffers;
  56341. private _indexBuffer;
  56342. private _ringBufferIndex;
  56343. private _ringScreenBuffer;
  56344. private _fullscreenViewport;
  56345. private _getNextFrameBuffer;
  56346. /**
  56347. * Creates an effect renderer
  56348. * @param engine the engine to use for rendering
  56349. * @param options defines the options of the effect renderer
  56350. */
  56351. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  56352. /**
  56353. * Sets the current viewport in normalized coordinates 0-1
  56354. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56355. */
  56356. setViewport(viewport?: Viewport): void;
  56357. /**
  56358. * Binds the embedded attributes buffer to the effect.
  56359. * @param effect Defines the effect to bind the attributes for
  56360. */
  56361. bindBuffers(effect: Effect): void;
  56362. /**
  56363. * Sets the current effect wrapper to use during draw.
  56364. * The effect needs to be ready before calling this api.
  56365. * This also sets the default full screen position attribute.
  56366. * @param effectWrapper Defines the effect to draw with
  56367. */
  56368. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56369. /**
  56370. * Draws a full screen quad.
  56371. */
  56372. draw(): void;
  56373. /**
  56374. * renders one or more effects to a specified texture
  56375. * @param effectWrappers list of effects to renderer
  56376. * @param outputTexture texture to draw to, if null it will render to the screen
  56377. */
  56378. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56379. /**
  56380. * Disposes of the effect renderer
  56381. */
  56382. dispose(): void;
  56383. }
  56384. /**
  56385. * Options to create an EffectWrapper
  56386. */
  56387. interface EffectWrapperCreationOptions {
  56388. /**
  56389. * Engine to use to create the effect
  56390. */
  56391. engine: ThinEngine;
  56392. /**
  56393. * Fragment shader for the effect
  56394. */
  56395. fragmentShader: string;
  56396. /**
  56397. * Vertex shader for the effect
  56398. */
  56399. vertexShader?: string;
  56400. /**
  56401. * Attributes to use in the shader
  56402. */
  56403. attributeNames?: Array<string>;
  56404. /**
  56405. * Uniforms to use in the shader
  56406. */
  56407. uniformNames?: Array<string>;
  56408. /**
  56409. * Texture sampler names to use in the shader
  56410. */
  56411. samplerNames?: Array<string>;
  56412. /**
  56413. * The friendly name of the effect displayed in Spector.
  56414. */
  56415. name?: string;
  56416. }
  56417. /**
  56418. * Wraps an effect to be used for rendering
  56419. */
  56420. export class EffectWrapper {
  56421. /**
  56422. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56423. */
  56424. onApplyObservable: Observable<{}>;
  56425. /**
  56426. * The underlying effect
  56427. */
  56428. effect: Effect;
  56429. /**
  56430. * Creates an effect to be renderer
  56431. * @param creationOptions options to create the effect
  56432. */
  56433. constructor(creationOptions: EffectWrapperCreationOptions);
  56434. /**
  56435. * Disposes of the effect wrapper
  56436. */
  56437. dispose(): void;
  56438. }
  56439. }
  56440. declare module BABYLON {
  56441. /**
  56442. * Helper class to push actions to a pool of workers.
  56443. */
  56444. export class WorkerPool implements IDisposable {
  56445. private _workerInfos;
  56446. private _pendingActions;
  56447. /**
  56448. * Constructor
  56449. * @param workers Array of workers to use for actions
  56450. */
  56451. constructor(workers: Array<Worker>);
  56452. /**
  56453. * Terminates all workers and clears any pending actions.
  56454. */
  56455. dispose(): void;
  56456. /**
  56457. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56458. * pended until a worker has completed its action.
  56459. * @param action The action to perform. Call onComplete when the action is complete.
  56460. */
  56461. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56462. private _execute;
  56463. }
  56464. }
  56465. declare module BABYLON {
  56466. /**
  56467. * Configuration for Draco compression
  56468. */
  56469. export interface IDracoCompressionConfiguration {
  56470. /**
  56471. * Configuration for the decoder.
  56472. */
  56473. decoder: {
  56474. /**
  56475. * The url to the WebAssembly module.
  56476. */
  56477. wasmUrl?: string;
  56478. /**
  56479. * The url to the WebAssembly binary.
  56480. */
  56481. wasmBinaryUrl?: string;
  56482. /**
  56483. * The url to the fallback JavaScript module.
  56484. */
  56485. fallbackUrl?: string;
  56486. };
  56487. }
  56488. /**
  56489. * Draco compression (https://google.github.io/draco/)
  56490. *
  56491. * This class wraps the Draco module.
  56492. *
  56493. * **Encoder**
  56494. *
  56495. * The encoder is not currently implemented.
  56496. *
  56497. * **Decoder**
  56498. *
  56499. * 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.
  56500. *
  56501. * To update the configuration, use the following code:
  56502. * ```javascript
  56503. * DracoCompression.Configuration = {
  56504. * decoder: {
  56505. * wasmUrl: "<url to the WebAssembly library>",
  56506. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56507. * fallbackUrl: "<url to the fallback JavaScript library>",
  56508. * }
  56509. * };
  56510. * ```
  56511. *
  56512. * 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.
  56513. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56514. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56515. *
  56516. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56517. * ```javascript
  56518. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56519. * ```
  56520. *
  56521. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56522. */
  56523. export class DracoCompression implements IDisposable {
  56524. private _workerPoolPromise?;
  56525. private _decoderModulePromise?;
  56526. /**
  56527. * The configuration. Defaults to the following urls:
  56528. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56529. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56530. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56531. */
  56532. static Configuration: IDracoCompressionConfiguration;
  56533. /**
  56534. * Returns true if the decoder configuration is available.
  56535. */
  56536. static readonly DecoderAvailable: boolean;
  56537. /**
  56538. * Default number of workers to create when creating the draco compression object.
  56539. */
  56540. static DefaultNumWorkers: number;
  56541. private static GetDefaultNumWorkers;
  56542. private static _Default;
  56543. /**
  56544. * Default instance for the draco compression object.
  56545. */
  56546. static readonly Default: DracoCompression;
  56547. /**
  56548. * Constructor
  56549. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56550. */
  56551. constructor(numWorkers?: number);
  56552. /**
  56553. * Stop all async operations and release resources.
  56554. */
  56555. dispose(): void;
  56556. /**
  56557. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56558. * @returns a promise that resolves when ready
  56559. */
  56560. whenReadyAsync(): Promise<void>;
  56561. /**
  56562. * Decode Draco compressed mesh data to vertex data.
  56563. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56564. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56565. * @returns A promise that resolves with the decoded vertex data
  56566. */
  56567. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56568. [kind: string]: number;
  56569. }): Promise<VertexData>;
  56570. }
  56571. }
  56572. declare module BABYLON {
  56573. /**
  56574. * Class for building Constructive Solid Geometry
  56575. */
  56576. export class CSG {
  56577. private polygons;
  56578. /**
  56579. * The world matrix
  56580. */
  56581. matrix: Matrix;
  56582. /**
  56583. * Stores the position
  56584. */
  56585. position: Vector3;
  56586. /**
  56587. * Stores the rotation
  56588. */
  56589. rotation: Vector3;
  56590. /**
  56591. * Stores the rotation quaternion
  56592. */
  56593. rotationQuaternion: Nullable<Quaternion>;
  56594. /**
  56595. * Stores the scaling vector
  56596. */
  56597. scaling: Vector3;
  56598. /**
  56599. * Convert the Mesh to CSG
  56600. * @param mesh The Mesh to convert to CSG
  56601. * @returns A new CSG from the Mesh
  56602. */
  56603. static FromMesh(mesh: Mesh): CSG;
  56604. /**
  56605. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56606. * @param polygons Polygons used to construct a CSG solid
  56607. */
  56608. private static FromPolygons;
  56609. /**
  56610. * Clones, or makes a deep copy, of the CSG
  56611. * @returns A new CSG
  56612. */
  56613. clone(): CSG;
  56614. /**
  56615. * Unions this CSG with another CSG
  56616. * @param csg The CSG to union against this CSG
  56617. * @returns The unioned CSG
  56618. */
  56619. union(csg: CSG): CSG;
  56620. /**
  56621. * Unions this CSG with another CSG in place
  56622. * @param csg The CSG to union against this CSG
  56623. */
  56624. unionInPlace(csg: CSG): void;
  56625. /**
  56626. * Subtracts this CSG with another CSG
  56627. * @param csg The CSG to subtract against this CSG
  56628. * @returns A new CSG
  56629. */
  56630. subtract(csg: CSG): CSG;
  56631. /**
  56632. * Subtracts this CSG with another CSG in place
  56633. * @param csg The CSG to subtact against this CSG
  56634. */
  56635. subtractInPlace(csg: CSG): void;
  56636. /**
  56637. * Intersect this CSG with another CSG
  56638. * @param csg The CSG to intersect against this CSG
  56639. * @returns A new CSG
  56640. */
  56641. intersect(csg: CSG): CSG;
  56642. /**
  56643. * Intersects this CSG with another CSG in place
  56644. * @param csg The CSG to intersect against this CSG
  56645. */
  56646. intersectInPlace(csg: CSG): void;
  56647. /**
  56648. * Return a new CSG solid with solid and empty space switched. This solid is
  56649. * not modified.
  56650. * @returns A new CSG solid with solid and empty space switched
  56651. */
  56652. inverse(): CSG;
  56653. /**
  56654. * Inverses the CSG in place
  56655. */
  56656. inverseInPlace(): void;
  56657. /**
  56658. * This is used to keep meshes transformations so they can be restored
  56659. * when we build back a Babylon Mesh
  56660. * NB : All CSG operations are performed in world coordinates
  56661. * @param csg The CSG to copy the transform attributes from
  56662. * @returns This CSG
  56663. */
  56664. copyTransformAttributes(csg: CSG): CSG;
  56665. /**
  56666. * Build Raw mesh from CSG
  56667. * Coordinates here are in world space
  56668. * @param name The name of the mesh geometry
  56669. * @param scene The Scene
  56670. * @param keepSubMeshes Specifies if the submeshes should be kept
  56671. * @returns A new Mesh
  56672. */
  56673. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56674. /**
  56675. * Build Mesh from CSG taking material and transforms into account
  56676. * @param name The name of the Mesh
  56677. * @param material The material of the Mesh
  56678. * @param scene The Scene
  56679. * @param keepSubMeshes Specifies if submeshes should be kept
  56680. * @returns The new Mesh
  56681. */
  56682. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56683. }
  56684. }
  56685. declare module BABYLON {
  56686. /**
  56687. * Class used to create a trail following a mesh
  56688. */
  56689. export class TrailMesh extends Mesh {
  56690. private _generator;
  56691. private _autoStart;
  56692. private _running;
  56693. private _diameter;
  56694. private _length;
  56695. private _sectionPolygonPointsCount;
  56696. private _sectionVectors;
  56697. private _sectionNormalVectors;
  56698. private _beforeRenderObserver;
  56699. /**
  56700. * @constructor
  56701. * @param name The value used by scene.getMeshByName() to do a lookup.
  56702. * @param generator The mesh to generate a trail.
  56703. * @param scene The scene to add this mesh to.
  56704. * @param diameter Diameter of trailing mesh. Default is 1.
  56705. * @param length Length of trailing mesh. Default is 60.
  56706. * @param autoStart Automatically start trailing mesh. Default true.
  56707. */
  56708. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56709. /**
  56710. * "TrailMesh"
  56711. * @returns "TrailMesh"
  56712. */
  56713. getClassName(): string;
  56714. private _createMesh;
  56715. /**
  56716. * Start trailing mesh.
  56717. */
  56718. start(): void;
  56719. /**
  56720. * Stop trailing mesh.
  56721. */
  56722. stop(): void;
  56723. /**
  56724. * Update trailing mesh geometry.
  56725. */
  56726. update(): void;
  56727. /**
  56728. * Returns a new TrailMesh object.
  56729. * @param name is a string, the name given to the new mesh
  56730. * @param newGenerator use new generator object for cloned trail mesh
  56731. * @returns a new mesh
  56732. */
  56733. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56734. /**
  56735. * Serializes this trail mesh
  56736. * @param serializationObject object to write serialization to
  56737. */
  56738. serialize(serializationObject: any): void;
  56739. /**
  56740. * Parses a serialized trail mesh
  56741. * @param parsedMesh the serialized mesh
  56742. * @param scene the scene to create the trail mesh in
  56743. * @returns the created trail mesh
  56744. */
  56745. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56746. }
  56747. }
  56748. declare module BABYLON {
  56749. /**
  56750. * Class containing static functions to help procedurally build meshes
  56751. */
  56752. export class TiledBoxBuilder {
  56753. /**
  56754. * Creates a box mesh
  56755. * 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)
  56756. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56758. * * 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
  56759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56760. * @param name defines the name of the mesh
  56761. * @param options defines the options used to create the mesh
  56762. * @param scene defines the hosting scene
  56763. * @returns the box mesh
  56764. */
  56765. static CreateTiledBox(name: string, options: {
  56766. pattern?: number;
  56767. width?: number;
  56768. height?: number;
  56769. depth?: number;
  56770. tileSize?: number;
  56771. tileWidth?: number;
  56772. tileHeight?: number;
  56773. alignHorizontal?: number;
  56774. alignVertical?: number;
  56775. faceUV?: Vector4[];
  56776. faceColors?: Color4[];
  56777. sideOrientation?: number;
  56778. updatable?: boolean;
  56779. }, scene?: Nullable<Scene>): Mesh;
  56780. }
  56781. }
  56782. declare module BABYLON {
  56783. /**
  56784. * Class containing static functions to help procedurally build meshes
  56785. */
  56786. export class TorusKnotBuilder {
  56787. /**
  56788. * Creates a torus knot mesh
  56789. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56790. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56791. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56792. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56794. * * 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
  56795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56796. * @param name defines the name of the mesh
  56797. * @param options defines the options used to create the mesh
  56798. * @param scene defines the hosting scene
  56799. * @returns the torus knot mesh
  56800. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56801. */
  56802. static CreateTorusKnot(name: string, options: {
  56803. radius?: number;
  56804. tube?: number;
  56805. radialSegments?: number;
  56806. tubularSegments?: number;
  56807. p?: number;
  56808. q?: number;
  56809. updatable?: boolean;
  56810. sideOrientation?: number;
  56811. frontUVs?: Vector4;
  56812. backUVs?: Vector4;
  56813. }, scene: any): Mesh;
  56814. }
  56815. }
  56816. declare module BABYLON {
  56817. /**
  56818. * Polygon
  56819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56820. */
  56821. export class Polygon {
  56822. /**
  56823. * Creates a rectangle
  56824. * @param xmin bottom X coord
  56825. * @param ymin bottom Y coord
  56826. * @param xmax top X coord
  56827. * @param ymax top Y coord
  56828. * @returns points that make the resulting rectation
  56829. */
  56830. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56831. /**
  56832. * Creates a circle
  56833. * @param radius radius of circle
  56834. * @param cx scale in x
  56835. * @param cy scale in y
  56836. * @param numberOfSides number of sides that make up the circle
  56837. * @returns points that make the resulting circle
  56838. */
  56839. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56840. /**
  56841. * Creates a polygon from input string
  56842. * @param input Input polygon data
  56843. * @returns the parsed points
  56844. */
  56845. static Parse(input: string): Vector2[];
  56846. /**
  56847. * Starts building a polygon from x and y coordinates
  56848. * @param x x coordinate
  56849. * @param y y coordinate
  56850. * @returns the started path2
  56851. */
  56852. static StartingAt(x: number, y: number): Path2;
  56853. }
  56854. /**
  56855. * Builds a polygon
  56856. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56857. */
  56858. export class PolygonMeshBuilder {
  56859. private _points;
  56860. private _outlinepoints;
  56861. private _holes;
  56862. private _name;
  56863. private _scene;
  56864. private _epoints;
  56865. private _eholes;
  56866. private _addToepoint;
  56867. /**
  56868. * Babylon reference to the earcut plugin.
  56869. */
  56870. bjsEarcut: any;
  56871. /**
  56872. * Creates a PolygonMeshBuilder
  56873. * @param name name of the builder
  56874. * @param contours Path of the polygon
  56875. * @param scene scene to add to when creating the mesh
  56876. * @param earcutInjection can be used to inject your own earcut reference
  56877. */
  56878. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56879. /**
  56880. * Adds a whole within the polygon
  56881. * @param hole Array of points defining the hole
  56882. * @returns this
  56883. */
  56884. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56885. /**
  56886. * Creates the polygon
  56887. * @param updatable If the mesh should be updatable
  56888. * @param depth The depth of the mesh created
  56889. * @returns the created mesh
  56890. */
  56891. build(updatable?: boolean, depth?: number): Mesh;
  56892. /**
  56893. * Creates the polygon
  56894. * @param depth The depth of the mesh created
  56895. * @returns the created VertexData
  56896. */
  56897. buildVertexData(depth?: number): VertexData;
  56898. /**
  56899. * Adds a side to the polygon
  56900. * @param positions points that make the polygon
  56901. * @param normals normals of the polygon
  56902. * @param uvs uvs of the polygon
  56903. * @param indices indices of the polygon
  56904. * @param bounds bounds of the polygon
  56905. * @param points points of the polygon
  56906. * @param depth depth of the polygon
  56907. * @param flip flip of the polygon
  56908. */
  56909. private addSide;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * Class containing static functions to help procedurally build meshes
  56915. */
  56916. export class PolygonBuilder {
  56917. /**
  56918. * Creates a polygon mesh
  56919. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56920. * * 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
  56921. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56923. * * 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)
  56924. * * Remember you can only change the shape positions, not their number when updating a polygon
  56925. * @param name defines the name of the mesh
  56926. * @param options defines the options used to create the mesh
  56927. * @param scene defines the hosting scene
  56928. * @param earcutInjection can be used to inject your own earcut reference
  56929. * @returns the polygon mesh
  56930. */
  56931. static CreatePolygon(name: string, options: {
  56932. shape: Vector3[];
  56933. holes?: Vector3[][];
  56934. depth?: number;
  56935. faceUV?: Vector4[];
  56936. faceColors?: Color4[];
  56937. updatable?: boolean;
  56938. sideOrientation?: number;
  56939. frontUVs?: Vector4;
  56940. backUVs?: Vector4;
  56941. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56942. /**
  56943. * Creates an extruded polygon mesh, with depth in the Y direction.
  56944. * * 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)
  56945. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56946. * @param name defines the name of the mesh
  56947. * @param options defines the options used to create the mesh
  56948. * @param scene defines the hosting scene
  56949. * @param earcutInjection can be used to inject your own earcut reference
  56950. * @returns the polygon mesh
  56951. */
  56952. static ExtrudePolygon(name: string, options: {
  56953. shape: Vector3[];
  56954. holes?: Vector3[][];
  56955. depth?: number;
  56956. faceUV?: Vector4[];
  56957. faceColors?: Color4[];
  56958. updatable?: boolean;
  56959. sideOrientation?: number;
  56960. frontUVs?: Vector4;
  56961. backUVs?: Vector4;
  56962. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56963. }
  56964. }
  56965. declare module BABYLON {
  56966. /**
  56967. * Class containing static functions to help procedurally build meshes
  56968. */
  56969. export class LatheBuilder {
  56970. /**
  56971. * Creates lathe mesh.
  56972. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56973. * * 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
  56974. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56975. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56976. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56977. * * 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
  56978. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56979. * * 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
  56980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56981. * * 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
  56982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56984. * @param name defines the name of the mesh
  56985. * @param options defines the options used to create the mesh
  56986. * @param scene defines the hosting scene
  56987. * @returns the lathe mesh
  56988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56989. */
  56990. static CreateLathe(name: string, options: {
  56991. shape: Vector3[];
  56992. radius?: number;
  56993. tessellation?: number;
  56994. clip?: number;
  56995. arc?: number;
  56996. closed?: boolean;
  56997. updatable?: boolean;
  56998. sideOrientation?: number;
  56999. frontUVs?: Vector4;
  57000. backUVs?: Vector4;
  57001. cap?: number;
  57002. invertUV?: boolean;
  57003. }, scene?: Nullable<Scene>): Mesh;
  57004. }
  57005. }
  57006. declare module BABYLON {
  57007. /**
  57008. * Class containing static functions to help procedurally build meshes
  57009. */
  57010. export class TiledPlaneBuilder {
  57011. /**
  57012. * Creates a tiled plane mesh
  57013. * * The parameter `pattern` will, depending on value, do nothing or
  57014. * * * flip (reflect about central vertical) alternate tiles across and up
  57015. * * * flip every tile on alternate rows
  57016. * * * rotate (180 degs) alternate tiles across and up
  57017. * * * rotate every tile on alternate rows
  57018. * * * flip and rotate alternate tiles across and up
  57019. * * * flip and rotate every tile on alternate rows
  57020. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57021. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57022. * * 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
  57023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57024. * * 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)
  57025. * * 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)
  57026. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57027. * @param name defines the name of the mesh
  57028. * @param options defines the options used to create the mesh
  57029. * @param scene defines the hosting scene
  57030. * @returns the box mesh
  57031. */
  57032. static CreateTiledPlane(name: string, options: {
  57033. pattern?: number;
  57034. tileSize?: number;
  57035. tileWidth?: number;
  57036. tileHeight?: number;
  57037. size?: number;
  57038. width?: number;
  57039. height?: number;
  57040. alignHorizontal?: number;
  57041. alignVertical?: number;
  57042. sideOrientation?: number;
  57043. frontUVs?: Vector4;
  57044. backUVs?: Vector4;
  57045. updatable?: boolean;
  57046. }, scene?: Nullable<Scene>): Mesh;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Class containing static functions to help procedurally build meshes
  57052. */
  57053. export class TubeBuilder {
  57054. /**
  57055. * Creates a tube mesh.
  57056. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57057. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57058. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57059. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57060. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57061. * * 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)
  57062. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57063. * * 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
  57064. * * 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
  57065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57066. * * 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
  57067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57069. * @param name defines the name of the mesh
  57070. * @param options defines the options used to create the mesh
  57071. * @param scene defines the hosting scene
  57072. * @returns the tube mesh
  57073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57074. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57075. */
  57076. static CreateTube(name: string, options: {
  57077. path: Vector3[];
  57078. radius?: number;
  57079. tessellation?: number;
  57080. radiusFunction?: {
  57081. (i: number, distance: number): number;
  57082. };
  57083. cap?: number;
  57084. arc?: number;
  57085. updatable?: boolean;
  57086. sideOrientation?: number;
  57087. frontUVs?: Vector4;
  57088. backUVs?: Vector4;
  57089. instance?: Mesh;
  57090. invertUV?: boolean;
  57091. }, scene?: Nullable<Scene>): Mesh;
  57092. }
  57093. }
  57094. declare module BABYLON {
  57095. /**
  57096. * Class containing static functions to help procedurally build meshes
  57097. */
  57098. export class IcoSphereBuilder {
  57099. /**
  57100. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57101. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57102. * * 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`)
  57103. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57104. * * 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
  57105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57106. * * 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
  57107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57108. * @param name defines the name of the mesh
  57109. * @param options defines the options used to create the mesh
  57110. * @param scene defines the hosting scene
  57111. * @returns the icosahedron mesh
  57112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57113. */
  57114. static CreateIcoSphere(name: string, options: {
  57115. radius?: number;
  57116. radiusX?: number;
  57117. radiusY?: number;
  57118. radiusZ?: number;
  57119. flat?: boolean;
  57120. subdivisions?: number;
  57121. sideOrientation?: number;
  57122. frontUVs?: Vector4;
  57123. backUVs?: Vector4;
  57124. updatable?: boolean;
  57125. }, scene?: Nullable<Scene>): Mesh;
  57126. }
  57127. }
  57128. declare module BABYLON {
  57129. /**
  57130. * Class containing static functions to help procedurally build meshes
  57131. */
  57132. export class DecalBuilder {
  57133. /**
  57134. * Creates a decal mesh.
  57135. * 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
  57136. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57137. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57138. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57139. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57140. * @param name defines the name of the mesh
  57141. * @param sourceMesh defines the mesh where the decal must be applied
  57142. * @param options defines the options used to create the mesh
  57143. * @param scene defines the hosting scene
  57144. * @returns the decal mesh
  57145. * @see https://doc.babylonjs.com/how_to/decals
  57146. */
  57147. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57148. position?: Vector3;
  57149. normal?: Vector3;
  57150. size?: Vector3;
  57151. angle?: number;
  57152. }): Mesh;
  57153. }
  57154. }
  57155. declare module BABYLON {
  57156. /**
  57157. * Class containing static functions to help procedurally build meshes
  57158. */
  57159. export class MeshBuilder {
  57160. /**
  57161. * Creates a box mesh
  57162. * * The parameter `size` sets the size (float) of each box side (default 1)
  57163. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57164. * * 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)
  57165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57167. * * 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
  57168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57169. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57170. * @param name defines the name of the mesh
  57171. * @param options defines the options used to create the mesh
  57172. * @param scene defines the hosting scene
  57173. * @returns the box mesh
  57174. */
  57175. static CreateBox(name: string, options: {
  57176. size?: number;
  57177. width?: number;
  57178. height?: number;
  57179. depth?: number;
  57180. faceUV?: Vector4[];
  57181. faceColors?: Color4[];
  57182. sideOrientation?: number;
  57183. frontUVs?: Vector4;
  57184. backUVs?: Vector4;
  57185. updatable?: boolean;
  57186. }, scene?: Nullable<Scene>): Mesh;
  57187. /**
  57188. * Creates a tiled box mesh
  57189. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57191. * @param name defines the name of the mesh
  57192. * @param options defines the options used to create the mesh
  57193. * @param scene defines the hosting scene
  57194. * @returns the tiled box mesh
  57195. */
  57196. static CreateTiledBox(name: string, options: {
  57197. pattern?: number;
  57198. size?: number;
  57199. width?: number;
  57200. height?: number;
  57201. depth: number;
  57202. tileSize?: number;
  57203. tileWidth?: number;
  57204. tileHeight?: number;
  57205. faceUV?: Vector4[];
  57206. faceColors?: Color4[];
  57207. alignHorizontal?: number;
  57208. alignVertical?: number;
  57209. sideOrientation?: number;
  57210. updatable?: boolean;
  57211. }, scene?: Nullable<Scene>): Mesh;
  57212. /**
  57213. * Creates a sphere mesh
  57214. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57215. * * 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`)
  57216. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57217. * * 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
  57218. * * 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)
  57219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57220. * * 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
  57221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57222. * @param name defines the name of the mesh
  57223. * @param options defines the options used to create the mesh
  57224. * @param scene defines the hosting scene
  57225. * @returns the sphere mesh
  57226. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57227. */
  57228. static CreateSphere(name: string, options: {
  57229. segments?: number;
  57230. diameter?: number;
  57231. diameterX?: number;
  57232. diameterY?: number;
  57233. diameterZ?: number;
  57234. arc?: number;
  57235. slice?: number;
  57236. sideOrientation?: number;
  57237. frontUVs?: Vector4;
  57238. backUVs?: Vector4;
  57239. updatable?: boolean;
  57240. }, scene?: Nullable<Scene>): Mesh;
  57241. /**
  57242. * Creates a plane polygonal mesh. By default, this is a disc
  57243. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57244. * * 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
  57245. * * 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
  57246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57247. * * 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
  57248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57249. * @param name defines the name of the mesh
  57250. * @param options defines the options used to create the mesh
  57251. * @param scene defines the hosting scene
  57252. * @returns the plane polygonal mesh
  57253. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57254. */
  57255. static CreateDisc(name: string, options: {
  57256. radius?: number;
  57257. tessellation?: number;
  57258. arc?: number;
  57259. updatable?: boolean;
  57260. sideOrientation?: number;
  57261. frontUVs?: Vector4;
  57262. backUVs?: Vector4;
  57263. }, scene?: Nullable<Scene>): Mesh;
  57264. /**
  57265. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57266. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57267. * * 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`)
  57268. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57269. * * 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
  57270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57271. * * 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
  57272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57273. * @param name defines the name of the mesh
  57274. * @param options defines the options used to create the mesh
  57275. * @param scene defines the hosting scene
  57276. * @returns the icosahedron mesh
  57277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57278. */
  57279. static CreateIcoSphere(name: string, options: {
  57280. radius?: number;
  57281. radiusX?: number;
  57282. radiusY?: number;
  57283. radiusZ?: number;
  57284. flat?: boolean;
  57285. subdivisions?: number;
  57286. sideOrientation?: number;
  57287. frontUVs?: Vector4;
  57288. backUVs?: Vector4;
  57289. updatable?: boolean;
  57290. }, scene?: Nullable<Scene>): Mesh;
  57291. /**
  57292. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57293. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57294. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57295. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57296. * * 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
  57297. * * 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
  57298. * * 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
  57299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57300. * * 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
  57301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57302. * * 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
  57303. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57304. * * 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
  57305. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57307. * @param name defines the name of the mesh
  57308. * @param options defines the options used to create the mesh
  57309. * @param scene defines the hosting scene
  57310. * @returns the ribbon mesh
  57311. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57312. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57313. */
  57314. static CreateRibbon(name: string, options: {
  57315. pathArray: Vector3[][];
  57316. closeArray?: boolean;
  57317. closePath?: boolean;
  57318. offset?: number;
  57319. updatable?: boolean;
  57320. sideOrientation?: number;
  57321. frontUVs?: Vector4;
  57322. backUVs?: Vector4;
  57323. instance?: Mesh;
  57324. invertUV?: boolean;
  57325. uvs?: Vector2[];
  57326. colors?: Color4[];
  57327. }, scene?: Nullable<Scene>): Mesh;
  57328. /**
  57329. * Creates a cylinder or a cone mesh
  57330. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57331. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57332. * * 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.
  57333. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57334. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57335. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57336. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57337. * * 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).
  57338. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57339. * * 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).
  57340. * * 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
  57341. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57342. * * 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
  57343. * * 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.
  57344. * * If `enclose` is false, a ring surface is one element.
  57345. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57346. * * 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
  57347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57348. * * 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
  57349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57350. * @param name defines the name of the mesh
  57351. * @param options defines the options used to create the mesh
  57352. * @param scene defines the hosting scene
  57353. * @returns the cylinder mesh
  57354. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57355. */
  57356. static CreateCylinder(name: string, options: {
  57357. height?: number;
  57358. diameterTop?: number;
  57359. diameterBottom?: number;
  57360. diameter?: number;
  57361. tessellation?: number;
  57362. subdivisions?: number;
  57363. arc?: number;
  57364. faceColors?: Color4[];
  57365. faceUV?: Vector4[];
  57366. updatable?: boolean;
  57367. hasRings?: boolean;
  57368. enclose?: boolean;
  57369. cap?: number;
  57370. sideOrientation?: number;
  57371. frontUVs?: Vector4;
  57372. backUVs?: Vector4;
  57373. }, scene?: Nullable<Scene>): Mesh;
  57374. /**
  57375. * Creates a torus mesh
  57376. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57377. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57378. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57380. * * 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
  57381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57382. * @param name defines the name of the mesh
  57383. * @param options defines the options used to create the mesh
  57384. * @param scene defines the hosting scene
  57385. * @returns the torus mesh
  57386. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57387. */
  57388. static CreateTorus(name: string, options: {
  57389. diameter?: number;
  57390. thickness?: number;
  57391. tessellation?: number;
  57392. updatable?: boolean;
  57393. sideOrientation?: number;
  57394. frontUVs?: Vector4;
  57395. backUVs?: Vector4;
  57396. }, scene?: Nullable<Scene>): Mesh;
  57397. /**
  57398. * Creates a torus knot mesh
  57399. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57400. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57401. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57402. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57404. * * 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
  57405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57406. * @param name defines the name of the mesh
  57407. * @param options defines the options used to create the mesh
  57408. * @param scene defines the hosting scene
  57409. * @returns the torus knot mesh
  57410. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57411. */
  57412. static CreateTorusKnot(name: string, options: {
  57413. radius?: number;
  57414. tube?: number;
  57415. radialSegments?: number;
  57416. tubularSegments?: number;
  57417. p?: number;
  57418. q?: number;
  57419. updatable?: boolean;
  57420. sideOrientation?: number;
  57421. frontUVs?: Vector4;
  57422. backUVs?: Vector4;
  57423. }, scene?: Nullable<Scene>): Mesh;
  57424. /**
  57425. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57426. * * 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
  57427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57428. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57429. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57430. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57431. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57432. * * 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
  57433. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57436. * @param name defines the name of the new line system
  57437. * @param options defines the options used to create the line system
  57438. * @param scene defines the hosting scene
  57439. * @returns a new line system mesh
  57440. */
  57441. static CreateLineSystem(name: string, options: {
  57442. lines: Vector3[][];
  57443. updatable?: boolean;
  57444. instance?: Nullable<LinesMesh>;
  57445. colors?: Nullable<Color4[][]>;
  57446. useVertexAlpha?: boolean;
  57447. }, scene: Nullable<Scene>): LinesMesh;
  57448. /**
  57449. * Creates a line mesh
  57450. * 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
  57451. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57452. * * The parameter `points` is an array successive Vector3
  57453. * * 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
  57454. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57455. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57456. * * When updating an instance, remember that only point positions can change, not the number of points
  57457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57459. * @param name defines the name of the new line system
  57460. * @param options defines the options used to create the line system
  57461. * @param scene defines the hosting scene
  57462. * @returns a new line mesh
  57463. */
  57464. static CreateLines(name: string, options: {
  57465. points: Vector3[];
  57466. updatable?: boolean;
  57467. instance?: Nullable<LinesMesh>;
  57468. colors?: Color4[];
  57469. useVertexAlpha?: boolean;
  57470. }, scene?: Nullable<Scene>): LinesMesh;
  57471. /**
  57472. * Creates a dashed line mesh
  57473. * * 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
  57474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57475. * * The parameter `points` is an array successive Vector3
  57476. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57477. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57478. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57479. * * 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
  57480. * * When updating an instance, remember that only point positions can change, not the number of points
  57481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57482. * @param name defines the name of the mesh
  57483. * @param options defines the options used to create the mesh
  57484. * @param scene defines the hosting scene
  57485. * @returns the dashed line mesh
  57486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57487. */
  57488. static CreateDashedLines(name: string, options: {
  57489. points: Vector3[];
  57490. dashSize?: number;
  57491. gapSize?: number;
  57492. dashNb?: number;
  57493. updatable?: boolean;
  57494. instance?: LinesMesh;
  57495. }, scene?: Nullable<Scene>): LinesMesh;
  57496. /**
  57497. * 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.
  57498. * * 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.
  57499. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57500. * * 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.
  57501. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57502. * * 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
  57503. * * 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
  57504. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57506. * * 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
  57507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57509. * @param name defines the name of the mesh
  57510. * @param options defines the options used to create the mesh
  57511. * @param scene defines the hosting scene
  57512. * @returns the extruded shape mesh
  57513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57515. */
  57516. static ExtrudeShape(name: string, options: {
  57517. shape: Vector3[];
  57518. path: Vector3[];
  57519. scale?: number;
  57520. rotation?: number;
  57521. cap?: number;
  57522. updatable?: boolean;
  57523. sideOrientation?: number;
  57524. frontUVs?: Vector4;
  57525. backUVs?: Vector4;
  57526. instance?: Mesh;
  57527. invertUV?: boolean;
  57528. }, scene?: Nullable<Scene>): Mesh;
  57529. /**
  57530. * Creates an custom extruded shape mesh.
  57531. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57532. * * 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.
  57533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57534. * * 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
  57535. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57536. * * 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
  57537. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57538. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57539. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57540. * * 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
  57541. * * 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
  57542. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57544. * * 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
  57545. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57547. * @param name defines the name of the mesh
  57548. * @param options defines the options used to create the mesh
  57549. * @param scene defines the hosting scene
  57550. * @returns the custom extruded shape mesh
  57551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57554. */
  57555. static ExtrudeShapeCustom(name: string, options: {
  57556. shape: Vector3[];
  57557. path: Vector3[];
  57558. scaleFunction?: any;
  57559. rotationFunction?: any;
  57560. ribbonCloseArray?: boolean;
  57561. ribbonClosePath?: boolean;
  57562. cap?: number;
  57563. updatable?: boolean;
  57564. sideOrientation?: number;
  57565. frontUVs?: Vector4;
  57566. backUVs?: Vector4;
  57567. instance?: Mesh;
  57568. invertUV?: boolean;
  57569. }, scene?: Nullable<Scene>): Mesh;
  57570. /**
  57571. * Creates lathe mesh.
  57572. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57573. * * 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
  57574. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57575. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57576. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57577. * * 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
  57578. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57579. * * 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
  57580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57581. * * 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
  57582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57584. * @param name defines the name of the mesh
  57585. * @param options defines the options used to create the mesh
  57586. * @param scene defines the hosting scene
  57587. * @returns the lathe mesh
  57588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57589. */
  57590. static CreateLathe(name: string, options: {
  57591. shape: Vector3[];
  57592. radius?: number;
  57593. tessellation?: number;
  57594. clip?: number;
  57595. arc?: number;
  57596. closed?: boolean;
  57597. updatable?: boolean;
  57598. sideOrientation?: number;
  57599. frontUVs?: Vector4;
  57600. backUVs?: Vector4;
  57601. cap?: number;
  57602. invertUV?: boolean;
  57603. }, scene?: Nullable<Scene>): Mesh;
  57604. /**
  57605. * Creates a tiled plane mesh
  57606. * * You can set a limited pattern arrangement with the tiles
  57607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57608. * * 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
  57609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57610. * @param name defines the name of the mesh
  57611. * @param options defines the options used to create the mesh
  57612. * @param scene defines the hosting scene
  57613. * @returns the plane mesh
  57614. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57615. */
  57616. static CreateTiledPlane(name: string, options: {
  57617. pattern?: number;
  57618. tileSize?: number;
  57619. tileWidth?: number;
  57620. tileHeight?: number;
  57621. size?: number;
  57622. width?: number;
  57623. height?: number;
  57624. alignHorizontal?: number;
  57625. alignVertical?: number;
  57626. sideOrientation?: number;
  57627. frontUVs?: Vector4;
  57628. backUVs?: Vector4;
  57629. updatable?: boolean;
  57630. }, scene?: Nullable<Scene>): Mesh;
  57631. /**
  57632. * Creates a plane mesh
  57633. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57634. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57635. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57637. * * 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
  57638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57639. * @param name defines the name of the mesh
  57640. * @param options defines the options used to create the mesh
  57641. * @param scene defines the hosting scene
  57642. * @returns the plane mesh
  57643. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57644. */
  57645. static CreatePlane(name: string, options: {
  57646. size?: number;
  57647. width?: number;
  57648. height?: number;
  57649. sideOrientation?: number;
  57650. frontUVs?: Vector4;
  57651. backUVs?: Vector4;
  57652. updatable?: boolean;
  57653. sourcePlane?: Plane;
  57654. }, scene?: Nullable<Scene>): Mesh;
  57655. /**
  57656. * Creates a ground mesh
  57657. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57658. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57660. * @param name defines the name of the mesh
  57661. * @param options defines the options used to create the mesh
  57662. * @param scene defines the hosting scene
  57663. * @returns the ground mesh
  57664. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57665. */
  57666. static CreateGround(name: string, options: {
  57667. width?: number;
  57668. height?: number;
  57669. subdivisions?: number;
  57670. subdivisionsX?: number;
  57671. subdivisionsY?: number;
  57672. updatable?: boolean;
  57673. }, scene?: Nullable<Scene>): Mesh;
  57674. /**
  57675. * Creates a tiled ground mesh
  57676. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57677. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57678. * * 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
  57679. * * 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
  57680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57681. * @param name defines the name of the mesh
  57682. * @param options defines the options used to create the mesh
  57683. * @param scene defines the hosting scene
  57684. * @returns the tiled ground mesh
  57685. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57686. */
  57687. static CreateTiledGround(name: string, options: {
  57688. xmin: number;
  57689. zmin: number;
  57690. xmax: number;
  57691. zmax: number;
  57692. subdivisions?: {
  57693. w: number;
  57694. h: number;
  57695. };
  57696. precision?: {
  57697. w: number;
  57698. h: number;
  57699. };
  57700. updatable?: boolean;
  57701. }, scene?: Nullable<Scene>): Mesh;
  57702. /**
  57703. * Creates a ground mesh from a height map
  57704. * * The parameter `url` sets the URL of the height map image resource.
  57705. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57706. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57707. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57708. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57709. * * 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.
  57710. * * 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).
  57711. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57713. * @param name defines the name of the mesh
  57714. * @param url defines the url to the height map
  57715. * @param options defines the options used to create the mesh
  57716. * @param scene defines the hosting scene
  57717. * @returns the ground mesh
  57718. * @see https://doc.babylonjs.com/babylon101/height_map
  57719. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57720. */
  57721. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57722. width?: number;
  57723. height?: number;
  57724. subdivisions?: number;
  57725. minHeight?: number;
  57726. maxHeight?: number;
  57727. colorFilter?: Color3;
  57728. alphaFilter?: number;
  57729. updatable?: boolean;
  57730. onReady?: (mesh: GroundMesh) => void;
  57731. }, scene?: Nullable<Scene>): GroundMesh;
  57732. /**
  57733. * Creates a polygon mesh
  57734. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57735. * * 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
  57736. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57738. * * 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)
  57739. * * Remember you can only change the shape positions, not their number when updating a polygon
  57740. * @param name defines the name of the mesh
  57741. * @param options defines the options used to create the mesh
  57742. * @param scene defines the hosting scene
  57743. * @param earcutInjection can be used to inject your own earcut reference
  57744. * @returns the polygon mesh
  57745. */
  57746. static CreatePolygon(name: string, options: {
  57747. shape: Vector3[];
  57748. holes?: Vector3[][];
  57749. depth?: number;
  57750. faceUV?: Vector4[];
  57751. faceColors?: Color4[];
  57752. updatable?: boolean;
  57753. sideOrientation?: number;
  57754. frontUVs?: Vector4;
  57755. backUVs?: Vector4;
  57756. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57757. /**
  57758. * Creates an extruded polygon mesh, with depth in the Y direction.
  57759. * * 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)
  57760. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57761. * @param name defines the name of the mesh
  57762. * @param options defines the options used to create the mesh
  57763. * @param scene defines the hosting scene
  57764. * @param earcutInjection can be used to inject your own earcut reference
  57765. * @returns the polygon mesh
  57766. */
  57767. static ExtrudePolygon(name: string, options: {
  57768. shape: Vector3[];
  57769. holes?: Vector3[][];
  57770. depth?: number;
  57771. faceUV?: Vector4[];
  57772. faceColors?: Color4[];
  57773. updatable?: boolean;
  57774. sideOrientation?: number;
  57775. frontUVs?: Vector4;
  57776. backUVs?: Vector4;
  57777. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57778. /**
  57779. * Creates a tube mesh.
  57780. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57781. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57782. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57783. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57784. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57785. * * 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)
  57786. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57787. * * 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
  57788. * * 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
  57789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57790. * * 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
  57791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57793. * @param name defines the name of the mesh
  57794. * @param options defines the options used to create the mesh
  57795. * @param scene defines the hosting scene
  57796. * @returns the tube mesh
  57797. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57798. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57799. */
  57800. static CreateTube(name: string, options: {
  57801. path: Vector3[];
  57802. radius?: number;
  57803. tessellation?: number;
  57804. radiusFunction?: {
  57805. (i: number, distance: number): number;
  57806. };
  57807. cap?: number;
  57808. arc?: number;
  57809. updatable?: boolean;
  57810. sideOrientation?: number;
  57811. frontUVs?: Vector4;
  57812. backUVs?: Vector4;
  57813. instance?: Mesh;
  57814. invertUV?: boolean;
  57815. }, scene?: Nullable<Scene>): Mesh;
  57816. /**
  57817. * Creates a polyhedron mesh
  57818. * * 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
  57819. * * The parameter `size` (positive float, default 1) sets the polygon size
  57820. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57821. * * 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`
  57822. * * 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
  57823. * * 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)`)
  57824. * * 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
  57825. * * 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
  57826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57827. * * 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
  57828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57829. * @param name defines the name of the mesh
  57830. * @param options defines the options used to create the mesh
  57831. * @param scene defines the hosting scene
  57832. * @returns the polyhedron mesh
  57833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57834. */
  57835. static CreatePolyhedron(name: string, options: {
  57836. type?: number;
  57837. size?: number;
  57838. sizeX?: number;
  57839. sizeY?: number;
  57840. sizeZ?: number;
  57841. custom?: any;
  57842. faceUV?: Vector4[];
  57843. faceColors?: Color4[];
  57844. flat?: boolean;
  57845. updatable?: boolean;
  57846. sideOrientation?: number;
  57847. frontUVs?: Vector4;
  57848. backUVs?: Vector4;
  57849. }, scene?: Nullable<Scene>): Mesh;
  57850. /**
  57851. * Creates a decal mesh.
  57852. * 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
  57853. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57854. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57855. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57856. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57857. * @param name defines the name of the mesh
  57858. * @param sourceMesh defines the mesh where the decal must be applied
  57859. * @param options defines the options used to create the mesh
  57860. * @param scene defines the hosting scene
  57861. * @returns the decal mesh
  57862. * @see https://doc.babylonjs.com/how_to/decals
  57863. */
  57864. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57865. position?: Vector3;
  57866. normal?: Vector3;
  57867. size?: Vector3;
  57868. angle?: number;
  57869. }): Mesh;
  57870. }
  57871. }
  57872. declare module BABYLON {
  57873. /**
  57874. * A simplifier interface for future simplification implementations
  57875. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57876. */
  57877. export interface ISimplifier {
  57878. /**
  57879. * Simplification of a given mesh according to the given settings.
  57880. * Since this requires computation, it is assumed that the function runs async.
  57881. * @param settings The settings of the simplification, including quality and distance
  57882. * @param successCallback A callback that will be called after the mesh was simplified.
  57883. * @param errorCallback in case of an error, this callback will be called. optional.
  57884. */
  57885. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57886. }
  57887. /**
  57888. * Expected simplification settings.
  57889. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57891. */
  57892. export interface ISimplificationSettings {
  57893. /**
  57894. * Gets or sets the expected quality
  57895. */
  57896. quality: number;
  57897. /**
  57898. * Gets or sets the distance when this optimized version should be used
  57899. */
  57900. distance: number;
  57901. /**
  57902. * Gets an already optimized mesh
  57903. */
  57904. optimizeMesh?: boolean;
  57905. }
  57906. /**
  57907. * Class used to specify simplification options
  57908. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57909. */
  57910. export class SimplificationSettings implements ISimplificationSettings {
  57911. /** expected quality */
  57912. quality: number;
  57913. /** distance when this optimized version should be used */
  57914. distance: number;
  57915. /** already optimized mesh */
  57916. optimizeMesh?: boolean | undefined;
  57917. /**
  57918. * Creates a SimplificationSettings
  57919. * @param quality expected quality
  57920. * @param distance distance when this optimized version should be used
  57921. * @param optimizeMesh already optimized mesh
  57922. */
  57923. constructor(
  57924. /** expected quality */
  57925. quality: number,
  57926. /** distance when this optimized version should be used */
  57927. distance: number,
  57928. /** already optimized mesh */
  57929. optimizeMesh?: boolean | undefined);
  57930. }
  57931. /**
  57932. * Interface used to define a simplification task
  57933. */
  57934. export interface ISimplificationTask {
  57935. /**
  57936. * Array of settings
  57937. */
  57938. settings: Array<ISimplificationSettings>;
  57939. /**
  57940. * Simplification type
  57941. */
  57942. simplificationType: SimplificationType;
  57943. /**
  57944. * Mesh to simplify
  57945. */
  57946. mesh: Mesh;
  57947. /**
  57948. * Callback called on success
  57949. */
  57950. successCallback?: () => void;
  57951. /**
  57952. * Defines if parallel processing can be used
  57953. */
  57954. parallelProcessing: boolean;
  57955. }
  57956. /**
  57957. * Queue used to order the simplification tasks
  57958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57959. */
  57960. export class SimplificationQueue {
  57961. private _simplificationArray;
  57962. /**
  57963. * Gets a boolean indicating that the process is still running
  57964. */
  57965. running: boolean;
  57966. /**
  57967. * Creates a new queue
  57968. */
  57969. constructor();
  57970. /**
  57971. * Adds a new simplification task
  57972. * @param task defines a task to add
  57973. */
  57974. addTask(task: ISimplificationTask): void;
  57975. /**
  57976. * Execute next task
  57977. */
  57978. executeNext(): void;
  57979. /**
  57980. * Execute a simplification task
  57981. * @param task defines the task to run
  57982. */
  57983. runSimplification(task: ISimplificationTask): void;
  57984. private getSimplifier;
  57985. }
  57986. /**
  57987. * The implemented types of simplification
  57988. * At the moment only Quadratic Error Decimation is implemented
  57989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57990. */
  57991. export enum SimplificationType {
  57992. /** Quadratic error decimation */
  57993. QUADRATIC = 0
  57994. }
  57995. }
  57996. declare module BABYLON {
  57997. interface Scene {
  57998. /** @hidden (Backing field) */
  57999. _simplificationQueue: SimplificationQueue;
  58000. /**
  58001. * Gets or sets the simplification queue attached to the scene
  58002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58003. */
  58004. simplificationQueue: SimplificationQueue;
  58005. }
  58006. interface Mesh {
  58007. /**
  58008. * Simplify the mesh according to the given array of settings.
  58009. * Function will return immediately and will simplify async
  58010. * @param settings a collection of simplification settings
  58011. * @param parallelProcessing should all levels calculate parallel or one after the other
  58012. * @param simplificationType the type of simplification to run
  58013. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58014. * @returns the current mesh
  58015. */
  58016. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58017. }
  58018. /**
  58019. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58020. * created in a scene
  58021. */
  58022. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58023. /**
  58024. * The component name helpfull to identify the component in the list of scene components.
  58025. */
  58026. readonly name: string;
  58027. /**
  58028. * The scene the component belongs to.
  58029. */
  58030. scene: Scene;
  58031. /**
  58032. * Creates a new instance of the component for the given scene
  58033. * @param scene Defines the scene to register the component in
  58034. */
  58035. constructor(scene: Scene);
  58036. /**
  58037. * Registers the component in a given scene
  58038. */
  58039. register(): void;
  58040. /**
  58041. * Rebuilds the elements related to this component in case of
  58042. * context lost for instance.
  58043. */
  58044. rebuild(): void;
  58045. /**
  58046. * Disposes the component and the associated ressources
  58047. */
  58048. dispose(): void;
  58049. private _beforeCameraUpdate;
  58050. }
  58051. }
  58052. declare module BABYLON {
  58053. /**
  58054. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58055. */
  58056. export interface INavigationEnginePlugin {
  58057. /**
  58058. * plugin name
  58059. */
  58060. name: string;
  58061. /**
  58062. * Creates a navigation mesh
  58063. * @param meshes array of all the geometry used to compute the navigatio mesh
  58064. * @param parameters bunch of parameters used to filter geometry
  58065. */
  58066. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58067. /**
  58068. * Create a navigation mesh debug mesh
  58069. * @param scene is where the mesh will be added
  58070. * @returns debug display mesh
  58071. */
  58072. createDebugNavMesh(scene: Scene): Mesh;
  58073. /**
  58074. * Get a navigation mesh constrained position, closest to the parameter position
  58075. * @param position world position
  58076. * @returns the closest point to position constrained by the navigation mesh
  58077. */
  58078. getClosestPoint(position: Vector3): Vector3;
  58079. /**
  58080. * Get a navigation mesh constrained position, within a particular radius
  58081. * @param position world position
  58082. * @param maxRadius the maximum distance to the constrained world position
  58083. * @returns the closest point to position constrained by the navigation mesh
  58084. */
  58085. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58086. /**
  58087. * Compute the final position from a segment made of destination-position
  58088. * @param position world position
  58089. * @param destination world position
  58090. * @returns the resulting point along the navmesh
  58091. */
  58092. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58093. /**
  58094. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58095. * @param start world position
  58096. * @param end world position
  58097. * @returns array containing world position composing the path
  58098. */
  58099. computePath(start: Vector3, end: Vector3): Vector3[];
  58100. /**
  58101. * If this plugin is supported
  58102. * @returns true if plugin is supported
  58103. */
  58104. isSupported(): boolean;
  58105. /**
  58106. * Create a new Crowd so you can add agents
  58107. * @param maxAgents the maximum agent count in the crowd
  58108. * @param maxAgentRadius the maximum radius an agent can have
  58109. * @param scene to attach the crowd to
  58110. * @returns the crowd you can add agents to
  58111. */
  58112. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58113. /**
  58114. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58115. * The queries will try to find a solution within those bounds
  58116. * default is (1,1,1)
  58117. * @param extent x,y,z value that define the extent around the queries point of reference
  58118. */
  58119. setDefaultQueryExtent(extent: Vector3): void;
  58120. /**
  58121. * Get the Bounding box extent specified by setDefaultQueryExtent
  58122. * @returns the box extent values
  58123. */
  58124. getDefaultQueryExtent(): Vector3;
  58125. /**
  58126. * Release all resources
  58127. */
  58128. dispose(): void;
  58129. }
  58130. /**
  58131. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58132. */
  58133. export interface ICrowd {
  58134. /**
  58135. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58136. * You can attach anything to that node. The node position is updated in the scene update tick.
  58137. * @param pos world position that will be constrained by the navigation mesh
  58138. * @param parameters agent parameters
  58139. * @param transform hooked to the agent that will be update by the scene
  58140. * @returns agent index
  58141. */
  58142. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58143. /**
  58144. * Returns the agent position in world space
  58145. * @param index agent index returned by addAgent
  58146. * @returns world space position
  58147. */
  58148. getAgentPosition(index: number): Vector3;
  58149. /**
  58150. * Gets the agent velocity in world space
  58151. * @param index agent index returned by addAgent
  58152. * @returns world space velocity
  58153. */
  58154. getAgentVelocity(index: number): Vector3;
  58155. /**
  58156. * remove a particular agent previously created
  58157. * @param index agent index returned by addAgent
  58158. */
  58159. removeAgent(index: number): void;
  58160. /**
  58161. * get the list of all agents attached to this crowd
  58162. * @returns list of agent indices
  58163. */
  58164. getAgents(): number[];
  58165. /**
  58166. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58167. * @param deltaTime in seconds
  58168. */
  58169. update(deltaTime: number): void;
  58170. /**
  58171. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58172. * @param index agent index returned by addAgent
  58173. * @param destination targeted world position
  58174. */
  58175. agentGoto(index: number, destination: Vector3): void;
  58176. /**
  58177. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58178. * The queries will try to find a solution within those bounds
  58179. * default is (1,1,1)
  58180. * @param extent x,y,z value that define the extent around the queries point of reference
  58181. */
  58182. setDefaultQueryExtent(extent: Vector3): void;
  58183. /**
  58184. * Get the Bounding box extent specified by setDefaultQueryExtent
  58185. * @returns the box extent values
  58186. */
  58187. getDefaultQueryExtent(): Vector3;
  58188. /**
  58189. * Release all resources
  58190. */
  58191. dispose(): void;
  58192. }
  58193. /**
  58194. * Configures an agent
  58195. */
  58196. export interface IAgentParameters {
  58197. /**
  58198. * Agent radius. [Limit: >= 0]
  58199. */
  58200. radius: number;
  58201. /**
  58202. * Agent height. [Limit: > 0]
  58203. */
  58204. height: number;
  58205. /**
  58206. * Maximum allowed acceleration. [Limit: >= 0]
  58207. */
  58208. maxAcceleration: number;
  58209. /**
  58210. * Maximum allowed speed. [Limit: >= 0]
  58211. */
  58212. maxSpeed: number;
  58213. /**
  58214. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58215. */
  58216. collisionQueryRange: number;
  58217. /**
  58218. * The path visibility optimization range. [Limit: > 0]
  58219. */
  58220. pathOptimizationRange: number;
  58221. /**
  58222. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58223. */
  58224. separationWeight: number;
  58225. }
  58226. /**
  58227. * Configures the navigation mesh creation
  58228. */
  58229. export interface INavMeshParameters {
  58230. /**
  58231. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58232. */
  58233. cs: number;
  58234. /**
  58235. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58236. */
  58237. ch: number;
  58238. /**
  58239. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58240. */
  58241. walkableSlopeAngle: number;
  58242. /**
  58243. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58244. * be considered walkable. [Limit: >= 3] [Units: vx]
  58245. */
  58246. walkableHeight: number;
  58247. /**
  58248. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58249. */
  58250. walkableClimb: number;
  58251. /**
  58252. * The distance to erode/shrink the walkable area of the heightfield away from
  58253. * obstructions. [Limit: >=0] [Units: vx]
  58254. */
  58255. walkableRadius: number;
  58256. /**
  58257. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58258. */
  58259. maxEdgeLen: number;
  58260. /**
  58261. * The maximum distance a simplfied contour's border edges should deviate
  58262. * the original raw contour. [Limit: >=0] [Units: vx]
  58263. */
  58264. maxSimplificationError: number;
  58265. /**
  58266. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58267. */
  58268. minRegionArea: number;
  58269. /**
  58270. * Any regions with a span count smaller than this value will, if possible,
  58271. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58272. */
  58273. mergeRegionArea: number;
  58274. /**
  58275. * The maximum number of vertices allowed for polygons generated during the
  58276. * contour to polygon conversion process. [Limit: >= 3]
  58277. */
  58278. maxVertsPerPoly: number;
  58279. /**
  58280. * Sets the sampling distance to use when generating the detail mesh.
  58281. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58282. */
  58283. detailSampleDist: number;
  58284. /**
  58285. * The maximum distance the detail mesh surface should deviate from heightfield
  58286. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58287. */
  58288. detailSampleMaxError: number;
  58289. }
  58290. }
  58291. declare module BABYLON {
  58292. /**
  58293. * RecastJS navigation plugin
  58294. */
  58295. export class RecastJSPlugin implements INavigationEnginePlugin {
  58296. /**
  58297. * Reference to the Recast library
  58298. */
  58299. bjsRECAST: any;
  58300. /**
  58301. * plugin name
  58302. */
  58303. name: string;
  58304. /**
  58305. * the first navmesh created. We might extend this to support multiple navmeshes
  58306. */
  58307. navMesh: any;
  58308. /**
  58309. * Initializes the recastJS plugin
  58310. * @param recastInjection can be used to inject your own recast reference
  58311. */
  58312. constructor(recastInjection?: any);
  58313. /**
  58314. * Creates a navigation mesh
  58315. * @param meshes array of all the geometry used to compute the navigatio mesh
  58316. * @param parameters bunch of parameters used to filter geometry
  58317. */
  58318. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58319. /**
  58320. * Create a navigation mesh debug mesh
  58321. * @param scene is where the mesh will be added
  58322. * @returns debug display mesh
  58323. */
  58324. createDebugNavMesh(scene: Scene): Mesh;
  58325. /**
  58326. * Get a navigation mesh constrained position, closest to the parameter position
  58327. * @param position world position
  58328. * @returns the closest point to position constrained by the navigation mesh
  58329. */
  58330. getClosestPoint(position: Vector3): Vector3;
  58331. /**
  58332. * Get a navigation mesh constrained position, within a particular radius
  58333. * @param position world position
  58334. * @param maxRadius the maximum distance to the constrained world position
  58335. * @returns the closest point to position constrained by the navigation mesh
  58336. */
  58337. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58338. /**
  58339. * Compute the final position from a segment made of destination-position
  58340. * @param position world position
  58341. * @param destination world position
  58342. * @returns the resulting point along the navmesh
  58343. */
  58344. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58345. /**
  58346. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58347. * @param start world position
  58348. * @param end world position
  58349. * @returns array containing world position composing the path
  58350. */
  58351. computePath(start: Vector3, end: Vector3): Vector3[];
  58352. /**
  58353. * Create a new Crowd so you can add agents
  58354. * @param maxAgents the maximum agent count in the crowd
  58355. * @param maxAgentRadius the maximum radius an agent can have
  58356. * @param scene to attach the crowd to
  58357. * @returns the crowd you can add agents to
  58358. */
  58359. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58360. /**
  58361. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58362. * The queries will try to find a solution within those bounds
  58363. * default is (1,1,1)
  58364. * @param extent x,y,z value that define the extent around the queries point of reference
  58365. */
  58366. setDefaultQueryExtent(extent: Vector3): void;
  58367. /**
  58368. * Get the Bounding box extent specified by setDefaultQueryExtent
  58369. * @returns the box extent values
  58370. */
  58371. getDefaultQueryExtent(): Vector3;
  58372. /**
  58373. * Disposes
  58374. */
  58375. dispose(): void;
  58376. /**
  58377. * If this plugin is supported
  58378. * @returns true if plugin is supported
  58379. */
  58380. isSupported(): boolean;
  58381. }
  58382. /**
  58383. * Recast detour crowd implementation
  58384. */
  58385. export class RecastJSCrowd implements ICrowd {
  58386. /**
  58387. * Recast/detour plugin
  58388. */
  58389. bjsRECASTPlugin: RecastJSPlugin;
  58390. /**
  58391. * Link to the detour crowd
  58392. */
  58393. recastCrowd: any;
  58394. /**
  58395. * One transform per agent
  58396. */
  58397. transforms: TransformNode[];
  58398. /**
  58399. * All agents created
  58400. */
  58401. agents: number[];
  58402. /**
  58403. * Link to the scene is kept to unregister the crowd from the scene
  58404. */
  58405. private _scene;
  58406. /**
  58407. * Observer for crowd updates
  58408. */
  58409. private _onBeforeAnimationsObserver;
  58410. /**
  58411. * Constructor
  58412. * @param plugin recastJS plugin
  58413. * @param maxAgents the maximum agent count in the crowd
  58414. * @param maxAgentRadius the maximum radius an agent can have
  58415. * @param scene to attach the crowd to
  58416. * @returns the crowd you can add agents to
  58417. */
  58418. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58419. /**
  58420. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58421. * You can attach anything to that node. The node position is updated in the scene update tick.
  58422. * @param pos world position that will be constrained by the navigation mesh
  58423. * @param parameters agent parameters
  58424. * @param transform hooked to the agent that will be update by the scene
  58425. * @returns agent index
  58426. */
  58427. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58428. /**
  58429. * Returns the agent position in world space
  58430. * @param index agent index returned by addAgent
  58431. * @returns world space position
  58432. */
  58433. getAgentPosition(index: number): Vector3;
  58434. /**
  58435. * Returns the agent velocity in world space
  58436. * @param index agent index returned by addAgent
  58437. * @returns world space velocity
  58438. */
  58439. getAgentVelocity(index: number): Vector3;
  58440. /**
  58441. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58442. * @param index agent index returned by addAgent
  58443. * @param destination targeted world position
  58444. */
  58445. agentGoto(index: number, destination: Vector3): void;
  58446. /**
  58447. * remove a particular agent previously created
  58448. * @param index agent index returned by addAgent
  58449. */
  58450. removeAgent(index: number): void;
  58451. /**
  58452. * get the list of all agents attached to this crowd
  58453. * @returns list of agent indices
  58454. */
  58455. getAgents(): number[];
  58456. /**
  58457. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58458. * @param deltaTime in seconds
  58459. */
  58460. update(deltaTime: number): void;
  58461. /**
  58462. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58463. * The queries will try to find a solution within those bounds
  58464. * default is (1,1,1)
  58465. * @param extent x,y,z value that define the extent around the queries point of reference
  58466. */
  58467. setDefaultQueryExtent(extent: Vector3): void;
  58468. /**
  58469. * Get the Bounding box extent specified by setDefaultQueryExtent
  58470. * @returns the box extent values
  58471. */
  58472. getDefaultQueryExtent(): Vector3;
  58473. /**
  58474. * Release all resources
  58475. */
  58476. dispose(): void;
  58477. }
  58478. }
  58479. declare module BABYLON {
  58480. /**
  58481. * Class used to enable access to IndexedDB
  58482. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58483. */
  58484. export class Database implements IOfflineProvider {
  58485. private _callbackManifestChecked;
  58486. private _currentSceneUrl;
  58487. private _db;
  58488. private _enableSceneOffline;
  58489. private _enableTexturesOffline;
  58490. private _manifestVersionFound;
  58491. private _mustUpdateRessources;
  58492. private _hasReachedQuota;
  58493. private _isSupported;
  58494. private _idbFactory;
  58495. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58496. private static IsUASupportingBlobStorage;
  58497. /**
  58498. * Gets a boolean indicating if Database storate is enabled (off by default)
  58499. */
  58500. static IDBStorageEnabled: boolean;
  58501. /**
  58502. * Gets a boolean indicating if scene must be saved in the database
  58503. */
  58504. readonly enableSceneOffline: boolean;
  58505. /**
  58506. * Gets a boolean indicating if textures must be saved in the database
  58507. */
  58508. readonly enableTexturesOffline: boolean;
  58509. /**
  58510. * Creates a new Database
  58511. * @param urlToScene defines the url to load the scene
  58512. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58513. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58514. */
  58515. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58516. private static _ParseURL;
  58517. private static _ReturnFullUrlLocation;
  58518. private _checkManifestFile;
  58519. /**
  58520. * Open the database and make it available
  58521. * @param successCallback defines the callback to call on success
  58522. * @param errorCallback defines the callback to call on error
  58523. */
  58524. open(successCallback: () => void, errorCallback: () => void): void;
  58525. /**
  58526. * Loads an image from the database
  58527. * @param url defines the url to load from
  58528. * @param image defines the target DOM image
  58529. */
  58530. loadImage(url: string, image: HTMLImageElement): void;
  58531. private _loadImageFromDBAsync;
  58532. private _saveImageIntoDBAsync;
  58533. private _checkVersionFromDB;
  58534. private _loadVersionFromDBAsync;
  58535. private _saveVersionIntoDBAsync;
  58536. /**
  58537. * Loads a file from database
  58538. * @param url defines the URL to load from
  58539. * @param sceneLoaded defines a callback to call on success
  58540. * @param progressCallBack defines a callback to call when progress changed
  58541. * @param errorCallback defines a callback to call on error
  58542. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58543. */
  58544. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58545. private _loadFileAsync;
  58546. private _saveFileAsync;
  58547. /**
  58548. * Validates if xhr data is correct
  58549. * @param xhr defines the request to validate
  58550. * @param dataType defines the expected data type
  58551. * @returns true if data is correct
  58552. */
  58553. private static _ValidateXHRData;
  58554. }
  58555. }
  58556. declare module BABYLON {
  58557. /** @hidden */
  58558. export var gpuUpdateParticlesPixelShader: {
  58559. name: string;
  58560. shader: string;
  58561. };
  58562. }
  58563. declare module BABYLON {
  58564. /** @hidden */
  58565. export var gpuUpdateParticlesVertexShader: {
  58566. name: string;
  58567. shader: string;
  58568. };
  58569. }
  58570. declare module BABYLON {
  58571. /** @hidden */
  58572. export var clipPlaneFragmentDeclaration2: {
  58573. name: string;
  58574. shader: string;
  58575. };
  58576. }
  58577. declare module BABYLON {
  58578. /** @hidden */
  58579. export var gpuRenderParticlesPixelShader: {
  58580. name: string;
  58581. shader: string;
  58582. };
  58583. }
  58584. declare module BABYLON {
  58585. /** @hidden */
  58586. export var clipPlaneVertexDeclaration2: {
  58587. name: string;
  58588. shader: string;
  58589. };
  58590. }
  58591. declare module BABYLON {
  58592. /** @hidden */
  58593. export var gpuRenderParticlesVertexShader: {
  58594. name: string;
  58595. shader: string;
  58596. };
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * This represents a GPU particle system in Babylon
  58601. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58602. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58603. */
  58604. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58605. /**
  58606. * The layer mask we are rendering the particles through.
  58607. */
  58608. layerMask: number;
  58609. private _capacity;
  58610. private _activeCount;
  58611. private _currentActiveCount;
  58612. private _accumulatedCount;
  58613. private _renderEffect;
  58614. private _updateEffect;
  58615. private _buffer0;
  58616. private _buffer1;
  58617. private _spriteBuffer;
  58618. private _updateVAO;
  58619. private _renderVAO;
  58620. private _targetIndex;
  58621. private _sourceBuffer;
  58622. private _targetBuffer;
  58623. private _engine;
  58624. private _currentRenderId;
  58625. private _started;
  58626. private _stopped;
  58627. private _timeDelta;
  58628. private _randomTexture;
  58629. private _randomTexture2;
  58630. private _attributesStrideSize;
  58631. private _updateEffectOptions;
  58632. private _randomTextureSize;
  58633. private _actualFrame;
  58634. private readonly _rawTextureWidth;
  58635. /**
  58636. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58637. */
  58638. static readonly IsSupported: boolean;
  58639. /**
  58640. * An event triggered when the system is disposed.
  58641. */
  58642. onDisposeObservable: Observable<GPUParticleSystem>;
  58643. /**
  58644. * Gets the maximum number of particles active at the same time.
  58645. * @returns The max number of active particles.
  58646. */
  58647. getCapacity(): number;
  58648. /**
  58649. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58650. * to override the particles.
  58651. */
  58652. forceDepthWrite: boolean;
  58653. /**
  58654. * Gets or set the number of active particles
  58655. */
  58656. activeParticleCount: number;
  58657. private _preWarmDone;
  58658. /**
  58659. * Is this system ready to be used/rendered
  58660. * @return true if the system is ready
  58661. */
  58662. isReady(): boolean;
  58663. /**
  58664. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58665. * @returns True if it has been started, otherwise false.
  58666. */
  58667. isStarted(): boolean;
  58668. /**
  58669. * Starts the particle system and begins to emit
  58670. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58671. */
  58672. start(delay?: number): void;
  58673. /**
  58674. * Stops the particle system.
  58675. */
  58676. stop(): void;
  58677. /**
  58678. * Remove all active particles
  58679. */
  58680. reset(): void;
  58681. /**
  58682. * Returns the string "GPUParticleSystem"
  58683. * @returns a string containing the class name
  58684. */
  58685. getClassName(): string;
  58686. private _colorGradientsTexture;
  58687. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58688. /**
  58689. * Adds a new color gradient
  58690. * @param gradient defines the gradient to use (between 0 and 1)
  58691. * @param color1 defines the color to affect to the specified gradient
  58692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58693. * @returns the current particle system
  58694. */
  58695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58696. /**
  58697. * Remove a specific color gradient
  58698. * @param gradient defines the gradient to remove
  58699. * @returns the current particle system
  58700. */
  58701. removeColorGradient(gradient: number): GPUParticleSystem;
  58702. private _angularSpeedGradientsTexture;
  58703. private _sizeGradientsTexture;
  58704. private _velocityGradientsTexture;
  58705. private _limitVelocityGradientsTexture;
  58706. private _dragGradientsTexture;
  58707. private _addFactorGradient;
  58708. /**
  58709. * Adds a new size gradient
  58710. * @param gradient defines the gradient to use (between 0 and 1)
  58711. * @param factor defines the size factor to affect to the specified gradient
  58712. * @returns the current particle system
  58713. */
  58714. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58715. /**
  58716. * Remove a specific size gradient
  58717. * @param gradient defines the gradient to remove
  58718. * @returns the current particle system
  58719. */
  58720. removeSizeGradient(gradient: number): GPUParticleSystem;
  58721. /**
  58722. * Adds a new angular speed gradient
  58723. * @param gradient defines the gradient to use (between 0 and 1)
  58724. * @param factor defines the angular speed to affect to the specified gradient
  58725. * @returns the current particle system
  58726. */
  58727. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58728. /**
  58729. * Remove a specific angular speed gradient
  58730. * @param gradient defines the gradient to remove
  58731. * @returns the current particle system
  58732. */
  58733. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58734. /**
  58735. * Adds a new velocity gradient
  58736. * @param gradient defines the gradient to use (between 0 and 1)
  58737. * @param factor defines the velocity to affect to the specified gradient
  58738. * @returns the current particle system
  58739. */
  58740. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58741. /**
  58742. * Remove a specific velocity gradient
  58743. * @param gradient defines the gradient to remove
  58744. * @returns the current particle system
  58745. */
  58746. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58747. /**
  58748. * Adds a new limit velocity gradient
  58749. * @param gradient defines the gradient to use (between 0 and 1)
  58750. * @param factor defines the limit velocity value to affect to the specified gradient
  58751. * @returns the current particle system
  58752. */
  58753. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58754. /**
  58755. * Remove a specific limit velocity gradient
  58756. * @param gradient defines the gradient to remove
  58757. * @returns the current particle system
  58758. */
  58759. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58760. /**
  58761. * Adds a new drag gradient
  58762. * @param gradient defines the gradient to use (between 0 and 1)
  58763. * @param factor defines the drag value to affect to the specified gradient
  58764. * @returns the current particle system
  58765. */
  58766. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58767. /**
  58768. * Remove a specific drag gradient
  58769. * @param gradient defines the gradient to remove
  58770. * @returns the current particle system
  58771. */
  58772. removeDragGradient(gradient: number): GPUParticleSystem;
  58773. /**
  58774. * Not supported by GPUParticleSystem
  58775. * @param gradient defines the gradient to use (between 0 and 1)
  58776. * @param factor defines the emit rate value to affect to the specified gradient
  58777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58778. * @returns the current particle system
  58779. */
  58780. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58781. /**
  58782. * Not supported by GPUParticleSystem
  58783. * @param gradient defines the gradient to remove
  58784. * @returns the current particle system
  58785. */
  58786. removeEmitRateGradient(gradient: number): IParticleSystem;
  58787. /**
  58788. * Not supported by GPUParticleSystem
  58789. * @param gradient defines the gradient to use (between 0 and 1)
  58790. * @param factor defines the start size value to affect to the specified gradient
  58791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58792. * @returns the current particle system
  58793. */
  58794. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58795. /**
  58796. * Not supported by GPUParticleSystem
  58797. * @param gradient defines the gradient to remove
  58798. * @returns the current particle system
  58799. */
  58800. removeStartSizeGradient(gradient: number): IParticleSystem;
  58801. /**
  58802. * Not supported by GPUParticleSystem
  58803. * @param gradient defines the gradient to use (between 0 and 1)
  58804. * @param min defines the color remap minimal range
  58805. * @param max defines the color remap maximal range
  58806. * @returns the current particle system
  58807. */
  58808. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58809. /**
  58810. * Not supported by GPUParticleSystem
  58811. * @param gradient defines the gradient to remove
  58812. * @returns the current particle system
  58813. */
  58814. removeColorRemapGradient(): IParticleSystem;
  58815. /**
  58816. * Not supported by GPUParticleSystem
  58817. * @param gradient defines the gradient to use (between 0 and 1)
  58818. * @param min defines the alpha remap minimal range
  58819. * @param max defines the alpha remap maximal range
  58820. * @returns the current particle system
  58821. */
  58822. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58823. /**
  58824. * Not supported by GPUParticleSystem
  58825. * @param gradient defines the gradient to remove
  58826. * @returns the current particle system
  58827. */
  58828. removeAlphaRemapGradient(): IParticleSystem;
  58829. /**
  58830. * Not supported by GPUParticleSystem
  58831. * @param gradient defines the gradient to use (between 0 and 1)
  58832. * @param color defines the color to affect to the specified gradient
  58833. * @returns the current particle system
  58834. */
  58835. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58836. /**
  58837. * Not supported by GPUParticleSystem
  58838. * @param gradient defines the gradient to remove
  58839. * @returns the current particle system
  58840. */
  58841. removeRampGradient(): IParticleSystem;
  58842. /**
  58843. * Not supported by GPUParticleSystem
  58844. * @returns the list of ramp gradients
  58845. */
  58846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58847. /**
  58848. * Not supported by GPUParticleSystem
  58849. * Gets or sets a boolean indicating that ramp gradients must be used
  58850. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58851. */
  58852. useRampGradients: boolean;
  58853. /**
  58854. * Not supported by GPUParticleSystem
  58855. * @param gradient defines the gradient to use (between 0 and 1)
  58856. * @param factor defines the life time factor to affect to the specified gradient
  58857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58858. * @returns the current particle system
  58859. */
  58860. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58861. /**
  58862. * Not supported by GPUParticleSystem
  58863. * @param gradient defines the gradient to remove
  58864. * @returns the current particle system
  58865. */
  58866. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58867. /**
  58868. * Instantiates a GPU particle system.
  58869. * 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.
  58870. * @param name The name of the particle system
  58871. * @param options The options used to create the system
  58872. * @param scene The scene the particle system belongs to
  58873. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58874. */
  58875. constructor(name: string, options: Partial<{
  58876. capacity: number;
  58877. randomTextureSize: number;
  58878. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58879. protected _reset(): void;
  58880. private _createUpdateVAO;
  58881. private _createRenderVAO;
  58882. private _initialize;
  58883. /** @hidden */
  58884. _recreateUpdateEffect(): void;
  58885. /** @hidden */
  58886. _recreateRenderEffect(): void;
  58887. /**
  58888. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58889. * @param preWarm defines if we are in the pre-warmimg phase
  58890. */
  58891. animate(preWarm?: boolean): void;
  58892. private _createFactorGradientTexture;
  58893. private _createSizeGradientTexture;
  58894. private _createAngularSpeedGradientTexture;
  58895. private _createVelocityGradientTexture;
  58896. private _createLimitVelocityGradientTexture;
  58897. private _createDragGradientTexture;
  58898. private _createColorGradientTexture;
  58899. /**
  58900. * Renders the particle system in its current state
  58901. * @param preWarm defines if the system should only update the particles but not render them
  58902. * @returns the current number of particles
  58903. */
  58904. render(preWarm?: boolean): number;
  58905. /**
  58906. * Rebuilds the particle system
  58907. */
  58908. rebuild(): void;
  58909. private _releaseBuffers;
  58910. private _releaseVAOs;
  58911. /**
  58912. * Disposes the particle system and free the associated resources
  58913. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58914. */
  58915. dispose(disposeTexture?: boolean): void;
  58916. /**
  58917. * Clones the particle system.
  58918. * @param name The name of the cloned object
  58919. * @param newEmitter The new emitter to use
  58920. * @returns the cloned particle system
  58921. */
  58922. clone(name: string, newEmitter: any): GPUParticleSystem;
  58923. /**
  58924. * Serializes the particle system to a JSON object.
  58925. * @returns the JSON object
  58926. */
  58927. serialize(): any;
  58928. /**
  58929. * Parses a JSON object to create a GPU particle system.
  58930. * @param parsedParticleSystem The JSON object to parse
  58931. * @param scene The scene to create the particle system in
  58932. * @param rootUrl The root url to use to load external dependencies like texture
  58933. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58934. * @returns the parsed GPU particle system
  58935. */
  58936. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58937. }
  58938. }
  58939. declare module BABYLON {
  58940. /**
  58941. * Represents a set of particle systems working together to create a specific effect
  58942. */
  58943. export class ParticleSystemSet implements IDisposable {
  58944. /**
  58945. * Gets or sets base Assets URL
  58946. */
  58947. static BaseAssetsUrl: string;
  58948. private _emitterCreationOptions;
  58949. private _emitterNode;
  58950. /**
  58951. * Gets the particle system list
  58952. */
  58953. systems: IParticleSystem[];
  58954. /**
  58955. * Gets the emitter node used with this set
  58956. */
  58957. readonly emitterNode: Nullable<TransformNode>;
  58958. /**
  58959. * Creates a new emitter mesh as a sphere
  58960. * @param options defines the options used to create the sphere
  58961. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58962. * @param scene defines the hosting scene
  58963. */
  58964. setEmitterAsSphere(options: {
  58965. diameter: number;
  58966. segments: number;
  58967. color: Color3;
  58968. }, renderingGroupId: number, scene: Scene): void;
  58969. /**
  58970. * Starts all particle systems of the set
  58971. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58972. */
  58973. start(emitter?: AbstractMesh): void;
  58974. /**
  58975. * Release all associated resources
  58976. */
  58977. dispose(): void;
  58978. /**
  58979. * Serialize the set into a JSON compatible object
  58980. * @returns a JSON compatible representation of the set
  58981. */
  58982. serialize(): any;
  58983. /**
  58984. * Parse a new ParticleSystemSet from a serialized source
  58985. * @param data defines a JSON compatible representation of the set
  58986. * @param scene defines the hosting scene
  58987. * @param gpu defines if we want GPU particles or CPU particles
  58988. * @returns a new ParticleSystemSet
  58989. */
  58990. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * This class is made for on one-liner static method to help creating particle system set.
  58996. */
  58997. export class ParticleHelper {
  58998. /**
  58999. * Gets or sets base Assets URL
  59000. */
  59001. static BaseAssetsUrl: string;
  59002. /**
  59003. * Create a default particle system that you can tweak
  59004. * @param emitter defines the emitter to use
  59005. * @param capacity defines the system capacity (default is 500 particles)
  59006. * @param scene defines the hosting scene
  59007. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59008. * @returns the new Particle system
  59009. */
  59010. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59011. /**
  59012. * This is the main static method (one-liner) of this helper to create different particle systems
  59013. * @param type This string represents the type to the particle system to create
  59014. * @param scene The scene where the particle system should live
  59015. * @param gpu If the system will use gpu
  59016. * @returns the ParticleSystemSet created
  59017. */
  59018. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59019. /**
  59020. * Static function used to export a particle system to a ParticleSystemSet variable.
  59021. * Please note that the emitter shape is not exported
  59022. * @param systems defines the particle systems to export
  59023. * @returns the created particle system set
  59024. */
  59025. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59026. }
  59027. }
  59028. declare module BABYLON {
  59029. interface Engine {
  59030. /**
  59031. * Create an effect to use with particle systems.
  59032. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59033. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59034. * @param uniformsNames defines a list of attribute names
  59035. * @param samplers defines an array of string used to represent textures
  59036. * @param defines defines the string containing the defines to use to compile the shaders
  59037. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59038. * @param onCompiled defines a function to call when the effect creation is successful
  59039. * @param onError defines a function to call when the effect creation has failed
  59040. * @returns the new Effect
  59041. */
  59042. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59043. }
  59044. interface Mesh {
  59045. /**
  59046. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59047. * @returns an array of IParticleSystem
  59048. */
  59049. getEmittedParticleSystems(): IParticleSystem[];
  59050. /**
  59051. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59052. * @returns an array of IParticleSystem
  59053. */
  59054. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59055. }
  59056. /**
  59057. * @hidden
  59058. */
  59059. export var _IDoNeedToBeInTheBuild: number;
  59060. }
  59061. declare module BABYLON {
  59062. /** Defines the 4 color options */
  59063. export enum PointColor {
  59064. /** color value */
  59065. Color = 2,
  59066. /** uv value */
  59067. UV = 1,
  59068. /** random value */
  59069. Random = 0,
  59070. /** stated value */
  59071. Stated = 3
  59072. }
  59073. /**
  59074. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59075. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  59076. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59077. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59078. *
  59079. * Full documentation here : TO BE ENTERED
  59080. */
  59081. export class PointsCloudSystem implements IDisposable {
  59082. /**
  59083. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59084. * Example : var p = SPS.particles[i];
  59085. */
  59086. particles: CloudPoint[];
  59087. /**
  59088. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59089. */
  59090. nbParticles: number;
  59091. /**
  59092. * This a counter for your own usage. It's not set by any SPS functions.
  59093. */
  59094. counter: number;
  59095. /**
  59096. * The PCS name. This name is also given to the underlying mesh.
  59097. */
  59098. name: string;
  59099. /**
  59100. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  59101. */
  59102. mesh: Mesh;
  59103. /**
  59104. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  59105. * Please read :
  59106. */
  59107. vars: any;
  59108. /**
  59109. * @hidden
  59110. */
  59111. _size: number;
  59112. private _scene;
  59113. private _promises;
  59114. private _positions;
  59115. private _indices;
  59116. private _normals;
  59117. private _colors;
  59118. private _uvs;
  59119. private _indices32;
  59120. private _positions32;
  59121. private _colors32;
  59122. private _uvs32;
  59123. private _updatable;
  59124. private _isVisibilityBoxLocked;
  59125. private _alwaysVisible;
  59126. private _groups;
  59127. private _groupCounter;
  59128. private _computeParticleColor;
  59129. private _computeParticleTexture;
  59130. private _computeParticleRotation;
  59131. private _computeBoundingBox;
  59132. private _isReady;
  59133. /**
  59134. * Creates a PCS (Points Cloud System) object
  59135. * @param name (String) is the PCS name, this will be the underlying mesh name
  59136. * @param pointSize (number) is the size for each point
  59137. * @param scene (Scene) is the scene in which the PCS is added
  59138. * @param options defines the options of the PCS e.g.
  59139. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59140. */
  59141. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59142. updatable?: boolean;
  59143. });
  59144. /**
  59145. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59146. * If no points were added to the PCS, the returned mesh is just a single point.
  59147. * @returns a promise for the created mesh
  59148. */
  59149. buildMeshAsync(): Promise<Mesh>;
  59150. /**
  59151. * @hidden
  59152. */
  59153. private _buildMesh;
  59154. private _addParticle;
  59155. private _randomUnitVector;
  59156. private _getColorIndicesForCoord;
  59157. private _setPointsColorOrUV;
  59158. private _colorFromTexture;
  59159. private _calculateDensity;
  59160. /**
  59161. * Adds points to the PCS in random positions within a unit sphere
  59162. * @param nb (positive integer) the number of particles to be created from this model
  59163. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59164. * @returns the number of groups in the system
  59165. */
  59166. addPoints(nb: number, pointFunction?: any): number;
  59167. /**
  59168. * Adds points to the PCS from the surface of the model shape
  59169. * @param mesh is any Mesh object that will be used as a surface model for the points
  59170. * @param nb (positive integer) the number of particles to be created from this model
  59171. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59172. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59173. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59174. * @returns the number of groups in the system
  59175. */
  59176. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59177. /**
  59178. * Adds points to the PCS inside the model shape
  59179. * @param mesh is any Mesh object that will be used as a surface model for the points
  59180. * @param nb (positive integer) the number of particles to be created from this model
  59181. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59182. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59183. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59184. * @returns the number of groups in the system
  59185. */
  59186. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59187. /**
  59188. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59189. * This method calls `updateParticle()` for each particle of the SPS.
  59190. * For an animated SPS, it is usually called within the render loop.
  59191. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59192. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59193. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59194. * @returns the PCS.
  59195. */
  59196. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59197. /**
  59198. * Disposes the PCS.
  59199. */
  59200. dispose(): void;
  59201. /**
  59202. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59203. * doc :
  59204. * @returns the PCS.
  59205. */
  59206. refreshVisibleSize(): PointsCloudSystem;
  59207. /**
  59208. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59209. * @param size the size (float) of the visibility box
  59210. * note : this doesn't lock the PCS mesh bounding box.
  59211. * doc :
  59212. */
  59213. setVisibilityBox(size: number): void;
  59214. /**
  59215. * Gets whether the PCS is always visible or not
  59216. * doc :
  59217. */
  59218. /**
  59219. * Sets the PCS as always visible or not
  59220. * doc :
  59221. */
  59222. isAlwaysVisible: boolean;
  59223. /**
  59224. * Tells to `setParticles()` to compute the particle rotations or not
  59225. * Default value : false. The PCS is faster when it's set to false
  59226. * Note : particle rotations are only applied to parent particles
  59227. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59228. */
  59229. computeParticleRotation: boolean;
  59230. /**
  59231. * Tells to `setParticles()` to compute the particle colors or not.
  59232. * Default value : true. The PCS is faster when it's set to false.
  59233. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59234. */
  59235. /**
  59236. * Gets if `setParticles()` computes the particle colors or not.
  59237. * Default value : false. The PCS is faster when it's set to false.
  59238. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59239. */
  59240. computeParticleColor: boolean;
  59241. /**
  59242. * Gets if `setParticles()` computes the particle textures or not.
  59243. * Default value : false. The PCS is faster when it's set to false.
  59244. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59245. */
  59246. computeParticleTexture: boolean;
  59247. /**
  59248. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59249. */
  59250. /**
  59251. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59252. */
  59253. computeBoundingBox: boolean;
  59254. /**
  59255. * This function does nothing. It may be overwritten to set all the particle first values.
  59256. * The PCS doesn't call this function, you may have to call it by your own.
  59257. * doc :
  59258. */
  59259. initParticles(): void;
  59260. /**
  59261. * This function does nothing. It may be overwritten to recycle a particle
  59262. * The PCS doesn't call this function, you can to call it
  59263. * doc :
  59264. * @param particle The particle to recycle
  59265. * @returns the recycled particle
  59266. */
  59267. recycleParticle(particle: CloudPoint): CloudPoint;
  59268. /**
  59269. * Updates a particle : this function should be overwritten by the user.
  59270. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59271. * doc :
  59272. * @example : just set a particle position or velocity and recycle conditions
  59273. * @param particle The particle to update
  59274. * @returns the updated particle
  59275. */
  59276. updateParticle(particle: CloudPoint): CloudPoint;
  59277. /**
  59278. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59279. * This does nothing and may be overwritten by the user.
  59280. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59281. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59282. * @param update the boolean update value actually passed to setParticles()
  59283. */
  59284. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59285. /**
  59286. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59287. * This will be passed three parameters.
  59288. * This does nothing and may be overwritten by the user.
  59289. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59290. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59291. * @param update the boolean update value actually passed to setParticles()
  59292. */
  59293. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59294. }
  59295. }
  59296. declare module BABYLON {
  59297. /**
  59298. * Represents one particle of a points cloud system.
  59299. */
  59300. export class CloudPoint {
  59301. /**
  59302. * particle global index
  59303. */
  59304. idx: number;
  59305. /**
  59306. * The color of the particle
  59307. */
  59308. color: Nullable<Color4>;
  59309. /**
  59310. * The world space position of the particle.
  59311. */
  59312. position: Vector3;
  59313. /**
  59314. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  59315. */
  59316. rotation: Vector3;
  59317. /**
  59318. * The world space rotation quaternion of the particle.
  59319. */
  59320. rotationQuaternion: Nullable<Quaternion>;
  59321. /**
  59322. * The uv of the particle.
  59323. */
  59324. uv: Nullable<Vector2>;
  59325. /**
  59326. * The current speed of the particle.
  59327. */
  59328. velocity: Vector3;
  59329. /**
  59330. * The pivot point in the particle local space.
  59331. */
  59332. pivot: Vector3;
  59333. /**
  59334. * Must the particle be translated from its pivot point in its local space ?
  59335. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  59336. * Default : false
  59337. */
  59338. translateFromPivot: boolean;
  59339. /**
  59340. * Index of this particle in the global "positions" array (Internal use)
  59341. * @hidden
  59342. */
  59343. _pos: number;
  59344. /**
  59345. * @hidden Index of this particle in the global "indices" array (Internal use)
  59346. */
  59347. _ind: number;
  59348. /**
  59349. * Group this particle belongs to
  59350. */
  59351. _group: PointsGroup;
  59352. /**
  59353. * Group id of this particle
  59354. */
  59355. groupId: number;
  59356. /**
  59357. * Index of the particle in its group id (Internal use)
  59358. */
  59359. idxInGroup: number;
  59360. /**
  59361. * @hidden Particle BoundingInfo object (Internal use)
  59362. */
  59363. _boundingInfo: BoundingInfo;
  59364. /**
  59365. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  59366. */
  59367. _pcs: PointsCloudSystem;
  59368. /**
  59369. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59370. */
  59371. _stillInvisible: boolean;
  59372. /**
  59373. * @hidden Last computed particle rotation matrix
  59374. */
  59375. _rotationMatrix: number[];
  59376. /**
  59377. * Parent particle Id, if any.
  59378. * Default null.
  59379. */
  59380. parentId: Nullable<number>;
  59381. /**
  59382. * @hidden Internal global position in the PCS.
  59383. */
  59384. _globalPosition: Vector3;
  59385. /**
  59386. * Creates a Point Cloud object.
  59387. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59388. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59389. * @param group (PointsGroup) is the group the particle belongs to
  59390. * @param groupId (integer) is the group identifier in the PCS.
  59391. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59392. * @param pcs defines the PCS it is associated to
  59393. */
  59394. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59395. /**
  59396. * get point size
  59397. */
  59398. /**
  59399. * Set point size
  59400. */
  59401. size: Vector3;
  59402. /**
  59403. * Legacy support, changed quaternion to rotationQuaternion
  59404. */
  59405. /**
  59406. * Legacy support, changed quaternion to rotationQuaternion
  59407. */
  59408. quaternion: Nullable<Quaternion>;
  59409. /**
  59410. * Returns a boolean. True if the particle intersects a mesh, else false
  59411. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59412. * @param target is the object (point or mesh) what the intersection is computed against
  59413. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59414. * @returns true if it intersects
  59415. */
  59416. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59417. /**
  59418. * get the rotation matrix of the particle
  59419. * @hidden
  59420. */
  59421. getRotationMatrix(m: Matrix): void;
  59422. }
  59423. /**
  59424. * Represents a group of points in a points cloud system
  59425. * * PCS internal tool, don't use it manually.
  59426. */
  59427. export class PointsGroup {
  59428. /**
  59429. * The group id
  59430. * @hidden
  59431. */
  59432. groupID: number;
  59433. /**
  59434. * image data for group (internal use)
  59435. * @hidden
  59436. */
  59437. _groupImageData: Nullable<ArrayBufferView>;
  59438. /**
  59439. * Image Width (internal use)
  59440. * @hidden
  59441. */
  59442. _groupImgWidth: number;
  59443. /**
  59444. * Image Height (internal use)
  59445. * @hidden
  59446. */
  59447. _groupImgHeight: number;
  59448. /**
  59449. * Custom position function (internal use)
  59450. * @hidden
  59451. */
  59452. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59453. /**
  59454. * density per facet for surface points
  59455. * @hidden
  59456. */
  59457. _groupDensity: number[];
  59458. /**
  59459. * Only when points are colored by texture carries pointer to texture list array
  59460. * @hidden
  59461. */
  59462. _textureNb: number;
  59463. /**
  59464. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59465. * PCS internal tool, don't use it manually.
  59466. * @hidden
  59467. */
  59468. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59469. }
  59470. }
  59471. declare module BABYLON {
  59472. interface Scene {
  59473. /** @hidden (Backing field) */
  59474. _physicsEngine: Nullable<IPhysicsEngine>;
  59475. /**
  59476. * Gets the current physics engine
  59477. * @returns a IPhysicsEngine or null if none attached
  59478. */
  59479. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59480. /**
  59481. * Enables physics to the current scene
  59482. * @param gravity defines the scene's gravity for the physics engine
  59483. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59484. * @return a boolean indicating if the physics engine was initialized
  59485. */
  59486. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59487. /**
  59488. * Disables and disposes the physics engine associated with the scene
  59489. */
  59490. disablePhysicsEngine(): void;
  59491. /**
  59492. * Gets a boolean indicating if there is an active physics engine
  59493. * @returns a boolean indicating if there is an active physics engine
  59494. */
  59495. isPhysicsEnabled(): boolean;
  59496. /**
  59497. * Deletes a physics compound impostor
  59498. * @param compound defines the compound to delete
  59499. */
  59500. deleteCompoundImpostor(compound: any): void;
  59501. /**
  59502. * An event triggered when physic simulation is about to be run
  59503. */
  59504. onBeforePhysicsObservable: Observable<Scene>;
  59505. /**
  59506. * An event triggered when physic simulation has been done
  59507. */
  59508. onAfterPhysicsObservable: Observable<Scene>;
  59509. }
  59510. interface AbstractMesh {
  59511. /** @hidden */
  59512. _physicsImpostor: Nullable<PhysicsImpostor>;
  59513. /**
  59514. * Gets or sets impostor used for physic simulation
  59515. * @see http://doc.babylonjs.com/features/physics_engine
  59516. */
  59517. physicsImpostor: Nullable<PhysicsImpostor>;
  59518. /**
  59519. * Gets the current physics impostor
  59520. * @see http://doc.babylonjs.com/features/physics_engine
  59521. * @returns a physics impostor or null
  59522. */
  59523. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59524. /** Apply a physic impulse to the mesh
  59525. * @param force defines the force to apply
  59526. * @param contactPoint defines where to apply the force
  59527. * @returns the current mesh
  59528. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59529. */
  59530. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59531. /**
  59532. * Creates a physic joint between two meshes
  59533. * @param otherMesh defines the other mesh to use
  59534. * @param pivot1 defines the pivot to use on this mesh
  59535. * @param pivot2 defines the pivot to use on the other mesh
  59536. * @param options defines additional options (can be plugin dependent)
  59537. * @returns the current mesh
  59538. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59539. */
  59540. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59541. /** @hidden */
  59542. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59543. }
  59544. /**
  59545. * Defines the physics engine scene component responsible to manage a physics engine
  59546. */
  59547. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59548. /**
  59549. * The component name helpful to identify the component in the list of scene components.
  59550. */
  59551. readonly name: string;
  59552. /**
  59553. * The scene the component belongs to.
  59554. */
  59555. scene: Scene;
  59556. /**
  59557. * Creates a new instance of the component for the given scene
  59558. * @param scene Defines the scene to register the component in
  59559. */
  59560. constructor(scene: Scene);
  59561. /**
  59562. * Registers the component in a given scene
  59563. */
  59564. register(): void;
  59565. /**
  59566. * Rebuilds the elements related to this component in case of
  59567. * context lost for instance.
  59568. */
  59569. rebuild(): void;
  59570. /**
  59571. * Disposes the component and the associated ressources
  59572. */
  59573. dispose(): void;
  59574. }
  59575. }
  59576. declare module BABYLON {
  59577. /**
  59578. * A helper for physics simulations
  59579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59580. */
  59581. export class PhysicsHelper {
  59582. private _scene;
  59583. private _physicsEngine;
  59584. /**
  59585. * Initializes the Physics helper
  59586. * @param scene Babylon.js scene
  59587. */
  59588. constructor(scene: Scene);
  59589. /**
  59590. * Applies a radial explosion impulse
  59591. * @param origin the origin of the explosion
  59592. * @param radiusOrEventOptions the radius or the options of radial explosion
  59593. * @param strength the explosion strength
  59594. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59595. * @returns A physics radial explosion event, or null
  59596. */
  59597. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59598. /**
  59599. * Applies a radial explosion force
  59600. * @param origin the origin of the explosion
  59601. * @param radiusOrEventOptions the radius or the options of radial explosion
  59602. * @param strength the explosion strength
  59603. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59604. * @returns A physics radial explosion event, or null
  59605. */
  59606. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59607. /**
  59608. * Creates a gravitational field
  59609. * @param origin the origin of the explosion
  59610. * @param radiusOrEventOptions the radius or the options of radial explosion
  59611. * @param strength the explosion strength
  59612. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59613. * @returns A physics gravitational field event, or null
  59614. */
  59615. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59616. /**
  59617. * Creates a physics updraft event
  59618. * @param origin the origin of the updraft
  59619. * @param radiusOrEventOptions the radius or the options of the updraft
  59620. * @param strength the strength of the updraft
  59621. * @param height the height of the updraft
  59622. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59623. * @returns A physics updraft event, or null
  59624. */
  59625. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59626. /**
  59627. * Creates a physics vortex event
  59628. * @param origin the of the vortex
  59629. * @param radiusOrEventOptions the radius or the options of the vortex
  59630. * @param strength the strength of the vortex
  59631. * @param height the height of the vortex
  59632. * @returns a Physics vortex event, or null
  59633. * A physics vortex event or null
  59634. */
  59635. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59636. }
  59637. /**
  59638. * Represents a physics radial explosion event
  59639. */
  59640. class PhysicsRadialExplosionEvent {
  59641. private _scene;
  59642. private _options;
  59643. private _sphere;
  59644. private _dataFetched;
  59645. /**
  59646. * Initializes a radial explosioin event
  59647. * @param _scene BabylonJS scene
  59648. * @param _options The options for the vortex event
  59649. */
  59650. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59651. /**
  59652. * Returns the data related to the radial explosion event (sphere).
  59653. * @returns The radial explosion event data
  59654. */
  59655. getData(): PhysicsRadialExplosionEventData;
  59656. /**
  59657. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59658. * @param impostor A physics imposter
  59659. * @param origin the origin of the explosion
  59660. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59661. */
  59662. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59663. /**
  59664. * Triggers affecterd impostors callbacks
  59665. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59666. */
  59667. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59668. /**
  59669. * Disposes the sphere.
  59670. * @param force Specifies if the sphere should be disposed by force
  59671. */
  59672. dispose(force?: boolean): void;
  59673. /*** Helpers ***/
  59674. private _prepareSphere;
  59675. private _intersectsWithSphere;
  59676. }
  59677. /**
  59678. * Represents a gravitational field event
  59679. */
  59680. class PhysicsGravitationalFieldEvent {
  59681. private _physicsHelper;
  59682. private _scene;
  59683. private _origin;
  59684. private _options;
  59685. private _tickCallback;
  59686. private _sphere;
  59687. private _dataFetched;
  59688. /**
  59689. * Initializes the physics gravitational field event
  59690. * @param _physicsHelper A physics helper
  59691. * @param _scene BabylonJS scene
  59692. * @param _origin The origin position of the gravitational field event
  59693. * @param _options The options for the vortex event
  59694. */
  59695. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59696. /**
  59697. * Returns the data related to the gravitational field event (sphere).
  59698. * @returns A gravitational field event
  59699. */
  59700. getData(): PhysicsGravitationalFieldEventData;
  59701. /**
  59702. * Enables the gravitational field.
  59703. */
  59704. enable(): void;
  59705. /**
  59706. * Disables the gravitational field.
  59707. */
  59708. disable(): void;
  59709. /**
  59710. * Disposes the sphere.
  59711. * @param force The force to dispose from the gravitational field event
  59712. */
  59713. dispose(force?: boolean): void;
  59714. private _tick;
  59715. }
  59716. /**
  59717. * Represents a physics updraft event
  59718. */
  59719. class PhysicsUpdraftEvent {
  59720. private _scene;
  59721. private _origin;
  59722. private _options;
  59723. private _physicsEngine;
  59724. private _originTop;
  59725. private _originDirection;
  59726. private _tickCallback;
  59727. private _cylinder;
  59728. private _cylinderPosition;
  59729. private _dataFetched;
  59730. /**
  59731. * Initializes the physics updraft event
  59732. * @param _scene BabylonJS scene
  59733. * @param _origin The origin position of the updraft
  59734. * @param _options The options for the updraft event
  59735. */
  59736. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59737. /**
  59738. * Returns the data related to the updraft event (cylinder).
  59739. * @returns A physics updraft event
  59740. */
  59741. getData(): PhysicsUpdraftEventData;
  59742. /**
  59743. * Enables the updraft.
  59744. */
  59745. enable(): void;
  59746. /**
  59747. * Disables the updraft.
  59748. */
  59749. disable(): void;
  59750. /**
  59751. * Disposes the cylinder.
  59752. * @param force Specifies if the updraft should be disposed by force
  59753. */
  59754. dispose(force?: boolean): void;
  59755. private getImpostorHitData;
  59756. private _tick;
  59757. /*** Helpers ***/
  59758. private _prepareCylinder;
  59759. private _intersectsWithCylinder;
  59760. }
  59761. /**
  59762. * Represents a physics vortex event
  59763. */
  59764. class PhysicsVortexEvent {
  59765. private _scene;
  59766. private _origin;
  59767. private _options;
  59768. private _physicsEngine;
  59769. private _originTop;
  59770. private _tickCallback;
  59771. private _cylinder;
  59772. private _cylinderPosition;
  59773. private _dataFetched;
  59774. /**
  59775. * Initializes the physics vortex event
  59776. * @param _scene The BabylonJS scene
  59777. * @param _origin The origin position of the vortex
  59778. * @param _options The options for the vortex event
  59779. */
  59780. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59781. /**
  59782. * Returns the data related to the vortex event (cylinder).
  59783. * @returns The physics vortex event data
  59784. */
  59785. getData(): PhysicsVortexEventData;
  59786. /**
  59787. * Enables the vortex.
  59788. */
  59789. enable(): void;
  59790. /**
  59791. * Disables the cortex.
  59792. */
  59793. disable(): void;
  59794. /**
  59795. * Disposes the sphere.
  59796. * @param force
  59797. */
  59798. dispose(force?: boolean): void;
  59799. private getImpostorHitData;
  59800. private _tick;
  59801. /*** Helpers ***/
  59802. private _prepareCylinder;
  59803. private _intersectsWithCylinder;
  59804. }
  59805. /**
  59806. * Options fot the radial explosion event
  59807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59808. */
  59809. export class PhysicsRadialExplosionEventOptions {
  59810. /**
  59811. * The radius of the sphere for the radial explosion.
  59812. */
  59813. radius: number;
  59814. /**
  59815. * The strenth of the explosion.
  59816. */
  59817. strength: number;
  59818. /**
  59819. * The strenght of the force in correspondence to the distance of the affected object
  59820. */
  59821. falloff: PhysicsRadialImpulseFalloff;
  59822. /**
  59823. * Sphere options for the radial explosion.
  59824. */
  59825. sphere: {
  59826. segments: number;
  59827. diameter: number;
  59828. };
  59829. /**
  59830. * Sphere options for the radial explosion.
  59831. */
  59832. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59833. }
  59834. /**
  59835. * Options fot the updraft event
  59836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59837. */
  59838. export class PhysicsUpdraftEventOptions {
  59839. /**
  59840. * The radius of the cylinder for the vortex
  59841. */
  59842. radius: number;
  59843. /**
  59844. * The strenth of the updraft.
  59845. */
  59846. strength: number;
  59847. /**
  59848. * The height of the cylinder for the updraft.
  59849. */
  59850. height: number;
  59851. /**
  59852. * The mode for the the updraft.
  59853. */
  59854. updraftMode: PhysicsUpdraftMode;
  59855. }
  59856. /**
  59857. * Options fot the vortex event
  59858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59859. */
  59860. export class PhysicsVortexEventOptions {
  59861. /**
  59862. * The radius of the cylinder for the vortex
  59863. */
  59864. radius: number;
  59865. /**
  59866. * The strenth of the vortex.
  59867. */
  59868. strength: number;
  59869. /**
  59870. * The height of the cylinder for the vortex.
  59871. */
  59872. height: number;
  59873. /**
  59874. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59875. */
  59876. centripetalForceThreshold: number;
  59877. /**
  59878. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59879. */
  59880. centripetalForceMultiplier: number;
  59881. /**
  59882. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59883. */
  59884. centrifugalForceMultiplier: number;
  59885. /**
  59886. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59887. */
  59888. updraftForceMultiplier: number;
  59889. }
  59890. /**
  59891. * The strenght of the force in correspondence to the distance of the affected object
  59892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59893. */
  59894. export enum PhysicsRadialImpulseFalloff {
  59895. /** Defines that impulse is constant in strength across it's whole radius */
  59896. Constant = 0,
  59897. /** Defines that impulse gets weaker if it's further from the origin */
  59898. Linear = 1
  59899. }
  59900. /**
  59901. * The strength of the force in correspondence to the distance of the affected object
  59902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59903. */
  59904. export enum PhysicsUpdraftMode {
  59905. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59906. Center = 0,
  59907. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59908. Perpendicular = 1
  59909. }
  59910. /**
  59911. * Interface for a physics hit data
  59912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59913. */
  59914. export interface PhysicsHitData {
  59915. /**
  59916. * The force applied at the contact point
  59917. */
  59918. force: Vector3;
  59919. /**
  59920. * The contact point
  59921. */
  59922. contactPoint: Vector3;
  59923. /**
  59924. * The distance from the origin to the contact point
  59925. */
  59926. distanceFromOrigin: number;
  59927. }
  59928. /**
  59929. * Interface for radial explosion event data
  59930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59931. */
  59932. export interface PhysicsRadialExplosionEventData {
  59933. /**
  59934. * A sphere used for the radial explosion event
  59935. */
  59936. sphere: Mesh;
  59937. }
  59938. /**
  59939. * Interface for gravitational field event data
  59940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59941. */
  59942. export interface PhysicsGravitationalFieldEventData {
  59943. /**
  59944. * A sphere mesh used for the gravitational field event
  59945. */
  59946. sphere: Mesh;
  59947. }
  59948. /**
  59949. * Interface for updraft event data
  59950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59951. */
  59952. export interface PhysicsUpdraftEventData {
  59953. /**
  59954. * A cylinder used for the updraft event
  59955. */
  59956. cylinder: Mesh;
  59957. }
  59958. /**
  59959. * Interface for vortex event data
  59960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59961. */
  59962. export interface PhysicsVortexEventData {
  59963. /**
  59964. * A cylinder used for the vortex event
  59965. */
  59966. cylinder: Mesh;
  59967. }
  59968. /**
  59969. * Interface for an affected physics impostor
  59970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59971. */
  59972. export interface PhysicsAffectedImpostorWithData {
  59973. /**
  59974. * The impostor affected by the effect
  59975. */
  59976. impostor: PhysicsImpostor;
  59977. /**
  59978. * The data about the hit/horce from the explosion
  59979. */
  59980. hitData: PhysicsHitData;
  59981. }
  59982. }
  59983. declare module BABYLON {
  59984. /** @hidden */
  59985. export var blackAndWhitePixelShader: {
  59986. name: string;
  59987. shader: string;
  59988. };
  59989. }
  59990. declare module BABYLON {
  59991. /**
  59992. * Post process used to render in black and white
  59993. */
  59994. export class BlackAndWhitePostProcess extends PostProcess {
  59995. /**
  59996. * Linear about to convert he result to black and white (default: 1)
  59997. */
  59998. degree: number;
  59999. /**
  60000. * Creates a black and white post process
  60001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60002. * @param name The name of the effect.
  60003. * @param options The required width/height ratio to downsize to before computing the render pass.
  60004. * @param camera The camera to apply the render pass to.
  60005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60006. * @param engine The engine which the post process will be applied. (default: current engine)
  60007. * @param reusable If the post process can be reused on the same frame. (default: false)
  60008. */
  60009. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60010. }
  60011. }
  60012. declare module BABYLON {
  60013. /**
  60014. * This represents a set of one or more post processes in Babylon.
  60015. * A post process can be used to apply a shader to a texture after it is rendered.
  60016. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60017. */
  60018. export class PostProcessRenderEffect {
  60019. private _postProcesses;
  60020. private _getPostProcesses;
  60021. private _singleInstance;
  60022. private _cameras;
  60023. private _indicesForCamera;
  60024. /**
  60025. * Name of the effect
  60026. * @hidden
  60027. */
  60028. _name: string;
  60029. /**
  60030. * Instantiates a post process render effect.
  60031. * A post process can be used to apply a shader to a texture after it is rendered.
  60032. * @param engine The engine the effect is tied to
  60033. * @param name The name of the effect
  60034. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60035. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60036. */
  60037. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60038. /**
  60039. * Checks if all the post processes in the effect are supported.
  60040. */
  60041. readonly isSupported: boolean;
  60042. /**
  60043. * Updates the current state of the effect
  60044. * @hidden
  60045. */
  60046. _update(): void;
  60047. /**
  60048. * Attaches the effect on cameras
  60049. * @param cameras The camera to attach to.
  60050. * @hidden
  60051. */
  60052. _attachCameras(cameras: Camera): void;
  60053. /**
  60054. * Attaches the effect on cameras
  60055. * @param cameras The camera to attach to.
  60056. * @hidden
  60057. */
  60058. _attachCameras(cameras: Camera[]): void;
  60059. /**
  60060. * Detaches the effect on cameras
  60061. * @param cameras The camera to detatch from.
  60062. * @hidden
  60063. */
  60064. _detachCameras(cameras: Camera): void;
  60065. /**
  60066. * Detatches the effect on cameras
  60067. * @param cameras The camera to detatch from.
  60068. * @hidden
  60069. */
  60070. _detachCameras(cameras: Camera[]): void;
  60071. /**
  60072. * Enables the effect on given cameras
  60073. * @param cameras The camera to enable.
  60074. * @hidden
  60075. */
  60076. _enable(cameras: Camera): void;
  60077. /**
  60078. * Enables the effect on given cameras
  60079. * @param cameras The camera to enable.
  60080. * @hidden
  60081. */
  60082. _enable(cameras: Nullable<Camera[]>): void;
  60083. /**
  60084. * Disables the effect on the given cameras
  60085. * @param cameras The camera to disable.
  60086. * @hidden
  60087. */
  60088. _disable(cameras: Camera): void;
  60089. /**
  60090. * Disables the effect on the given cameras
  60091. * @param cameras The camera to disable.
  60092. * @hidden
  60093. */
  60094. _disable(cameras: Nullable<Camera[]>): void;
  60095. /**
  60096. * Gets a list of the post processes contained in the effect.
  60097. * @param camera The camera to get the post processes on.
  60098. * @returns The list of the post processes in the effect.
  60099. */
  60100. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60101. }
  60102. }
  60103. declare module BABYLON {
  60104. /** @hidden */
  60105. export var extractHighlightsPixelShader: {
  60106. name: string;
  60107. shader: string;
  60108. };
  60109. }
  60110. declare module BABYLON {
  60111. /**
  60112. * 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.
  60113. */
  60114. export class ExtractHighlightsPostProcess extends PostProcess {
  60115. /**
  60116. * The luminance threshold, pixels below this value will be set to black.
  60117. */
  60118. threshold: number;
  60119. /** @hidden */
  60120. _exposure: number;
  60121. /**
  60122. * Post process which has the input texture to be used when performing highlight extraction
  60123. * @hidden
  60124. */
  60125. _inputPostProcess: Nullable<PostProcess>;
  60126. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60127. }
  60128. }
  60129. declare module BABYLON {
  60130. /** @hidden */
  60131. export var bloomMergePixelShader: {
  60132. name: string;
  60133. shader: string;
  60134. };
  60135. }
  60136. declare module BABYLON {
  60137. /**
  60138. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60139. */
  60140. export class BloomMergePostProcess extends PostProcess {
  60141. /** Weight of the bloom to be added to the original input. */
  60142. weight: number;
  60143. /**
  60144. * Creates a new instance of @see BloomMergePostProcess
  60145. * @param name The name of the effect.
  60146. * @param originalFromInput Post process which's input will be used for the merge.
  60147. * @param blurred Blurred highlights post process which's output will be used.
  60148. * @param weight Weight of the bloom to be added to the original input.
  60149. * @param options The required width/height ratio to downsize to before computing the render pass.
  60150. * @param camera The camera to apply the render pass to.
  60151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60152. * @param engine The engine which the post process will be applied. (default: current engine)
  60153. * @param reusable If the post process can be reused on the same frame. (default: false)
  60154. * @param textureType Type of textures used when performing the post process. (default: 0)
  60155. * @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)
  60156. */
  60157. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60158. /** Weight of the bloom to be added to the original input. */
  60159. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60160. }
  60161. }
  60162. declare module BABYLON {
  60163. /**
  60164. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60165. */
  60166. export class BloomEffect extends PostProcessRenderEffect {
  60167. private bloomScale;
  60168. /**
  60169. * @hidden Internal
  60170. */
  60171. _effects: Array<PostProcess>;
  60172. /**
  60173. * @hidden Internal
  60174. */
  60175. _downscale: ExtractHighlightsPostProcess;
  60176. private _blurX;
  60177. private _blurY;
  60178. private _merge;
  60179. /**
  60180. * The luminance threshold to find bright areas of the image to bloom.
  60181. */
  60182. threshold: number;
  60183. /**
  60184. * The strength of the bloom.
  60185. */
  60186. weight: number;
  60187. /**
  60188. * Specifies the size of the bloom blur kernel, relative to the final output size
  60189. */
  60190. kernel: number;
  60191. /**
  60192. * Creates a new instance of @see BloomEffect
  60193. * @param scene The scene the effect belongs to.
  60194. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60195. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60196. * @param bloomWeight The the strength of bloom.
  60197. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60198. * @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)
  60199. */
  60200. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60201. /**
  60202. * Disposes each of the internal effects for a given camera.
  60203. * @param camera The camera to dispose the effect on.
  60204. */
  60205. disposeEffects(camera: Camera): void;
  60206. /**
  60207. * @hidden Internal
  60208. */
  60209. _updateEffects(): void;
  60210. /**
  60211. * Internal
  60212. * @returns if all the contained post processes are ready.
  60213. * @hidden
  60214. */
  60215. _isReady(): boolean;
  60216. }
  60217. }
  60218. declare module BABYLON {
  60219. /** @hidden */
  60220. export var chromaticAberrationPixelShader: {
  60221. name: string;
  60222. shader: string;
  60223. };
  60224. }
  60225. declare module BABYLON {
  60226. /**
  60227. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60228. */
  60229. export class ChromaticAberrationPostProcess extends PostProcess {
  60230. /**
  60231. * The amount of seperation of rgb channels (default: 30)
  60232. */
  60233. aberrationAmount: number;
  60234. /**
  60235. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60236. */
  60237. radialIntensity: number;
  60238. /**
  60239. * 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))
  60240. */
  60241. direction: Vector2;
  60242. /**
  60243. * 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))
  60244. */
  60245. centerPosition: Vector2;
  60246. /**
  60247. * Creates a new instance ChromaticAberrationPostProcess
  60248. * @param name The name of the effect.
  60249. * @param screenWidth The width of the screen to apply the effect on.
  60250. * @param screenHeight The height of the screen to apply the effect on.
  60251. * @param options The required width/height ratio to downsize to before computing the render pass.
  60252. * @param camera The camera to apply the render pass to.
  60253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60254. * @param engine The engine which the post process will be applied. (default: current engine)
  60255. * @param reusable If the post process can be reused on the same frame. (default: false)
  60256. * @param textureType Type of textures used when performing the post process. (default: 0)
  60257. * @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)
  60258. */
  60259. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60260. }
  60261. }
  60262. declare module BABYLON {
  60263. /** @hidden */
  60264. export var circleOfConfusionPixelShader: {
  60265. name: string;
  60266. shader: string;
  60267. };
  60268. }
  60269. declare module BABYLON {
  60270. /**
  60271. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60272. */
  60273. export class CircleOfConfusionPostProcess extends PostProcess {
  60274. /**
  60275. * 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.
  60276. */
  60277. lensSize: number;
  60278. /**
  60279. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60280. */
  60281. fStop: number;
  60282. /**
  60283. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60284. */
  60285. focusDistance: number;
  60286. /**
  60287. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60288. */
  60289. focalLength: number;
  60290. private _depthTexture;
  60291. /**
  60292. * Creates a new instance CircleOfConfusionPostProcess
  60293. * @param name The name of the effect.
  60294. * @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.
  60295. * @param options The required width/height ratio to downsize to before computing the render pass.
  60296. * @param camera The camera to apply the render pass to.
  60297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60298. * @param engine The engine which the post process will be applied. (default: current engine)
  60299. * @param reusable If the post process can be reused on the same frame. (default: false)
  60300. * @param textureType Type of textures used when performing the post process. (default: 0)
  60301. * @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)
  60302. */
  60303. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60304. /**
  60305. * 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.
  60306. */
  60307. depthTexture: RenderTargetTexture;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /** @hidden */
  60312. export var colorCorrectionPixelShader: {
  60313. name: string;
  60314. shader: string;
  60315. };
  60316. }
  60317. declare module BABYLON {
  60318. /**
  60319. *
  60320. * This post-process allows the modification of rendered colors by using
  60321. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60322. *
  60323. * The object needs to be provided an url to a texture containing the color
  60324. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60325. * Use an image editing software to tweak the LUT to match your needs.
  60326. *
  60327. * For an example of a color LUT, see here:
  60328. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60329. * For explanations on color grading, see here:
  60330. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60331. *
  60332. */
  60333. export class ColorCorrectionPostProcess extends PostProcess {
  60334. private _colorTableTexture;
  60335. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60336. }
  60337. }
  60338. declare module BABYLON {
  60339. /** @hidden */
  60340. export var convolutionPixelShader: {
  60341. name: string;
  60342. shader: string;
  60343. };
  60344. }
  60345. declare module BABYLON {
  60346. /**
  60347. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60348. * input texture to perform effects such as edge detection or sharpening
  60349. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60350. */
  60351. export class ConvolutionPostProcess extends PostProcess {
  60352. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60353. kernel: number[];
  60354. /**
  60355. * Creates a new instance ConvolutionPostProcess
  60356. * @param name The name of the effect.
  60357. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60358. * @param options The required width/height ratio to downsize to before computing the render pass.
  60359. * @param camera The camera to apply the render pass to.
  60360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60361. * @param engine The engine which the post process will be applied. (default: current engine)
  60362. * @param reusable If the post process can be reused on the same frame. (default: false)
  60363. * @param textureType Type of textures used when performing the post process. (default: 0)
  60364. */
  60365. constructor(name: string,
  60366. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60367. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60368. /**
  60369. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60370. */
  60371. static EdgeDetect0Kernel: number[];
  60372. /**
  60373. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60374. */
  60375. static EdgeDetect1Kernel: number[];
  60376. /**
  60377. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60378. */
  60379. static EdgeDetect2Kernel: number[];
  60380. /**
  60381. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60382. */
  60383. static SharpenKernel: number[];
  60384. /**
  60385. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60386. */
  60387. static EmbossKernel: number[];
  60388. /**
  60389. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60390. */
  60391. static GaussianKernel: number[];
  60392. }
  60393. }
  60394. declare module BABYLON {
  60395. /**
  60396. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60397. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60398. * based on samples that have a large difference in distance than the center pixel.
  60399. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60400. */
  60401. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60402. direction: Vector2;
  60403. /**
  60404. * Creates a new instance CircleOfConfusionPostProcess
  60405. * @param name The name of the effect.
  60406. * @param scene The scene the effect belongs to.
  60407. * @param direction The direction the blur should be applied.
  60408. * @param kernel The size of the kernel used to blur.
  60409. * @param options The required width/height ratio to downsize to before computing the render pass.
  60410. * @param camera The camera to apply the render pass to.
  60411. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60412. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60414. * @param engine The engine which the post process will be applied. (default: current engine)
  60415. * @param reusable If the post process can be reused on the same frame. (default: false)
  60416. * @param textureType Type of textures used when performing the post process. (default: 0)
  60417. * @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)
  60418. */
  60419. 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);
  60420. }
  60421. }
  60422. declare module BABYLON {
  60423. /** @hidden */
  60424. export var depthOfFieldMergePixelShader: {
  60425. name: string;
  60426. shader: string;
  60427. };
  60428. }
  60429. declare module BABYLON {
  60430. /**
  60431. * Options to be set when merging outputs from the default pipeline.
  60432. */
  60433. export class DepthOfFieldMergePostProcessOptions {
  60434. /**
  60435. * The original image to merge on top of
  60436. */
  60437. originalFromInput: PostProcess;
  60438. /**
  60439. * Parameters to perform the merge of the depth of field effect
  60440. */
  60441. depthOfField?: {
  60442. circleOfConfusion: PostProcess;
  60443. blurSteps: Array<PostProcess>;
  60444. };
  60445. /**
  60446. * Parameters to perform the merge of bloom effect
  60447. */
  60448. bloom?: {
  60449. blurred: PostProcess;
  60450. weight: number;
  60451. };
  60452. }
  60453. /**
  60454. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60455. */
  60456. export class DepthOfFieldMergePostProcess extends PostProcess {
  60457. private blurSteps;
  60458. /**
  60459. * Creates a new instance of DepthOfFieldMergePostProcess
  60460. * @param name The name of the effect.
  60461. * @param originalFromInput Post process which's input will be used for the merge.
  60462. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60463. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60464. * @param options The required width/height ratio to downsize to before computing the render pass.
  60465. * @param camera The camera to apply the render pass to.
  60466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60467. * @param engine The engine which the post process will be applied. (default: current engine)
  60468. * @param reusable If the post process can be reused on the same frame. (default: false)
  60469. * @param textureType Type of textures used when performing the post process. (default: 0)
  60470. * @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)
  60471. */
  60472. 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);
  60473. /**
  60474. * Updates the effect with the current post process compile time values and recompiles the shader.
  60475. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60476. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60477. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60478. * @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
  60479. * @param onCompiled Called when the shader has been compiled.
  60480. * @param onError Called if there is an error when compiling a shader.
  60481. */
  60482. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60483. }
  60484. }
  60485. declare module BABYLON {
  60486. /**
  60487. * Specifies the level of max blur that should be applied when using the depth of field effect
  60488. */
  60489. export enum DepthOfFieldEffectBlurLevel {
  60490. /**
  60491. * Subtle blur
  60492. */
  60493. Low = 0,
  60494. /**
  60495. * Medium blur
  60496. */
  60497. Medium = 1,
  60498. /**
  60499. * Large blur
  60500. */
  60501. High = 2
  60502. }
  60503. /**
  60504. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60505. */
  60506. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60507. private _circleOfConfusion;
  60508. /**
  60509. * @hidden Internal, blurs from high to low
  60510. */
  60511. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60512. private _depthOfFieldBlurY;
  60513. private _dofMerge;
  60514. /**
  60515. * @hidden Internal post processes in depth of field effect
  60516. */
  60517. _effects: Array<PostProcess>;
  60518. /**
  60519. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60520. */
  60521. focalLength: number;
  60522. /**
  60523. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60524. */
  60525. fStop: number;
  60526. /**
  60527. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60528. */
  60529. focusDistance: number;
  60530. /**
  60531. * 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.
  60532. */
  60533. lensSize: number;
  60534. /**
  60535. * Creates a new instance DepthOfFieldEffect
  60536. * @param scene The scene the effect belongs to.
  60537. * @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.
  60538. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60539. * @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)
  60540. */
  60541. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60542. /**
  60543. * Get the current class name of the current effet
  60544. * @returns "DepthOfFieldEffect"
  60545. */
  60546. getClassName(): string;
  60547. /**
  60548. * 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.
  60549. */
  60550. depthTexture: RenderTargetTexture;
  60551. /**
  60552. * Disposes each of the internal effects for a given camera.
  60553. * @param camera The camera to dispose the effect on.
  60554. */
  60555. disposeEffects(camera: Camera): void;
  60556. /**
  60557. * @hidden Internal
  60558. */
  60559. _updateEffects(): void;
  60560. /**
  60561. * Internal
  60562. * @returns if all the contained post processes are ready.
  60563. * @hidden
  60564. */
  60565. _isReady(): boolean;
  60566. }
  60567. }
  60568. declare module BABYLON {
  60569. /** @hidden */
  60570. export var displayPassPixelShader: {
  60571. name: string;
  60572. shader: string;
  60573. };
  60574. }
  60575. declare module BABYLON {
  60576. /**
  60577. * DisplayPassPostProcess which produces an output the same as it's input
  60578. */
  60579. export class DisplayPassPostProcess extends PostProcess {
  60580. /**
  60581. * Creates the DisplayPassPostProcess
  60582. * @param name The name of the effect.
  60583. * @param options The required width/height ratio to downsize to before computing the render pass.
  60584. * @param camera The camera to apply the render pass to.
  60585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60586. * @param engine The engine which the post process will be applied. (default: current engine)
  60587. * @param reusable If the post process can be reused on the same frame. (default: false)
  60588. */
  60589. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60590. }
  60591. }
  60592. declare module BABYLON {
  60593. /** @hidden */
  60594. export var filterPixelShader: {
  60595. name: string;
  60596. shader: string;
  60597. };
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Applies a kernel filter to the image
  60602. */
  60603. export class FilterPostProcess extends PostProcess {
  60604. /** The matrix to be applied to the image */
  60605. kernelMatrix: Matrix;
  60606. /**
  60607. *
  60608. * @param name The name of the effect.
  60609. * @param kernelMatrix The matrix to be applied to the image
  60610. * @param options The required width/height ratio to downsize to before computing the render pass.
  60611. * @param camera The camera to apply the render pass to.
  60612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60613. * @param engine The engine which the post process will be applied. (default: current engine)
  60614. * @param reusable If the post process can be reused on the same frame. (default: false)
  60615. */
  60616. constructor(name: string,
  60617. /** The matrix to be applied to the image */
  60618. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /** @hidden */
  60623. export var fxaaPixelShader: {
  60624. name: string;
  60625. shader: string;
  60626. };
  60627. }
  60628. declare module BABYLON {
  60629. /** @hidden */
  60630. export var fxaaVertexShader: {
  60631. name: string;
  60632. shader: string;
  60633. };
  60634. }
  60635. declare module BABYLON {
  60636. /**
  60637. * Fxaa post process
  60638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60639. */
  60640. export class FxaaPostProcess extends PostProcess {
  60641. /** @hidden */
  60642. texelWidth: number;
  60643. /** @hidden */
  60644. texelHeight: number;
  60645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60646. private _getDefines;
  60647. }
  60648. }
  60649. declare module BABYLON {
  60650. /** @hidden */
  60651. export var grainPixelShader: {
  60652. name: string;
  60653. shader: string;
  60654. };
  60655. }
  60656. declare module BABYLON {
  60657. /**
  60658. * The GrainPostProcess adds noise to the image at mid luminance levels
  60659. */
  60660. export class GrainPostProcess extends PostProcess {
  60661. /**
  60662. * The intensity of the grain added (default: 30)
  60663. */
  60664. intensity: number;
  60665. /**
  60666. * If the grain should be randomized on every frame
  60667. */
  60668. animated: boolean;
  60669. /**
  60670. * Creates a new instance of @see GrainPostProcess
  60671. * @param name The name of the effect.
  60672. * @param options The required width/height ratio to downsize to before computing the render pass.
  60673. * @param camera The camera to apply the render pass to.
  60674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60675. * @param engine The engine which the post process will be applied. (default: current engine)
  60676. * @param reusable If the post process can be reused on the same frame. (default: false)
  60677. * @param textureType Type of textures used when performing the post process. (default: 0)
  60678. * @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)
  60679. */
  60680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60681. }
  60682. }
  60683. declare module BABYLON {
  60684. /** @hidden */
  60685. export var highlightsPixelShader: {
  60686. name: string;
  60687. shader: string;
  60688. };
  60689. }
  60690. declare module BABYLON {
  60691. /**
  60692. * Extracts highlights from the image
  60693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60694. */
  60695. export class HighlightsPostProcess extends PostProcess {
  60696. /**
  60697. * Extracts highlights from the image
  60698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60699. * @param name The name of the effect.
  60700. * @param options The required width/height ratio to downsize to before computing the render pass.
  60701. * @param camera The camera to apply the render pass to.
  60702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60703. * @param engine The engine which the post process will be applied. (default: current engine)
  60704. * @param reusable If the post process can be reused on the same frame. (default: false)
  60705. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60706. */
  60707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60708. }
  60709. }
  60710. declare module BABYLON {
  60711. /** @hidden */
  60712. export var mrtFragmentDeclaration: {
  60713. name: string;
  60714. shader: string;
  60715. };
  60716. }
  60717. declare module BABYLON {
  60718. /** @hidden */
  60719. export var geometryPixelShader: {
  60720. name: string;
  60721. shader: string;
  60722. };
  60723. }
  60724. declare module BABYLON {
  60725. /** @hidden */
  60726. export var geometryVertexShader: {
  60727. name: string;
  60728. shader: string;
  60729. };
  60730. }
  60731. declare module BABYLON {
  60732. /** @hidden */
  60733. interface ISavedTransformationMatrix {
  60734. world: Matrix;
  60735. viewProjection: Matrix;
  60736. }
  60737. /**
  60738. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60739. */
  60740. export class GeometryBufferRenderer {
  60741. /**
  60742. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60743. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60744. */
  60745. static readonly POSITION_TEXTURE_TYPE: number;
  60746. /**
  60747. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60748. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60749. */
  60750. static readonly VELOCITY_TEXTURE_TYPE: number;
  60751. /**
  60752. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60753. * in order to compute objects velocities when enableVelocity is set to "true"
  60754. * @hidden
  60755. */
  60756. _previousTransformationMatrices: {
  60757. [index: number]: ISavedTransformationMatrix;
  60758. };
  60759. /**
  60760. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60761. * in order to compute objects velocities when enableVelocity is set to "true"
  60762. * @hidden
  60763. */
  60764. _previousBonesTransformationMatrices: {
  60765. [index: number]: Float32Array;
  60766. };
  60767. /**
  60768. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60769. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60770. */
  60771. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60772. private _scene;
  60773. private _multiRenderTarget;
  60774. private _ratio;
  60775. private _enablePosition;
  60776. private _enableVelocity;
  60777. private _positionIndex;
  60778. private _velocityIndex;
  60779. protected _effect: Effect;
  60780. protected _cachedDefines: string;
  60781. /**
  60782. * Set the render list (meshes to be rendered) used in the G buffer.
  60783. */
  60784. renderList: Mesh[];
  60785. /**
  60786. * Gets wether or not G buffer are supported by the running hardware.
  60787. * This requires draw buffer supports
  60788. */
  60789. readonly isSupported: boolean;
  60790. /**
  60791. * Returns the index of the given texture type in the G-Buffer textures array
  60792. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60793. * @returns the index of the given texture type in the G-Buffer textures array
  60794. */
  60795. getTextureIndex(textureType: number): number;
  60796. /**
  60797. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60798. */
  60799. /**
  60800. * Sets whether or not objects positions are enabled for the G buffer.
  60801. */
  60802. enablePosition: boolean;
  60803. /**
  60804. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60805. */
  60806. /**
  60807. * Sets wether or not objects velocities are enabled for the G buffer.
  60808. */
  60809. enableVelocity: boolean;
  60810. /**
  60811. * Gets the scene associated with the buffer.
  60812. */
  60813. readonly scene: Scene;
  60814. /**
  60815. * Gets the ratio used by the buffer during its creation.
  60816. * How big is the buffer related to the main canvas.
  60817. */
  60818. readonly ratio: number;
  60819. /** @hidden */
  60820. static _SceneComponentInitialization: (scene: Scene) => void;
  60821. /**
  60822. * Creates a new G Buffer for the scene
  60823. * @param scene The scene the buffer belongs to
  60824. * @param ratio How big is the buffer related to the main canvas.
  60825. */
  60826. constructor(scene: Scene, ratio?: number);
  60827. /**
  60828. * Checks wether everything is ready to render a submesh to the G buffer.
  60829. * @param subMesh the submesh to check readiness for
  60830. * @param useInstances is the mesh drawn using instance or not
  60831. * @returns true if ready otherwise false
  60832. */
  60833. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60834. /**
  60835. * Gets the current underlying G Buffer.
  60836. * @returns the buffer
  60837. */
  60838. getGBuffer(): MultiRenderTarget;
  60839. /**
  60840. * Gets the number of samples used to render the buffer (anti aliasing).
  60841. */
  60842. /**
  60843. * Sets the number of samples used to render the buffer (anti aliasing).
  60844. */
  60845. samples: number;
  60846. /**
  60847. * Disposes the renderer and frees up associated resources.
  60848. */
  60849. dispose(): void;
  60850. protected _createRenderTargets(): void;
  60851. private _copyBonesTransformationMatrices;
  60852. }
  60853. }
  60854. declare module BABYLON {
  60855. interface Scene {
  60856. /** @hidden (Backing field) */
  60857. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60858. /**
  60859. * Gets or Sets the current geometry buffer associated to the scene.
  60860. */
  60861. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60862. /**
  60863. * Enables a GeometryBufferRender and associates it with the scene
  60864. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60865. * @returns the GeometryBufferRenderer
  60866. */
  60867. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60868. /**
  60869. * Disables the GeometryBufferRender associated with the scene
  60870. */
  60871. disableGeometryBufferRenderer(): void;
  60872. }
  60873. /**
  60874. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60875. * in several rendering techniques.
  60876. */
  60877. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60878. /**
  60879. * The component name helpful to identify the component in the list of scene components.
  60880. */
  60881. readonly name: string;
  60882. /**
  60883. * The scene the component belongs to.
  60884. */
  60885. scene: Scene;
  60886. /**
  60887. * Creates a new instance of the component for the given scene
  60888. * @param scene Defines the scene to register the component in
  60889. */
  60890. constructor(scene: Scene);
  60891. /**
  60892. * Registers the component in a given scene
  60893. */
  60894. register(): void;
  60895. /**
  60896. * Rebuilds the elements related to this component in case of
  60897. * context lost for instance.
  60898. */
  60899. rebuild(): void;
  60900. /**
  60901. * Disposes the component and the associated ressources
  60902. */
  60903. dispose(): void;
  60904. private _gatherRenderTargets;
  60905. }
  60906. }
  60907. declare module BABYLON {
  60908. /** @hidden */
  60909. export var motionBlurPixelShader: {
  60910. name: string;
  60911. shader: string;
  60912. };
  60913. }
  60914. declare module BABYLON {
  60915. /**
  60916. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60917. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60918. * As an example, all you have to do is to create the post-process:
  60919. * var mb = new BABYLON.MotionBlurPostProcess(
  60920. * 'mb', // The name of the effect.
  60921. * scene, // The scene containing the objects to blur according to their velocity.
  60922. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60923. * camera // The camera to apply the render pass to.
  60924. * );
  60925. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60926. */
  60927. export class MotionBlurPostProcess extends PostProcess {
  60928. /**
  60929. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60930. */
  60931. motionStrength: number;
  60932. /**
  60933. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60934. */
  60935. /**
  60936. * Sets the number of iterations to be used for motion blur quality
  60937. */
  60938. motionBlurSamples: number;
  60939. private _motionBlurSamples;
  60940. private _geometryBufferRenderer;
  60941. /**
  60942. * Creates a new instance MotionBlurPostProcess
  60943. * @param name The name of the effect.
  60944. * @param scene The scene containing the objects to blur according to their velocity.
  60945. * @param options The required width/height ratio to downsize to before computing the render pass.
  60946. * @param camera The camera to apply the render pass to.
  60947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60948. * @param engine The engine which the post process will be applied. (default: current engine)
  60949. * @param reusable If the post process can be reused on the same frame. (default: false)
  60950. * @param textureType Type of textures used when performing the post process. (default: 0)
  60951. * @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)
  60952. */
  60953. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60954. /**
  60955. * Excludes the given skinned mesh from computing bones velocities.
  60956. * 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.
  60957. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60958. */
  60959. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60960. /**
  60961. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60962. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60963. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60964. */
  60965. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60966. /**
  60967. * Disposes the post process.
  60968. * @param camera The camera to dispose the post process on.
  60969. */
  60970. dispose(camera?: Camera): void;
  60971. }
  60972. }
  60973. declare module BABYLON {
  60974. /** @hidden */
  60975. export var refractionPixelShader: {
  60976. name: string;
  60977. shader: string;
  60978. };
  60979. }
  60980. declare module BABYLON {
  60981. /**
  60982. * Post process which applies a refractin texture
  60983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60984. */
  60985. export class RefractionPostProcess extends PostProcess {
  60986. /** the base color of the refraction (used to taint the rendering) */
  60987. color: Color3;
  60988. /** simulated refraction depth */
  60989. depth: number;
  60990. /** the coefficient of the base color (0 to remove base color tainting) */
  60991. colorLevel: number;
  60992. private _refTexture;
  60993. private _ownRefractionTexture;
  60994. /**
  60995. * Gets or sets the refraction texture
  60996. * Please note that you are responsible for disposing the texture if you set it manually
  60997. */
  60998. refractionTexture: Texture;
  60999. /**
  61000. * Initializes the RefractionPostProcess
  61001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61002. * @param name The name of the effect.
  61003. * @param refractionTextureUrl Url of the refraction texture to use
  61004. * @param color the base color of the refraction (used to taint the rendering)
  61005. * @param depth simulated refraction depth
  61006. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61007. * @param camera The camera to apply the render pass to.
  61008. * @param options The required width/height ratio to downsize to before computing the render pass.
  61009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61010. * @param engine The engine which the post process will be applied. (default: current engine)
  61011. * @param reusable If the post process can be reused on the same frame. (default: false)
  61012. */
  61013. constructor(name: string, refractionTextureUrl: string,
  61014. /** the base color of the refraction (used to taint the rendering) */
  61015. color: Color3,
  61016. /** simulated refraction depth */
  61017. depth: number,
  61018. /** the coefficient of the base color (0 to remove base color tainting) */
  61019. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61020. /**
  61021. * Disposes of the post process
  61022. * @param camera Camera to dispose post process on
  61023. */
  61024. dispose(camera: Camera): void;
  61025. }
  61026. }
  61027. declare module BABYLON {
  61028. /** @hidden */
  61029. export var sharpenPixelShader: {
  61030. name: string;
  61031. shader: string;
  61032. };
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61037. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61038. */
  61039. export class SharpenPostProcess extends PostProcess {
  61040. /**
  61041. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61042. */
  61043. colorAmount: number;
  61044. /**
  61045. * How much sharpness should be applied (default: 0.3)
  61046. */
  61047. edgeAmount: number;
  61048. /**
  61049. * Creates a new instance ConvolutionPostProcess
  61050. * @param name The name of the effect.
  61051. * @param options The required width/height ratio to downsize to before computing the render pass.
  61052. * @param camera The camera to apply the render pass to.
  61053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61054. * @param engine The engine which the post process will be applied. (default: current engine)
  61055. * @param reusable If the post process can be reused on the same frame. (default: false)
  61056. * @param textureType Type of textures used when performing the post process. (default: 0)
  61057. * @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)
  61058. */
  61059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61060. }
  61061. }
  61062. declare module BABYLON {
  61063. /**
  61064. * PostProcessRenderPipeline
  61065. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61066. */
  61067. export class PostProcessRenderPipeline {
  61068. private engine;
  61069. private _renderEffects;
  61070. private _renderEffectsForIsolatedPass;
  61071. /**
  61072. * List of inspectable custom properties (used by the Inspector)
  61073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61074. */
  61075. inspectableCustomProperties: IInspectable[];
  61076. /**
  61077. * @hidden
  61078. */
  61079. protected _cameras: Camera[];
  61080. /** @hidden */
  61081. _name: string;
  61082. /**
  61083. * Gets pipeline name
  61084. */
  61085. readonly name: string;
  61086. /** Gets the list of attached cameras */
  61087. readonly cameras: Camera[];
  61088. /**
  61089. * Initializes a PostProcessRenderPipeline
  61090. * @param engine engine to add the pipeline to
  61091. * @param name name of the pipeline
  61092. */
  61093. constructor(engine: Engine, name: string);
  61094. /**
  61095. * Gets the class name
  61096. * @returns "PostProcessRenderPipeline"
  61097. */
  61098. getClassName(): string;
  61099. /**
  61100. * If all the render effects in the pipeline are supported
  61101. */
  61102. readonly isSupported: boolean;
  61103. /**
  61104. * Adds an effect to the pipeline
  61105. * @param renderEffect the effect to add
  61106. */
  61107. addEffect(renderEffect: PostProcessRenderEffect): void;
  61108. /** @hidden */
  61109. _rebuild(): void;
  61110. /** @hidden */
  61111. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61112. /** @hidden */
  61113. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61114. /** @hidden */
  61115. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61116. /** @hidden */
  61117. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61118. /** @hidden */
  61119. _attachCameras(cameras: Camera, unique: boolean): void;
  61120. /** @hidden */
  61121. _attachCameras(cameras: Camera[], unique: boolean): void;
  61122. /** @hidden */
  61123. _detachCameras(cameras: Camera): void;
  61124. /** @hidden */
  61125. _detachCameras(cameras: Nullable<Camera[]>): void;
  61126. /** @hidden */
  61127. _update(): void;
  61128. /** @hidden */
  61129. _reset(): void;
  61130. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61131. /**
  61132. * Disposes of the pipeline
  61133. */
  61134. dispose(): void;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * PostProcessRenderPipelineManager class
  61140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61141. */
  61142. export class PostProcessRenderPipelineManager {
  61143. private _renderPipelines;
  61144. /**
  61145. * Initializes a PostProcessRenderPipelineManager
  61146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61147. */
  61148. constructor();
  61149. /**
  61150. * Gets the list of supported render pipelines
  61151. */
  61152. readonly supportedPipelines: PostProcessRenderPipeline[];
  61153. /**
  61154. * Adds a pipeline to the manager
  61155. * @param renderPipeline The pipeline to add
  61156. */
  61157. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61158. /**
  61159. * Attaches a camera to the pipeline
  61160. * @param renderPipelineName The name of the pipeline to attach to
  61161. * @param cameras the camera to attach
  61162. * @param unique if the camera can be attached multiple times to the pipeline
  61163. */
  61164. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61165. /**
  61166. * Detaches a camera from the pipeline
  61167. * @param renderPipelineName The name of the pipeline to detach from
  61168. * @param cameras the camera to detach
  61169. */
  61170. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61171. /**
  61172. * Enables an effect by name on a pipeline
  61173. * @param renderPipelineName the name of the pipeline to enable the effect in
  61174. * @param renderEffectName the name of the effect to enable
  61175. * @param cameras the cameras that the effect should be enabled on
  61176. */
  61177. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61178. /**
  61179. * Disables an effect by name on a pipeline
  61180. * @param renderPipelineName the name of the pipeline to disable the effect in
  61181. * @param renderEffectName the name of the effect to disable
  61182. * @param cameras the cameras that the effect should be disabled on
  61183. */
  61184. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61185. /**
  61186. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61187. */
  61188. update(): void;
  61189. /** @hidden */
  61190. _rebuild(): void;
  61191. /**
  61192. * Disposes of the manager and pipelines
  61193. */
  61194. dispose(): void;
  61195. }
  61196. }
  61197. declare module BABYLON {
  61198. interface Scene {
  61199. /** @hidden (Backing field) */
  61200. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61201. /**
  61202. * Gets the postprocess render pipeline manager
  61203. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61204. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61205. */
  61206. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61207. }
  61208. /**
  61209. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61210. */
  61211. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61212. /**
  61213. * The component name helpfull to identify the component in the list of scene components.
  61214. */
  61215. readonly name: string;
  61216. /**
  61217. * The scene the component belongs to.
  61218. */
  61219. scene: Scene;
  61220. /**
  61221. * Creates a new instance of the component for the given scene
  61222. * @param scene Defines the scene to register the component in
  61223. */
  61224. constructor(scene: Scene);
  61225. /**
  61226. * Registers the component in a given scene
  61227. */
  61228. register(): void;
  61229. /**
  61230. * Rebuilds the elements related to this component in case of
  61231. * context lost for instance.
  61232. */
  61233. rebuild(): void;
  61234. /**
  61235. * Disposes the component and the associated ressources
  61236. */
  61237. dispose(): void;
  61238. private _gatherRenderTargets;
  61239. }
  61240. }
  61241. declare module BABYLON {
  61242. /**
  61243. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61244. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61245. */
  61246. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61247. private _scene;
  61248. private _camerasToBeAttached;
  61249. /**
  61250. * ID of the sharpen post process,
  61251. */
  61252. private readonly SharpenPostProcessId;
  61253. /**
  61254. * @ignore
  61255. * ID of the image processing post process;
  61256. */
  61257. readonly ImageProcessingPostProcessId: string;
  61258. /**
  61259. * @ignore
  61260. * ID of the Fast Approximate Anti-Aliasing post process;
  61261. */
  61262. readonly FxaaPostProcessId: string;
  61263. /**
  61264. * ID of the chromatic aberration post process,
  61265. */
  61266. private readonly ChromaticAberrationPostProcessId;
  61267. /**
  61268. * ID of the grain post process
  61269. */
  61270. private readonly GrainPostProcessId;
  61271. /**
  61272. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61273. */
  61274. sharpen: SharpenPostProcess;
  61275. private _sharpenEffect;
  61276. private bloom;
  61277. /**
  61278. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61279. */
  61280. depthOfField: DepthOfFieldEffect;
  61281. /**
  61282. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61283. */
  61284. fxaa: FxaaPostProcess;
  61285. /**
  61286. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61287. */
  61288. imageProcessing: ImageProcessingPostProcess;
  61289. /**
  61290. * Chromatic aberration post process which will shift rgb colors in the image
  61291. */
  61292. chromaticAberration: ChromaticAberrationPostProcess;
  61293. private _chromaticAberrationEffect;
  61294. /**
  61295. * Grain post process which add noise to the image
  61296. */
  61297. grain: GrainPostProcess;
  61298. private _grainEffect;
  61299. /**
  61300. * Glow post process which adds a glow to emissive areas of the image
  61301. */
  61302. private _glowLayer;
  61303. /**
  61304. * Animations which can be used to tweak settings over a period of time
  61305. */
  61306. animations: Animation[];
  61307. private _imageProcessingConfigurationObserver;
  61308. private _sharpenEnabled;
  61309. private _bloomEnabled;
  61310. private _depthOfFieldEnabled;
  61311. private _depthOfFieldBlurLevel;
  61312. private _fxaaEnabled;
  61313. private _imageProcessingEnabled;
  61314. private _defaultPipelineTextureType;
  61315. private _bloomScale;
  61316. private _chromaticAberrationEnabled;
  61317. private _grainEnabled;
  61318. private _buildAllowed;
  61319. /**
  61320. * Gets active scene
  61321. */
  61322. readonly scene: Scene;
  61323. /**
  61324. * Enable or disable the sharpen process from the pipeline
  61325. */
  61326. sharpenEnabled: boolean;
  61327. private _resizeObserver;
  61328. private _hardwareScaleLevel;
  61329. private _bloomKernel;
  61330. /**
  61331. * Specifies the size of the bloom blur kernel, relative to the final output size
  61332. */
  61333. bloomKernel: number;
  61334. /**
  61335. * Specifies the weight of the bloom in the final rendering
  61336. */
  61337. private _bloomWeight;
  61338. /**
  61339. * Specifies the luma threshold for the area that will be blurred by the bloom
  61340. */
  61341. private _bloomThreshold;
  61342. private _hdr;
  61343. /**
  61344. * The strength of the bloom.
  61345. */
  61346. bloomWeight: number;
  61347. /**
  61348. * The strength of the bloom.
  61349. */
  61350. bloomThreshold: number;
  61351. /**
  61352. * The scale of the bloom, lower value will provide better performance.
  61353. */
  61354. bloomScale: number;
  61355. /**
  61356. * Enable or disable the bloom from the pipeline
  61357. */
  61358. bloomEnabled: boolean;
  61359. private _rebuildBloom;
  61360. /**
  61361. * If the depth of field is enabled.
  61362. */
  61363. depthOfFieldEnabled: boolean;
  61364. /**
  61365. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61366. */
  61367. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61368. /**
  61369. * If the anti aliasing is enabled.
  61370. */
  61371. fxaaEnabled: boolean;
  61372. private _samples;
  61373. /**
  61374. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61375. */
  61376. samples: number;
  61377. /**
  61378. * If image processing is enabled.
  61379. */
  61380. imageProcessingEnabled: boolean;
  61381. /**
  61382. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61383. */
  61384. glowLayerEnabled: boolean;
  61385. /**
  61386. * Gets the glow layer (or null if not defined)
  61387. */
  61388. readonly glowLayer: Nullable<GlowLayer>;
  61389. /**
  61390. * Enable or disable the chromaticAberration process from the pipeline
  61391. */
  61392. chromaticAberrationEnabled: boolean;
  61393. /**
  61394. * Enable or disable the grain process from the pipeline
  61395. */
  61396. grainEnabled: boolean;
  61397. /**
  61398. * @constructor
  61399. * @param name - The rendering pipeline name (default: "")
  61400. * @param hdr - If high dynamic range textures should be used (default: true)
  61401. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61402. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61403. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61404. */
  61405. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61406. /**
  61407. * Get the class name
  61408. * @returns "DefaultRenderingPipeline"
  61409. */
  61410. getClassName(): string;
  61411. /**
  61412. * Force the compilation of the entire pipeline.
  61413. */
  61414. prepare(): void;
  61415. private _hasCleared;
  61416. private _prevPostProcess;
  61417. private _prevPrevPostProcess;
  61418. private _setAutoClearAndTextureSharing;
  61419. private _depthOfFieldSceneObserver;
  61420. private _buildPipeline;
  61421. private _disposePostProcesses;
  61422. /**
  61423. * Adds a camera to the pipeline
  61424. * @param camera the camera to be added
  61425. */
  61426. addCamera(camera: Camera): void;
  61427. /**
  61428. * Removes a camera from the pipeline
  61429. * @param camera the camera to remove
  61430. */
  61431. removeCamera(camera: Camera): void;
  61432. /**
  61433. * Dispose of the pipeline and stop all post processes
  61434. */
  61435. dispose(): void;
  61436. /**
  61437. * Serialize the rendering pipeline (Used when exporting)
  61438. * @returns the serialized object
  61439. */
  61440. serialize(): any;
  61441. /**
  61442. * Parse the serialized pipeline
  61443. * @param source Source pipeline.
  61444. * @param scene The scene to load the pipeline to.
  61445. * @param rootUrl The URL of the serialized pipeline.
  61446. * @returns An instantiated pipeline from the serialized object.
  61447. */
  61448. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61449. }
  61450. }
  61451. declare module BABYLON {
  61452. /** @hidden */
  61453. export var lensHighlightsPixelShader: {
  61454. name: string;
  61455. shader: string;
  61456. };
  61457. }
  61458. declare module BABYLON {
  61459. /** @hidden */
  61460. export var depthOfFieldPixelShader: {
  61461. name: string;
  61462. shader: string;
  61463. };
  61464. }
  61465. declare module BABYLON {
  61466. /**
  61467. * BABYLON.JS Chromatic Aberration GLSL Shader
  61468. * Author: Olivier Guyot
  61469. * Separates very slightly R, G and B colors on the edges of the screen
  61470. * Inspired by Francois Tarlier & Martins Upitis
  61471. */
  61472. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61473. /**
  61474. * @ignore
  61475. * The chromatic aberration PostProcess id in the pipeline
  61476. */
  61477. LensChromaticAberrationEffect: string;
  61478. /**
  61479. * @ignore
  61480. * The highlights enhancing PostProcess id in the pipeline
  61481. */
  61482. HighlightsEnhancingEffect: string;
  61483. /**
  61484. * @ignore
  61485. * The depth-of-field PostProcess id in the pipeline
  61486. */
  61487. LensDepthOfFieldEffect: string;
  61488. private _scene;
  61489. private _depthTexture;
  61490. private _grainTexture;
  61491. private _chromaticAberrationPostProcess;
  61492. private _highlightsPostProcess;
  61493. private _depthOfFieldPostProcess;
  61494. private _edgeBlur;
  61495. private _grainAmount;
  61496. private _chromaticAberration;
  61497. private _distortion;
  61498. private _highlightsGain;
  61499. private _highlightsThreshold;
  61500. private _dofDistance;
  61501. private _dofAperture;
  61502. private _dofDarken;
  61503. private _dofPentagon;
  61504. private _blurNoise;
  61505. /**
  61506. * @constructor
  61507. *
  61508. * Effect parameters are as follow:
  61509. * {
  61510. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61511. * edge_blur: number; // from 0 to x (1 for realism)
  61512. * distortion: number; // from 0 to x (1 for realism)
  61513. * grain_amount: number; // from 0 to 1
  61514. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61515. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61516. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61517. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61518. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61519. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61520. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61521. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61522. * }
  61523. * Note: if an effect parameter is unset, effect is disabled
  61524. *
  61525. * @param name The rendering pipeline name
  61526. * @param parameters - An object containing all parameters (see above)
  61527. * @param scene The scene linked to this pipeline
  61528. * @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)
  61529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61530. */
  61531. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61532. /**
  61533. * Get the class name
  61534. * @returns "LensRenderingPipeline"
  61535. */
  61536. getClassName(): string;
  61537. /**
  61538. * Gets associated scene
  61539. */
  61540. readonly scene: Scene;
  61541. /**
  61542. * Gets or sets the edge blur
  61543. */
  61544. edgeBlur: number;
  61545. /**
  61546. * Gets or sets the grain amount
  61547. */
  61548. grainAmount: number;
  61549. /**
  61550. * Gets or sets the chromatic aberration amount
  61551. */
  61552. chromaticAberration: number;
  61553. /**
  61554. * Gets or sets the depth of field aperture
  61555. */
  61556. dofAperture: number;
  61557. /**
  61558. * Gets or sets the edge distortion
  61559. */
  61560. edgeDistortion: number;
  61561. /**
  61562. * Gets or sets the depth of field distortion
  61563. */
  61564. dofDistortion: number;
  61565. /**
  61566. * Gets or sets the darken out of focus amount
  61567. */
  61568. darkenOutOfFocus: number;
  61569. /**
  61570. * Gets or sets a boolean indicating if blur noise is enabled
  61571. */
  61572. blurNoise: boolean;
  61573. /**
  61574. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61575. */
  61576. pentagonBokeh: boolean;
  61577. /**
  61578. * Gets or sets the highlight grain amount
  61579. */
  61580. highlightsGain: number;
  61581. /**
  61582. * Gets or sets the highlight threshold
  61583. */
  61584. highlightsThreshold: number;
  61585. /**
  61586. * Sets the amount of blur at the edges
  61587. * @param amount blur amount
  61588. */
  61589. setEdgeBlur(amount: number): void;
  61590. /**
  61591. * Sets edge blur to 0
  61592. */
  61593. disableEdgeBlur(): void;
  61594. /**
  61595. * Sets the amout of grain
  61596. * @param amount Amount of grain
  61597. */
  61598. setGrainAmount(amount: number): void;
  61599. /**
  61600. * Set grain amount to 0
  61601. */
  61602. disableGrain(): void;
  61603. /**
  61604. * Sets the chromatic aberration amount
  61605. * @param amount amount of chromatic aberration
  61606. */
  61607. setChromaticAberration(amount: number): void;
  61608. /**
  61609. * Sets chromatic aberration amount to 0
  61610. */
  61611. disableChromaticAberration(): void;
  61612. /**
  61613. * Sets the EdgeDistortion amount
  61614. * @param amount amount of EdgeDistortion
  61615. */
  61616. setEdgeDistortion(amount: number): void;
  61617. /**
  61618. * Sets edge distortion to 0
  61619. */
  61620. disableEdgeDistortion(): void;
  61621. /**
  61622. * Sets the FocusDistance amount
  61623. * @param amount amount of FocusDistance
  61624. */
  61625. setFocusDistance(amount: number): void;
  61626. /**
  61627. * Disables depth of field
  61628. */
  61629. disableDepthOfField(): void;
  61630. /**
  61631. * Sets the Aperture amount
  61632. * @param amount amount of Aperture
  61633. */
  61634. setAperture(amount: number): void;
  61635. /**
  61636. * Sets the DarkenOutOfFocus amount
  61637. * @param amount amount of DarkenOutOfFocus
  61638. */
  61639. setDarkenOutOfFocus(amount: number): void;
  61640. private _pentagonBokehIsEnabled;
  61641. /**
  61642. * Creates a pentagon bokeh effect
  61643. */
  61644. enablePentagonBokeh(): void;
  61645. /**
  61646. * Disables the pentagon bokeh effect
  61647. */
  61648. disablePentagonBokeh(): void;
  61649. /**
  61650. * Enables noise blur
  61651. */
  61652. enableNoiseBlur(): void;
  61653. /**
  61654. * Disables noise blur
  61655. */
  61656. disableNoiseBlur(): void;
  61657. /**
  61658. * Sets the HighlightsGain amount
  61659. * @param amount amount of HighlightsGain
  61660. */
  61661. setHighlightsGain(amount: number): void;
  61662. /**
  61663. * Sets the HighlightsThreshold amount
  61664. * @param amount amount of HighlightsThreshold
  61665. */
  61666. setHighlightsThreshold(amount: number): void;
  61667. /**
  61668. * Disables highlights
  61669. */
  61670. disableHighlights(): void;
  61671. /**
  61672. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61673. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61674. */
  61675. dispose(disableDepthRender?: boolean): void;
  61676. private _createChromaticAberrationPostProcess;
  61677. private _createHighlightsPostProcess;
  61678. private _createDepthOfFieldPostProcess;
  61679. private _createGrainTexture;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. /** @hidden */
  61684. export var ssao2PixelShader: {
  61685. name: string;
  61686. shader: string;
  61687. };
  61688. }
  61689. declare module BABYLON {
  61690. /** @hidden */
  61691. export var ssaoCombinePixelShader: {
  61692. name: string;
  61693. shader: string;
  61694. };
  61695. }
  61696. declare module BABYLON {
  61697. /**
  61698. * Render pipeline to produce ssao effect
  61699. */
  61700. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61701. /**
  61702. * @ignore
  61703. * The PassPostProcess id in the pipeline that contains the original scene color
  61704. */
  61705. SSAOOriginalSceneColorEffect: string;
  61706. /**
  61707. * @ignore
  61708. * The SSAO PostProcess id in the pipeline
  61709. */
  61710. SSAORenderEffect: string;
  61711. /**
  61712. * @ignore
  61713. * The horizontal blur PostProcess id in the pipeline
  61714. */
  61715. SSAOBlurHRenderEffect: string;
  61716. /**
  61717. * @ignore
  61718. * The vertical blur PostProcess id in the pipeline
  61719. */
  61720. SSAOBlurVRenderEffect: string;
  61721. /**
  61722. * @ignore
  61723. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61724. */
  61725. SSAOCombineRenderEffect: string;
  61726. /**
  61727. * The output strength of the SSAO post-process. Default value is 1.0.
  61728. */
  61729. totalStrength: number;
  61730. /**
  61731. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61732. */
  61733. maxZ: number;
  61734. /**
  61735. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61736. */
  61737. minZAspect: number;
  61738. private _samples;
  61739. /**
  61740. * Number of samples used for the SSAO calculations. Default value is 8
  61741. */
  61742. samples: number;
  61743. private _textureSamples;
  61744. /**
  61745. * Number of samples to use for antialiasing
  61746. */
  61747. textureSamples: number;
  61748. /**
  61749. * Ratio object used for SSAO ratio and blur ratio
  61750. */
  61751. private _ratio;
  61752. /**
  61753. * Dynamically generated sphere sampler.
  61754. */
  61755. private _sampleSphere;
  61756. /**
  61757. * Blur filter offsets
  61758. */
  61759. private _samplerOffsets;
  61760. private _expensiveBlur;
  61761. /**
  61762. * If bilateral blur should be used
  61763. */
  61764. expensiveBlur: boolean;
  61765. /**
  61766. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61767. */
  61768. radius: number;
  61769. /**
  61770. * The base color of the SSAO post-process
  61771. * The final result is "base + ssao" between [0, 1]
  61772. */
  61773. base: number;
  61774. /**
  61775. * Support test.
  61776. */
  61777. static readonly IsSupported: boolean;
  61778. private _scene;
  61779. private _depthTexture;
  61780. private _normalTexture;
  61781. private _randomTexture;
  61782. private _originalColorPostProcess;
  61783. private _ssaoPostProcess;
  61784. private _blurHPostProcess;
  61785. private _blurVPostProcess;
  61786. private _ssaoCombinePostProcess;
  61787. /**
  61788. * Gets active scene
  61789. */
  61790. readonly scene: Scene;
  61791. /**
  61792. * @constructor
  61793. * @param name The rendering pipeline name
  61794. * @param scene The scene linked to this pipeline
  61795. * @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 }
  61796. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61797. */
  61798. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61799. /**
  61800. * Get the class name
  61801. * @returns "SSAO2RenderingPipeline"
  61802. */
  61803. getClassName(): string;
  61804. /**
  61805. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61806. */
  61807. dispose(disableGeometryBufferRenderer?: boolean): void;
  61808. private _createBlurPostProcess;
  61809. /** @hidden */
  61810. _rebuild(): void;
  61811. private _bits;
  61812. private _radicalInverse_VdC;
  61813. private _hammersley;
  61814. private _hemisphereSample_uniform;
  61815. private _generateHemisphere;
  61816. private _createSSAOPostProcess;
  61817. private _createSSAOCombinePostProcess;
  61818. private _createRandomTexture;
  61819. /**
  61820. * Serialize the rendering pipeline (Used when exporting)
  61821. * @returns the serialized object
  61822. */
  61823. serialize(): any;
  61824. /**
  61825. * Parse the serialized pipeline
  61826. * @param source Source pipeline.
  61827. * @param scene The scene to load the pipeline to.
  61828. * @param rootUrl The URL of the serialized pipeline.
  61829. * @returns An instantiated pipeline from the serialized object.
  61830. */
  61831. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61832. }
  61833. }
  61834. declare module BABYLON {
  61835. /** @hidden */
  61836. export var ssaoPixelShader: {
  61837. name: string;
  61838. shader: string;
  61839. };
  61840. }
  61841. declare module BABYLON {
  61842. /**
  61843. * Render pipeline to produce ssao effect
  61844. */
  61845. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61846. /**
  61847. * @ignore
  61848. * The PassPostProcess id in the pipeline that contains the original scene color
  61849. */
  61850. SSAOOriginalSceneColorEffect: string;
  61851. /**
  61852. * @ignore
  61853. * The SSAO PostProcess id in the pipeline
  61854. */
  61855. SSAORenderEffect: string;
  61856. /**
  61857. * @ignore
  61858. * The horizontal blur PostProcess id in the pipeline
  61859. */
  61860. SSAOBlurHRenderEffect: string;
  61861. /**
  61862. * @ignore
  61863. * The vertical blur PostProcess id in the pipeline
  61864. */
  61865. SSAOBlurVRenderEffect: string;
  61866. /**
  61867. * @ignore
  61868. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61869. */
  61870. SSAOCombineRenderEffect: string;
  61871. /**
  61872. * The output strength of the SSAO post-process. Default value is 1.0.
  61873. */
  61874. totalStrength: number;
  61875. /**
  61876. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61877. */
  61878. radius: number;
  61879. /**
  61880. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61881. * Must not be equal to fallOff and superior to fallOff.
  61882. * Default value is 0.0075
  61883. */
  61884. area: number;
  61885. /**
  61886. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61887. * Must not be equal to area and inferior to area.
  61888. * Default value is 0.000001
  61889. */
  61890. fallOff: number;
  61891. /**
  61892. * The base color of the SSAO post-process
  61893. * The final result is "base + ssao" between [0, 1]
  61894. */
  61895. base: number;
  61896. private _scene;
  61897. private _depthTexture;
  61898. private _randomTexture;
  61899. private _originalColorPostProcess;
  61900. private _ssaoPostProcess;
  61901. private _blurHPostProcess;
  61902. private _blurVPostProcess;
  61903. private _ssaoCombinePostProcess;
  61904. private _firstUpdate;
  61905. /**
  61906. * Gets active scene
  61907. */
  61908. readonly scene: Scene;
  61909. /**
  61910. * @constructor
  61911. * @param name - The rendering pipeline name
  61912. * @param scene - The scene linked to this pipeline
  61913. * @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 }
  61914. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61915. */
  61916. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61917. /**
  61918. * Get the class name
  61919. * @returns "SSAORenderingPipeline"
  61920. */
  61921. getClassName(): string;
  61922. /**
  61923. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61924. */
  61925. dispose(disableDepthRender?: boolean): void;
  61926. private _createBlurPostProcess;
  61927. /** @hidden */
  61928. _rebuild(): void;
  61929. private _createSSAOPostProcess;
  61930. private _createSSAOCombinePostProcess;
  61931. private _createRandomTexture;
  61932. }
  61933. }
  61934. declare module BABYLON {
  61935. /** @hidden */
  61936. export var standardPixelShader: {
  61937. name: string;
  61938. shader: string;
  61939. };
  61940. }
  61941. declare module BABYLON {
  61942. /**
  61943. * Standard rendering pipeline
  61944. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61945. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61946. */
  61947. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61948. /**
  61949. * Public members
  61950. */
  61951. /**
  61952. * Post-process which contains the original scene color before the pipeline applies all the effects
  61953. */
  61954. originalPostProcess: Nullable<PostProcess>;
  61955. /**
  61956. * Post-process used to down scale an image x4
  61957. */
  61958. downSampleX4PostProcess: Nullable<PostProcess>;
  61959. /**
  61960. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61961. */
  61962. brightPassPostProcess: Nullable<PostProcess>;
  61963. /**
  61964. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61965. */
  61966. blurHPostProcesses: PostProcess[];
  61967. /**
  61968. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61969. */
  61970. blurVPostProcesses: PostProcess[];
  61971. /**
  61972. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61973. */
  61974. textureAdderPostProcess: Nullable<PostProcess>;
  61975. /**
  61976. * Post-process used to create volumetric lighting effect
  61977. */
  61978. volumetricLightPostProcess: Nullable<PostProcess>;
  61979. /**
  61980. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61981. */
  61982. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61983. /**
  61984. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61985. */
  61986. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61987. /**
  61988. * Post-process used to merge the volumetric light effect and the real scene color
  61989. */
  61990. volumetricLightMergePostProces: Nullable<PostProcess>;
  61991. /**
  61992. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61993. */
  61994. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61995. /**
  61996. * Base post-process used to calculate the average luminance of the final image for HDR
  61997. */
  61998. luminancePostProcess: Nullable<PostProcess>;
  61999. /**
  62000. * Post-processes used to create down sample post-processes in order to get
  62001. * the average luminance of the final image for HDR
  62002. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62003. */
  62004. luminanceDownSamplePostProcesses: PostProcess[];
  62005. /**
  62006. * Post-process used to create a HDR effect (light adaptation)
  62007. */
  62008. hdrPostProcess: Nullable<PostProcess>;
  62009. /**
  62010. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62011. */
  62012. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62013. /**
  62014. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62015. */
  62016. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62017. /**
  62018. * Post-process used to merge the final HDR post-process and the real scene color
  62019. */
  62020. hdrFinalPostProcess: Nullable<PostProcess>;
  62021. /**
  62022. * Post-process used to create a lens flare effect
  62023. */
  62024. lensFlarePostProcess: Nullable<PostProcess>;
  62025. /**
  62026. * Post-process that merges the result of the lens flare post-process and the real scene color
  62027. */
  62028. lensFlareComposePostProcess: Nullable<PostProcess>;
  62029. /**
  62030. * Post-process used to create a motion blur effect
  62031. */
  62032. motionBlurPostProcess: Nullable<PostProcess>;
  62033. /**
  62034. * Post-process used to create a depth of field effect
  62035. */
  62036. depthOfFieldPostProcess: Nullable<PostProcess>;
  62037. /**
  62038. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62039. */
  62040. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62041. /**
  62042. * Represents the brightness threshold in order to configure the illuminated surfaces
  62043. */
  62044. brightThreshold: number;
  62045. /**
  62046. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62047. */
  62048. blurWidth: number;
  62049. /**
  62050. * Sets if the blur for highlighted surfaces must be only horizontal
  62051. */
  62052. horizontalBlur: boolean;
  62053. /**
  62054. * Gets the overall exposure used by the pipeline
  62055. */
  62056. /**
  62057. * Sets the overall exposure used by the pipeline
  62058. */
  62059. exposure: number;
  62060. /**
  62061. * Texture used typically to simulate "dirty" on camera lens
  62062. */
  62063. lensTexture: Nullable<Texture>;
  62064. /**
  62065. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62066. */
  62067. volumetricLightCoefficient: number;
  62068. /**
  62069. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62070. */
  62071. volumetricLightPower: number;
  62072. /**
  62073. * Used the set the blur intensity to smooth the volumetric lights
  62074. */
  62075. volumetricLightBlurScale: number;
  62076. /**
  62077. * Light (spot or directional) used to generate the volumetric lights rays
  62078. * The source light must have a shadow generate so the pipeline can get its
  62079. * depth map
  62080. */
  62081. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62082. /**
  62083. * For eye adaptation, represents the minimum luminance the eye can see
  62084. */
  62085. hdrMinimumLuminance: number;
  62086. /**
  62087. * For eye adaptation, represents the decrease luminance speed
  62088. */
  62089. hdrDecreaseRate: number;
  62090. /**
  62091. * For eye adaptation, represents the increase luminance speed
  62092. */
  62093. hdrIncreaseRate: number;
  62094. /**
  62095. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62096. */
  62097. /**
  62098. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62099. */
  62100. hdrAutoExposure: boolean;
  62101. /**
  62102. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62103. */
  62104. lensColorTexture: Nullable<Texture>;
  62105. /**
  62106. * The overall strengh for the lens flare effect
  62107. */
  62108. lensFlareStrength: number;
  62109. /**
  62110. * Dispersion coefficient for lens flare ghosts
  62111. */
  62112. lensFlareGhostDispersal: number;
  62113. /**
  62114. * Main lens flare halo width
  62115. */
  62116. lensFlareHaloWidth: number;
  62117. /**
  62118. * Based on the lens distortion effect, defines how much the lens flare result
  62119. * is distorted
  62120. */
  62121. lensFlareDistortionStrength: number;
  62122. /**
  62123. * Configures the blur intensity used for for lens flare (halo)
  62124. */
  62125. lensFlareBlurWidth: number;
  62126. /**
  62127. * Lens star texture must be used to simulate rays on the flares and is available
  62128. * in the documentation
  62129. */
  62130. lensStarTexture: Nullable<Texture>;
  62131. /**
  62132. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62133. * flare effect by taking account of the dirt texture
  62134. */
  62135. lensFlareDirtTexture: Nullable<Texture>;
  62136. /**
  62137. * Represents the focal length for the depth of field effect
  62138. */
  62139. depthOfFieldDistance: number;
  62140. /**
  62141. * Represents the blur intensity for the blurred part of the depth of field effect
  62142. */
  62143. depthOfFieldBlurWidth: number;
  62144. /**
  62145. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62146. */
  62147. /**
  62148. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62149. */
  62150. motionStrength: number;
  62151. /**
  62152. * Gets wether or not the motion blur post-process is object based or screen based.
  62153. */
  62154. /**
  62155. * Sets wether or not the motion blur post-process should be object based or screen based
  62156. */
  62157. objectBasedMotionBlur: boolean;
  62158. /**
  62159. * List of animations for the pipeline (IAnimatable implementation)
  62160. */
  62161. animations: Animation[];
  62162. /**
  62163. * Private members
  62164. */
  62165. private _scene;
  62166. private _currentDepthOfFieldSource;
  62167. private _basePostProcess;
  62168. private _fixedExposure;
  62169. private _currentExposure;
  62170. private _hdrAutoExposure;
  62171. private _hdrCurrentLuminance;
  62172. private _motionStrength;
  62173. private _isObjectBasedMotionBlur;
  62174. private _floatTextureType;
  62175. private _camerasToBeAttached;
  62176. private _ratio;
  62177. private _bloomEnabled;
  62178. private _depthOfFieldEnabled;
  62179. private _vlsEnabled;
  62180. private _lensFlareEnabled;
  62181. private _hdrEnabled;
  62182. private _motionBlurEnabled;
  62183. private _fxaaEnabled;
  62184. private _motionBlurSamples;
  62185. private _volumetricLightStepsCount;
  62186. private _samples;
  62187. /**
  62188. * @ignore
  62189. * Specifies if the bloom pipeline is enabled
  62190. */
  62191. BloomEnabled: boolean;
  62192. /**
  62193. * @ignore
  62194. * Specifies if the depth of field pipeline is enabed
  62195. */
  62196. DepthOfFieldEnabled: boolean;
  62197. /**
  62198. * @ignore
  62199. * Specifies if the lens flare pipeline is enabed
  62200. */
  62201. LensFlareEnabled: boolean;
  62202. /**
  62203. * @ignore
  62204. * Specifies if the HDR pipeline is enabled
  62205. */
  62206. HDREnabled: boolean;
  62207. /**
  62208. * @ignore
  62209. * Specifies if the volumetric lights scattering effect is enabled
  62210. */
  62211. VLSEnabled: boolean;
  62212. /**
  62213. * @ignore
  62214. * Specifies if the motion blur effect is enabled
  62215. */
  62216. MotionBlurEnabled: boolean;
  62217. /**
  62218. * Specifies if anti-aliasing is enabled
  62219. */
  62220. fxaaEnabled: boolean;
  62221. /**
  62222. * Specifies the number of steps used to calculate the volumetric lights
  62223. * Typically in interval [50, 200]
  62224. */
  62225. volumetricLightStepsCount: number;
  62226. /**
  62227. * Specifies the number of samples used for the motion blur effect
  62228. * Typically in interval [16, 64]
  62229. */
  62230. motionBlurSamples: number;
  62231. /**
  62232. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62233. */
  62234. samples: number;
  62235. /**
  62236. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62237. * @constructor
  62238. * @param name The rendering pipeline name
  62239. * @param scene The scene linked to this pipeline
  62240. * @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)
  62241. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62242. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62243. */
  62244. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62245. private _buildPipeline;
  62246. private _createDownSampleX4PostProcess;
  62247. private _createBrightPassPostProcess;
  62248. private _createBlurPostProcesses;
  62249. private _createTextureAdderPostProcess;
  62250. private _createVolumetricLightPostProcess;
  62251. private _createLuminancePostProcesses;
  62252. private _createHdrPostProcess;
  62253. private _createLensFlarePostProcess;
  62254. private _createDepthOfFieldPostProcess;
  62255. private _createMotionBlurPostProcess;
  62256. private _getDepthTexture;
  62257. private _disposePostProcesses;
  62258. /**
  62259. * Dispose of the pipeline and stop all post processes
  62260. */
  62261. dispose(): void;
  62262. /**
  62263. * Serialize the rendering pipeline (Used when exporting)
  62264. * @returns the serialized object
  62265. */
  62266. serialize(): any;
  62267. /**
  62268. * Parse the serialized pipeline
  62269. * @param source Source pipeline.
  62270. * @param scene The scene to load the pipeline to.
  62271. * @param rootUrl The URL of the serialized pipeline.
  62272. * @returns An instantiated pipeline from the serialized object.
  62273. */
  62274. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62275. /**
  62276. * Luminance steps
  62277. */
  62278. static LuminanceSteps: number;
  62279. }
  62280. }
  62281. declare module BABYLON {
  62282. /** @hidden */
  62283. export var tonemapPixelShader: {
  62284. name: string;
  62285. shader: string;
  62286. };
  62287. }
  62288. declare module BABYLON {
  62289. /** Defines operator used for tonemapping */
  62290. export enum TonemappingOperator {
  62291. /** Hable */
  62292. Hable = 0,
  62293. /** Reinhard */
  62294. Reinhard = 1,
  62295. /** HejiDawson */
  62296. HejiDawson = 2,
  62297. /** Photographic */
  62298. Photographic = 3
  62299. }
  62300. /**
  62301. * Defines a post process to apply tone mapping
  62302. */
  62303. export class TonemapPostProcess extends PostProcess {
  62304. private _operator;
  62305. /** Defines the required exposure adjustement */
  62306. exposureAdjustment: number;
  62307. /**
  62308. * Creates a new TonemapPostProcess
  62309. * @param name defines the name of the postprocess
  62310. * @param _operator defines the operator to use
  62311. * @param exposureAdjustment defines the required exposure adjustement
  62312. * @param camera defines the camera to use (can be null)
  62313. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62314. * @param engine defines the hosting engine (can be ignore if camera is set)
  62315. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62316. */
  62317. constructor(name: string, _operator: TonemappingOperator,
  62318. /** Defines the required exposure adjustement */
  62319. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62320. }
  62321. }
  62322. declare module BABYLON {
  62323. /** @hidden */
  62324. export var depthVertexShader: {
  62325. name: string;
  62326. shader: string;
  62327. };
  62328. }
  62329. declare module BABYLON {
  62330. /** @hidden */
  62331. export var volumetricLightScatteringPixelShader: {
  62332. name: string;
  62333. shader: string;
  62334. };
  62335. }
  62336. declare module BABYLON {
  62337. /** @hidden */
  62338. export var volumetricLightScatteringPassVertexShader: {
  62339. name: string;
  62340. shader: string;
  62341. };
  62342. }
  62343. declare module BABYLON {
  62344. /** @hidden */
  62345. export var volumetricLightScatteringPassPixelShader: {
  62346. name: string;
  62347. shader: string;
  62348. };
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62353. */
  62354. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62355. private _volumetricLightScatteringPass;
  62356. private _volumetricLightScatteringRTT;
  62357. private _viewPort;
  62358. private _screenCoordinates;
  62359. private _cachedDefines;
  62360. /**
  62361. * If not undefined, the mesh position is computed from the attached node position
  62362. */
  62363. attachedNode: {
  62364. position: Vector3;
  62365. };
  62366. /**
  62367. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62368. */
  62369. customMeshPosition: Vector3;
  62370. /**
  62371. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62372. */
  62373. useCustomMeshPosition: boolean;
  62374. /**
  62375. * If the post-process should inverse the light scattering direction
  62376. */
  62377. invert: boolean;
  62378. /**
  62379. * The internal mesh used by the post-process
  62380. */
  62381. mesh: Mesh;
  62382. /**
  62383. * @hidden
  62384. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62385. */
  62386. useDiffuseColor: boolean;
  62387. /**
  62388. * Array containing the excluded meshes not rendered in the internal pass
  62389. */
  62390. excludedMeshes: AbstractMesh[];
  62391. /**
  62392. * Controls the overall intensity of the post-process
  62393. */
  62394. exposure: number;
  62395. /**
  62396. * Dissipates each sample's contribution in range [0, 1]
  62397. */
  62398. decay: number;
  62399. /**
  62400. * Controls the overall intensity of each sample
  62401. */
  62402. weight: number;
  62403. /**
  62404. * Controls the density of each sample
  62405. */
  62406. density: number;
  62407. /**
  62408. * @constructor
  62409. * @param name The post-process name
  62410. * @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)
  62411. * @param camera The camera that the post-process will be attached to
  62412. * @param mesh The mesh used to create the light scattering
  62413. * @param samples The post-process quality, default 100
  62414. * @param samplingModeThe post-process filtering mode
  62415. * @param engine The babylon engine
  62416. * @param reusable If the post-process is reusable
  62417. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62418. */
  62419. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62420. /**
  62421. * Returns the string "VolumetricLightScatteringPostProcess"
  62422. * @returns "VolumetricLightScatteringPostProcess"
  62423. */
  62424. getClassName(): string;
  62425. private _isReady;
  62426. /**
  62427. * Sets the new light position for light scattering effect
  62428. * @param position The new custom light position
  62429. */
  62430. setCustomMeshPosition(position: Vector3): void;
  62431. /**
  62432. * Returns the light position for light scattering effect
  62433. * @return Vector3 The custom light position
  62434. */
  62435. getCustomMeshPosition(): Vector3;
  62436. /**
  62437. * Disposes the internal assets and detaches the post-process from the camera
  62438. */
  62439. dispose(camera: Camera): void;
  62440. /**
  62441. * Returns the render target texture used by the post-process
  62442. * @return the render target texture used by the post-process
  62443. */
  62444. getPass(): RenderTargetTexture;
  62445. private _meshExcluded;
  62446. private _createPass;
  62447. private _updateMeshScreenCoordinates;
  62448. /**
  62449. * Creates a default mesh for the Volumeric Light Scattering post-process
  62450. * @param name The mesh name
  62451. * @param scene The scene where to create the mesh
  62452. * @return the default mesh
  62453. */
  62454. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62455. }
  62456. }
  62457. declare module BABYLON {
  62458. interface Scene {
  62459. /** @hidden (Backing field) */
  62460. _boundingBoxRenderer: BoundingBoxRenderer;
  62461. /** @hidden (Backing field) */
  62462. _forceShowBoundingBoxes: boolean;
  62463. /**
  62464. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62465. */
  62466. forceShowBoundingBoxes: boolean;
  62467. /**
  62468. * Gets the bounding box renderer associated with the scene
  62469. * @returns a BoundingBoxRenderer
  62470. */
  62471. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62472. }
  62473. interface AbstractMesh {
  62474. /** @hidden (Backing field) */
  62475. _showBoundingBox: boolean;
  62476. /**
  62477. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62478. */
  62479. showBoundingBox: boolean;
  62480. }
  62481. /**
  62482. * Component responsible of rendering the bounding box of the meshes in a scene.
  62483. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62484. */
  62485. export class BoundingBoxRenderer implements ISceneComponent {
  62486. /**
  62487. * The component name helpfull to identify the component in the list of scene components.
  62488. */
  62489. readonly name: string;
  62490. /**
  62491. * The scene the component belongs to.
  62492. */
  62493. scene: Scene;
  62494. /**
  62495. * Color of the bounding box lines placed in front of an object
  62496. */
  62497. frontColor: Color3;
  62498. /**
  62499. * Color of the bounding box lines placed behind an object
  62500. */
  62501. backColor: Color3;
  62502. /**
  62503. * Defines if the renderer should show the back lines or not
  62504. */
  62505. showBackLines: boolean;
  62506. /**
  62507. * @hidden
  62508. */
  62509. renderList: SmartArray<BoundingBox>;
  62510. private _colorShader;
  62511. private _vertexBuffers;
  62512. private _indexBuffer;
  62513. private _fillIndexBuffer;
  62514. private _fillIndexData;
  62515. /**
  62516. * Instantiates a new bounding box renderer in a scene.
  62517. * @param scene the scene the renderer renders in
  62518. */
  62519. constructor(scene: Scene);
  62520. /**
  62521. * Registers the component in a given scene
  62522. */
  62523. register(): void;
  62524. private _evaluateSubMesh;
  62525. private _activeMesh;
  62526. private _prepareRessources;
  62527. private _createIndexBuffer;
  62528. /**
  62529. * Rebuilds the elements related to this component in case of
  62530. * context lost for instance.
  62531. */
  62532. rebuild(): void;
  62533. /**
  62534. * @hidden
  62535. */
  62536. reset(): void;
  62537. /**
  62538. * Render the bounding boxes of a specific rendering group
  62539. * @param renderingGroupId defines the rendering group to render
  62540. */
  62541. render(renderingGroupId: number): void;
  62542. /**
  62543. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62544. * @param mesh Define the mesh to render the occlusion bounding box for
  62545. */
  62546. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62547. /**
  62548. * Dispose and release the resources attached to this renderer.
  62549. */
  62550. dispose(): void;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /** @hidden */
  62555. export var depthPixelShader: {
  62556. name: string;
  62557. shader: string;
  62558. };
  62559. }
  62560. declare module BABYLON {
  62561. /**
  62562. * This represents a depth renderer in Babylon.
  62563. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62564. */
  62565. export class DepthRenderer {
  62566. private _scene;
  62567. private _depthMap;
  62568. private _effect;
  62569. private readonly _storeNonLinearDepth;
  62570. private readonly _clearColor;
  62571. /** Get if the depth renderer is using packed depth or not */
  62572. readonly isPacked: boolean;
  62573. private _cachedDefines;
  62574. private _camera;
  62575. /**
  62576. * Specifiess that the depth renderer will only be used within
  62577. * the camera it is created for.
  62578. * This can help forcing its rendering during the camera processing.
  62579. */
  62580. useOnlyInActiveCamera: boolean;
  62581. /** @hidden */
  62582. static _SceneComponentInitialization: (scene: Scene) => void;
  62583. /**
  62584. * Instantiates a depth renderer
  62585. * @param scene The scene the renderer belongs to
  62586. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62587. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62588. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62589. */
  62590. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62591. /**
  62592. * Creates the depth rendering effect and checks if the effect is ready.
  62593. * @param subMesh The submesh to be used to render the depth map of
  62594. * @param useInstances If multiple world instances should be used
  62595. * @returns if the depth renderer is ready to render the depth map
  62596. */
  62597. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62598. /**
  62599. * Gets the texture which the depth map will be written to.
  62600. * @returns The depth map texture
  62601. */
  62602. getDepthMap(): RenderTargetTexture;
  62603. /**
  62604. * Disposes of the depth renderer.
  62605. */
  62606. dispose(): void;
  62607. }
  62608. }
  62609. declare module BABYLON {
  62610. interface Scene {
  62611. /** @hidden (Backing field) */
  62612. _depthRenderer: {
  62613. [id: string]: DepthRenderer;
  62614. };
  62615. /**
  62616. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62617. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62618. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62619. * @returns the created depth renderer
  62620. */
  62621. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62622. /**
  62623. * Disables a depth renderer for a given camera
  62624. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62625. */
  62626. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62627. }
  62628. /**
  62629. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62630. * in several rendering techniques.
  62631. */
  62632. export class DepthRendererSceneComponent implements ISceneComponent {
  62633. /**
  62634. * The component name helpfull to identify the component in the list of scene components.
  62635. */
  62636. readonly name: string;
  62637. /**
  62638. * The scene the component belongs to.
  62639. */
  62640. scene: Scene;
  62641. /**
  62642. * Creates a new instance of the component for the given scene
  62643. * @param scene Defines the scene to register the component in
  62644. */
  62645. constructor(scene: Scene);
  62646. /**
  62647. * Registers the component in a given scene
  62648. */
  62649. register(): void;
  62650. /**
  62651. * Rebuilds the elements related to this component in case of
  62652. * context lost for instance.
  62653. */
  62654. rebuild(): void;
  62655. /**
  62656. * Disposes the component and the associated ressources
  62657. */
  62658. dispose(): void;
  62659. private _gatherRenderTargets;
  62660. private _gatherActiveCameraRenderTargets;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /** @hidden */
  62665. export var outlinePixelShader: {
  62666. name: string;
  62667. shader: string;
  62668. };
  62669. }
  62670. declare module BABYLON {
  62671. /** @hidden */
  62672. export var outlineVertexShader: {
  62673. name: string;
  62674. shader: string;
  62675. };
  62676. }
  62677. declare module BABYLON {
  62678. interface Scene {
  62679. /** @hidden */
  62680. _outlineRenderer: OutlineRenderer;
  62681. /**
  62682. * Gets the outline renderer associated with the scene
  62683. * @returns a OutlineRenderer
  62684. */
  62685. getOutlineRenderer(): OutlineRenderer;
  62686. }
  62687. interface AbstractMesh {
  62688. /** @hidden (Backing field) */
  62689. _renderOutline: boolean;
  62690. /**
  62691. * Gets or sets a boolean indicating if the outline must be rendered as well
  62692. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62693. */
  62694. renderOutline: boolean;
  62695. /** @hidden (Backing field) */
  62696. _renderOverlay: boolean;
  62697. /**
  62698. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62699. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62700. */
  62701. renderOverlay: boolean;
  62702. }
  62703. /**
  62704. * This class is responsible to draw bothe outline/overlay of meshes.
  62705. * It should not be used directly but through the available method on mesh.
  62706. */
  62707. export class OutlineRenderer implements ISceneComponent {
  62708. /**
  62709. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62710. */
  62711. private static _StencilReference;
  62712. /**
  62713. * The name of the component. Each component must have a unique name.
  62714. */
  62715. name: string;
  62716. /**
  62717. * The scene the component belongs to.
  62718. */
  62719. scene: Scene;
  62720. /**
  62721. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62722. */
  62723. zOffset: number;
  62724. private _engine;
  62725. private _effect;
  62726. private _cachedDefines;
  62727. private _savedDepthWrite;
  62728. /**
  62729. * Instantiates a new outline renderer. (There could be only one per scene).
  62730. * @param scene Defines the scene it belongs to
  62731. */
  62732. constructor(scene: Scene);
  62733. /**
  62734. * Register the component to one instance of a scene.
  62735. */
  62736. register(): void;
  62737. /**
  62738. * Rebuilds the elements related to this component in case of
  62739. * context lost for instance.
  62740. */
  62741. rebuild(): void;
  62742. /**
  62743. * Disposes the component and the associated ressources.
  62744. */
  62745. dispose(): void;
  62746. /**
  62747. * Renders the outline in the canvas.
  62748. * @param subMesh Defines the sumesh to render
  62749. * @param batch Defines the batch of meshes in case of instances
  62750. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62751. */
  62752. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62753. /**
  62754. * Returns whether or not the outline renderer is ready for a given submesh.
  62755. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62756. * @param subMesh Defines the submesh to check readyness for
  62757. * @param useInstances Defines wheter wee are trying to render instances or not
  62758. * @returns true if ready otherwise false
  62759. */
  62760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62761. private _beforeRenderingMesh;
  62762. private _afterRenderingMesh;
  62763. }
  62764. }
  62765. declare module BABYLON {
  62766. /**
  62767. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62768. * @see http://doc.babylonjs.com/babylon101/sprites
  62769. */
  62770. export class SpritePackedManager extends SpriteManager {
  62771. /** defines the packed manager's name */
  62772. name: string;
  62773. /**
  62774. * Creates a new sprite manager from a packed sprite sheet
  62775. * @param name defines the manager's name
  62776. * @param imgUrl defines the sprite sheet url
  62777. * @param capacity defines the maximum allowed number of sprites
  62778. * @param scene defines the hosting scene
  62779. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62780. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62781. * @param samplingMode defines the smapling mode to use with spritesheet
  62782. * @param fromPacked set to true; do not alter
  62783. */
  62784. constructor(
  62785. /** defines the packed manager's name */
  62786. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62787. }
  62788. }
  62789. declare module BABYLON {
  62790. /**
  62791. * Defines the list of states available for a task inside a AssetsManager
  62792. */
  62793. export enum AssetTaskState {
  62794. /**
  62795. * Initialization
  62796. */
  62797. INIT = 0,
  62798. /**
  62799. * Running
  62800. */
  62801. RUNNING = 1,
  62802. /**
  62803. * Done
  62804. */
  62805. DONE = 2,
  62806. /**
  62807. * Error
  62808. */
  62809. ERROR = 3
  62810. }
  62811. /**
  62812. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62813. */
  62814. export abstract class AbstractAssetTask {
  62815. /**
  62816. * Task name
  62817. */ name: string;
  62818. /**
  62819. * Callback called when the task is successful
  62820. */
  62821. onSuccess: (task: any) => void;
  62822. /**
  62823. * Callback called when the task is not successful
  62824. */
  62825. onError: (task: any, message?: string, exception?: any) => void;
  62826. /**
  62827. * Creates a new AssetsManager
  62828. * @param name defines the name of the task
  62829. */
  62830. constructor(
  62831. /**
  62832. * Task name
  62833. */ name: string);
  62834. private _isCompleted;
  62835. private _taskState;
  62836. private _errorObject;
  62837. /**
  62838. * Get if the task is completed
  62839. */
  62840. readonly isCompleted: boolean;
  62841. /**
  62842. * Gets the current state of the task
  62843. */
  62844. readonly taskState: AssetTaskState;
  62845. /**
  62846. * Gets the current error object (if task is in error)
  62847. */
  62848. readonly errorObject: {
  62849. message?: string;
  62850. exception?: any;
  62851. };
  62852. /**
  62853. * Internal only
  62854. * @hidden
  62855. */
  62856. _setErrorObject(message?: string, exception?: any): void;
  62857. /**
  62858. * Execute the current task
  62859. * @param scene defines the scene where you want your assets to be loaded
  62860. * @param onSuccess is a callback called when the task is successfully executed
  62861. * @param onError is a callback called if an error occurs
  62862. */
  62863. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62864. /**
  62865. * Execute the current task
  62866. * @param scene defines the scene where you want your assets to be loaded
  62867. * @param onSuccess is a callback called when the task is successfully executed
  62868. * @param onError is a callback called if an error occurs
  62869. */
  62870. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62871. /**
  62872. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62873. * This can be used with failed tasks that have the reason for failure fixed.
  62874. */
  62875. reset(): void;
  62876. private onErrorCallback;
  62877. private onDoneCallback;
  62878. }
  62879. /**
  62880. * Define the interface used by progress events raised during assets loading
  62881. */
  62882. export interface IAssetsProgressEvent {
  62883. /**
  62884. * Defines the number of remaining tasks to process
  62885. */
  62886. remainingCount: number;
  62887. /**
  62888. * Defines the total number of tasks
  62889. */
  62890. totalCount: number;
  62891. /**
  62892. * Defines the task that was just processed
  62893. */
  62894. task: AbstractAssetTask;
  62895. }
  62896. /**
  62897. * Class used to share progress information about assets loading
  62898. */
  62899. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62900. /**
  62901. * Defines the number of remaining tasks to process
  62902. */
  62903. remainingCount: number;
  62904. /**
  62905. * Defines the total number of tasks
  62906. */
  62907. totalCount: number;
  62908. /**
  62909. * Defines the task that was just processed
  62910. */
  62911. task: AbstractAssetTask;
  62912. /**
  62913. * Creates a AssetsProgressEvent
  62914. * @param remainingCount defines the number of remaining tasks to process
  62915. * @param totalCount defines the total number of tasks
  62916. * @param task defines the task that was just processed
  62917. */
  62918. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62919. }
  62920. /**
  62921. * Define a task used by AssetsManager to load meshes
  62922. */
  62923. export class MeshAssetTask extends AbstractAssetTask {
  62924. /**
  62925. * Defines the name of the task
  62926. */
  62927. name: string;
  62928. /**
  62929. * Defines the list of mesh's names you want to load
  62930. */
  62931. meshesNames: any;
  62932. /**
  62933. * Defines the root url to use as a base to load your meshes and associated resources
  62934. */
  62935. rootUrl: string;
  62936. /**
  62937. * Defines the filename of the scene to load from
  62938. */
  62939. sceneFilename: string;
  62940. /**
  62941. * Gets the list of loaded meshes
  62942. */
  62943. loadedMeshes: Array<AbstractMesh>;
  62944. /**
  62945. * Gets the list of loaded particle systems
  62946. */
  62947. loadedParticleSystems: Array<IParticleSystem>;
  62948. /**
  62949. * Gets the list of loaded skeletons
  62950. */
  62951. loadedSkeletons: Array<Skeleton>;
  62952. /**
  62953. * Gets the list of loaded animation groups
  62954. */
  62955. loadedAnimationGroups: Array<AnimationGroup>;
  62956. /**
  62957. * Callback called when the task is successful
  62958. */
  62959. onSuccess: (task: MeshAssetTask) => void;
  62960. /**
  62961. * Callback called when the task is successful
  62962. */
  62963. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62964. /**
  62965. * Creates a new MeshAssetTask
  62966. * @param name defines the name of the task
  62967. * @param meshesNames defines the list of mesh's names you want to load
  62968. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62969. * @param sceneFilename defines the filename of the scene to load from
  62970. */
  62971. constructor(
  62972. /**
  62973. * Defines the name of the task
  62974. */
  62975. name: string,
  62976. /**
  62977. * Defines the list of mesh's names you want to load
  62978. */
  62979. meshesNames: any,
  62980. /**
  62981. * Defines the root url to use as a base to load your meshes and associated resources
  62982. */
  62983. rootUrl: string,
  62984. /**
  62985. * Defines the filename of the scene to load from
  62986. */
  62987. sceneFilename: string);
  62988. /**
  62989. * Execute the current task
  62990. * @param scene defines the scene where you want your assets to be loaded
  62991. * @param onSuccess is a callback called when the task is successfully executed
  62992. * @param onError is a callback called if an error occurs
  62993. */
  62994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62995. }
  62996. /**
  62997. * Define a task used by AssetsManager to load text content
  62998. */
  62999. export class TextFileAssetTask extends AbstractAssetTask {
  63000. /**
  63001. * Defines the name of the task
  63002. */
  63003. name: string;
  63004. /**
  63005. * Defines the location of the file to load
  63006. */
  63007. url: string;
  63008. /**
  63009. * Gets the loaded text string
  63010. */
  63011. text: string;
  63012. /**
  63013. * Callback called when the task is successful
  63014. */
  63015. onSuccess: (task: TextFileAssetTask) => void;
  63016. /**
  63017. * Callback called when the task is successful
  63018. */
  63019. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63020. /**
  63021. * Creates a new TextFileAssetTask object
  63022. * @param name defines the name of the task
  63023. * @param url defines the location of the file to load
  63024. */
  63025. constructor(
  63026. /**
  63027. * Defines the name of the task
  63028. */
  63029. name: string,
  63030. /**
  63031. * Defines the location of the file to load
  63032. */
  63033. url: string);
  63034. /**
  63035. * Execute the current task
  63036. * @param scene defines the scene where you want your assets to be loaded
  63037. * @param onSuccess is a callback called when the task is successfully executed
  63038. * @param onError is a callback called if an error occurs
  63039. */
  63040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63041. }
  63042. /**
  63043. * Define a task used by AssetsManager to load binary data
  63044. */
  63045. export class BinaryFileAssetTask extends AbstractAssetTask {
  63046. /**
  63047. * Defines the name of the task
  63048. */
  63049. name: string;
  63050. /**
  63051. * Defines the location of the file to load
  63052. */
  63053. url: string;
  63054. /**
  63055. * Gets the lodaded data (as an array buffer)
  63056. */
  63057. data: ArrayBuffer;
  63058. /**
  63059. * Callback called when the task is successful
  63060. */
  63061. onSuccess: (task: BinaryFileAssetTask) => void;
  63062. /**
  63063. * Callback called when the task is successful
  63064. */
  63065. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63066. /**
  63067. * Creates a new BinaryFileAssetTask object
  63068. * @param name defines the name of the new task
  63069. * @param url defines the location of the file to load
  63070. */
  63071. constructor(
  63072. /**
  63073. * Defines the name of the task
  63074. */
  63075. name: string,
  63076. /**
  63077. * Defines the location of the file to load
  63078. */
  63079. url: string);
  63080. /**
  63081. * Execute the current task
  63082. * @param scene defines the scene where you want your assets to be loaded
  63083. * @param onSuccess is a callback called when the task is successfully executed
  63084. * @param onError is a callback called if an error occurs
  63085. */
  63086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63087. }
  63088. /**
  63089. * Define a task used by AssetsManager to load images
  63090. */
  63091. export class ImageAssetTask extends AbstractAssetTask {
  63092. /**
  63093. * Defines the name of the task
  63094. */
  63095. name: string;
  63096. /**
  63097. * Defines the location of the image to load
  63098. */
  63099. url: string;
  63100. /**
  63101. * Gets the loaded images
  63102. */
  63103. image: HTMLImageElement;
  63104. /**
  63105. * Callback called when the task is successful
  63106. */
  63107. onSuccess: (task: ImageAssetTask) => void;
  63108. /**
  63109. * Callback called when the task is successful
  63110. */
  63111. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63112. /**
  63113. * Creates a new ImageAssetTask
  63114. * @param name defines the name of the task
  63115. * @param url defines the location of the image to load
  63116. */
  63117. constructor(
  63118. /**
  63119. * Defines the name of the task
  63120. */
  63121. name: string,
  63122. /**
  63123. * Defines the location of the image to load
  63124. */
  63125. url: string);
  63126. /**
  63127. * Execute the current task
  63128. * @param scene defines the scene where you want your assets to be loaded
  63129. * @param onSuccess is a callback called when the task is successfully executed
  63130. * @param onError is a callback called if an error occurs
  63131. */
  63132. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63133. }
  63134. /**
  63135. * Defines the interface used by texture loading tasks
  63136. */
  63137. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63138. /**
  63139. * Gets the loaded texture
  63140. */
  63141. texture: TEX;
  63142. }
  63143. /**
  63144. * Define a task used by AssetsManager to load 2D textures
  63145. */
  63146. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63147. /**
  63148. * Defines the name of the task
  63149. */
  63150. name: string;
  63151. /**
  63152. * Defines the location of the file to load
  63153. */
  63154. url: string;
  63155. /**
  63156. * Defines if mipmap should not be generated (default is false)
  63157. */
  63158. noMipmap?: boolean | undefined;
  63159. /**
  63160. * Defines if texture must be inverted on Y axis (default is false)
  63161. */
  63162. invertY?: boolean | undefined;
  63163. /**
  63164. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63165. */
  63166. samplingMode: number;
  63167. /**
  63168. * Gets the loaded texture
  63169. */
  63170. texture: Texture;
  63171. /**
  63172. * Callback called when the task is successful
  63173. */
  63174. onSuccess: (task: TextureAssetTask) => void;
  63175. /**
  63176. * Callback called when the task is successful
  63177. */
  63178. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63179. /**
  63180. * Creates a new TextureAssetTask object
  63181. * @param name defines the name of the task
  63182. * @param url defines the location of the file to load
  63183. * @param noMipmap defines if mipmap should not be generated (default is false)
  63184. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63185. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63186. */
  63187. constructor(
  63188. /**
  63189. * Defines the name of the task
  63190. */
  63191. name: string,
  63192. /**
  63193. * Defines the location of the file to load
  63194. */
  63195. url: string,
  63196. /**
  63197. * Defines if mipmap should not be generated (default is false)
  63198. */
  63199. noMipmap?: boolean | undefined,
  63200. /**
  63201. * Defines if texture must be inverted on Y axis (default is false)
  63202. */
  63203. invertY?: boolean | undefined,
  63204. /**
  63205. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63206. */
  63207. samplingMode?: number);
  63208. /**
  63209. * Execute the current task
  63210. * @param scene defines the scene where you want your assets to be loaded
  63211. * @param onSuccess is a callback called when the task is successfully executed
  63212. * @param onError is a callback called if an error occurs
  63213. */
  63214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63215. }
  63216. /**
  63217. * Define a task used by AssetsManager to load cube textures
  63218. */
  63219. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63220. /**
  63221. * Defines the name of the task
  63222. */
  63223. name: string;
  63224. /**
  63225. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63226. */
  63227. url: string;
  63228. /**
  63229. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63230. */
  63231. extensions?: string[] | undefined;
  63232. /**
  63233. * Defines if mipmaps should not be generated (default is false)
  63234. */
  63235. noMipmap?: boolean | undefined;
  63236. /**
  63237. * Defines the explicit list of files (undefined by default)
  63238. */
  63239. files?: string[] | undefined;
  63240. /**
  63241. * Gets the loaded texture
  63242. */
  63243. texture: CubeTexture;
  63244. /**
  63245. * Callback called when the task is successful
  63246. */
  63247. onSuccess: (task: CubeTextureAssetTask) => void;
  63248. /**
  63249. * Callback called when the task is successful
  63250. */
  63251. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63252. /**
  63253. * Creates a new CubeTextureAssetTask
  63254. * @param name defines the name of the task
  63255. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63256. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63257. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63258. * @param files defines the explicit list of files (undefined by default)
  63259. */
  63260. constructor(
  63261. /**
  63262. * Defines the name of the task
  63263. */
  63264. name: string,
  63265. /**
  63266. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63267. */
  63268. url: string,
  63269. /**
  63270. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63271. */
  63272. extensions?: string[] | undefined,
  63273. /**
  63274. * Defines if mipmaps should not be generated (default is false)
  63275. */
  63276. noMipmap?: boolean | undefined,
  63277. /**
  63278. * Defines the explicit list of files (undefined by default)
  63279. */
  63280. files?: string[] | undefined);
  63281. /**
  63282. * Execute the current task
  63283. * @param scene defines the scene where you want your assets to be loaded
  63284. * @param onSuccess is a callback called when the task is successfully executed
  63285. * @param onError is a callback called if an error occurs
  63286. */
  63287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63288. }
  63289. /**
  63290. * Define a task used by AssetsManager to load HDR cube textures
  63291. */
  63292. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63293. /**
  63294. * Defines the name of the task
  63295. */
  63296. name: string;
  63297. /**
  63298. * Defines the location of the file to load
  63299. */
  63300. url: string;
  63301. /**
  63302. * Defines the desired size (the more it increases the longer the generation will be)
  63303. */
  63304. size: number;
  63305. /**
  63306. * Defines if mipmaps should not be generated (default is false)
  63307. */
  63308. noMipmap: boolean;
  63309. /**
  63310. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63311. */
  63312. generateHarmonics: boolean;
  63313. /**
  63314. * 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)
  63315. */
  63316. gammaSpace: boolean;
  63317. /**
  63318. * Internal Use Only
  63319. */
  63320. reserved: boolean;
  63321. /**
  63322. * Gets the loaded texture
  63323. */
  63324. texture: HDRCubeTexture;
  63325. /**
  63326. * Callback called when the task is successful
  63327. */
  63328. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63329. /**
  63330. * Callback called when the task is successful
  63331. */
  63332. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63333. /**
  63334. * Creates a new HDRCubeTextureAssetTask object
  63335. * @param name defines the name of the task
  63336. * @param url defines the location of the file to load
  63337. * @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.
  63338. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63339. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63340. * @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)
  63341. * @param reserved Internal use only
  63342. */
  63343. constructor(
  63344. /**
  63345. * Defines the name of the task
  63346. */
  63347. name: string,
  63348. /**
  63349. * Defines the location of the file to load
  63350. */
  63351. url: string,
  63352. /**
  63353. * Defines the desired size (the more it increases the longer the generation will be)
  63354. */
  63355. size: number,
  63356. /**
  63357. * Defines if mipmaps should not be generated (default is false)
  63358. */
  63359. noMipmap?: boolean,
  63360. /**
  63361. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63362. */
  63363. generateHarmonics?: boolean,
  63364. /**
  63365. * 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)
  63366. */
  63367. gammaSpace?: boolean,
  63368. /**
  63369. * Internal Use Only
  63370. */
  63371. reserved?: boolean);
  63372. /**
  63373. * Execute the current task
  63374. * @param scene defines the scene where you want your assets to be loaded
  63375. * @param onSuccess is a callback called when the task is successfully executed
  63376. * @param onError is a callback called if an error occurs
  63377. */
  63378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63379. }
  63380. /**
  63381. * Define a task used by AssetsManager to load Equirectangular cube textures
  63382. */
  63383. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63384. /**
  63385. * Defines the name of the task
  63386. */
  63387. name: string;
  63388. /**
  63389. * Defines the location of the file to load
  63390. */
  63391. url: string;
  63392. /**
  63393. * Defines the desired size (the more it increases the longer the generation will be)
  63394. */
  63395. size: number;
  63396. /**
  63397. * Defines if mipmaps should not be generated (default is false)
  63398. */
  63399. noMipmap: boolean;
  63400. /**
  63401. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63402. * but the standard material would require them in Gamma space) (default is true)
  63403. */
  63404. gammaSpace: boolean;
  63405. /**
  63406. * Gets the loaded texture
  63407. */
  63408. texture: EquiRectangularCubeTexture;
  63409. /**
  63410. * Callback called when the task is successful
  63411. */
  63412. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63413. /**
  63414. * Callback called when the task is successful
  63415. */
  63416. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63417. /**
  63418. * Creates a new EquiRectangularCubeTextureAssetTask object
  63419. * @param name defines the name of the task
  63420. * @param url defines the location of the file to load
  63421. * @param size defines the desired size (the more it increases the longer the generation will be)
  63422. * If the size is omitted this implies you are using a preprocessed cubemap.
  63423. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63424. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63425. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63426. * (default is true)
  63427. */
  63428. constructor(
  63429. /**
  63430. * Defines the name of the task
  63431. */
  63432. name: string,
  63433. /**
  63434. * Defines the location of the file to load
  63435. */
  63436. url: string,
  63437. /**
  63438. * Defines the desired size (the more it increases the longer the generation will be)
  63439. */
  63440. size: number,
  63441. /**
  63442. * Defines if mipmaps should not be generated (default is false)
  63443. */
  63444. noMipmap?: boolean,
  63445. /**
  63446. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63447. * but the standard material would require them in Gamma space) (default is true)
  63448. */
  63449. gammaSpace?: boolean);
  63450. /**
  63451. * Execute the current task
  63452. * @param scene defines the scene where you want your assets to be loaded
  63453. * @param onSuccess is a callback called when the task is successfully executed
  63454. * @param onError is a callback called if an error occurs
  63455. */
  63456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63457. }
  63458. /**
  63459. * This class can be used to easily import assets into a scene
  63460. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63461. */
  63462. export class AssetsManager {
  63463. private _scene;
  63464. private _isLoading;
  63465. protected _tasks: AbstractAssetTask[];
  63466. protected _waitingTasksCount: number;
  63467. protected _totalTasksCount: number;
  63468. /**
  63469. * Callback called when all tasks are processed
  63470. */
  63471. onFinish: (tasks: AbstractAssetTask[]) => void;
  63472. /**
  63473. * Callback called when a task is successful
  63474. */
  63475. onTaskSuccess: (task: AbstractAssetTask) => void;
  63476. /**
  63477. * Callback called when a task had an error
  63478. */
  63479. onTaskError: (task: AbstractAssetTask) => void;
  63480. /**
  63481. * Callback called when a task is done (whatever the result is)
  63482. */
  63483. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63484. /**
  63485. * Observable called when all tasks are processed
  63486. */
  63487. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63488. /**
  63489. * Observable called when a task had an error
  63490. */
  63491. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63492. /**
  63493. * Observable called when all tasks were executed
  63494. */
  63495. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63496. /**
  63497. * Observable called when a task is done (whatever the result is)
  63498. */
  63499. onProgressObservable: Observable<IAssetsProgressEvent>;
  63500. /**
  63501. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63503. */
  63504. useDefaultLoadingScreen: boolean;
  63505. /**
  63506. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63507. * when all assets have been downloaded.
  63508. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63509. */
  63510. autoHideLoadingUI: boolean;
  63511. /**
  63512. * Creates a new AssetsManager
  63513. * @param scene defines the scene to work on
  63514. */
  63515. constructor(scene: Scene);
  63516. /**
  63517. * Add a MeshAssetTask to the list of active tasks
  63518. * @param taskName defines the name of the new task
  63519. * @param meshesNames defines the name of meshes to load
  63520. * @param rootUrl defines the root url to use to locate files
  63521. * @param sceneFilename defines the filename of the scene file
  63522. * @returns a new MeshAssetTask object
  63523. */
  63524. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63525. /**
  63526. * Add a TextFileAssetTask to the list of active tasks
  63527. * @param taskName defines the name of the new task
  63528. * @param url defines the url of the file to load
  63529. * @returns a new TextFileAssetTask object
  63530. */
  63531. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63532. /**
  63533. * Add a BinaryFileAssetTask to the list of active tasks
  63534. * @param taskName defines the name of the new task
  63535. * @param url defines the url of the file to load
  63536. * @returns a new BinaryFileAssetTask object
  63537. */
  63538. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63539. /**
  63540. * Add a ImageAssetTask to the list of active tasks
  63541. * @param taskName defines the name of the new task
  63542. * @param url defines the url of the file to load
  63543. * @returns a new ImageAssetTask object
  63544. */
  63545. addImageTask(taskName: string, url: string): ImageAssetTask;
  63546. /**
  63547. * Add a TextureAssetTask to the list of active tasks
  63548. * @param taskName defines the name of the new task
  63549. * @param url defines the url of the file to load
  63550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63551. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63552. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63553. * @returns a new TextureAssetTask object
  63554. */
  63555. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63556. /**
  63557. * Add a CubeTextureAssetTask to the list of active tasks
  63558. * @param taskName defines the name of the new task
  63559. * @param url defines the url of the file to load
  63560. * @param extensions defines the extension to use to load the cube map (can be null)
  63561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63562. * @param files defines the list of files to load (can be null)
  63563. * @returns a new CubeTextureAssetTask object
  63564. */
  63565. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63566. /**
  63567. *
  63568. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63569. * @param taskName defines the name of the new task
  63570. * @param url defines the url of the file to load
  63571. * @param size defines the size you want for the cubemap (can be null)
  63572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63573. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63574. * @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)
  63575. * @param reserved Internal use only
  63576. * @returns a new HDRCubeTextureAssetTask object
  63577. */
  63578. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63579. /**
  63580. *
  63581. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63582. * @param taskName defines the name of the new task
  63583. * @param url defines the url of the file to load
  63584. * @param size defines the size you want for the cubemap (can be null)
  63585. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63586. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63587. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63588. * @returns a new EquiRectangularCubeTextureAssetTask object
  63589. */
  63590. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63591. /**
  63592. * Remove a task from the assets manager.
  63593. * @param task the task to remove
  63594. */
  63595. removeTask(task: AbstractAssetTask): void;
  63596. private _decreaseWaitingTasksCount;
  63597. private _runTask;
  63598. /**
  63599. * Reset the AssetsManager and remove all tasks
  63600. * @return the current instance of the AssetsManager
  63601. */
  63602. reset(): AssetsManager;
  63603. /**
  63604. * Start the loading process
  63605. * @return the current instance of the AssetsManager
  63606. */
  63607. load(): AssetsManager;
  63608. /**
  63609. * Start the loading process as an async operation
  63610. * @return a promise returning the list of failed tasks
  63611. */
  63612. loadAsync(): Promise<void>;
  63613. }
  63614. }
  63615. declare module BABYLON {
  63616. /**
  63617. * Wrapper class for promise with external resolve and reject.
  63618. */
  63619. export class Deferred<T> {
  63620. /**
  63621. * The promise associated with this deferred object.
  63622. */
  63623. readonly promise: Promise<T>;
  63624. private _resolve;
  63625. private _reject;
  63626. /**
  63627. * The resolve method of the promise associated with this deferred object.
  63628. */
  63629. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63630. /**
  63631. * The reject method of the promise associated with this deferred object.
  63632. */
  63633. readonly reject: (reason?: any) => void;
  63634. /**
  63635. * Constructor for this deferred object.
  63636. */
  63637. constructor();
  63638. }
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63643. */
  63644. export class MeshExploder {
  63645. private _centerMesh;
  63646. private _meshes;
  63647. private _meshesOrigins;
  63648. private _toCenterVectors;
  63649. private _scaledDirection;
  63650. private _newPosition;
  63651. private _centerPosition;
  63652. /**
  63653. * Explodes meshes from a center mesh.
  63654. * @param meshes The meshes to explode.
  63655. * @param centerMesh The mesh to be center of explosion.
  63656. */
  63657. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63658. private _setCenterMesh;
  63659. /**
  63660. * Get class name
  63661. * @returns "MeshExploder"
  63662. */
  63663. getClassName(): string;
  63664. /**
  63665. * "Exploded meshes"
  63666. * @returns Array of meshes with the centerMesh at index 0.
  63667. */
  63668. getMeshes(): Array<Mesh>;
  63669. /**
  63670. * Explodes meshes giving a specific direction
  63671. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63672. */
  63673. explode(direction?: number): void;
  63674. }
  63675. }
  63676. declare module BABYLON {
  63677. /**
  63678. * Class used to help managing file picking and drag'n'drop
  63679. */
  63680. export class FilesInput {
  63681. /**
  63682. * List of files ready to be loaded
  63683. */
  63684. static readonly FilesToLoad: {
  63685. [key: string]: File;
  63686. };
  63687. /**
  63688. * Callback called when a file is processed
  63689. */
  63690. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63691. private _engine;
  63692. private _currentScene;
  63693. private _sceneLoadedCallback;
  63694. private _progressCallback;
  63695. private _additionalRenderLoopLogicCallback;
  63696. private _textureLoadingCallback;
  63697. private _startingProcessingFilesCallback;
  63698. private _onReloadCallback;
  63699. private _errorCallback;
  63700. private _elementToMonitor;
  63701. private _sceneFileToLoad;
  63702. private _filesToLoad;
  63703. /**
  63704. * Creates a new FilesInput
  63705. * @param engine defines the rendering engine
  63706. * @param scene defines the hosting scene
  63707. * @param sceneLoadedCallback callback called when scene is loaded
  63708. * @param progressCallback callback called to track progress
  63709. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63710. * @param textureLoadingCallback callback called when a texture is loading
  63711. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63712. * @param onReloadCallback callback called when a reload is requested
  63713. * @param errorCallback callback call if an error occurs
  63714. */
  63715. 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);
  63716. private _dragEnterHandler;
  63717. private _dragOverHandler;
  63718. private _dropHandler;
  63719. /**
  63720. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63721. * @param elementToMonitor defines the DOM element to track
  63722. */
  63723. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63724. /**
  63725. * Release all associated resources
  63726. */
  63727. dispose(): void;
  63728. private renderFunction;
  63729. private drag;
  63730. private drop;
  63731. private _traverseFolder;
  63732. private _processFiles;
  63733. /**
  63734. * Load files from a drop event
  63735. * @param event defines the drop event to use as source
  63736. */
  63737. loadFiles(event: any): void;
  63738. private _processReload;
  63739. /**
  63740. * Reload the current scene from the loaded files
  63741. */
  63742. reload(): void;
  63743. }
  63744. }
  63745. declare module BABYLON {
  63746. /**
  63747. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63749. */
  63750. export class SceneOptimization {
  63751. /**
  63752. * Defines the priority of this optimization (0 by default which means first in the list)
  63753. */
  63754. priority: number;
  63755. /**
  63756. * Gets a string describing the action executed by the current optimization
  63757. * @returns description string
  63758. */
  63759. getDescription(): string;
  63760. /**
  63761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63762. * @param scene defines the current scene where to apply this optimization
  63763. * @param optimizer defines the current optimizer
  63764. * @returns true if everything that can be done was applied
  63765. */
  63766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63767. /**
  63768. * Creates the SceneOptimization object
  63769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63770. * @param desc defines the description associated with the optimization
  63771. */
  63772. constructor(
  63773. /**
  63774. * Defines the priority of this optimization (0 by default which means first in the list)
  63775. */
  63776. priority?: number);
  63777. }
  63778. /**
  63779. * Defines an optimization used to reduce the size of render target textures
  63780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63781. */
  63782. export class TextureOptimization extends SceneOptimization {
  63783. /**
  63784. * Defines the priority of this optimization (0 by default which means first in the list)
  63785. */
  63786. priority: number;
  63787. /**
  63788. * 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
  63789. */
  63790. maximumSize: number;
  63791. /**
  63792. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63793. */
  63794. step: number;
  63795. /**
  63796. * Gets a string describing the action executed by the current optimization
  63797. * @returns description string
  63798. */
  63799. getDescription(): string;
  63800. /**
  63801. * Creates the TextureOptimization object
  63802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63803. * @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
  63804. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63805. */
  63806. constructor(
  63807. /**
  63808. * Defines the priority of this optimization (0 by default which means first in the list)
  63809. */
  63810. priority?: number,
  63811. /**
  63812. * 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
  63813. */
  63814. maximumSize?: number,
  63815. /**
  63816. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63817. */
  63818. step?: number);
  63819. /**
  63820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63821. * @param scene defines the current scene where to apply this optimization
  63822. * @param optimizer defines the current optimizer
  63823. * @returns true if everything that can be done was applied
  63824. */
  63825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63826. }
  63827. /**
  63828. * Defines an optimization used to increase or decrease the rendering resolution
  63829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63830. */
  63831. export class HardwareScalingOptimization extends SceneOptimization {
  63832. /**
  63833. * Defines the priority of this optimization (0 by default which means first in the list)
  63834. */
  63835. priority: number;
  63836. /**
  63837. * Defines the maximum scale to use (2 by default)
  63838. */
  63839. maximumScale: number;
  63840. /**
  63841. * Defines the step to use between two passes (0.5 by default)
  63842. */
  63843. step: number;
  63844. private _currentScale;
  63845. private _directionOffset;
  63846. /**
  63847. * Gets a string describing the action executed by the current optimization
  63848. * @return description string
  63849. */
  63850. getDescription(): string;
  63851. /**
  63852. * Creates the HardwareScalingOptimization object
  63853. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63854. * @param maximumScale defines the maximum scale to use (2 by default)
  63855. * @param step defines the step to use between two passes (0.5 by default)
  63856. */
  63857. constructor(
  63858. /**
  63859. * Defines the priority of this optimization (0 by default which means first in the list)
  63860. */
  63861. priority?: number,
  63862. /**
  63863. * Defines the maximum scale to use (2 by default)
  63864. */
  63865. maximumScale?: number,
  63866. /**
  63867. * Defines the step to use between two passes (0.5 by default)
  63868. */
  63869. step?: number);
  63870. /**
  63871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63872. * @param scene defines the current scene where to apply this optimization
  63873. * @param optimizer defines the current optimizer
  63874. * @returns true if everything that can be done was applied
  63875. */
  63876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63877. }
  63878. /**
  63879. * Defines an optimization used to remove shadows
  63880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63881. */
  63882. export class ShadowsOptimization extends SceneOptimization {
  63883. /**
  63884. * Gets a string describing the action executed by the current optimization
  63885. * @return description string
  63886. */
  63887. getDescription(): string;
  63888. /**
  63889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63890. * @param scene defines the current scene where to apply this optimization
  63891. * @param optimizer defines the current optimizer
  63892. * @returns true if everything that can be done was applied
  63893. */
  63894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63895. }
  63896. /**
  63897. * Defines an optimization used to turn post-processes off
  63898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63899. */
  63900. export class PostProcessesOptimization extends SceneOptimization {
  63901. /**
  63902. * Gets a string describing the action executed by the current optimization
  63903. * @return description string
  63904. */
  63905. getDescription(): string;
  63906. /**
  63907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63908. * @param scene defines the current scene where to apply this optimization
  63909. * @param optimizer defines the current optimizer
  63910. * @returns true if everything that can be done was applied
  63911. */
  63912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63913. }
  63914. /**
  63915. * Defines an optimization used to turn lens flares off
  63916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63917. */
  63918. export class LensFlaresOptimization extends SceneOptimization {
  63919. /**
  63920. * Gets a string describing the action executed by the current optimization
  63921. * @return description string
  63922. */
  63923. getDescription(): string;
  63924. /**
  63925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63926. * @param scene defines the current scene where to apply this optimization
  63927. * @param optimizer defines the current optimizer
  63928. * @returns true if everything that can be done was applied
  63929. */
  63930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63931. }
  63932. /**
  63933. * Defines an optimization based on user defined callback.
  63934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63935. */
  63936. export class CustomOptimization extends SceneOptimization {
  63937. /**
  63938. * Callback called to apply the custom optimization.
  63939. */
  63940. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63941. /**
  63942. * Callback called to get custom description
  63943. */
  63944. onGetDescription: () => string;
  63945. /**
  63946. * Gets a string describing the action executed by the current optimization
  63947. * @returns description string
  63948. */
  63949. getDescription(): string;
  63950. /**
  63951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63952. * @param scene defines the current scene where to apply this optimization
  63953. * @param optimizer defines the current optimizer
  63954. * @returns true if everything that can be done was applied
  63955. */
  63956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63957. }
  63958. /**
  63959. * Defines an optimization used to turn particles off
  63960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63961. */
  63962. export class ParticlesOptimization extends SceneOptimization {
  63963. /**
  63964. * Gets a string describing the action executed by the current optimization
  63965. * @return description string
  63966. */
  63967. getDescription(): string;
  63968. /**
  63969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63970. * @param scene defines the current scene where to apply this optimization
  63971. * @param optimizer defines the current optimizer
  63972. * @returns true if everything that can be done was applied
  63973. */
  63974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63975. }
  63976. /**
  63977. * Defines an optimization used to turn render targets off
  63978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63979. */
  63980. export class RenderTargetsOptimization extends SceneOptimization {
  63981. /**
  63982. * Gets a string describing the action executed by the current optimization
  63983. * @return description string
  63984. */
  63985. getDescription(): string;
  63986. /**
  63987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63988. * @param scene defines the current scene where to apply this optimization
  63989. * @param optimizer defines the current optimizer
  63990. * @returns true if everything that can be done was applied
  63991. */
  63992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63993. }
  63994. /**
  63995. * Defines an optimization used to merge meshes with compatible materials
  63996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63997. */
  63998. export class MergeMeshesOptimization extends SceneOptimization {
  63999. private static _UpdateSelectionTree;
  64000. /**
  64001. * Gets or sets a boolean which defines if optimization octree has to be updated
  64002. */
  64003. /**
  64004. * Gets or sets a boolean which defines if optimization octree has to be updated
  64005. */
  64006. static UpdateSelectionTree: boolean;
  64007. /**
  64008. * Gets a string describing the action executed by the current optimization
  64009. * @return description string
  64010. */
  64011. getDescription(): string;
  64012. private _canBeMerged;
  64013. /**
  64014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64015. * @param scene defines the current scene where to apply this optimization
  64016. * @param optimizer defines the current optimizer
  64017. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64018. * @returns true if everything that can be done was applied
  64019. */
  64020. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64021. }
  64022. /**
  64023. * Defines a list of options used by SceneOptimizer
  64024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64025. */
  64026. export class SceneOptimizerOptions {
  64027. /**
  64028. * Defines the target frame rate to reach (60 by default)
  64029. */
  64030. targetFrameRate: number;
  64031. /**
  64032. * Defines the interval between two checkes (2000ms by default)
  64033. */
  64034. trackerDuration: number;
  64035. /**
  64036. * Gets the list of optimizations to apply
  64037. */
  64038. optimizations: SceneOptimization[];
  64039. /**
  64040. * Creates a new list of options used by SceneOptimizer
  64041. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64042. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64043. */
  64044. constructor(
  64045. /**
  64046. * Defines the target frame rate to reach (60 by default)
  64047. */
  64048. targetFrameRate?: number,
  64049. /**
  64050. * Defines the interval between two checkes (2000ms by default)
  64051. */
  64052. trackerDuration?: number);
  64053. /**
  64054. * Add a new optimization
  64055. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64056. * @returns the current SceneOptimizerOptions
  64057. */
  64058. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64059. /**
  64060. * Add a new custom optimization
  64061. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64062. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64063. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64064. * @returns the current SceneOptimizerOptions
  64065. */
  64066. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64067. /**
  64068. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64069. * @param targetFrameRate defines the target frame rate (60 by default)
  64070. * @returns a SceneOptimizerOptions object
  64071. */
  64072. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64073. /**
  64074. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64075. * @param targetFrameRate defines the target frame rate (60 by default)
  64076. * @returns a SceneOptimizerOptions object
  64077. */
  64078. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64079. /**
  64080. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64081. * @param targetFrameRate defines the target frame rate (60 by default)
  64082. * @returns a SceneOptimizerOptions object
  64083. */
  64084. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64085. }
  64086. /**
  64087. * Class used to run optimizations in order to reach a target frame rate
  64088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64089. */
  64090. export class SceneOptimizer implements IDisposable {
  64091. private _isRunning;
  64092. private _options;
  64093. private _scene;
  64094. private _currentPriorityLevel;
  64095. private _targetFrameRate;
  64096. private _trackerDuration;
  64097. private _currentFrameRate;
  64098. private _sceneDisposeObserver;
  64099. private _improvementMode;
  64100. /**
  64101. * Defines an observable called when the optimizer reaches the target frame rate
  64102. */
  64103. onSuccessObservable: Observable<SceneOptimizer>;
  64104. /**
  64105. * Defines an observable called when the optimizer enables an optimization
  64106. */
  64107. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64108. /**
  64109. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64110. */
  64111. onFailureObservable: Observable<SceneOptimizer>;
  64112. /**
  64113. * Gets a boolean indicating if the optimizer is in improvement mode
  64114. */
  64115. readonly isInImprovementMode: boolean;
  64116. /**
  64117. * Gets the current priority level (0 at start)
  64118. */
  64119. readonly currentPriorityLevel: number;
  64120. /**
  64121. * Gets the current frame rate checked by the SceneOptimizer
  64122. */
  64123. readonly currentFrameRate: number;
  64124. /**
  64125. * Gets or sets the current target frame rate (60 by default)
  64126. */
  64127. /**
  64128. * Gets or sets the current target frame rate (60 by default)
  64129. */
  64130. targetFrameRate: number;
  64131. /**
  64132. * Gets or sets the current interval between two checks (every 2000ms by default)
  64133. */
  64134. /**
  64135. * Gets or sets the current interval between two checks (every 2000ms by default)
  64136. */
  64137. trackerDuration: number;
  64138. /**
  64139. * Gets the list of active optimizations
  64140. */
  64141. readonly optimizations: SceneOptimization[];
  64142. /**
  64143. * Creates a new SceneOptimizer
  64144. * @param scene defines the scene to work on
  64145. * @param options defines the options to use with the SceneOptimizer
  64146. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64147. * @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)
  64148. */
  64149. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64150. /**
  64151. * Stops the current optimizer
  64152. */
  64153. stop(): void;
  64154. /**
  64155. * Reset the optimizer to initial step (current priority level = 0)
  64156. */
  64157. reset(): void;
  64158. /**
  64159. * Start the optimizer. By default it will try to reach a specific framerate
  64160. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64161. */
  64162. start(): void;
  64163. private _checkCurrentState;
  64164. /**
  64165. * Release all resources
  64166. */
  64167. dispose(): void;
  64168. /**
  64169. * Helper function to create a SceneOptimizer with one single line of code
  64170. * @param scene defines the scene to work on
  64171. * @param options defines the options to use with the SceneOptimizer
  64172. * @param onSuccess defines a callback to call on success
  64173. * @param onFailure defines a callback to call on failure
  64174. * @returns the new SceneOptimizer object
  64175. */
  64176. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64177. }
  64178. }
  64179. declare module BABYLON {
  64180. /**
  64181. * Class used to serialize a scene into a string
  64182. */
  64183. export class SceneSerializer {
  64184. /**
  64185. * Clear cache used by a previous serialization
  64186. */
  64187. static ClearCache(): void;
  64188. /**
  64189. * Serialize a scene into a JSON compatible object
  64190. * @param scene defines the scene to serialize
  64191. * @returns a JSON compatible object
  64192. */
  64193. static Serialize(scene: Scene): any;
  64194. /**
  64195. * Serialize a mesh into a JSON compatible object
  64196. * @param toSerialize defines the mesh to serialize
  64197. * @param withParents defines if parents must be serialized as well
  64198. * @param withChildren defines if children must be serialized as well
  64199. * @returns a JSON compatible object
  64200. */
  64201. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64202. }
  64203. }
  64204. declare module BABYLON {
  64205. /**
  64206. * Class used to host texture specific utilities
  64207. */
  64208. export class TextureTools {
  64209. /**
  64210. * Uses the GPU to create a copy texture rescaled at a given size
  64211. * @param texture Texture to copy from
  64212. * @param width defines the desired width
  64213. * @param height defines the desired height
  64214. * @param useBilinearMode defines if bilinear mode has to be used
  64215. * @return the generated texture
  64216. */
  64217. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64218. }
  64219. }
  64220. declare module BABYLON {
  64221. /**
  64222. * This represents the different options available for the video capture.
  64223. */
  64224. export interface VideoRecorderOptions {
  64225. /** Defines the mime type of the video. */
  64226. mimeType: string;
  64227. /** Defines the FPS the video should be recorded at. */
  64228. fps: number;
  64229. /** Defines the chunk size for the recording data. */
  64230. recordChunckSize: number;
  64231. /** The audio tracks to attach to the recording. */
  64232. audioTracks?: MediaStreamTrack[];
  64233. }
  64234. /**
  64235. * This can help with recording videos from BabylonJS.
  64236. * This is based on the available WebRTC functionalities of the browser.
  64237. *
  64238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64239. */
  64240. export class VideoRecorder {
  64241. private static readonly _defaultOptions;
  64242. /**
  64243. * Returns whether or not the VideoRecorder is available in your browser.
  64244. * @param engine Defines the Babylon Engine.
  64245. * @returns true if supported otherwise false.
  64246. */
  64247. static IsSupported(engine: Engine): boolean;
  64248. private readonly _options;
  64249. private _canvas;
  64250. private _mediaRecorder;
  64251. private _recordedChunks;
  64252. private _fileName;
  64253. private _resolve;
  64254. private _reject;
  64255. /**
  64256. * True when a recording is already in progress.
  64257. */
  64258. readonly isRecording: boolean;
  64259. /**
  64260. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64261. * @param engine Defines the BabylonJS Engine you wish to record.
  64262. * @param options Defines options that can be used to customize the capture.
  64263. */
  64264. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64265. /**
  64266. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64267. */
  64268. stopRecording(): void;
  64269. /**
  64270. * Starts recording the canvas for a max duration specified in parameters.
  64271. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64272. * If null no automatic download will start and you can rely on the promise to get the data back.
  64273. * @param maxDuration Defines the maximum recording time in seconds.
  64274. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64275. * @return A promise callback at the end of the recording with the video data in Blob.
  64276. */
  64277. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64278. /**
  64279. * Releases internal resources used during the recording.
  64280. */
  64281. dispose(): void;
  64282. private _handleDataAvailable;
  64283. private _handleError;
  64284. private _handleStop;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * Class containing a set of static utilities functions for screenshots
  64290. */
  64291. export class ScreenshotTools {
  64292. /**
  64293. * Captures a screenshot of the current rendering
  64294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64295. * @param engine defines the rendering engine
  64296. * @param camera defines the source camera
  64297. * @param size This parameter can be set to a single number or to an object with the
  64298. * following (optional) properties: precision, width, height. If a single number is passed,
  64299. * it will be used for both width and height. If an object is passed, the screenshot size
  64300. * will be derived from the parameters. The precision property is a multiplier allowing
  64301. * rendering at a higher or lower resolution
  64302. * @param successCallback defines the callback receives a single parameter which contains the
  64303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64304. * src parameter of an <img> to display it
  64305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64306. * Check your browser for supported MIME types
  64307. */
  64308. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64309. /**
  64310. * Captures a screenshot of the current rendering
  64311. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64312. * @param engine defines the rendering engine
  64313. * @param camera defines the source camera
  64314. * @param size This parameter can be set to a single number or to an object with the
  64315. * following (optional) properties: precision, width, height. If a single number is passed,
  64316. * it will be used for both width and height. If an object is passed, the screenshot size
  64317. * will be derived from the parameters. The precision property is a multiplier allowing
  64318. * rendering at a higher or lower resolution
  64319. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64320. * Check your browser for supported MIME types
  64321. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64322. * to the src parameter of an <img> to display it
  64323. */
  64324. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64325. /**
  64326. * Generates an image screenshot from the specified camera.
  64327. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64328. * @param engine The engine to use for rendering
  64329. * @param camera The camera to use for rendering
  64330. * @param size This parameter can be set to a single number or to an object with the
  64331. * following (optional) properties: precision, width, height. If a single number is passed,
  64332. * it will be used for both width and height. If an object is passed, the screenshot size
  64333. * will be derived from the parameters. The precision property is a multiplier allowing
  64334. * rendering at a higher or lower resolution
  64335. * @param successCallback The callback receives a single parameter which contains the
  64336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64337. * src parameter of an <img> to display it
  64338. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64339. * Check your browser for supported MIME types
  64340. * @param samples Texture samples (default: 1)
  64341. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64342. * @param fileName A name for for the downloaded file.
  64343. */
  64344. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64345. /**
  64346. * Generates an image screenshot from the specified camera.
  64347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64348. * @param engine The engine to use for rendering
  64349. * @param camera The camera to use for rendering
  64350. * @param size This parameter can be set to a single number or to an object with the
  64351. * following (optional) properties: precision, width, height. If a single number is passed,
  64352. * it will be used for both width and height. If an object is passed, the screenshot size
  64353. * will be derived from the parameters. The precision property is a multiplier allowing
  64354. * rendering at a higher or lower resolution
  64355. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64356. * Check your browser for supported MIME types
  64357. * @param samples Texture samples (default: 1)
  64358. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64359. * @param fileName A name for for the downloaded file.
  64360. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64361. * to the src parameter of an <img> to display it
  64362. */
  64363. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64364. /**
  64365. * Gets height and width for screenshot size
  64366. * @private
  64367. */
  64368. private static _getScreenshotSize;
  64369. }
  64370. }
  64371. declare module BABYLON {
  64372. /**
  64373. * Interface for a data buffer
  64374. */
  64375. export interface IDataBuffer {
  64376. /**
  64377. * Reads bytes from the data buffer.
  64378. * @param byteOffset The byte offset to read
  64379. * @param byteLength The byte length to read
  64380. * @returns A promise that resolves when the bytes are read
  64381. */
  64382. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64383. /**
  64384. * The byte length of the buffer.
  64385. */
  64386. readonly byteLength: number;
  64387. }
  64388. /**
  64389. * Utility class for reading from a data buffer
  64390. */
  64391. export class DataReader {
  64392. /**
  64393. * The data buffer associated with this data reader.
  64394. */
  64395. readonly buffer: IDataBuffer;
  64396. /**
  64397. * The current byte offset from the beginning of the data buffer.
  64398. */
  64399. byteOffset: number;
  64400. private _dataView;
  64401. private _dataByteOffset;
  64402. /**
  64403. * Constructor
  64404. * @param buffer The buffer to read
  64405. */
  64406. constructor(buffer: IDataBuffer);
  64407. /**
  64408. * Loads the given byte length.
  64409. * @param byteLength The byte length to load
  64410. * @returns A promise that resolves when the load is complete
  64411. */
  64412. loadAsync(byteLength: number): Promise<void>;
  64413. /**
  64414. * Read a unsigned 32-bit integer from the currently loaded data range.
  64415. * @returns The 32-bit integer read
  64416. */
  64417. readUint32(): number;
  64418. /**
  64419. * Read a byte array from the currently loaded data range.
  64420. * @param byteLength The byte length to read
  64421. * @returns The byte array read
  64422. */
  64423. readUint8Array(byteLength: number): Uint8Array;
  64424. /**
  64425. * Read a string from the currently loaded data range.
  64426. * @param byteLength The byte length to read
  64427. * @returns The string read
  64428. */
  64429. readString(byteLength: number): string;
  64430. /**
  64431. * Skips the given byte length the currently loaded data range.
  64432. * @param byteLength The byte length to skip
  64433. */
  64434. skipBytes(byteLength: number): void;
  64435. }
  64436. }
  64437. declare module BABYLON {
  64438. /**
  64439. * A cursor which tracks a point on a path
  64440. */
  64441. export class PathCursor {
  64442. private path;
  64443. /**
  64444. * Stores path cursor callbacks for when an onchange event is triggered
  64445. */
  64446. private _onchange;
  64447. /**
  64448. * The value of the path cursor
  64449. */
  64450. value: number;
  64451. /**
  64452. * The animation array of the path cursor
  64453. */
  64454. animations: Animation[];
  64455. /**
  64456. * Initializes the path cursor
  64457. * @param path The path to track
  64458. */
  64459. constructor(path: Path2);
  64460. /**
  64461. * Gets the cursor point on the path
  64462. * @returns A point on the path cursor at the cursor location
  64463. */
  64464. getPoint(): Vector3;
  64465. /**
  64466. * Moves the cursor ahead by the step amount
  64467. * @param step The amount to move the cursor forward
  64468. * @returns This path cursor
  64469. */
  64470. moveAhead(step?: number): PathCursor;
  64471. /**
  64472. * Moves the cursor behind by the step amount
  64473. * @param step The amount to move the cursor back
  64474. * @returns This path cursor
  64475. */
  64476. moveBack(step?: number): PathCursor;
  64477. /**
  64478. * Moves the cursor by the step amount
  64479. * If the step amount is greater than one, an exception is thrown
  64480. * @param step The amount to move the cursor
  64481. * @returns This path cursor
  64482. */
  64483. move(step: number): PathCursor;
  64484. /**
  64485. * Ensures that the value is limited between zero and one
  64486. * @returns This path cursor
  64487. */
  64488. private ensureLimits;
  64489. /**
  64490. * Runs onchange callbacks on change (used by the animation engine)
  64491. * @returns This path cursor
  64492. */
  64493. private raiseOnChange;
  64494. /**
  64495. * Executes a function on change
  64496. * @param f A path cursor onchange callback
  64497. * @returns This path cursor
  64498. */
  64499. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64500. }
  64501. }
  64502. declare module BABYLON {
  64503. /** @hidden */
  64504. export var blurPixelShader: {
  64505. name: string;
  64506. shader: string;
  64507. };
  64508. }
  64509. declare module BABYLON {
  64510. /** @hidden */
  64511. export var pointCloudVertexDeclaration: {
  64512. name: string;
  64513. shader: string;
  64514. };
  64515. }
  64516. // Mixins
  64517. interface Window {
  64518. mozIndexedDB: IDBFactory;
  64519. webkitIndexedDB: IDBFactory;
  64520. msIndexedDB: IDBFactory;
  64521. webkitURL: typeof URL;
  64522. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64523. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64524. WebGLRenderingContext: WebGLRenderingContext;
  64525. MSGesture: MSGesture;
  64526. CANNON: any;
  64527. AudioContext: AudioContext;
  64528. webkitAudioContext: AudioContext;
  64529. PointerEvent: any;
  64530. Math: Math;
  64531. Uint8Array: Uint8ArrayConstructor;
  64532. Float32Array: Float32ArrayConstructor;
  64533. mozURL: typeof URL;
  64534. msURL: typeof URL;
  64535. VRFrameData: any; // WebVR, from specs 1.1
  64536. DracoDecoderModule: any;
  64537. setImmediate(handler: (...args: any[]) => void): number;
  64538. }
  64539. interface HTMLCanvasElement {
  64540. requestPointerLock(): void;
  64541. msRequestPointerLock?(): void;
  64542. mozRequestPointerLock?(): void;
  64543. webkitRequestPointerLock?(): void;
  64544. /** Track wether a record is in progress */
  64545. isRecording: boolean;
  64546. /** Capture Stream method defined by some browsers */
  64547. captureStream(fps?: number): MediaStream;
  64548. }
  64549. interface CanvasRenderingContext2D {
  64550. msImageSmoothingEnabled: boolean;
  64551. }
  64552. interface MouseEvent {
  64553. mozMovementX: number;
  64554. mozMovementY: number;
  64555. webkitMovementX: number;
  64556. webkitMovementY: number;
  64557. msMovementX: number;
  64558. msMovementY: number;
  64559. }
  64560. interface Navigator {
  64561. mozGetVRDevices: (any: any) => any;
  64562. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64563. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64564. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64565. webkitGetGamepads(): Gamepad[];
  64566. msGetGamepads(): Gamepad[];
  64567. webkitGamepads(): Gamepad[];
  64568. }
  64569. interface HTMLVideoElement {
  64570. mozSrcObject: any;
  64571. }
  64572. interface Math {
  64573. fround(x: number): number;
  64574. imul(a: number, b: number): number;
  64575. }
  64576. interface WebGLRenderingContext {
  64577. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64578. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64579. vertexAttribDivisor(index: number, divisor: number): void;
  64580. createVertexArray(): any;
  64581. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64582. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64583. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64584. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64585. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64586. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64587. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64588. // Queries
  64589. createQuery(): WebGLQuery;
  64590. deleteQuery(query: WebGLQuery): void;
  64591. beginQuery(target: number, query: WebGLQuery): void;
  64592. endQuery(target: number): void;
  64593. getQueryParameter(query: WebGLQuery, pname: number): any;
  64594. getQuery(target: number, pname: number): any;
  64595. MAX_SAMPLES: number;
  64596. RGBA8: number;
  64597. READ_FRAMEBUFFER: number;
  64598. DRAW_FRAMEBUFFER: number;
  64599. UNIFORM_BUFFER: number;
  64600. HALF_FLOAT_OES: number;
  64601. RGBA16F: number;
  64602. RGBA32F: number;
  64603. R32F: number;
  64604. RG32F: number;
  64605. RGB32F: number;
  64606. R16F: number;
  64607. RG16F: number;
  64608. RGB16F: number;
  64609. RED: number;
  64610. RG: number;
  64611. R8: number;
  64612. RG8: number;
  64613. UNSIGNED_INT_24_8: number;
  64614. DEPTH24_STENCIL8: number;
  64615. MIN: number;
  64616. MAX: number;
  64617. /* Multiple Render Targets */
  64618. drawBuffers(buffers: number[]): void;
  64619. readBuffer(src: number): void;
  64620. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64621. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64622. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64623. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64624. // Occlusion Query
  64625. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64626. ANY_SAMPLES_PASSED: number;
  64627. QUERY_RESULT_AVAILABLE: number;
  64628. QUERY_RESULT: number;
  64629. }
  64630. interface WebGLProgram {
  64631. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64632. }
  64633. interface EXT_disjoint_timer_query {
  64634. QUERY_COUNTER_BITS_EXT: number;
  64635. TIME_ELAPSED_EXT: number;
  64636. TIMESTAMP_EXT: number;
  64637. GPU_DISJOINT_EXT: number;
  64638. QUERY_RESULT_EXT: number;
  64639. QUERY_RESULT_AVAILABLE_EXT: number;
  64640. queryCounterEXT(query: WebGLQuery, target: number): void;
  64641. createQueryEXT(): WebGLQuery;
  64642. beginQueryEXT(target: number, query: WebGLQuery): void;
  64643. endQueryEXT(target: number): void;
  64644. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64645. deleteQueryEXT(query: WebGLQuery): void;
  64646. }
  64647. interface WebGLUniformLocation {
  64648. _currentState: any;
  64649. }
  64650. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64651. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64652. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64653. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64654. interface WebGLRenderingContext {
  64655. readonly RASTERIZER_DISCARD: number;
  64656. readonly DEPTH_COMPONENT24: number;
  64657. readonly TEXTURE_3D: number;
  64658. readonly TEXTURE_2D_ARRAY: number;
  64659. readonly TEXTURE_COMPARE_FUNC: number;
  64660. readonly TEXTURE_COMPARE_MODE: number;
  64661. readonly COMPARE_REF_TO_TEXTURE: number;
  64662. readonly TEXTURE_WRAP_R: number;
  64663. readonly HALF_FLOAT: number;
  64664. readonly RGB8: number;
  64665. readonly RED_INTEGER: number;
  64666. readonly RG_INTEGER: number;
  64667. readonly RGB_INTEGER: number;
  64668. readonly RGBA_INTEGER: number;
  64669. readonly R8_SNORM: number;
  64670. readonly RG8_SNORM: number;
  64671. readonly RGB8_SNORM: number;
  64672. readonly RGBA8_SNORM: number;
  64673. readonly R8I: number;
  64674. readonly RG8I: number;
  64675. readonly RGB8I: number;
  64676. readonly RGBA8I: number;
  64677. readonly R8UI: number;
  64678. readonly RG8UI: number;
  64679. readonly RGB8UI: number;
  64680. readonly RGBA8UI: number;
  64681. readonly R16I: number;
  64682. readonly RG16I: number;
  64683. readonly RGB16I: number;
  64684. readonly RGBA16I: number;
  64685. readonly R16UI: number;
  64686. readonly RG16UI: number;
  64687. readonly RGB16UI: number;
  64688. readonly RGBA16UI: number;
  64689. readonly R32I: number;
  64690. readonly RG32I: number;
  64691. readonly RGB32I: number;
  64692. readonly RGBA32I: number;
  64693. readonly R32UI: number;
  64694. readonly RG32UI: number;
  64695. readonly RGB32UI: number;
  64696. readonly RGBA32UI: number;
  64697. readonly RGB10_A2UI: number;
  64698. readonly R11F_G11F_B10F: number;
  64699. readonly RGB9_E5: number;
  64700. readonly RGB10_A2: number;
  64701. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64702. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64703. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64704. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64705. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64706. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64707. 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;
  64708. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64709. readonly TRANSFORM_FEEDBACK: number;
  64710. readonly INTERLEAVED_ATTRIBS: number;
  64711. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64712. createTransformFeedback(): WebGLTransformFeedback;
  64713. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64714. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64715. beginTransformFeedback(primitiveMode: number): void;
  64716. endTransformFeedback(): void;
  64717. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64718. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64719. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64720. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64721. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64722. }
  64723. interface ImageBitmap {
  64724. readonly width: number;
  64725. readonly height: number;
  64726. close(): void;
  64727. }
  64728. interface WebGLQuery extends WebGLObject {
  64729. }
  64730. declare var WebGLQuery: {
  64731. prototype: WebGLQuery;
  64732. new(): WebGLQuery;
  64733. };
  64734. interface WebGLSampler extends WebGLObject {
  64735. }
  64736. declare var WebGLSampler: {
  64737. prototype: WebGLSampler;
  64738. new(): WebGLSampler;
  64739. };
  64740. interface WebGLSync extends WebGLObject {
  64741. }
  64742. declare var WebGLSync: {
  64743. prototype: WebGLSync;
  64744. new(): WebGLSync;
  64745. };
  64746. interface WebGLTransformFeedback extends WebGLObject {
  64747. }
  64748. declare var WebGLTransformFeedback: {
  64749. prototype: WebGLTransformFeedback;
  64750. new(): WebGLTransformFeedback;
  64751. };
  64752. interface WebGLVertexArrayObject extends WebGLObject {
  64753. }
  64754. declare var WebGLVertexArrayObject: {
  64755. prototype: WebGLVertexArrayObject;
  64756. new(): WebGLVertexArrayObject;
  64757. };
  64758. // Type definitions for WebVR API
  64759. // Project: https://w3c.github.io/webvr/
  64760. // Definitions by: six a <https://github.com/lostfictions>
  64761. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64762. interface VRDisplay extends EventTarget {
  64763. /**
  64764. * Dictionary of capabilities describing the VRDisplay.
  64765. */
  64766. readonly capabilities: VRDisplayCapabilities;
  64767. /**
  64768. * z-depth defining the far plane of the eye view frustum
  64769. * enables mapping of values in the render target depth
  64770. * attachment to scene coordinates. Initially set to 10000.0.
  64771. */
  64772. depthFar: number;
  64773. /**
  64774. * z-depth defining the near plane of the eye view frustum
  64775. * enables mapping of values in the render target depth
  64776. * attachment to scene coordinates. Initially set to 0.01.
  64777. */
  64778. depthNear: number;
  64779. /**
  64780. * An identifier for this distinct VRDisplay. Used as an
  64781. * association point in the Gamepad API.
  64782. */
  64783. readonly displayId: number;
  64784. /**
  64785. * A display name, a user-readable name identifying it.
  64786. */
  64787. readonly displayName: string;
  64788. readonly isConnected: boolean;
  64789. readonly isPresenting: boolean;
  64790. /**
  64791. * If this VRDisplay supports room-scale experiences, the optional
  64792. * stage attribute contains details on the room-scale parameters.
  64793. */
  64794. readonly stageParameters: VRStageParameters | null;
  64795. /**
  64796. * Passing the value returned by `requestAnimationFrame` to
  64797. * `cancelAnimationFrame` will unregister the callback.
  64798. * @param handle Define the hanle of the request to cancel
  64799. */
  64800. cancelAnimationFrame(handle: number): void;
  64801. /**
  64802. * Stops presenting to the VRDisplay.
  64803. * @returns a promise to know when it stopped
  64804. */
  64805. exitPresent(): Promise<void>;
  64806. /**
  64807. * Return the current VREyeParameters for the given eye.
  64808. * @param whichEye Define the eye we want the parameter for
  64809. * @returns the eye parameters
  64810. */
  64811. getEyeParameters(whichEye: string): VREyeParameters;
  64812. /**
  64813. * Populates the passed VRFrameData with the information required to render
  64814. * the current frame.
  64815. * @param frameData Define the data structure to populate
  64816. * @returns true if ok otherwise false
  64817. */
  64818. getFrameData(frameData: VRFrameData): boolean;
  64819. /**
  64820. * Get the layers currently being presented.
  64821. * @returns the list of VR layers
  64822. */
  64823. getLayers(): VRLayer[];
  64824. /**
  64825. * Return a VRPose containing the future predicted pose of the VRDisplay
  64826. * when the current frame will be presented. The value returned will not
  64827. * change until JavaScript has returned control to the browser.
  64828. *
  64829. * The VRPose will contain the position, orientation, velocity,
  64830. * and acceleration of each of these properties.
  64831. * @returns the pose object
  64832. */
  64833. getPose(): VRPose;
  64834. /**
  64835. * Return the current instantaneous pose of the VRDisplay, with no
  64836. * prediction applied.
  64837. * @returns the current instantaneous pose
  64838. */
  64839. getImmediatePose(): VRPose;
  64840. /**
  64841. * The callback passed to `requestAnimationFrame` will be called
  64842. * any time a new frame should be rendered. When the VRDisplay is
  64843. * presenting the callback will be called at the native refresh
  64844. * rate of the HMD. When not presenting this function acts
  64845. * identically to how window.requestAnimationFrame acts. Content should
  64846. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64847. * asynchronously from other displays and at differing refresh rates.
  64848. * @param callback Define the eaction to run next frame
  64849. * @returns the request handle it
  64850. */
  64851. requestAnimationFrame(callback: FrameRequestCallback): number;
  64852. /**
  64853. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64854. * Repeat calls while already presenting will update the VRLayers being displayed.
  64855. * @param layers Define the list of layer to present
  64856. * @returns a promise to know when the request has been fulfilled
  64857. */
  64858. requestPresent(layers: VRLayer[]): Promise<void>;
  64859. /**
  64860. * Reset the pose for this display, treating its current position and
  64861. * orientation as the "origin/zero" values. VRPose.position,
  64862. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64863. * updated when calling resetPose(). This should be called in only
  64864. * sitting-space experiences.
  64865. */
  64866. resetPose(): void;
  64867. /**
  64868. * The VRLayer provided to the VRDisplay will be captured and presented
  64869. * in the HMD. Calling this function has the same effect on the source
  64870. * canvas as any other operation that uses its source image, and canvases
  64871. * created without preserveDrawingBuffer set to true will be cleared.
  64872. * @param pose Define the pose to submit
  64873. */
  64874. submitFrame(pose?: VRPose): void;
  64875. }
  64876. declare var VRDisplay: {
  64877. prototype: VRDisplay;
  64878. new(): VRDisplay;
  64879. };
  64880. interface VRLayer {
  64881. leftBounds?: number[] | Float32Array | null;
  64882. rightBounds?: number[] | Float32Array | null;
  64883. source?: HTMLCanvasElement | null;
  64884. }
  64885. interface VRDisplayCapabilities {
  64886. readonly canPresent: boolean;
  64887. readonly hasExternalDisplay: boolean;
  64888. readonly hasOrientation: boolean;
  64889. readonly hasPosition: boolean;
  64890. readonly maxLayers: number;
  64891. }
  64892. interface VREyeParameters {
  64893. /** @deprecated */
  64894. readonly fieldOfView: VRFieldOfView;
  64895. readonly offset: Float32Array;
  64896. readonly renderHeight: number;
  64897. readonly renderWidth: number;
  64898. }
  64899. interface VRFieldOfView {
  64900. readonly downDegrees: number;
  64901. readonly leftDegrees: number;
  64902. readonly rightDegrees: number;
  64903. readonly upDegrees: number;
  64904. }
  64905. interface VRFrameData {
  64906. readonly leftProjectionMatrix: Float32Array;
  64907. readonly leftViewMatrix: Float32Array;
  64908. readonly pose: VRPose;
  64909. readonly rightProjectionMatrix: Float32Array;
  64910. readonly rightViewMatrix: Float32Array;
  64911. readonly timestamp: number;
  64912. }
  64913. interface VRPose {
  64914. readonly angularAcceleration: Float32Array | null;
  64915. readonly angularVelocity: Float32Array | null;
  64916. readonly linearAcceleration: Float32Array | null;
  64917. readonly linearVelocity: Float32Array | null;
  64918. readonly orientation: Float32Array | null;
  64919. readonly position: Float32Array | null;
  64920. readonly timestamp: number;
  64921. }
  64922. interface VRStageParameters {
  64923. sittingToStandingTransform?: Float32Array;
  64924. sizeX?: number;
  64925. sizeY?: number;
  64926. }
  64927. interface Navigator {
  64928. getVRDisplays(): Promise<VRDisplay[]>;
  64929. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64930. }
  64931. interface Window {
  64932. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64933. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64934. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64935. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64936. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64937. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64938. }
  64939. interface Gamepad {
  64940. readonly displayId: number;
  64941. }
  64942. type XRSessionMode =
  64943. | "inline"
  64944. | "immersive-vr"
  64945. | "immersive-ar";
  64946. type XRReferenceSpaceType =
  64947. | "viewer"
  64948. | "local"
  64949. | "local-floor"
  64950. | "bounded-floor"
  64951. | "unbounded";
  64952. type XREnvironmentBlendMode =
  64953. | "opaque"
  64954. | "additive"
  64955. | "alpha-blend";
  64956. type XRVisibilityState =
  64957. | "visible"
  64958. | "visible-blurred"
  64959. | "hidden";
  64960. type XRHandedness =
  64961. | "none"
  64962. | "left"
  64963. | "right";
  64964. type XRTargetRayMode =
  64965. | "gaze"
  64966. | "tracked-pointer"
  64967. | "screen";
  64968. type XREye =
  64969. | "none"
  64970. | "left"
  64971. | "right";
  64972. interface XRSpace extends EventTarget {
  64973. }
  64974. interface XRRenderState {
  64975. depthNear?: number;
  64976. depthFar?: number;
  64977. inlineVerticalFieldOfView?: number;
  64978. baseLayer?: XRWebGLLayer;
  64979. }
  64980. interface XRInputSource {
  64981. handedness: XRHandedness;
  64982. targetRayMode: XRTargetRayMode;
  64983. targetRaySpace: XRSpace;
  64984. gripSpace: XRSpace | undefined;
  64985. gamepad: Gamepad | undefined;
  64986. profiles: Array<string>;
  64987. }
  64988. interface XRSession {
  64989. addEventListener: Function;
  64990. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64991. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64992. requestAnimationFrame: Function;
  64993. end(): Promise<void>;
  64994. renderState: XRRenderState;
  64995. inputSources: Array<XRInputSource>;
  64996. }
  64997. interface XRReferenceSpace extends XRSpace {
  64998. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64999. onreset: any;
  65000. }
  65001. interface XRFrame {
  65002. session: XRSession;
  65003. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  65004. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  65005. }
  65006. interface XRViewerPose extends XRPose {
  65007. views: Array<XRView>;
  65008. }
  65009. interface XRPose {
  65010. transform: XRRigidTransform;
  65011. emulatedPosition: boolean;
  65012. }
  65013. declare var XRWebGLLayer: {
  65014. prototype: XRWebGLLayer;
  65015. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  65016. };
  65017. interface XRWebGLLayer {
  65018. framebuffer: WebGLFramebuffer;
  65019. framebufferWidth: number;
  65020. framebufferHeight: number;
  65021. getViewport: Function;
  65022. }
  65023. interface XRRigidTransform {
  65024. position: DOMPointReadOnly;
  65025. orientation: DOMPointReadOnly;
  65026. matrix: Float32Array;
  65027. inverse: XRRigidTransform;
  65028. }
  65029. interface XRView {
  65030. eye: XREye;
  65031. projectionMatrix: Float32Array;
  65032. transform: XRRigidTransform;
  65033. }
  65034. interface XRInputSourceChangeEvent {
  65035. session: XRSession;
  65036. removed: Array<XRInputSource>;
  65037. added: Array<XRInputSource>;
  65038. }
  65039. /**
  65040. * @ignore
  65041. */
  65042. declare module BABYLON.GLTF2.Exporter {
  65043. }
  65044. /**
  65045. * @ignore
  65046. */
  65047. declare module BABYLON.GLTF1 {
  65048. }
  65049. declare module BABYLON.GUI {
  65050. /**
  65051. * Class used to specific a value and its associated unit
  65052. */
  65053. export class ValueAndUnit {
  65054. /** defines the unit to store */
  65055. unit: number;
  65056. /** defines a boolean indicating if the value can be negative */
  65057. negativeValueAllowed: boolean;
  65058. private _value;
  65059. private _originalUnit;
  65060. /**
  65061. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  65062. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65063. */
  65064. ignoreAdaptiveScaling: boolean;
  65065. /**
  65066. * Creates a new ValueAndUnit
  65067. * @param value defines the value to store
  65068. * @param unit defines the unit to store
  65069. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  65070. */
  65071. constructor(value: number,
  65072. /** defines the unit to store */
  65073. unit?: number,
  65074. /** defines a boolean indicating if the value can be negative */
  65075. negativeValueAllowed?: boolean);
  65076. /** Gets a boolean indicating if the value is a percentage */
  65077. readonly isPercentage: boolean;
  65078. /** Gets a boolean indicating if the value is store as pixel */
  65079. readonly isPixel: boolean;
  65080. /** Gets direct internal value */
  65081. readonly internalValue: number;
  65082. /**
  65083. * Gets value as pixel
  65084. * @param host defines the root host
  65085. * @param refValue defines the reference value for percentages
  65086. * @returns the value as pixel
  65087. */
  65088. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  65089. /**
  65090. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  65091. * @param value defines the value to store
  65092. * @param unit defines the unit to store
  65093. * @returns the current ValueAndUnit
  65094. */
  65095. updateInPlace(value: number, unit?: number): ValueAndUnit;
  65096. /**
  65097. * Gets the value accordingly to its unit
  65098. * @param host defines the root host
  65099. * @returns the value
  65100. */
  65101. getValue(host: AdvancedDynamicTexture): number;
  65102. /**
  65103. * Gets a string representation of the value
  65104. * @param host defines the root host
  65105. * @param decimals defines an optional number of decimals to display
  65106. * @returns a string
  65107. */
  65108. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  65109. /**
  65110. * Store a value parsed from a string
  65111. * @param source defines the source string
  65112. * @returns true if the value was successfully parsed
  65113. */
  65114. fromString(source: string | number): boolean;
  65115. private static _Regex;
  65116. private static _UNITMODE_PERCENTAGE;
  65117. private static _UNITMODE_PIXEL;
  65118. /** UNITMODE_PERCENTAGE */
  65119. static readonly UNITMODE_PERCENTAGE: number;
  65120. /** UNITMODE_PIXEL */
  65121. static readonly UNITMODE_PIXEL: number;
  65122. }
  65123. }
  65124. declare module BABYLON.GUI {
  65125. /**
  65126. * Define a style used by control to automatically setup properties based on a template.
  65127. * Only support font related properties so far
  65128. */
  65129. export class Style implements BABYLON.IDisposable {
  65130. private _fontFamily;
  65131. private _fontStyle;
  65132. private _fontWeight;
  65133. /** @hidden */
  65134. _host: AdvancedDynamicTexture;
  65135. /** @hidden */
  65136. _fontSize: ValueAndUnit;
  65137. /**
  65138. * BABYLON.Observable raised when the style values are changed
  65139. */
  65140. onChangedObservable: BABYLON.Observable<Style>;
  65141. /**
  65142. * Creates a new style object
  65143. * @param host defines the AdvancedDynamicTexture which hosts this style
  65144. */
  65145. constructor(host: AdvancedDynamicTexture);
  65146. /**
  65147. * Gets or sets the font size
  65148. */
  65149. fontSize: string | number;
  65150. /**
  65151. * Gets or sets the font family
  65152. */
  65153. fontFamily: string;
  65154. /**
  65155. * Gets or sets the font style
  65156. */
  65157. fontStyle: string;
  65158. /** Gets or sets font weight */
  65159. fontWeight: string;
  65160. /** Dispose all associated resources */
  65161. dispose(): void;
  65162. }
  65163. }
  65164. declare module BABYLON.GUI {
  65165. /**
  65166. * Class used to transport BABYLON.Vector2 information for pointer events
  65167. */
  65168. export class Vector2WithInfo extends BABYLON.Vector2 {
  65169. /** defines the current mouse button index */
  65170. buttonIndex: number;
  65171. /**
  65172. * Creates a new Vector2WithInfo
  65173. * @param source defines the vector2 data to transport
  65174. * @param buttonIndex defines the current mouse button index
  65175. */
  65176. constructor(source: BABYLON.Vector2,
  65177. /** defines the current mouse button index */
  65178. buttonIndex?: number);
  65179. }
  65180. /** Class used to provide 2D matrix features */
  65181. export class Matrix2D {
  65182. /** Gets the internal array of 6 floats used to store matrix data */
  65183. m: Float32Array;
  65184. /**
  65185. * Creates a new matrix
  65186. * @param m00 defines value for (0, 0)
  65187. * @param m01 defines value for (0, 1)
  65188. * @param m10 defines value for (1, 0)
  65189. * @param m11 defines value for (1, 1)
  65190. * @param m20 defines value for (2, 0)
  65191. * @param m21 defines value for (2, 1)
  65192. */
  65193. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  65194. /**
  65195. * Fills the matrix from direct values
  65196. * @param m00 defines value for (0, 0)
  65197. * @param m01 defines value for (0, 1)
  65198. * @param m10 defines value for (1, 0)
  65199. * @param m11 defines value for (1, 1)
  65200. * @param m20 defines value for (2, 0)
  65201. * @param m21 defines value for (2, 1)
  65202. * @returns the current modified matrix
  65203. */
  65204. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  65205. /**
  65206. * Gets matrix determinant
  65207. * @returns the determinant
  65208. */
  65209. determinant(): number;
  65210. /**
  65211. * Inverses the matrix and stores it in a target matrix
  65212. * @param result defines the target matrix
  65213. * @returns the current matrix
  65214. */
  65215. invertToRef(result: Matrix2D): Matrix2D;
  65216. /**
  65217. * Multiplies the current matrix with another one
  65218. * @param other defines the second operand
  65219. * @param result defines the target matrix
  65220. * @returns the current matrix
  65221. */
  65222. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  65223. /**
  65224. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  65225. * @param x defines the x coordinate to transform
  65226. * @param y defines the x coordinate to transform
  65227. * @param result defines the target vector2
  65228. * @returns the current matrix
  65229. */
  65230. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  65231. /**
  65232. * Creates an identity matrix
  65233. * @returns a new matrix
  65234. */
  65235. static Identity(): Matrix2D;
  65236. /**
  65237. * Creates a translation matrix and stores it in a target matrix
  65238. * @param x defines the x coordinate of the translation
  65239. * @param y defines the y coordinate of the translation
  65240. * @param result defines the target matrix
  65241. */
  65242. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  65243. /**
  65244. * Creates a scaling matrix and stores it in a target matrix
  65245. * @param x defines the x coordinate of the scaling
  65246. * @param y defines the y coordinate of the scaling
  65247. * @param result defines the target matrix
  65248. */
  65249. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  65250. /**
  65251. * Creates a rotation matrix and stores it in a target matrix
  65252. * @param angle defines the rotation angle
  65253. * @param result defines the target matrix
  65254. */
  65255. static RotationToRef(angle: number, result: Matrix2D): void;
  65256. private static _TempPreTranslationMatrix;
  65257. private static _TempPostTranslationMatrix;
  65258. private static _TempRotationMatrix;
  65259. private static _TempScalingMatrix;
  65260. private static _TempCompose0;
  65261. private static _TempCompose1;
  65262. private static _TempCompose2;
  65263. /**
  65264. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  65265. * @param tx defines the x coordinate of the translation
  65266. * @param ty defines the y coordinate of the translation
  65267. * @param angle defines the rotation angle
  65268. * @param scaleX defines the x coordinate of the scaling
  65269. * @param scaleY defines the y coordinate of the scaling
  65270. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  65271. * @param result defines the target matrix
  65272. */
  65273. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  65274. }
  65275. }
  65276. declare module BABYLON.GUI {
  65277. /**
  65278. * Class used to store 2D control sizes
  65279. */
  65280. export class Measure {
  65281. /** defines left coordinate */
  65282. left: number;
  65283. /** defines top coordinate */
  65284. top: number;
  65285. /** defines width dimension */
  65286. width: number;
  65287. /** defines height dimension */
  65288. height: number;
  65289. /**
  65290. * Creates a new measure
  65291. * @param left defines left coordinate
  65292. * @param top defines top coordinate
  65293. * @param width defines width dimension
  65294. * @param height defines height dimension
  65295. */
  65296. constructor(
  65297. /** defines left coordinate */
  65298. left: number,
  65299. /** defines top coordinate */
  65300. top: number,
  65301. /** defines width dimension */
  65302. width: number,
  65303. /** defines height dimension */
  65304. height: number);
  65305. /**
  65306. * Copy from another measure
  65307. * @param other defines the other measure to copy from
  65308. */
  65309. copyFrom(other: Measure): void;
  65310. /**
  65311. * Copy from a group of 4 floats
  65312. * @param left defines left coordinate
  65313. * @param top defines top coordinate
  65314. * @param width defines width dimension
  65315. * @param height defines height dimension
  65316. */
  65317. copyFromFloats(left: number, top: number, width: number, height: number): void;
  65318. /**
  65319. * Computes the axis aligned bounding box measure for two given measures
  65320. * @param a Input measure
  65321. * @param b Input measure
  65322. * @param result the resulting bounding measure
  65323. */
  65324. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  65325. /**
  65326. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  65327. * @param transform the matrix to transform the measure before computing the AABB
  65328. * @param result the resulting AABB
  65329. */
  65330. transformToRef(transform: Matrix2D, result: Measure): void;
  65331. /**
  65332. * Check equality between this measure and another one
  65333. * @param other defines the other measures
  65334. * @returns true if both measures are equals
  65335. */
  65336. isEqualsTo(other: Measure): boolean;
  65337. /**
  65338. * Creates an empty measure
  65339. * @returns a new measure
  65340. */
  65341. static Empty(): Measure;
  65342. }
  65343. }
  65344. declare module BABYLON.GUI {
  65345. /**
  65346. * Interface used to define a control that can receive focus
  65347. */
  65348. export interface IFocusableControl {
  65349. /**
  65350. * Function called when the control receives the focus
  65351. */
  65352. onFocus(): void;
  65353. /**
  65354. * Function called when the control loses the focus
  65355. */
  65356. onBlur(): void;
  65357. /**
  65358. * Function called to let the control handle keyboard events
  65359. * @param evt defines the current keyboard event
  65360. */
  65361. processKeyboard(evt: KeyboardEvent): void;
  65362. /**
  65363. * Function called to get the list of controls that should not steal the focus from this control
  65364. * @returns an array of controls
  65365. */
  65366. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65367. }
  65368. /**
  65369. * Class used to create texture to support 2D GUI elements
  65370. * @see http://doc.babylonjs.com/how_to/gui
  65371. */
  65372. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  65373. private _isDirty;
  65374. private _renderObserver;
  65375. private _resizeObserver;
  65376. private _preKeyboardObserver;
  65377. private _pointerMoveObserver;
  65378. private _pointerObserver;
  65379. private _canvasPointerOutObserver;
  65380. private _background;
  65381. /** @hidden */
  65382. _rootContainer: Container;
  65383. /** @hidden */
  65384. _lastPickedControl: Control;
  65385. /** @hidden */
  65386. _lastControlOver: {
  65387. [pointerId: number]: Control;
  65388. };
  65389. /** @hidden */
  65390. _lastControlDown: {
  65391. [pointerId: number]: Control;
  65392. };
  65393. /** @hidden */
  65394. _capturingControl: {
  65395. [pointerId: number]: Control;
  65396. };
  65397. /** @hidden */
  65398. _shouldBlockPointer: boolean;
  65399. /** @hidden */
  65400. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  65401. /** @hidden */
  65402. _linkedControls: Control[];
  65403. private _isFullscreen;
  65404. private _fullscreenViewport;
  65405. private _idealWidth;
  65406. private _idealHeight;
  65407. private _useSmallestIdeal;
  65408. private _renderAtIdealSize;
  65409. private _focusedControl;
  65410. private _blockNextFocusCheck;
  65411. private _renderScale;
  65412. private _rootElement;
  65413. private _cursorChanged;
  65414. /**
  65415. * Define type to string to ensure compatibility across browsers
  65416. * Safari doesn't support DataTransfer constructor
  65417. */
  65418. private _clipboardData;
  65419. /**
  65420. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  65421. */
  65422. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  65423. /**
  65424. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  65425. */
  65426. onControlPickedObservable: BABYLON.Observable<Control>;
  65427. /**
  65428. * BABYLON.Observable event triggered before layout is evaluated
  65429. */
  65430. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65431. /**
  65432. * BABYLON.Observable event triggered after the layout was evaluated
  65433. */
  65434. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65435. /**
  65436. * BABYLON.Observable event triggered before the texture is rendered
  65437. */
  65438. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65439. /**
  65440. * BABYLON.Observable event triggered after the texture was rendered
  65441. */
  65442. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65443. /**
  65444. * Gets or sets a boolean defining if alpha is stored as premultiplied
  65445. */
  65446. premulAlpha: boolean;
  65447. /**
  65448. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  65449. * Useful when you want more antialiasing
  65450. */
  65451. renderScale: number;
  65452. /** Gets or sets the background color */
  65453. background: string;
  65454. /**
  65455. * Gets or sets the ideal width used to design controls.
  65456. * The GUI will then rescale everything accordingly
  65457. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65458. */
  65459. idealWidth: number;
  65460. /**
  65461. * Gets or sets the ideal height used to design controls.
  65462. * The GUI will then rescale everything accordingly
  65463. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65464. */
  65465. idealHeight: number;
  65466. /**
  65467. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  65468. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65469. */
  65470. useSmallestIdeal: boolean;
  65471. /**
  65472. * Gets or sets a boolean indicating if adaptive scaling must be used
  65473. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65474. */
  65475. renderAtIdealSize: boolean;
  65476. /**
  65477. * Gets the underlying layer used to render the texture when in fullscreen mode
  65478. */
  65479. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  65480. /**
  65481. * Gets the root container control
  65482. */
  65483. readonly rootContainer: Container;
  65484. /**
  65485. * Returns an array containing the root container.
  65486. * This is mostly used to let the Inspector introspects the ADT
  65487. * @returns an array containing the rootContainer
  65488. */
  65489. getChildren(): Array<Container>;
  65490. /**
  65491. * Will return all controls that are inside this texture
  65492. * @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
  65493. * @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
  65494. * @return all child controls
  65495. */
  65496. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65497. /**
  65498. * Gets or sets the current focused control
  65499. */
  65500. focusedControl: BABYLON.Nullable<IFocusableControl>;
  65501. /**
  65502. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  65503. */
  65504. isForeground: boolean;
  65505. /**
  65506. * Gets or set information about clipboardData
  65507. */
  65508. clipboardData: string;
  65509. /**
  65510. * Creates a new AdvancedDynamicTexture
  65511. * @param name defines the name of the texture
  65512. * @param width defines the width of the texture
  65513. * @param height defines the height of the texture
  65514. * @param scene defines the hosting scene
  65515. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  65516. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  65517. */
  65518. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  65519. /**
  65520. * Get the current class name of the texture useful for serialization or dynamic coding.
  65521. * @returns "AdvancedDynamicTexture"
  65522. */
  65523. getClassName(): string;
  65524. /**
  65525. * Function used to execute a function on all controls
  65526. * @param func defines the function to execute
  65527. * @param container defines the container where controls belong. If null the root container will be used
  65528. */
  65529. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  65530. private _useInvalidateRectOptimization;
  65531. /**
  65532. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  65533. */
  65534. useInvalidateRectOptimization: boolean;
  65535. private _invalidatedRectangle;
  65536. /**
  65537. * Invalidates a rectangle area on the gui texture
  65538. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  65539. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  65540. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  65541. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  65542. */
  65543. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  65544. /**
  65545. * Marks the texture as dirty forcing a complete update
  65546. */
  65547. markAsDirty(): void;
  65548. /**
  65549. * Helper function used to create a new style
  65550. * @returns a new style
  65551. * @see http://doc.babylonjs.com/how_to/gui#styles
  65552. */
  65553. createStyle(): Style;
  65554. /**
  65555. * Adds a new control to the root container
  65556. * @param control defines the control to add
  65557. * @returns the current texture
  65558. */
  65559. addControl(control: Control): AdvancedDynamicTexture;
  65560. /**
  65561. * Removes a control from the root container
  65562. * @param control defines the control to remove
  65563. * @returns the current texture
  65564. */
  65565. removeControl(control: Control): AdvancedDynamicTexture;
  65566. /**
  65567. * Release all resources
  65568. */
  65569. dispose(): void;
  65570. private _onResize;
  65571. /** @hidden */
  65572. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  65573. /**
  65574. * Get screen coordinates for a vector3
  65575. * @param position defines the position to project
  65576. * @param worldMatrix defines the world matrix to use
  65577. * @returns the projected position
  65578. */
  65579. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  65580. private _checkUpdate;
  65581. private _clearMeasure;
  65582. private _render;
  65583. /** @hidden */
  65584. _changeCursor(cursor: string): void;
  65585. /** @hidden */
  65586. _registerLastControlDown(control: Control, pointerId: number): void;
  65587. private _doPicking;
  65588. /** @hidden */
  65589. _cleanControlAfterRemovalFromList(list: {
  65590. [pointerId: number]: Control;
  65591. }, control: Control): void;
  65592. /** @hidden */
  65593. _cleanControlAfterRemoval(control: Control): void;
  65594. /** Attach to all scene events required to support pointer events */
  65595. attach(): void;
  65596. /** @hidden */
  65597. private onClipboardCopy;
  65598. /** @hidden */
  65599. private onClipboardCut;
  65600. /** @hidden */
  65601. private onClipboardPaste;
  65602. /**
  65603. * Register the clipboard Events onto the canvas
  65604. */
  65605. registerClipboardEvents(): void;
  65606. /**
  65607. * Unregister the clipboard Events from the canvas
  65608. */
  65609. unRegisterClipboardEvents(): void;
  65610. /**
  65611. * Connect the texture to a hosting mesh to enable interactions
  65612. * @param mesh defines the mesh to attach to
  65613. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  65614. */
  65615. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  65616. /**
  65617. * Move the focus to a specific control
  65618. * @param control defines the control which will receive the focus
  65619. */
  65620. moveFocusToControl(control: IFocusableControl): void;
  65621. private _manageFocus;
  65622. private _attachToOnPointerOut;
  65623. /**
  65624. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  65625. * @param mesh defines the mesh which will receive the texture
  65626. * @param width defines the texture width (1024 by default)
  65627. * @param height defines the texture height (1024 by default)
  65628. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  65629. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  65630. * @returns a new AdvancedDynamicTexture
  65631. */
  65632. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  65633. /**
  65634. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  65635. * In this mode the texture will rely on a layer for its rendering.
  65636. * This allows it to be treated like any other layer.
  65637. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  65638. * LayerMask is set through advancedTexture.layer.layerMask
  65639. * @param name defines name for the texture
  65640. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  65641. * @param scene defines the hsoting scene
  65642. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  65643. * @returns a new AdvancedDynamicTexture
  65644. */
  65645. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  65646. }
  65647. }
  65648. declare module BABYLON.GUI {
  65649. /**
  65650. * Root class used for all 2D controls
  65651. * @see http://doc.babylonjs.com/how_to/gui#controls
  65652. */
  65653. export class Control {
  65654. /** defines the name of the control */
  65655. name?: string | undefined;
  65656. /**
  65657. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  65658. */
  65659. static AllowAlphaInheritance: boolean;
  65660. private _alpha;
  65661. private _alphaSet;
  65662. private _zIndex;
  65663. /** @hidden */
  65664. _host: AdvancedDynamicTexture;
  65665. /** Gets or sets the control parent */
  65666. parent: BABYLON.Nullable<Container>;
  65667. /** @hidden */
  65668. _currentMeasure: Measure;
  65669. private _fontFamily;
  65670. private _fontStyle;
  65671. private _fontWeight;
  65672. private _fontSize;
  65673. private _font;
  65674. /** @hidden */
  65675. _width: ValueAndUnit;
  65676. /** @hidden */
  65677. _height: ValueAndUnit;
  65678. /** @hidden */
  65679. protected _fontOffset: {
  65680. ascent: number;
  65681. height: number;
  65682. descent: number;
  65683. };
  65684. private _color;
  65685. private _style;
  65686. private _styleObserver;
  65687. /** @hidden */
  65688. protected _horizontalAlignment: number;
  65689. /** @hidden */
  65690. protected _verticalAlignment: number;
  65691. /** @hidden */
  65692. protected _isDirty: boolean;
  65693. /** @hidden */
  65694. protected _wasDirty: boolean;
  65695. /** @hidden */
  65696. _tempParentMeasure: Measure;
  65697. /** @hidden */
  65698. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65699. /** @hidden */
  65700. protected _cachedParentMeasure: Measure;
  65701. private _paddingLeft;
  65702. private _paddingRight;
  65703. private _paddingTop;
  65704. private _paddingBottom;
  65705. /** @hidden */
  65706. _left: ValueAndUnit;
  65707. /** @hidden */
  65708. _top: ValueAndUnit;
  65709. private _scaleX;
  65710. private _scaleY;
  65711. private _rotation;
  65712. private _transformCenterX;
  65713. private _transformCenterY;
  65714. /** @hidden */
  65715. _transformMatrix: Matrix2D;
  65716. /** @hidden */
  65717. protected _invertTransformMatrix: Matrix2D;
  65718. /** @hidden */
  65719. protected _transformedPosition: BABYLON.Vector2;
  65720. private _isMatrixDirty;
  65721. private _cachedOffsetX;
  65722. private _cachedOffsetY;
  65723. private _isVisible;
  65724. private _isHighlighted;
  65725. /** @hidden */
  65726. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65727. private _fontSet;
  65728. private _dummyVector2;
  65729. private _downCount;
  65730. private _enterCount;
  65731. private _doNotRender;
  65732. private _downPointerIds;
  65733. protected _isEnabled: boolean;
  65734. protected _disabledColor: string;
  65735. /** @hidden */
  65736. protected _rebuildLayout: boolean;
  65737. /** @hidden */
  65738. _isClipped: boolean;
  65739. /** @hidden */
  65740. _tag: any;
  65741. /**
  65742. * 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
  65743. */
  65744. uniqueId: number;
  65745. /**
  65746. * Gets or sets an object used to store user defined information for the node
  65747. */
  65748. metadata: any;
  65749. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65750. isHitTestVisible: boolean;
  65751. /** Gets or sets a boolean indicating if the control can block pointer events */
  65752. isPointerBlocker: boolean;
  65753. /** Gets or sets a boolean indicating if the control can be focusable */
  65754. isFocusInvisible: boolean;
  65755. /**
  65756. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65757. * 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
  65758. */
  65759. clipChildren: boolean;
  65760. /**
  65761. * Gets or sets a boolean indicating that control content must be clipped
  65762. * 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
  65763. */
  65764. clipContent: boolean;
  65765. /**
  65766. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65767. */
  65768. useBitmapCache: boolean;
  65769. private _cacheData;
  65770. private _shadowOffsetX;
  65771. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65772. shadowOffsetX: number;
  65773. private _shadowOffsetY;
  65774. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65775. shadowOffsetY: number;
  65776. private _shadowBlur;
  65777. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65778. shadowBlur: number;
  65779. private _shadowColor;
  65780. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65781. shadowColor: string;
  65782. /** Gets or sets the cursor to use when the control is hovered */
  65783. hoverCursor: string;
  65784. /** @hidden */
  65785. protected _linkOffsetX: ValueAndUnit;
  65786. /** @hidden */
  65787. protected _linkOffsetY: ValueAndUnit;
  65788. /** Gets the control type name */
  65789. readonly typeName: string;
  65790. /**
  65791. * Get the current class name of the control.
  65792. * @returns current class name
  65793. */
  65794. getClassName(): string;
  65795. /**
  65796. * An event triggered when the pointer move over the control.
  65797. */
  65798. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65799. /**
  65800. * An event triggered when the pointer move out of the control.
  65801. */
  65802. onPointerOutObservable: BABYLON.Observable<Control>;
  65803. /**
  65804. * An event triggered when the pointer taps the control
  65805. */
  65806. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65807. /**
  65808. * An event triggered when pointer up
  65809. */
  65810. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65811. /**
  65812. * An event triggered when a control is clicked on
  65813. */
  65814. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65815. /**
  65816. * An event triggered when pointer enters the control
  65817. */
  65818. onPointerEnterObservable: BABYLON.Observable<Control>;
  65819. /**
  65820. * An event triggered when the control is marked as dirty
  65821. */
  65822. onDirtyObservable: BABYLON.Observable<Control>;
  65823. /**
  65824. * An event triggered before drawing the control
  65825. */
  65826. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65827. /**
  65828. * An event triggered after the control was drawn
  65829. */
  65830. onAfterDrawObservable: BABYLON.Observable<Control>;
  65831. /**
  65832. * Get the hosting AdvancedDynamicTexture
  65833. */
  65834. readonly host: AdvancedDynamicTexture;
  65835. /** Gets or set information about font offsets (used to render and align text) */
  65836. fontOffset: {
  65837. ascent: number;
  65838. height: number;
  65839. descent: number;
  65840. };
  65841. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65842. alpha: number;
  65843. /**
  65844. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65845. */
  65846. isHighlighted: boolean;
  65847. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65848. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65849. */
  65850. scaleX: number;
  65851. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65852. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65853. */
  65854. scaleY: number;
  65855. /** Gets or sets the rotation angle (0 by default)
  65856. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65857. */
  65858. rotation: number;
  65859. /** Gets or sets the transformation center on Y axis (0 by default)
  65860. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65861. */
  65862. transformCenterY: number;
  65863. /** Gets or sets the transformation center on X axis (0 by default)
  65864. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65865. */
  65866. transformCenterX: number;
  65867. /**
  65868. * Gets or sets the horizontal alignment
  65869. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65870. */
  65871. horizontalAlignment: number;
  65872. /**
  65873. * Gets or sets the vertical alignment
  65874. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65875. */
  65876. verticalAlignment: number;
  65877. /**
  65878. * Gets or sets control width
  65879. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65880. */
  65881. width: string | number;
  65882. /**
  65883. * Gets or sets the control width in pixel
  65884. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65885. */
  65886. widthInPixels: number;
  65887. /**
  65888. * Gets or sets control height
  65889. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65890. */
  65891. height: string | number;
  65892. /**
  65893. * Gets or sets control height in pixel
  65894. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65895. */
  65896. heightInPixels: number;
  65897. /** Gets or set font family */
  65898. fontFamily: string;
  65899. /** Gets or sets font style */
  65900. fontStyle: string;
  65901. /** Gets or sets font weight */
  65902. fontWeight: string;
  65903. /**
  65904. * Gets or sets style
  65905. * @see http://doc.babylonjs.com/how_to/gui#styles
  65906. */
  65907. style: BABYLON.Nullable<Style>;
  65908. /** @hidden */
  65909. readonly _isFontSizeInPercentage: boolean;
  65910. /** Gets or sets font size in pixels */
  65911. fontSizeInPixels: number;
  65912. /** Gets or sets font size */
  65913. fontSize: string | number;
  65914. /** Gets or sets foreground color */
  65915. color: string;
  65916. /** Gets or sets z index which is used to reorder controls on the z axis */
  65917. zIndex: number;
  65918. /** Gets or sets a boolean indicating if the control can be rendered */
  65919. notRenderable: boolean;
  65920. /** Gets or sets a boolean indicating if the control is visible */
  65921. isVisible: boolean;
  65922. /** Gets a boolean indicating that the control needs to update its rendering */
  65923. readonly isDirty: boolean;
  65924. /**
  65925. * Gets the current linked mesh (or null if none)
  65926. */
  65927. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65928. /**
  65929. * Gets or sets a value indicating the padding to use on the left of the control
  65930. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65931. */
  65932. paddingLeft: string | number;
  65933. /**
  65934. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65936. */
  65937. paddingLeftInPixels: number;
  65938. /**
  65939. * Gets or sets a value indicating the padding to use on the right of the control
  65940. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65941. */
  65942. paddingRight: string | number;
  65943. /**
  65944. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65946. */
  65947. paddingRightInPixels: number;
  65948. /**
  65949. * Gets or sets a value indicating the padding to use on the top of the control
  65950. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65951. */
  65952. paddingTop: string | number;
  65953. /**
  65954. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65955. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65956. */
  65957. paddingTopInPixels: number;
  65958. /**
  65959. * Gets or sets a value indicating the padding to use on the bottom of the control
  65960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65961. */
  65962. paddingBottom: string | number;
  65963. /**
  65964. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65966. */
  65967. paddingBottomInPixels: number;
  65968. /**
  65969. * Gets or sets a value indicating the left coordinate of the control
  65970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65971. */
  65972. left: string | number;
  65973. /**
  65974. * Gets or sets a value indicating the left coordinate in pixels of the control
  65975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65976. */
  65977. leftInPixels: number;
  65978. /**
  65979. * Gets or sets a value indicating the top coordinate of the control
  65980. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65981. */
  65982. top: string | number;
  65983. /**
  65984. * Gets or sets a value indicating the top coordinate in pixels of the control
  65985. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65986. */
  65987. topInPixels: number;
  65988. /**
  65989. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65990. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65991. */
  65992. linkOffsetX: string | number;
  65993. /**
  65994. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65995. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65996. */
  65997. linkOffsetXInPixels: number;
  65998. /**
  65999. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  66000. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66001. */
  66002. linkOffsetY: string | number;
  66003. /**
  66004. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  66005. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66006. */
  66007. linkOffsetYInPixels: number;
  66008. /** Gets the center coordinate on X axis */
  66009. readonly centerX: number;
  66010. /** Gets the center coordinate on Y axis */
  66011. readonly centerY: number;
  66012. /** Gets or sets if control is Enabled*/
  66013. isEnabled: boolean;
  66014. /** Gets or sets background color of control if it's disabled*/
  66015. disabledColor: string;
  66016. /**
  66017. * Creates a new control
  66018. * @param name defines the name of the control
  66019. */
  66020. constructor(
  66021. /** defines the name of the control */
  66022. name?: string | undefined);
  66023. /** @hidden */
  66024. protected _getTypeName(): string;
  66025. /**
  66026. * Gets the first ascendant in the hierarchy of the given type
  66027. * @param className defines the required type
  66028. * @returns the ascendant or null if not found
  66029. */
  66030. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  66031. /** @hidden */
  66032. _resetFontCache(): void;
  66033. /**
  66034. * Determines if a container is an ascendant of the current control
  66035. * @param container defines the container to look for
  66036. * @returns true if the container is one of the ascendant of the control
  66037. */
  66038. isAscendant(container: Control): boolean;
  66039. /**
  66040. * Gets coordinates in local control space
  66041. * @param globalCoordinates defines the coordinates to transform
  66042. * @returns the new coordinates in local space
  66043. */
  66044. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66045. /**
  66046. * Gets coordinates in local control space
  66047. * @param globalCoordinates defines the coordinates to transform
  66048. * @param result defines the target vector2 where to store the result
  66049. * @returns the current control
  66050. */
  66051. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  66052. /**
  66053. * Gets coordinates in parent local control space
  66054. * @param globalCoordinates defines the coordinates to transform
  66055. * @returns the new coordinates in parent local space
  66056. */
  66057. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66058. /**
  66059. * Move the current control to a vector3 position projected onto the screen.
  66060. * @param position defines the target position
  66061. * @param scene defines the hosting scene
  66062. */
  66063. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  66064. /** @hidden */
  66065. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66066. /**
  66067. * Will return all controls that have this control as ascendant
  66068. * @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
  66069. * @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
  66070. * @return all child controls
  66071. */
  66072. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66073. /**
  66074. * Link current control with a target mesh
  66075. * @param mesh defines the mesh to link with
  66076. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66077. */
  66078. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  66079. /** @hidden */
  66080. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  66081. /** @hidden */
  66082. _offsetLeft(offset: number): void;
  66083. /** @hidden */
  66084. _offsetTop(offset: number): void;
  66085. /** @hidden */
  66086. _markMatrixAsDirty(): void;
  66087. /** @hidden */
  66088. _flagDescendantsAsMatrixDirty(): void;
  66089. /** @hidden */
  66090. _intersectsRect(rect: Measure): boolean;
  66091. /** @hidden */
  66092. protected invalidateRect(): void;
  66093. /** @hidden */
  66094. _markAsDirty(force?: boolean): void;
  66095. /** @hidden */
  66096. _markAllAsDirty(): void;
  66097. /** @hidden */
  66098. _link(host: AdvancedDynamicTexture): void;
  66099. /** @hidden */
  66100. protected _transform(context?: CanvasRenderingContext2D): void;
  66101. /** @hidden */
  66102. _renderHighlight(context: CanvasRenderingContext2D): void;
  66103. /** @hidden */
  66104. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66105. /** @hidden */
  66106. protected _applyStates(context: CanvasRenderingContext2D): void;
  66107. /** @hidden */
  66108. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66109. /** @hidden */
  66110. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66111. protected _evaluateClippingState(parentMeasure: Measure): void;
  66112. /** @hidden */
  66113. _measure(): void;
  66114. /** @hidden */
  66115. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66116. /** @hidden */
  66117. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66118. /** @hidden */
  66119. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66120. /** @hidden */
  66121. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66122. private static _ClipMeasure;
  66123. private _tmpMeasureA;
  66124. private _clip;
  66125. /** @hidden */
  66126. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  66127. /** @hidden */
  66128. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  66129. /**
  66130. * Tests if a given coordinates belong to the current control
  66131. * @param x defines x coordinate to test
  66132. * @param y defines y coordinate to test
  66133. * @returns true if the coordinates are inside the control
  66134. */
  66135. contains(x: number, y: number): boolean;
  66136. /** @hidden */
  66137. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66138. /** @hidden */
  66139. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66140. /** @hidden */
  66141. _onPointerEnter(target: Control): boolean;
  66142. /** @hidden */
  66143. _onPointerOut(target: Control, force?: boolean): void;
  66144. /** @hidden */
  66145. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66146. /** @hidden */
  66147. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66148. /** @hidden */
  66149. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66150. /** @hidden */
  66151. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  66152. private _prepareFont;
  66153. /** Releases associated resources */
  66154. dispose(): void;
  66155. private static _HORIZONTAL_ALIGNMENT_LEFT;
  66156. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  66157. private static _HORIZONTAL_ALIGNMENT_CENTER;
  66158. private static _VERTICAL_ALIGNMENT_TOP;
  66159. private static _VERTICAL_ALIGNMENT_BOTTOM;
  66160. private static _VERTICAL_ALIGNMENT_CENTER;
  66161. /** HORIZONTAL_ALIGNMENT_LEFT */
  66162. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  66163. /** HORIZONTAL_ALIGNMENT_RIGHT */
  66164. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  66165. /** HORIZONTAL_ALIGNMENT_CENTER */
  66166. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  66167. /** VERTICAL_ALIGNMENT_TOP */
  66168. static readonly VERTICAL_ALIGNMENT_TOP: number;
  66169. /** VERTICAL_ALIGNMENT_BOTTOM */
  66170. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  66171. /** VERTICAL_ALIGNMENT_CENTER */
  66172. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  66173. private static _FontHeightSizes;
  66174. /** @hidden */
  66175. static _GetFontOffset(font: string): {
  66176. ascent: number;
  66177. height: number;
  66178. descent: number;
  66179. };
  66180. /**
  66181. * Creates a stack panel that can be used to render headers
  66182. * @param control defines the control to associate with the header
  66183. * @param text defines the text of the header
  66184. * @param size defines the size of the header
  66185. * @param options defines options used to configure the header
  66186. * @returns a new StackPanel
  66187. * @ignore
  66188. * @hidden
  66189. */
  66190. static AddHeader: (control: Control, text: string, size: string | number, options: {
  66191. isHorizontal: boolean;
  66192. controlFirst: boolean;
  66193. }) => any;
  66194. /** @hidden */
  66195. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  66196. }
  66197. }
  66198. declare module BABYLON.GUI {
  66199. /**
  66200. * Root class for 2D containers
  66201. * @see http://doc.babylonjs.com/how_to/gui#containers
  66202. */
  66203. export class Container extends Control {
  66204. name?: string | undefined;
  66205. /** @hidden */
  66206. protected _children: Control[];
  66207. /** @hidden */
  66208. protected _measureForChildren: Measure;
  66209. /** @hidden */
  66210. protected _background: string;
  66211. /** @hidden */
  66212. protected _adaptWidthToChildren: boolean;
  66213. /** @hidden */
  66214. protected _adaptHeightToChildren: boolean;
  66215. /**
  66216. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  66217. */
  66218. logLayoutCycleErrors: boolean;
  66219. /**
  66220. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  66221. */
  66222. maxLayoutCycle: number;
  66223. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  66224. adaptHeightToChildren: boolean;
  66225. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  66226. adaptWidthToChildren: boolean;
  66227. /** Gets or sets background color */
  66228. background: string;
  66229. /** Gets the list of children */
  66230. readonly children: Control[];
  66231. /**
  66232. * Creates a new Container
  66233. * @param name defines the name of the container
  66234. */
  66235. constructor(name?: string | undefined);
  66236. protected _getTypeName(): string;
  66237. _flagDescendantsAsMatrixDirty(): void;
  66238. /**
  66239. * Gets a child using its name
  66240. * @param name defines the child name to look for
  66241. * @returns the child control if found
  66242. */
  66243. getChildByName(name: string): BABYLON.Nullable<Control>;
  66244. /**
  66245. * Gets a child using its type and its name
  66246. * @param name defines the child name to look for
  66247. * @param type defines the child type to look for
  66248. * @returns the child control if found
  66249. */
  66250. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  66251. /**
  66252. * Search for a specific control in children
  66253. * @param control defines the control to look for
  66254. * @returns true if the control is in child list
  66255. */
  66256. containsControl(control: Control): boolean;
  66257. /**
  66258. * Adds a new control to the current container
  66259. * @param control defines the control to add
  66260. * @returns the current container
  66261. */
  66262. addControl(control: BABYLON.Nullable<Control>): Container;
  66263. /**
  66264. * Removes all controls from the current container
  66265. * @returns the current container
  66266. */
  66267. clearControls(): Container;
  66268. /**
  66269. * Removes a control from the current container
  66270. * @param control defines the control to remove
  66271. * @returns the current container
  66272. */
  66273. removeControl(control: Control): Container;
  66274. /** @hidden */
  66275. _reOrderControl(control: Control): void;
  66276. /** @hidden */
  66277. _offsetLeft(offset: number): void;
  66278. /** @hidden */
  66279. _offsetTop(offset: number): void;
  66280. /** @hidden */
  66281. _markAllAsDirty(): void;
  66282. /** @hidden */
  66283. protected _localDraw(context: CanvasRenderingContext2D): void;
  66284. /** @hidden */
  66285. _link(host: AdvancedDynamicTexture): void;
  66286. /** @hidden */
  66287. protected _beforeLayout(): void;
  66288. /** @hidden */
  66289. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66290. /** @hidden */
  66291. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66292. protected _postMeasure(): void;
  66293. /** @hidden */
  66294. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  66295. /** @hidden */
  66296. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66297. /** @hidden */
  66298. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66299. /** @hidden */
  66300. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66301. /** Releases associated resources */
  66302. dispose(): void;
  66303. }
  66304. }
  66305. declare module BABYLON.GUI {
  66306. /** Class used to create rectangle container */
  66307. export class Rectangle extends Container {
  66308. name?: string | undefined;
  66309. private _thickness;
  66310. private _cornerRadius;
  66311. /** Gets or sets border thickness */
  66312. thickness: number;
  66313. /** Gets or sets the corner radius angle */
  66314. cornerRadius: number;
  66315. /**
  66316. * Creates a new Rectangle
  66317. * @param name defines the control name
  66318. */
  66319. constructor(name?: string | undefined);
  66320. protected _getTypeName(): string;
  66321. protected _localDraw(context: CanvasRenderingContext2D): void;
  66322. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66323. private _drawRoundedRect;
  66324. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66325. }
  66326. }
  66327. declare module BABYLON.GUI {
  66328. /**
  66329. * Enum that determines the text-wrapping mode to use.
  66330. */
  66331. export enum TextWrapping {
  66332. /**
  66333. * Clip the text when it's larger than Control.width; this is the default mode.
  66334. */
  66335. Clip = 0,
  66336. /**
  66337. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  66338. */
  66339. WordWrap = 1,
  66340. /**
  66341. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  66342. */
  66343. Ellipsis = 2
  66344. }
  66345. /**
  66346. * Class used to create text block control
  66347. */
  66348. export class TextBlock extends Control {
  66349. /**
  66350. * Defines the name of the control
  66351. */
  66352. name?: string | undefined;
  66353. private _text;
  66354. private _textWrapping;
  66355. private _textHorizontalAlignment;
  66356. private _textVerticalAlignment;
  66357. private _lines;
  66358. private _resizeToFit;
  66359. private _lineSpacing;
  66360. private _outlineWidth;
  66361. private _outlineColor;
  66362. /**
  66363. * An event triggered after the text is changed
  66364. */
  66365. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  66366. /**
  66367. * An event triggered after the text was broken up into lines
  66368. */
  66369. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  66370. /**
  66371. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  66372. */
  66373. readonly lines: any[];
  66374. /**
  66375. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66376. */
  66377. /**
  66378. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66379. */
  66380. resizeToFit: boolean;
  66381. /**
  66382. * Gets or sets a boolean indicating if text must be wrapped
  66383. */
  66384. /**
  66385. * Gets or sets a boolean indicating if text must be wrapped
  66386. */
  66387. textWrapping: TextWrapping | boolean;
  66388. /**
  66389. * Gets or sets text to display
  66390. */
  66391. /**
  66392. * Gets or sets text to display
  66393. */
  66394. text: string;
  66395. /**
  66396. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66397. */
  66398. /**
  66399. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66400. */
  66401. textHorizontalAlignment: number;
  66402. /**
  66403. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66404. */
  66405. /**
  66406. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66407. */
  66408. textVerticalAlignment: number;
  66409. /**
  66410. * Gets or sets line spacing value
  66411. */
  66412. /**
  66413. * Gets or sets line spacing value
  66414. */
  66415. lineSpacing: string | number;
  66416. /**
  66417. * Gets or sets outlineWidth of the text to display
  66418. */
  66419. /**
  66420. * Gets or sets outlineWidth of the text to display
  66421. */
  66422. outlineWidth: number;
  66423. /**
  66424. * Gets or sets outlineColor of the text to display
  66425. */
  66426. /**
  66427. * Gets or sets outlineColor of the text to display
  66428. */
  66429. outlineColor: string;
  66430. /**
  66431. * Creates a new TextBlock object
  66432. * @param name defines the name of the control
  66433. * @param text defines the text to display (emptry string by default)
  66434. */
  66435. constructor(
  66436. /**
  66437. * Defines the name of the control
  66438. */
  66439. name?: string | undefined, text?: string);
  66440. protected _getTypeName(): string;
  66441. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66442. private _drawText;
  66443. /** @hidden */
  66444. _draw(context: CanvasRenderingContext2D): void;
  66445. protected _applyStates(context: CanvasRenderingContext2D): void;
  66446. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  66447. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  66448. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  66449. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  66450. protected _renderLines(context: CanvasRenderingContext2D): void;
  66451. /**
  66452. * Given a width constraint applied on the text block, find the expected height
  66453. * @returns expected height
  66454. */
  66455. computeExpectedHeight(): number;
  66456. dispose(): void;
  66457. }
  66458. }
  66459. declare module BABYLON.GUI {
  66460. /**
  66461. * Class used to create 2D images
  66462. */
  66463. export class Image extends Control {
  66464. name?: string | undefined;
  66465. private _workingCanvas;
  66466. private _domImage;
  66467. private _imageWidth;
  66468. private _imageHeight;
  66469. private _loaded;
  66470. private _stretch;
  66471. private _source;
  66472. private _autoScale;
  66473. private _sourceLeft;
  66474. private _sourceTop;
  66475. private _sourceWidth;
  66476. private _sourceHeight;
  66477. private _cellWidth;
  66478. private _cellHeight;
  66479. private _cellId;
  66480. private _populateNinePatchSlicesFromImage;
  66481. private _sliceLeft;
  66482. private _sliceRight;
  66483. private _sliceTop;
  66484. private _sliceBottom;
  66485. private _detectPointerOnOpaqueOnly;
  66486. /**
  66487. * BABYLON.Observable notified when the content is loaded
  66488. */
  66489. onImageLoadedObservable: BABYLON.Observable<Image>;
  66490. /**
  66491. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  66492. */
  66493. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  66494. /**
  66495. * Gets a boolean indicating that the content is loaded
  66496. */
  66497. readonly isLoaded: boolean;
  66498. /**
  66499. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  66500. */
  66501. populateNinePatchSlicesFromImage: boolean;
  66502. /**
  66503. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  66504. * Beware using this as this will comsume more memory as the image has to be stored twice
  66505. */
  66506. detectPointerOnOpaqueOnly: boolean;
  66507. /**
  66508. * Gets or sets the left value for slicing (9-patch)
  66509. */
  66510. sliceLeft: number;
  66511. /**
  66512. * Gets or sets the right value for slicing (9-patch)
  66513. */
  66514. sliceRight: number;
  66515. /**
  66516. * Gets or sets the top value for slicing (9-patch)
  66517. */
  66518. sliceTop: number;
  66519. /**
  66520. * Gets or sets the bottom value for slicing (9-patch)
  66521. */
  66522. sliceBottom: number;
  66523. /**
  66524. * Gets or sets the left coordinate in the source image
  66525. */
  66526. sourceLeft: number;
  66527. /**
  66528. * Gets or sets the top coordinate in the source image
  66529. */
  66530. sourceTop: number;
  66531. /**
  66532. * Gets or sets the width to capture in the source image
  66533. */
  66534. sourceWidth: number;
  66535. /**
  66536. * Gets or sets the height to capture in the source image
  66537. */
  66538. sourceHeight: number;
  66539. /**
  66540. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  66541. * @see http://doc.babylonjs.com/how_to/gui#image
  66542. */
  66543. autoScale: boolean;
  66544. /** Gets or sets the streching mode used by the image */
  66545. stretch: number;
  66546. /**
  66547. * Gets or sets the internal DOM image used to render the control
  66548. */
  66549. domImage: HTMLImageElement;
  66550. private _onImageLoaded;
  66551. private _extractNinePatchSliceDataFromImage;
  66552. /**
  66553. * Gets or sets image source url
  66554. */
  66555. source: BABYLON.Nullable<string>;
  66556. /**
  66557. * Checks for svg document with icon id present
  66558. */
  66559. private _svgCheck;
  66560. /**
  66561. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  66562. * given external svg file and icon id
  66563. */
  66564. private _getSVGAttribs;
  66565. /**
  66566. * Gets or sets the cell width to use when animation sheet is enabled
  66567. * @see http://doc.babylonjs.com/how_to/gui#image
  66568. */
  66569. cellWidth: number;
  66570. /**
  66571. * Gets or sets the cell height to use when animation sheet is enabled
  66572. * @see http://doc.babylonjs.com/how_to/gui#image
  66573. */
  66574. cellHeight: number;
  66575. /**
  66576. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  66577. * @see http://doc.babylonjs.com/how_to/gui#image
  66578. */
  66579. cellId: number;
  66580. /**
  66581. * Creates a new Image
  66582. * @param name defines the control name
  66583. * @param url defines the image url
  66584. */
  66585. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  66586. /**
  66587. * Tests if a given coordinates belong to the current control
  66588. * @param x defines x coordinate to test
  66589. * @param y defines y coordinate to test
  66590. * @returns true if the coordinates are inside the control
  66591. */
  66592. contains(x: number, y: number): boolean;
  66593. protected _getTypeName(): string;
  66594. /** Force the control to synchronize with its content */
  66595. synchronizeSizeWithContent(): void;
  66596. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66597. private _prepareWorkingCanvasForOpaqueDetection;
  66598. private _drawImage;
  66599. _draw(context: CanvasRenderingContext2D): void;
  66600. private _renderCornerPatch;
  66601. private _renderNinePatch;
  66602. dispose(): void;
  66603. /** STRETCH_NONE */
  66604. static readonly STRETCH_NONE: number;
  66605. /** STRETCH_FILL */
  66606. static readonly STRETCH_FILL: number;
  66607. /** STRETCH_UNIFORM */
  66608. static readonly STRETCH_UNIFORM: number;
  66609. /** STRETCH_EXTEND */
  66610. static readonly STRETCH_EXTEND: number;
  66611. /** NINE_PATCH */
  66612. static readonly STRETCH_NINE_PATCH: number;
  66613. }
  66614. }
  66615. declare module BABYLON.GUI {
  66616. /**
  66617. * Class used to create 2D buttons
  66618. */
  66619. export class Button extends Rectangle {
  66620. name?: string | undefined;
  66621. /**
  66622. * Function called to generate a pointer enter animation
  66623. */
  66624. pointerEnterAnimation: () => void;
  66625. /**
  66626. * Function called to generate a pointer out animation
  66627. */
  66628. pointerOutAnimation: () => void;
  66629. /**
  66630. * Function called to generate a pointer down animation
  66631. */
  66632. pointerDownAnimation: () => void;
  66633. /**
  66634. * Function called to generate a pointer up animation
  66635. */
  66636. pointerUpAnimation: () => void;
  66637. /**
  66638. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  66639. */
  66640. delegatePickingToChildren: boolean;
  66641. private _image;
  66642. /**
  66643. * Returns the image part of the button (if any)
  66644. */
  66645. readonly image: BABYLON.Nullable<Image>;
  66646. private _textBlock;
  66647. /**
  66648. * Returns the image part of the button (if any)
  66649. */
  66650. readonly textBlock: BABYLON.Nullable<TextBlock>;
  66651. /**
  66652. * Creates a new Button
  66653. * @param name defines the name of the button
  66654. */
  66655. constructor(name?: string | undefined);
  66656. protected _getTypeName(): string;
  66657. /** @hidden */
  66658. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66659. /** @hidden */
  66660. _onPointerEnter(target: Control): boolean;
  66661. /** @hidden */
  66662. _onPointerOut(target: Control, force?: boolean): void;
  66663. /** @hidden */
  66664. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66665. /** @hidden */
  66666. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66667. /**
  66668. * Creates a new button made with an image and a text
  66669. * @param name defines the name of the button
  66670. * @param text defines the text of the button
  66671. * @param imageUrl defines the url of the image
  66672. * @returns a new Button
  66673. */
  66674. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  66675. /**
  66676. * Creates a new button made with an image
  66677. * @param name defines the name of the button
  66678. * @param imageUrl defines the url of the image
  66679. * @returns a new Button
  66680. */
  66681. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66682. /**
  66683. * Creates a new button made with a text
  66684. * @param name defines the name of the button
  66685. * @param text defines the text of the button
  66686. * @returns a new Button
  66687. */
  66688. static CreateSimpleButton(name: string, text: string): Button;
  66689. /**
  66690. * Creates a new button made with an image and a centered text
  66691. * @param name defines the name of the button
  66692. * @param text defines the text of the button
  66693. * @param imageUrl defines the url of the image
  66694. * @returns a new Button
  66695. */
  66696. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66697. }
  66698. }
  66699. declare module BABYLON.GUI {
  66700. /**
  66701. * Class used to create a 2D stack panel container
  66702. */
  66703. export class StackPanel extends Container {
  66704. name?: string | undefined;
  66705. private _isVertical;
  66706. private _manualWidth;
  66707. private _manualHeight;
  66708. private _doNotTrackManualChanges;
  66709. /**
  66710. * Gets or sets a boolean indicating that layou warnings should be ignored
  66711. */
  66712. ignoreLayoutWarnings: boolean;
  66713. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66714. isVertical: boolean;
  66715. /**
  66716. * Gets or sets panel width.
  66717. * This value should not be set when in horizontal mode as it will be computed automatically
  66718. */
  66719. width: string | number;
  66720. /**
  66721. * Gets or sets panel height.
  66722. * This value should not be set when in vertical mode as it will be computed automatically
  66723. */
  66724. height: string | number;
  66725. /**
  66726. * Creates a new StackPanel
  66727. * @param name defines control name
  66728. */
  66729. constructor(name?: string | undefined);
  66730. protected _getTypeName(): string;
  66731. /** @hidden */
  66732. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66733. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66734. protected _postMeasure(): void;
  66735. }
  66736. }
  66737. declare module BABYLON.GUI {
  66738. /**
  66739. * Class used to represent a 2D checkbox
  66740. */
  66741. export class Checkbox extends Control {
  66742. name?: string | undefined;
  66743. private _isChecked;
  66744. private _background;
  66745. private _checkSizeRatio;
  66746. private _thickness;
  66747. /** Gets or sets border thickness */
  66748. thickness: number;
  66749. /**
  66750. * BABYLON.Observable raised when isChecked property changes
  66751. */
  66752. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66753. /** Gets or sets a value indicating the ratio between overall size and check size */
  66754. checkSizeRatio: number;
  66755. /** Gets or sets background color */
  66756. background: string;
  66757. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66758. isChecked: boolean;
  66759. /**
  66760. * Creates a new CheckBox
  66761. * @param name defines the control name
  66762. */
  66763. constructor(name?: string | undefined);
  66764. protected _getTypeName(): string;
  66765. /** @hidden */
  66766. _draw(context: CanvasRenderingContext2D): void;
  66767. /** @hidden */
  66768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66769. /**
  66770. * Utility function to easily create a checkbox with a header
  66771. * @param title defines the label to use for the header
  66772. * @param onValueChanged defines the callback to call when value changes
  66773. * @returns a StackPanel containing the checkbox and a textBlock
  66774. */
  66775. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66776. }
  66777. }
  66778. declare module BABYLON.GUI {
  66779. /**
  66780. * Class used to store key control properties
  66781. */
  66782. export class KeyPropertySet {
  66783. /** Width */
  66784. width?: string;
  66785. /** Height */
  66786. height?: string;
  66787. /** Left padding */
  66788. paddingLeft?: string;
  66789. /** Right padding */
  66790. paddingRight?: string;
  66791. /** Top padding */
  66792. paddingTop?: string;
  66793. /** Bottom padding */
  66794. paddingBottom?: string;
  66795. /** Foreground color */
  66796. color?: string;
  66797. /** Background color */
  66798. background?: string;
  66799. }
  66800. /**
  66801. * Class used to create virtual keyboard
  66802. */
  66803. export class VirtualKeyboard extends StackPanel {
  66804. /** BABYLON.Observable raised when a key is pressed */
  66805. onKeyPressObservable: BABYLON.Observable<string>;
  66806. /** Gets or sets default key button width */
  66807. defaultButtonWidth: string;
  66808. /** Gets or sets default key button height */
  66809. defaultButtonHeight: string;
  66810. /** Gets or sets default key button left padding */
  66811. defaultButtonPaddingLeft: string;
  66812. /** Gets or sets default key button right padding */
  66813. defaultButtonPaddingRight: string;
  66814. /** Gets or sets default key button top padding */
  66815. defaultButtonPaddingTop: string;
  66816. /** Gets or sets default key button bottom padding */
  66817. defaultButtonPaddingBottom: string;
  66818. /** Gets or sets default key button foreground color */
  66819. defaultButtonColor: string;
  66820. /** Gets or sets default key button background color */
  66821. defaultButtonBackground: string;
  66822. /** Gets or sets shift button foreground color */
  66823. shiftButtonColor: string;
  66824. /** Gets or sets shift button thickness*/
  66825. selectedShiftThickness: number;
  66826. /** Gets shift key state */
  66827. shiftState: number;
  66828. protected _getTypeName(): string;
  66829. private _createKey;
  66830. /**
  66831. * Adds a new row of keys
  66832. * @param keys defines the list of keys to add
  66833. * @param propertySets defines the associated property sets
  66834. */
  66835. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66836. /**
  66837. * Set the shift key to a specific state
  66838. * @param shiftState defines the new shift state
  66839. */
  66840. applyShiftState(shiftState: number): void;
  66841. private _currentlyConnectedInputText;
  66842. private _connectedInputTexts;
  66843. private _onKeyPressObserver;
  66844. /** Gets the input text control currently attached to the keyboard */
  66845. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66846. /**
  66847. * Connects the keyboard with an input text control
  66848. *
  66849. * @param input defines the target control
  66850. */
  66851. connect(input: InputText): void;
  66852. /**
  66853. * Disconnects the keyboard from connected InputText controls
  66854. *
  66855. * @param input optionally defines a target control, otherwise all are disconnected
  66856. */
  66857. disconnect(input?: InputText): void;
  66858. private _removeConnectedInputObservables;
  66859. /**
  66860. * Release all resources
  66861. */
  66862. dispose(): void;
  66863. /**
  66864. * Creates a new keyboard using a default layout
  66865. *
  66866. * @param name defines control name
  66867. * @returns a new VirtualKeyboard
  66868. */
  66869. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66870. }
  66871. }
  66872. declare module BABYLON.GUI {
  66873. /**
  66874. * Class used to create input text control
  66875. */
  66876. export class InputText extends Control implements IFocusableControl {
  66877. name?: string | undefined;
  66878. private _text;
  66879. private _placeholderText;
  66880. private _background;
  66881. private _focusedBackground;
  66882. private _focusedColor;
  66883. private _placeholderColor;
  66884. private _thickness;
  66885. private _margin;
  66886. private _autoStretchWidth;
  66887. private _maxWidth;
  66888. private _isFocused;
  66889. private _blinkTimeout;
  66890. private _blinkIsEven;
  66891. private _cursorOffset;
  66892. private _scrollLeft;
  66893. private _textWidth;
  66894. private _clickedCoordinate;
  66895. private _deadKey;
  66896. private _addKey;
  66897. private _currentKey;
  66898. private _isTextHighlightOn;
  66899. private _textHighlightColor;
  66900. private _highligherOpacity;
  66901. private _highlightedText;
  66902. private _startHighlightIndex;
  66903. private _endHighlightIndex;
  66904. private _cursorIndex;
  66905. private _onFocusSelectAll;
  66906. private _isPointerDown;
  66907. private _onClipboardObserver;
  66908. private _onPointerDblTapObserver;
  66909. /** @hidden */
  66910. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66911. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66912. promptMessage: string;
  66913. /** Force disable prompt on mobile device */
  66914. disableMobilePrompt: boolean;
  66915. /** BABYLON.Observable raised when the text changes */
  66916. onTextChangedObservable: BABYLON.Observable<InputText>;
  66917. /** BABYLON.Observable raised just before an entered character is to be added */
  66918. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66919. /** BABYLON.Observable raised when the control gets the focus */
  66920. onFocusObservable: BABYLON.Observable<InputText>;
  66921. /** BABYLON.Observable raised when the control loses the focus */
  66922. onBlurObservable: BABYLON.Observable<InputText>;
  66923. /**Observable raised when the text is highlighted */
  66924. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66925. /**Observable raised when copy event is triggered */
  66926. onTextCopyObservable: BABYLON.Observable<InputText>;
  66927. /** BABYLON.Observable raised when cut event is triggered */
  66928. onTextCutObservable: BABYLON.Observable<InputText>;
  66929. /** BABYLON.Observable raised when paste event is triggered */
  66930. onTextPasteObservable: BABYLON.Observable<InputText>;
  66931. /** BABYLON.Observable raised when a key event was processed */
  66932. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66933. /** Gets or sets the maximum width allowed by the control */
  66934. maxWidth: string | number;
  66935. /** Gets the maximum width allowed by the control in pixels */
  66936. readonly maxWidthInPixels: number;
  66937. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66938. highligherOpacity: number;
  66939. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66940. onFocusSelectAll: boolean;
  66941. /** Gets or sets the text hightlight color */
  66942. textHighlightColor: string;
  66943. /** Gets or sets control margin */
  66944. margin: string;
  66945. /** Gets control margin in pixels */
  66946. readonly marginInPixels: number;
  66947. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66948. autoStretchWidth: boolean;
  66949. /** Gets or sets border thickness */
  66950. thickness: number;
  66951. /** Gets or sets the background color when focused */
  66952. focusedBackground: string;
  66953. /** Gets or sets the background color when focused */
  66954. focusedColor: string;
  66955. /** Gets or sets the background color */
  66956. background: string;
  66957. /** Gets or sets the placeholder color */
  66958. placeholderColor: string;
  66959. /** Gets or sets the text displayed when the control is empty */
  66960. placeholderText: string;
  66961. /** Gets or sets the dead key flag */
  66962. deadKey: boolean;
  66963. /** Gets or sets the highlight text */
  66964. highlightedText: string;
  66965. /** Gets or sets if the current key should be added */
  66966. addKey: boolean;
  66967. /** Gets or sets the value of the current key being entered */
  66968. currentKey: string;
  66969. /** Gets or sets the text displayed in the control */
  66970. text: string;
  66971. /** Gets or sets control width */
  66972. width: string | number;
  66973. /**
  66974. * Creates a new InputText
  66975. * @param name defines the control name
  66976. * @param text defines the text of the control
  66977. */
  66978. constructor(name?: string | undefined, text?: string);
  66979. /** @hidden */
  66980. onBlur(): void;
  66981. /** @hidden */
  66982. onFocus(): void;
  66983. protected _getTypeName(): string;
  66984. /**
  66985. * Function called to get the list of controls that should not steal the focus from this control
  66986. * @returns an array of controls
  66987. */
  66988. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66989. /** @hidden */
  66990. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66991. /** @hidden */
  66992. private _updateValueFromCursorIndex;
  66993. /** @hidden */
  66994. private _processDblClick;
  66995. /** @hidden */
  66996. private _selectAllText;
  66997. /**
  66998. * Handles the keyboard event
  66999. * @param evt Defines the KeyboardEvent
  67000. */
  67001. processKeyboard(evt: KeyboardEvent): void;
  67002. /** @hidden */
  67003. private _onCopyText;
  67004. /** @hidden */
  67005. private _onCutText;
  67006. /** @hidden */
  67007. private _onPasteText;
  67008. _draw(context: CanvasRenderingContext2D): void;
  67009. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67010. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67011. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67012. protected _beforeRenderText(text: string): string;
  67013. dispose(): void;
  67014. }
  67015. }
  67016. declare module BABYLON.GUI {
  67017. /**
  67018. * Class used to create a 2D grid container
  67019. */
  67020. export class Grid extends Container {
  67021. name?: string | undefined;
  67022. private _rowDefinitions;
  67023. private _columnDefinitions;
  67024. private _cells;
  67025. private _childControls;
  67026. /**
  67027. * Gets the number of columns
  67028. */
  67029. readonly columnCount: number;
  67030. /**
  67031. * Gets the number of rows
  67032. */
  67033. readonly rowCount: number;
  67034. /** Gets the list of children */
  67035. readonly children: Control[];
  67036. /** Gets the list of cells (e.g. the containers) */
  67037. readonly cells: {
  67038. [key: string]: Container;
  67039. };
  67040. /**
  67041. * Gets the definition of a specific row
  67042. * @param index defines the index of the row
  67043. * @returns the row definition
  67044. */
  67045. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67046. /**
  67047. * Gets the definition of a specific column
  67048. * @param index defines the index of the column
  67049. * @returns the column definition
  67050. */
  67051. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67052. /**
  67053. * Adds a new row to the grid
  67054. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67055. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  67056. * @returns the current grid
  67057. */
  67058. addRowDefinition(height: number, isPixel?: boolean): Grid;
  67059. /**
  67060. * Adds a new column to the grid
  67061. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67062. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67063. * @returns the current grid
  67064. */
  67065. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  67066. /**
  67067. * Update a row definition
  67068. * @param index defines the index of the row to update
  67069. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67070. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  67071. * @returns the current grid
  67072. */
  67073. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  67074. /**
  67075. * Update a column definition
  67076. * @param index defines the index of the column to update
  67077. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67078. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67079. * @returns the current grid
  67080. */
  67081. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  67082. /**
  67083. * Gets the list of children stored in a specific cell
  67084. * @param row defines the row to check
  67085. * @param column defines the column to check
  67086. * @returns the list of controls
  67087. */
  67088. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  67089. /**
  67090. * Gets a string representing the child cell info (row x column)
  67091. * @param child defines the control to get info from
  67092. * @returns a string containing the child cell info (row x column)
  67093. */
  67094. getChildCellInfo(child: Control): string;
  67095. private _removeCell;
  67096. private _offsetCell;
  67097. /**
  67098. * Remove a column definition at specified index
  67099. * @param index defines the index of the column to remove
  67100. * @returns the current grid
  67101. */
  67102. removeColumnDefinition(index: number): Grid;
  67103. /**
  67104. * Remove a row definition at specified index
  67105. * @param index defines the index of the row to remove
  67106. * @returns the current grid
  67107. */
  67108. removeRowDefinition(index: number): Grid;
  67109. /**
  67110. * Adds a new control to the current grid
  67111. * @param control defines the control to add
  67112. * @param row defines the row where to add the control (0 by default)
  67113. * @param column defines the column where to add the control (0 by default)
  67114. * @returns the current grid
  67115. */
  67116. addControl(control: Control, row?: number, column?: number): Grid;
  67117. /**
  67118. * Removes a control from the current container
  67119. * @param control defines the control to remove
  67120. * @returns the current container
  67121. */
  67122. removeControl(control: Control): Container;
  67123. /**
  67124. * Creates a new Grid
  67125. * @param name defines control name
  67126. */
  67127. constructor(name?: string | undefined);
  67128. protected _getTypeName(): string;
  67129. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  67130. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67131. _flagDescendantsAsMatrixDirty(): void;
  67132. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67133. /** Releases associated resources */
  67134. dispose(): void;
  67135. }
  67136. }
  67137. declare module BABYLON.GUI {
  67138. /** Class used to create color pickers */
  67139. export class ColorPicker extends Control {
  67140. name?: string | undefined;
  67141. private static _Epsilon;
  67142. private _colorWheelCanvas;
  67143. private _value;
  67144. private _tmpColor;
  67145. private _pointerStartedOnSquare;
  67146. private _pointerStartedOnWheel;
  67147. private _squareLeft;
  67148. private _squareTop;
  67149. private _squareSize;
  67150. private _h;
  67151. private _s;
  67152. private _v;
  67153. private _lastPointerDownID;
  67154. /**
  67155. * BABYLON.Observable raised when the value changes
  67156. */
  67157. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  67158. /** Gets or sets the color of the color picker */
  67159. value: BABYLON.Color3;
  67160. /**
  67161. * Gets or sets control width
  67162. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67163. */
  67164. width: string | number;
  67165. /**
  67166. * Gets or sets control height
  67167. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67168. */
  67169. /** Gets or sets control height */
  67170. height: string | number;
  67171. /** Gets or sets control size */
  67172. size: string | number;
  67173. /**
  67174. * Creates a new ColorPicker
  67175. * @param name defines the control name
  67176. */
  67177. constructor(name?: string | undefined);
  67178. protected _getTypeName(): string;
  67179. /** @hidden */
  67180. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67181. private _updateSquareProps;
  67182. private _drawGradientSquare;
  67183. private _drawCircle;
  67184. private _createColorWheelCanvas;
  67185. /** @hidden */
  67186. _draw(context: CanvasRenderingContext2D): void;
  67187. private _pointerIsDown;
  67188. private _updateValueFromPointer;
  67189. private _isPointOnSquare;
  67190. private _isPointOnWheel;
  67191. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67192. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67193. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67194. /**
  67195. * This function expands the color picker by creating a color picker dialog with manual
  67196. * color value input and the ability to save colors into an array to be used later in
  67197. * subsequent launches of the dialogue.
  67198. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  67199. * @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.
  67200. * @returns picked color as a hex string and the saved colors array as hex strings.
  67201. */
  67202. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  67203. pickerWidth?: string;
  67204. pickerHeight?: string;
  67205. headerHeight?: string;
  67206. lastColor?: string;
  67207. swatchLimit?: number;
  67208. numSwatchesPerLine?: number;
  67209. savedColors?: Array<string>;
  67210. }): Promise<{
  67211. savedColors?: string[];
  67212. pickedColor: string;
  67213. }>;
  67214. }
  67215. }
  67216. declare module BABYLON.GUI {
  67217. /** Class used to create 2D ellipse containers */
  67218. export class Ellipse extends Container {
  67219. name?: string | undefined;
  67220. private _thickness;
  67221. /** Gets or sets border thickness */
  67222. thickness: number;
  67223. /**
  67224. * Creates a new Ellipse
  67225. * @param name defines the control name
  67226. */
  67227. constructor(name?: string | undefined);
  67228. protected _getTypeName(): string;
  67229. protected _localDraw(context: CanvasRenderingContext2D): void;
  67230. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67231. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67232. }
  67233. }
  67234. declare module BABYLON.GUI {
  67235. /**
  67236. * Class used to create a password control
  67237. */
  67238. export class InputPassword extends InputText {
  67239. protected _beforeRenderText(text: string): string;
  67240. }
  67241. }
  67242. declare module BABYLON.GUI {
  67243. /** Class used to render 2D lines */
  67244. export class Line extends Control {
  67245. name?: string | undefined;
  67246. private _lineWidth;
  67247. private _x1;
  67248. private _y1;
  67249. private _x2;
  67250. private _y2;
  67251. private _dash;
  67252. private _connectedControl;
  67253. private _connectedControlDirtyObserver;
  67254. /** Gets or sets the dash pattern */
  67255. dash: Array<number>;
  67256. /** Gets or sets the control connected with the line end */
  67257. connectedControl: Control;
  67258. /** Gets or sets start coordinates on X axis */
  67259. x1: string | number;
  67260. /** Gets or sets start coordinates on Y axis */
  67261. y1: string | number;
  67262. /** Gets or sets end coordinates on X axis */
  67263. x2: string | number;
  67264. /** Gets or sets end coordinates on Y axis */
  67265. y2: string | number;
  67266. /** Gets or sets line width */
  67267. lineWidth: number;
  67268. /** Gets or sets horizontal alignment */
  67269. horizontalAlignment: number;
  67270. /** Gets or sets vertical alignment */
  67271. verticalAlignment: number;
  67272. private readonly _effectiveX2;
  67273. private readonly _effectiveY2;
  67274. /**
  67275. * Creates a new Line
  67276. * @param name defines the control name
  67277. */
  67278. constructor(name?: string | undefined);
  67279. protected _getTypeName(): string;
  67280. _draw(context: CanvasRenderingContext2D): void;
  67281. _measure(): void;
  67282. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67283. /**
  67284. * Move one end of the line given 3D cartesian coordinates.
  67285. * @param position Targeted world position
  67286. * @param scene BABYLON.Scene
  67287. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67288. */
  67289. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  67290. /**
  67291. * Move one end of the line to a position in screen absolute space.
  67292. * @param projectedPosition Position in screen absolute space (X, Y)
  67293. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67294. */
  67295. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  67296. }
  67297. }
  67298. declare module BABYLON.GUI {
  67299. /**
  67300. * Class used to store a point for a MultiLine object.
  67301. * The point can be pure 2D coordinates, a mesh or a control
  67302. */
  67303. export class MultiLinePoint {
  67304. private _multiLine;
  67305. private _x;
  67306. private _y;
  67307. private _control;
  67308. private _mesh;
  67309. private _controlObserver;
  67310. private _meshObserver;
  67311. /** @hidden */
  67312. _point: BABYLON.Vector2;
  67313. /**
  67314. * Creates a new MultiLinePoint
  67315. * @param multiLine defines the source MultiLine object
  67316. */
  67317. constructor(multiLine: MultiLine);
  67318. /** Gets or sets x coordinate */
  67319. x: string | number;
  67320. /** Gets or sets y coordinate */
  67321. y: string | number;
  67322. /** Gets or sets the control associated with this point */
  67323. control: BABYLON.Nullable<Control>;
  67324. /** Gets or sets the mesh associated with this point */
  67325. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67326. /** Resets links */
  67327. resetLinks(): void;
  67328. /**
  67329. * Gets a translation vector
  67330. * @returns the translation vector
  67331. */
  67332. translate(): BABYLON.Vector2;
  67333. private _translatePoint;
  67334. /** Release associated resources */
  67335. dispose(): void;
  67336. }
  67337. }
  67338. declare module BABYLON.GUI {
  67339. /**
  67340. * Class used to create multi line control
  67341. */
  67342. export class MultiLine extends Control {
  67343. name?: string | undefined;
  67344. private _lineWidth;
  67345. private _dash;
  67346. private _points;
  67347. private _minX;
  67348. private _minY;
  67349. private _maxX;
  67350. private _maxY;
  67351. /**
  67352. * Creates a new MultiLine
  67353. * @param name defines the control name
  67354. */
  67355. constructor(name?: string | undefined);
  67356. /** Gets or sets dash pattern */
  67357. dash: Array<number>;
  67358. /**
  67359. * Gets point stored at specified index
  67360. * @param index defines the index to look for
  67361. * @returns the requested point if found
  67362. */
  67363. getAt(index: number): MultiLinePoint;
  67364. /** Function called when a point is updated */
  67365. onPointUpdate: () => void;
  67366. /**
  67367. * Adds new points to the point collection
  67368. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  67369. * @returns the list of created MultiLinePoint
  67370. */
  67371. add(...items: (AbstractMesh | Control | {
  67372. x: string | number;
  67373. y: string | number;
  67374. })[]): MultiLinePoint[];
  67375. /**
  67376. * Adds a new point to the point collection
  67377. * @param item defines the item (mesh, control or 2d coordiantes) to add
  67378. * @returns the created MultiLinePoint
  67379. */
  67380. push(item?: (AbstractMesh | Control | {
  67381. x: string | number;
  67382. y: string | number;
  67383. })): MultiLinePoint;
  67384. /**
  67385. * Remove a specific value or point from the active point collection
  67386. * @param value defines the value or point to remove
  67387. */
  67388. remove(value: number | MultiLinePoint): void;
  67389. /**
  67390. * Resets this object to initial state (no point)
  67391. */
  67392. reset(): void;
  67393. /**
  67394. * Resets all links
  67395. */
  67396. resetLinks(): void;
  67397. /** Gets or sets line width */
  67398. lineWidth: number;
  67399. horizontalAlignment: number;
  67400. verticalAlignment: number;
  67401. protected _getTypeName(): string;
  67402. _draw(context: CanvasRenderingContext2D): void;
  67403. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67404. _measure(): void;
  67405. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67406. dispose(): void;
  67407. }
  67408. }
  67409. declare module BABYLON.GUI {
  67410. /**
  67411. * Class used to create radio button controls
  67412. */
  67413. export class RadioButton extends Control {
  67414. name?: string | undefined;
  67415. private _isChecked;
  67416. private _background;
  67417. private _checkSizeRatio;
  67418. private _thickness;
  67419. /** Gets or sets border thickness */
  67420. thickness: number;
  67421. /** Gets or sets group name */
  67422. group: string;
  67423. /** BABYLON.Observable raised when isChecked is changed */
  67424. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67425. /** Gets or sets a value indicating the ratio between overall size and check size */
  67426. checkSizeRatio: number;
  67427. /** Gets or sets background color */
  67428. background: string;
  67429. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67430. isChecked: boolean;
  67431. /**
  67432. * Creates a new RadioButton
  67433. * @param name defines the control name
  67434. */
  67435. constructor(name?: string | undefined);
  67436. protected _getTypeName(): string;
  67437. _draw(context: CanvasRenderingContext2D): void;
  67438. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67439. /**
  67440. * Utility function to easily create a radio button with a header
  67441. * @param title defines the label to use for the header
  67442. * @param group defines the group to use for the radio button
  67443. * @param isChecked defines the initial state of the radio button
  67444. * @param onValueChanged defines the callback to call when value changes
  67445. * @returns a StackPanel containing the radio button and a textBlock
  67446. */
  67447. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  67448. }
  67449. }
  67450. declare module BABYLON.GUI {
  67451. /**
  67452. * Class used to create slider controls
  67453. */
  67454. export class BaseSlider extends Control {
  67455. name?: string | undefined;
  67456. protected _thumbWidth: ValueAndUnit;
  67457. private _minimum;
  67458. private _maximum;
  67459. private _value;
  67460. private _isVertical;
  67461. protected _barOffset: ValueAndUnit;
  67462. private _isThumbClamped;
  67463. protected _displayThumb: boolean;
  67464. private _step;
  67465. private _lastPointerDownID;
  67466. protected _effectiveBarOffset: number;
  67467. protected _renderLeft: number;
  67468. protected _renderTop: number;
  67469. protected _renderWidth: number;
  67470. protected _renderHeight: number;
  67471. protected _backgroundBoxLength: number;
  67472. protected _backgroundBoxThickness: number;
  67473. protected _effectiveThumbThickness: number;
  67474. /** BABYLON.Observable raised when the sldier value changes */
  67475. onValueChangedObservable: BABYLON.Observable<number>;
  67476. /** Gets or sets a boolean indicating if the thumb must be rendered */
  67477. displayThumb: boolean;
  67478. /** Gets or sets a step to apply to values (0 by default) */
  67479. step: number;
  67480. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  67481. barOffset: string | number;
  67482. /** Gets main bar offset in pixels*/
  67483. readonly barOffsetInPixels: number;
  67484. /** Gets or sets thumb width */
  67485. thumbWidth: string | number;
  67486. /** Gets thumb width in pixels */
  67487. readonly thumbWidthInPixels: number;
  67488. /** Gets or sets minimum value */
  67489. minimum: number;
  67490. /** Gets or sets maximum value */
  67491. maximum: number;
  67492. /** Gets or sets current value */
  67493. value: number;
  67494. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  67495. isVertical: boolean;
  67496. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  67497. isThumbClamped: boolean;
  67498. /**
  67499. * Creates a new BaseSlider
  67500. * @param name defines the control name
  67501. */
  67502. constructor(name?: string | undefined);
  67503. protected _getTypeName(): string;
  67504. protected _getThumbPosition(): number;
  67505. protected _getThumbThickness(type: string): number;
  67506. protected _prepareRenderingData(type: string): void;
  67507. private _pointerIsDown;
  67508. /** @hidden */
  67509. protected _updateValueFromPointer(x: number, y: number): void;
  67510. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67511. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67512. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67513. }
  67514. }
  67515. declare module BABYLON.GUI {
  67516. /**
  67517. * Class used to create slider controls
  67518. */
  67519. export class Slider extends BaseSlider {
  67520. name?: string | undefined;
  67521. private _background;
  67522. private _borderColor;
  67523. private _isThumbCircle;
  67524. protected _displayValueBar: boolean;
  67525. /** Gets or sets a boolean indicating if the value bar must be rendered */
  67526. displayValueBar: boolean;
  67527. /** Gets or sets border color */
  67528. borderColor: string;
  67529. /** Gets or sets background color */
  67530. background: string;
  67531. /** Gets or sets a boolean indicating if the thumb should be round or square */
  67532. isThumbCircle: boolean;
  67533. /**
  67534. * Creates a new Slider
  67535. * @param name defines the control name
  67536. */
  67537. constructor(name?: string | undefined);
  67538. protected _getTypeName(): string;
  67539. _draw(context: CanvasRenderingContext2D): void;
  67540. }
  67541. }
  67542. declare module BABYLON.GUI {
  67543. /** Class used to create a RadioGroup
  67544. * which contains groups of radio buttons
  67545. */
  67546. export class SelectorGroup {
  67547. /** name of SelectorGroup */
  67548. name: string;
  67549. private _groupPanel;
  67550. private _selectors;
  67551. private _groupHeader;
  67552. /**
  67553. * Creates a new SelectorGroup
  67554. * @param name of group, used as a group heading
  67555. */
  67556. constructor(
  67557. /** name of SelectorGroup */
  67558. name: string);
  67559. /** Gets the groupPanel of the SelectorGroup */
  67560. readonly groupPanel: StackPanel;
  67561. /** Gets the selectors array */
  67562. readonly selectors: StackPanel[];
  67563. /** Gets and sets the group header */
  67564. header: string;
  67565. /** @hidden */
  67566. private _addGroupHeader;
  67567. /** @hidden*/
  67568. _getSelector(selectorNb: number): StackPanel | undefined;
  67569. /** Removes the selector at the given position
  67570. * @param selectorNb the position of the selector within the group
  67571. */
  67572. removeSelector(selectorNb: number): void;
  67573. }
  67574. /** Class used to create a CheckboxGroup
  67575. * which contains groups of checkbox buttons
  67576. */
  67577. export class CheckboxGroup extends SelectorGroup {
  67578. /** Adds a checkbox as a control
  67579. * @param text is the label for the selector
  67580. * @param func is the function called when the Selector is checked
  67581. * @param checked is true when Selector is checked
  67582. */
  67583. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  67584. /** @hidden */
  67585. _setSelectorLabel(selectorNb: number, label: string): void;
  67586. /** @hidden */
  67587. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67588. /** @hidden */
  67589. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67590. /** @hidden */
  67591. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67592. }
  67593. /** Class used to create a RadioGroup
  67594. * which contains groups of radio buttons
  67595. */
  67596. export class RadioGroup extends SelectorGroup {
  67597. private _selectNb;
  67598. /** Adds a radio button as a control
  67599. * @param label is the label for the selector
  67600. * @param func is the function called when the Selector is checked
  67601. * @param checked is true when Selector is checked
  67602. */
  67603. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  67604. /** @hidden */
  67605. _setSelectorLabel(selectorNb: number, label: string): void;
  67606. /** @hidden */
  67607. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67608. /** @hidden */
  67609. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67610. /** @hidden */
  67611. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67612. }
  67613. /** Class used to create a SliderGroup
  67614. * which contains groups of slider buttons
  67615. */
  67616. export class SliderGroup extends SelectorGroup {
  67617. /**
  67618. * Adds a slider to the SelectorGroup
  67619. * @param label is the label for the SliderBar
  67620. * @param func is the function called when the Slider moves
  67621. * @param unit is a string describing the units used, eg degrees or metres
  67622. * @param min is the minimum value for the Slider
  67623. * @param max is the maximum value for the Slider
  67624. * @param value is the start value for the Slider between min and max
  67625. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  67626. */
  67627. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  67628. /** @hidden */
  67629. _setSelectorLabel(selectorNb: number, label: string): void;
  67630. /** @hidden */
  67631. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67632. /** @hidden */
  67633. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67634. /** @hidden */
  67635. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67636. }
  67637. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  67638. * @see http://doc.babylonjs.com/how_to/selector
  67639. */
  67640. export class SelectionPanel extends Rectangle {
  67641. /** name of SelectionPanel */
  67642. name: string;
  67643. /** an array of SelectionGroups */
  67644. groups: SelectorGroup[];
  67645. private _panel;
  67646. private _buttonColor;
  67647. private _buttonBackground;
  67648. private _headerColor;
  67649. private _barColor;
  67650. private _barHeight;
  67651. private _spacerHeight;
  67652. private _labelColor;
  67653. private _groups;
  67654. private _bars;
  67655. /**
  67656. * Creates a new SelectionPanel
  67657. * @param name of SelectionPanel
  67658. * @param groups is an array of SelectionGroups
  67659. */
  67660. constructor(
  67661. /** name of SelectionPanel */
  67662. name: string,
  67663. /** an array of SelectionGroups */
  67664. groups?: SelectorGroup[]);
  67665. protected _getTypeName(): string;
  67666. /** Gets or sets the headerColor */
  67667. headerColor: string;
  67668. private _setHeaderColor;
  67669. /** Gets or sets the button color */
  67670. buttonColor: string;
  67671. private _setbuttonColor;
  67672. /** Gets or sets the label color */
  67673. labelColor: string;
  67674. private _setLabelColor;
  67675. /** Gets or sets the button background */
  67676. buttonBackground: string;
  67677. private _setButtonBackground;
  67678. /** Gets or sets the color of separator bar */
  67679. barColor: string;
  67680. private _setBarColor;
  67681. /** Gets or sets the height of separator bar */
  67682. barHeight: string;
  67683. private _setBarHeight;
  67684. /** Gets or sets the height of spacers*/
  67685. spacerHeight: string;
  67686. private _setSpacerHeight;
  67687. /** Adds a bar between groups */
  67688. private _addSpacer;
  67689. /** Add a group to the selection panel
  67690. * @param group is the selector group to add
  67691. */
  67692. addGroup(group: SelectorGroup): void;
  67693. /** Remove the group from the given position
  67694. * @param groupNb is the position of the group in the list
  67695. */
  67696. removeGroup(groupNb: number): void;
  67697. /** Change a group header label
  67698. * @param label is the new group header label
  67699. * @param groupNb is the number of the group to relabel
  67700. * */
  67701. setHeaderName(label: string, groupNb: number): void;
  67702. /** Change selector label to the one given
  67703. * @param label is the new selector label
  67704. * @param groupNb is the number of the groupcontaining the selector
  67705. * @param selectorNb is the number of the selector within a group to relabel
  67706. * */
  67707. relabel(label: string, groupNb: number, selectorNb: number): void;
  67708. /** For a given group position remove the selector at the given position
  67709. * @param groupNb is the number of the group to remove the selector from
  67710. * @param selectorNb is the number of the selector within the group
  67711. */
  67712. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67713. /** For a given group position of correct type add a checkbox button
  67714. * @param groupNb is the number of the group to remove the selector from
  67715. * @param label is the label for the selector
  67716. * @param func is the function called when the Selector is checked
  67717. * @param checked is true when Selector is checked
  67718. */
  67719. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67720. /** For a given group position of correct type add a radio button
  67721. * @param groupNb is the number of the group to remove the selector from
  67722. * @param label is the label for the selector
  67723. * @param func is the function called when the Selector is checked
  67724. * @param checked is true when Selector is checked
  67725. */
  67726. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67727. /**
  67728. * For a given slider group add a slider
  67729. * @param groupNb is the number of the group to add the slider to
  67730. * @param label is the label for the Slider
  67731. * @param func is the function called when the Slider moves
  67732. * @param unit is a string describing the units used, eg degrees or metres
  67733. * @param min is the minimum value for the Slider
  67734. * @param max is the maximum value for the Slider
  67735. * @param value is the start value for the Slider between min and max
  67736. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67737. */
  67738. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67739. }
  67740. }
  67741. declare module BABYLON.GUI {
  67742. /**
  67743. * Class used to hold a the container for ScrollViewer
  67744. * @hidden
  67745. */
  67746. export class _ScrollViewerWindow extends Container {
  67747. parentClientWidth: number;
  67748. parentClientHeight: number;
  67749. /**
  67750. * Creates a new ScrollViewerWindow
  67751. * @param name of ScrollViewerWindow
  67752. */
  67753. constructor(name?: string);
  67754. protected _getTypeName(): string;
  67755. /** @hidden */
  67756. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67757. protected _postMeasure(): void;
  67758. }
  67759. }
  67760. declare module BABYLON.GUI {
  67761. /**
  67762. * Class used to create slider controls
  67763. */
  67764. export class ScrollBar extends BaseSlider {
  67765. name?: string | undefined;
  67766. private _background;
  67767. private _borderColor;
  67768. private _thumbMeasure;
  67769. /** Gets or sets border color */
  67770. borderColor: string;
  67771. /** Gets or sets background color */
  67772. background: string;
  67773. /**
  67774. * Creates a new Slider
  67775. * @param name defines the control name
  67776. */
  67777. constructor(name?: string | undefined);
  67778. protected _getTypeName(): string;
  67779. protected _getThumbThickness(): number;
  67780. _draw(context: CanvasRenderingContext2D): void;
  67781. private _first;
  67782. private _originX;
  67783. private _originY;
  67784. /** @hidden */
  67785. protected _updateValueFromPointer(x: number, y: number): void;
  67786. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67787. }
  67788. }
  67789. declare module BABYLON.GUI {
  67790. /**
  67791. * Class used to hold a viewer window and sliders in a grid
  67792. */
  67793. export class ScrollViewer extends Rectangle {
  67794. private _grid;
  67795. private _horizontalBarSpace;
  67796. private _verticalBarSpace;
  67797. private _dragSpace;
  67798. private _horizontalBar;
  67799. private _verticalBar;
  67800. private _barColor;
  67801. private _barBackground;
  67802. private _barSize;
  67803. private _endLeft;
  67804. private _endTop;
  67805. private _window;
  67806. private _pointerIsOver;
  67807. private _wheelPrecision;
  67808. private _onPointerObserver;
  67809. private _clientWidth;
  67810. private _clientHeight;
  67811. /**
  67812. * Gets the horizontal scrollbar
  67813. */
  67814. readonly horizontalBar: ScrollBar;
  67815. /**
  67816. * Gets the vertical scrollbar
  67817. */
  67818. readonly verticalBar: ScrollBar;
  67819. /**
  67820. * Adds a new control to the current container
  67821. * @param control defines the control to add
  67822. * @returns the current container
  67823. */
  67824. addControl(control: BABYLON.Nullable<Control>): Container;
  67825. /**
  67826. * Removes a control from the current container
  67827. * @param control defines the control to remove
  67828. * @returns the current container
  67829. */
  67830. removeControl(control: Control): Container;
  67831. /** Gets the list of children */
  67832. readonly children: Control[];
  67833. _flagDescendantsAsMatrixDirty(): void;
  67834. /**
  67835. * Creates a new ScrollViewer
  67836. * @param name of ScrollViewer
  67837. */
  67838. constructor(name?: string);
  67839. /** Reset the scroll viewer window to initial size */
  67840. resetWindow(): void;
  67841. protected _getTypeName(): string;
  67842. private _buildClientSizes;
  67843. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67844. protected _postMeasure(): void;
  67845. /**
  67846. * Gets or sets the mouse wheel precision
  67847. * from 0 to 1 with a default value of 0.05
  67848. * */
  67849. wheelPrecision: number;
  67850. /** Gets or sets the bar color */
  67851. barColor: string;
  67852. /** Gets or sets the size of the bar */
  67853. barSize: number;
  67854. /** Gets or sets the bar background */
  67855. barBackground: string;
  67856. /** @hidden */
  67857. private _updateScroller;
  67858. _link(host: AdvancedDynamicTexture): void;
  67859. /** @hidden */
  67860. private _attachWheel;
  67861. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67862. /** Releases associated resources */
  67863. dispose(): void;
  67864. }
  67865. }
  67866. declare module BABYLON.GUI {
  67867. /** Class used to render a grid */
  67868. export class DisplayGrid extends Control {
  67869. name?: string | undefined;
  67870. private _cellWidth;
  67871. private _cellHeight;
  67872. private _minorLineTickness;
  67873. private _minorLineColor;
  67874. private _majorLineTickness;
  67875. private _majorLineColor;
  67876. private _majorLineFrequency;
  67877. private _background;
  67878. private _displayMajorLines;
  67879. private _displayMinorLines;
  67880. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67881. displayMinorLines: boolean;
  67882. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67883. displayMajorLines: boolean;
  67884. /** Gets or sets background color (Black by default) */
  67885. background: string;
  67886. /** Gets or sets the width of each cell (20 by default) */
  67887. cellWidth: number;
  67888. /** Gets or sets the height of each cell (20 by default) */
  67889. cellHeight: number;
  67890. /** Gets or sets the tickness of minor lines (1 by default) */
  67891. minorLineTickness: number;
  67892. /** Gets or sets the color of minor lines (DarkGray by default) */
  67893. minorLineColor: string;
  67894. /** Gets or sets the tickness of major lines (2 by default) */
  67895. majorLineTickness: number;
  67896. /** Gets or sets the color of major lines (White by default) */
  67897. majorLineColor: string;
  67898. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67899. majorLineFrequency: number;
  67900. /**
  67901. * Creates a new GridDisplayRectangle
  67902. * @param name defines the control name
  67903. */
  67904. constructor(name?: string | undefined);
  67905. _draw(context: CanvasRenderingContext2D): void;
  67906. protected _getTypeName(): string;
  67907. }
  67908. }
  67909. declare module BABYLON.GUI {
  67910. /**
  67911. * Class used to create slider controls based on images
  67912. */
  67913. export class ImageBasedSlider extends BaseSlider {
  67914. name?: string | undefined;
  67915. private _backgroundImage;
  67916. private _thumbImage;
  67917. private _valueBarImage;
  67918. private _tempMeasure;
  67919. displayThumb: boolean;
  67920. /**
  67921. * Gets or sets the image used to render the background
  67922. */
  67923. backgroundImage: Image;
  67924. /**
  67925. * Gets or sets the image used to render the value bar
  67926. */
  67927. valueBarImage: Image;
  67928. /**
  67929. * Gets or sets the image used to render the thumb
  67930. */
  67931. thumbImage: Image;
  67932. /**
  67933. * Creates a new ImageBasedSlider
  67934. * @param name defines the control name
  67935. */
  67936. constructor(name?: string | undefined);
  67937. protected _getTypeName(): string;
  67938. _draw(context: CanvasRenderingContext2D): void;
  67939. }
  67940. }
  67941. declare module BABYLON.GUI {
  67942. /**
  67943. * Forcing an export so that this code will execute
  67944. * @hidden
  67945. */
  67946. const name = "Statics";
  67947. }
  67948. declare module BABYLON.GUI {
  67949. /**
  67950. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67951. */
  67952. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67953. /**
  67954. * Define the instrumented AdvancedDynamicTexture.
  67955. */
  67956. texture: AdvancedDynamicTexture;
  67957. private _captureRenderTime;
  67958. private _renderTime;
  67959. private _captureLayoutTime;
  67960. private _layoutTime;
  67961. private _onBeginRenderObserver;
  67962. private _onEndRenderObserver;
  67963. private _onBeginLayoutObserver;
  67964. private _onEndLayoutObserver;
  67965. /**
  67966. * Gets the perf counter used to capture render time
  67967. */
  67968. readonly renderTimeCounter: BABYLON.PerfCounter;
  67969. /**
  67970. * Gets the perf counter used to capture layout time
  67971. */
  67972. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67973. /**
  67974. * Enable or disable the render time capture
  67975. */
  67976. captureRenderTime: boolean;
  67977. /**
  67978. * Enable or disable the layout time capture
  67979. */
  67980. captureLayoutTime: boolean;
  67981. /**
  67982. * Instantiates a new advanced dynamic texture instrumentation.
  67983. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67984. * @param texture Defines the AdvancedDynamicTexture to instrument
  67985. */
  67986. constructor(
  67987. /**
  67988. * Define the instrumented AdvancedDynamicTexture.
  67989. */
  67990. texture: AdvancedDynamicTexture);
  67991. /**
  67992. * Dispose and release associated resources.
  67993. */
  67994. dispose(): void;
  67995. }
  67996. }
  67997. declare module BABYLON.GUI {
  67998. /**
  67999. * Class used to load GUI via XML.
  68000. */
  68001. export class XmlLoader {
  68002. private _nodes;
  68003. private _nodeTypes;
  68004. private _isLoaded;
  68005. private _objectAttributes;
  68006. private _parentClass;
  68007. /**
  68008. * Create a new xml loader
  68009. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  68010. */
  68011. constructor(parentClass?: null);
  68012. private _getChainElement;
  68013. private _getClassAttribute;
  68014. private _createGuiElement;
  68015. private _parseGrid;
  68016. private _parseElement;
  68017. private _prepareSourceElement;
  68018. private _parseElementsFromSource;
  68019. private _parseXml;
  68020. /**
  68021. * Gets if the loading has finished.
  68022. * @returns whether the loading has finished or not
  68023. */
  68024. isLoaded(): boolean;
  68025. /**
  68026. * Gets a loaded node / control by id.
  68027. * @param id the Controls id set in the xml
  68028. * @returns element of type Control
  68029. */
  68030. getNodeById(id: string): any;
  68031. /**
  68032. * Gets all loaded nodes / controls
  68033. * @returns Array of controls
  68034. */
  68035. getNodes(): any;
  68036. /**
  68037. * Initiates the xml layout loading
  68038. * @param xmlFile defines the xml layout to load
  68039. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  68040. * @param callback defines the callback called on layout load.
  68041. */
  68042. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  68043. }
  68044. }
  68045. declare module BABYLON.GUI {
  68046. /**
  68047. * Class used to create containers for controls
  68048. */
  68049. export class Container3D extends Control3D {
  68050. private _blockLayout;
  68051. /**
  68052. * Gets the list of child controls
  68053. */
  68054. protected _children: Control3D[];
  68055. /**
  68056. * Gets the list of child controls
  68057. */
  68058. readonly children: Array<Control3D>;
  68059. /**
  68060. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  68061. * This is helpful to optimize layout operation when adding multiple children in a row
  68062. */
  68063. blockLayout: boolean;
  68064. /**
  68065. * Creates a new container
  68066. * @param name defines the container name
  68067. */
  68068. constructor(name?: string);
  68069. /**
  68070. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  68071. * @returns the current container
  68072. */
  68073. updateLayout(): Container3D;
  68074. /**
  68075. * Gets a boolean indicating if the given control is in the children of this control
  68076. * @param control defines the control to check
  68077. * @returns true if the control is in the child list
  68078. */
  68079. containsControl(control: Control3D): boolean;
  68080. /**
  68081. * Adds a control to the children of this control
  68082. * @param control defines the control to add
  68083. * @returns the current container
  68084. */
  68085. addControl(control: Control3D): Container3D;
  68086. /**
  68087. * This function will be called everytime a new control is added
  68088. */
  68089. protected _arrangeChildren(): void;
  68090. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68091. /**
  68092. * Removes a control from the children of this control
  68093. * @param control defines the control to remove
  68094. * @returns the current container
  68095. */
  68096. removeControl(control: Control3D): Container3D;
  68097. protected _getTypeName(): string;
  68098. /**
  68099. * Releases all associated resources
  68100. */
  68101. dispose(): void;
  68102. /** Control rotation will remain unchanged */
  68103. static readonly UNSET_ORIENTATION: number;
  68104. /** Control will rotate to make it look at sphere central axis */
  68105. static readonly FACEORIGIN_ORIENTATION: number;
  68106. /** Control will rotate to make it look back at sphere central axis */
  68107. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  68108. /** Control will rotate to look at z axis (0, 0, 1) */
  68109. static readonly FACEFORWARD_ORIENTATION: number;
  68110. /** Control will rotate to look at negative z axis (0, 0, -1) */
  68111. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  68112. }
  68113. }
  68114. declare module BABYLON.GUI {
  68115. /**
  68116. * Class used to manage 3D user interface
  68117. * @see http://doc.babylonjs.com/how_to/gui3d
  68118. */
  68119. export class GUI3DManager implements BABYLON.IDisposable {
  68120. private _scene;
  68121. private _sceneDisposeObserver;
  68122. private _utilityLayer;
  68123. private _rootContainer;
  68124. private _pointerObserver;
  68125. private _pointerOutObserver;
  68126. /** @hidden */
  68127. _lastPickedControl: Control3D;
  68128. /** @hidden */
  68129. _lastControlOver: {
  68130. [pointerId: number]: Control3D;
  68131. };
  68132. /** @hidden */
  68133. _lastControlDown: {
  68134. [pointerId: number]: Control3D;
  68135. };
  68136. /**
  68137. * BABYLON.Observable raised when the point picked by the pointer events changed
  68138. */
  68139. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  68140. /** @hidden */
  68141. _sharedMaterials: {
  68142. [key: string]: BABYLON.Material;
  68143. };
  68144. /** Gets the hosting scene */
  68145. readonly scene: BABYLON.Scene;
  68146. /** Gets associated utility layer */
  68147. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  68148. /**
  68149. * Creates a new GUI3DManager
  68150. * @param scene
  68151. */
  68152. constructor(scene?: BABYLON.Scene);
  68153. private _handlePointerOut;
  68154. private _doPicking;
  68155. /**
  68156. * Gets the root container
  68157. */
  68158. readonly rootContainer: Container3D;
  68159. /**
  68160. * Gets a boolean indicating if the given control is in the root child list
  68161. * @param control defines the control to check
  68162. * @returns true if the control is in the root child list
  68163. */
  68164. containsControl(control: Control3D): boolean;
  68165. /**
  68166. * Adds a control to the root child list
  68167. * @param control defines the control to add
  68168. * @returns the current manager
  68169. */
  68170. addControl(control: Control3D): GUI3DManager;
  68171. /**
  68172. * Removes a control from the root child list
  68173. * @param control defines the control to remove
  68174. * @returns the current container
  68175. */
  68176. removeControl(control: Control3D): GUI3DManager;
  68177. /**
  68178. * Releases all associated resources
  68179. */
  68180. dispose(): void;
  68181. }
  68182. }
  68183. declare module BABYLON.GUI {
  68184. /**
  68185. * Class used to transport BABYLON.Vector3 information for pointer events
  68186. */
  68187. export class Vector3WithInfo extends BABYLON.Vector3 {
  68188. /** defines the current mouse button index */
  68189. buttonIndex: number;
  68190. /**
  68191. * Creates a new Vector3WithInfo
  68192. * @param source defines the vector3 data to transport
  68193. * @param buttonIndex defines the current mouse button index
  68194. */
  68195. constructor(source: BABYLON.Vector3,
  68196. /** defines the current mouse button index */
  68197. buttonIndex?: number);
  68198. }
  68199. }
  68200. declare module BABYLON.GUI {
  68201. /**
  68202. * Class used as base class for controls
  68203. */
  68204. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  68205. /** Defines the control name */
  68206. name?: string | undefined;
  68207. /** @hidden */
  68208. _host: GUI3DManager;
  68209. private _node;
  68210. private _downCount;
  68211. private _enterCount;
  68212. private _downPointerIds;
  68213. private _isVisible;
  68214. /** Gets or sets the control position in world space */
  68215. position: BABYLON.Vector3;
  68216. /** Gets or sets the control scaling in world space */
  68217. scaling: BABYLON.Vector3;
  68218. /** Callback used to start pointer enter animation */
  68219. pointerEnterAnimation: () => void;
  68220. /** Callback used to start pointer out animation */
  68221. pointerOutAnimation: () => void;
  68222. /** Callback used to start pointer down animation */
  68223. pointerDownAnimation: () => void;
  68224. /** Callback used to start pointer up animation */
  68225. pointerUpAnimation: () => void;
  68226. /**
  68227. * An event triggered when the pointer move over the control
  68228. */
  68229. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  68230. /**
  68231. * An event triggered when the pointer move out of the control
  68232. */
  68233. onPointerOutObservable: BABYLON.Observable<Control3D>;
  68234. /**
  68235. * An event triggered when the pointer taps the control
  68236. */
  68237. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  68238. /**
  68239. * An event triggered when pointer is up
  68240. */
  68241. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  68242. /**
  68243. * An event triggered when a control is clicked on (with a mouse)
  68244. */
  68245. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  68246. /**
  68247. * An event triggered when pointer enters the control
  68248. */
  68249. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  68250. /**
  68251. * Gets or sets the parent container
  68252. */
  68253. parent: BABYLON.Nullable<Container3D>;
  68254. private _behaviors;
  68255. /**
  68256. * Gets the list of attached behaviors
  68257. * @see http://doc.babylonjs.com/features/behaviour
  68258. */
  68259. readonly behaviors: BABYLON.Behavior<Control3D>[];
  68260. /**
  68261. * Attach a behavior to the control
  68262. * @see http://doc.babylonjs.com/features/behaviour
  68263. * @param behavior defines the behavior to attach
  68264. * @returns the current control
  68265. */
  68266. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68267. /**
  68268. * Remove an attached behavior
  68269. * @see http://doc.babylonjs.com/features/behaviour
  68270. * @param behavior defines the behavior to attach
  68271. * @returns the current control
  68272. */
  68273. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68274. /**
  68275. * Gets an attached behavior by name
  68276. * @param name defines the name of the behavior to look for
  68277. * @see http://doc.babylonjs.com/features/behaviour
  68278. * @returns null if behavior was not found else the requested behavior
  68279. */
  68280. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  68281. /** Gets or sets a boolean indicating if the control is visible */
  68282. isVisible: boolean;
  68283. /**
  68284. * Creates a new control
  68285. * @param name defines the control name
  68286. */
  68287. constructor(
  68288. /** Defines the control name */
  68289. name?: string | undefined);
  68290. /**
  68291. * Gets a string representing the class name
  68292. */
  68293. readonly typeName: string;
  68294. /**
  68295. * Get the current class name of the control.
  68296. * @returns current class name
  68297. */
  68298. getClassName(): string;
  68299. protected _getTypeName(): string;
  68300. /**
  68301. * Gets the transform node used by this control
  68302. */
  68303. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  68304. /**
  68305. * Gets the mesh used to render this control
  68306. */
  68307. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68308. /**
  68309. * Link the control as child of the given node
  68310. * @param node defines the node to link to. Use null to unlink the control
  68311. * @returns the current control
  68312. */
  68313. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  68314. /** @hidden **/
  68315. _prepareNode(scene: BABYLON.Scene): void;
  68316. /**
  68317. * Node creation.
  68318. * Can be overriden by children
  68319. * @param scene defines the scene where the node must be attached
  68320. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  68321. */
  68322. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68323. /**
  68324. * Affect a material to the given mesh
  68325. * @param mesh defines the mesh which will represent the control
  68326. */
  68327. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68328. /** @hidden */
  68329. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  68330. /** @hidden */
  68331. _onPointerEnter(target: Control3D): boolean;
  68332. /** @hidden */
  68333. _onPointerOut(target: Control3D): void;
  68334. /** @hidden */
  68335. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68336. /** @hidden */
  68337. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68338. /** @hidden */
  68339. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68340. /** @hidden */
  68341. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68342. /** @hidden */
  68343. _disposeNode(): void;
  68344. /**
  68345. * Releases all associated resources
  68346. */
  68347. dispose(): void;
  68348. }
  68349. }
  68350. declare module BABYLON.GUI {
  68351. /**
  68352. * Class used as a root to all buttons
  68353. */
  68354. export class AbstractButton3D extends Control3D {
  68355. /**
  68356. * Creates a new button
  68357. * @param name defines the control name
  68358. */
  68359. constructor(name?: string);
  68360. protected _getTypeName(): string;
  68361. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68362. }
  68363. }
  68364. declare module BABYLON.GUI {
  68365. /**
  68366. * Class used to create a button in 3D
  68367. */
  68368. export class Button3D extends AbstractButton3D {
  68369. /** @hidden */
  68370. protected _currentMaterial: BABYLON.Material;
  68371. private _facadeTexture;
  68372. private _content;
  68373. private _contentResolution;
  68374. private _contentScaleRatio;
  68375. /**
  68376. * Gets or sets the texture resolution used to render content (512 by default)
  68377. */
  68378. contentResolution: BABYLON.int;
  68379. /**
  68380. * Gets or sets the texture scale ratio used to render content (2 by default)
  68381. */
  68382. contentScaleRatio: number;
  68383. protected _disposeFacadeTexture(): void;
  68384. protected _resetContent(): void;
  68385. /**
  68386. * Creates a new button
  68387. * @param name defines the control name
  68388. */
  68389. constructor(name?: string);
  68390. /**
  68391. * Gets or sets the GUI 2D content used to display the button's facade
  68392. */
  68393. content: Control;
  68394. /**
  68395. * Apply the facade texture (created from the content property).
  68396. * This function can be overloaded by child classes
  68397. * @param facadeTexture defines the AdvancedDynamicTexture to use
  68398. */
  68399. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68400. protected _getTypeName(): string;
  68401. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68402. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68403. /**
  68404. * Releases all associated resources
  68405. */
  68406. dispose(): void;
  68407. }
  68408. }
  68409. declare module BABYLON.GUI {
  68410. /**
  68411. * Abstract class used to create a container panel deployed on the surface of a volume
  68412. */
  68413. export abstract class VolumeBasedPanel extends Container3D {
  68414. private _columns;
  68415. private _rows;
  68416. private _rowThenColum;
  68417. private _orientation;
  68418. protected _cellWidth: number;
  68419. protected _cellHeight: number;
  68420. /**
  68421. * Gets or sets the distance between elements
  68422. */
  68423. margin: number;
  68424. /**
  68425. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  68426. * | Value | Type | Description |
  68427. * | ----- | ----------------------------------- | ----------- |
  68428. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  68429. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  68430. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  68431. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  68432. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  68433. */
  68434. orientation: number;
  68435. /**
  68436. * Gets or sets the number of columns requested (10 by default).
  68437. * The panel will automatically compute the number of rows based on number of child controls.
  68438. */
  68439. columns: BABYLON.int;
  68440. /**
  68441. * Gets or sets a the number of rows requested.
  68442. * The panel will automatically compute the number of columns based on number of child controls.
  68443. */
  68444. rows: BABYLON.int;
  68445. /**
  68446. * Creates new VolumeBasedPanel
  68447. */
  68448. constructor();
  68449. protected _arrangeChildren(): void;
  68450. /** Child classes must implement this function to provide correct control positioning */
  68451. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68452. /** Child classes can implement this function to provide additional processing */
  68453. protected _finalProcessing(): void;
  68454. }
  68455. }
  68456. declare module BABYLON.GUI {
  68457. /**
  68458. * Class used to create a container panel deployed on the surface of a cylinder
  68459. */
  68460. export class CylinderPanel extends VolumeBasedPanel {
  68461. private _radius;
  68462. /**
  68463. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  68464. */
  68465. radius: BABYLON.float;
  68466. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68467. private _cylindricalMapping;
  68468. }
  68469. }
  68470. declare module BABYLON.GUI {
  68471. /** @hidden */
  68472. export var fluentVertexShader: {
  68473. name: string;
  68474. shader: string;
  68475. };
  68476. }
  68477. declare module BABYLON.GUI {
  68478. /** @hidden */
  68479. export var fluentPixelShader: {
  68480. name: string;
  68481. shader: string;
  68482. };
  68483. }
  68484. declare module BABYLON.GUI {
  68485. /** @hidden */
  68486. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  68487. INNERGLOW: boolean;
  68488. BORDER: boolean;
  68489. HOVERLIGHT: boolean;
  68490. TEXTURE: boolean;
  68491. constructor();
  68492. }
  68493. /**
  68494. * Class used to render controls with fluent desgin
  68495. */
  68496. export class FluentMaterial extends BABYLON.PushMaterial {
  68497. /**
  68498. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  68499. */
  68500. innerGlowColorIntensity: number;
  68501. /**
  68502. * Gets or sets the inner glow color (white by default)
  68503. */
  68504. innerGlowColor: BABYLON.Color3;
  68505. /**
  68506. * Gets or sets alpha value (default is 1.0)
  68507. */
  68508. alpha: number;
  68509. /**
  68510. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  68511. */
  68512. albedoColor: BABYLON.Color3;
  68513. /**
  68514. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  68515. */
  68516. renderBorders: boolean;
  68517. /**
  68518. * Gets or sets border width (default is 0.5)
  68519. */
  68520. borderWidth: number;
  68521. /**
  68522. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  68523. */
  68524. edgeSmoothingValue: number;
  68525. /**
  68526. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  68527. */
  68528. borderMinValue: number;
  68529. /**
  68530. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  68531. */
  68532. renderHoverLight: boolean;
  68533. /**
  68534. * Gets or sets the radius used to render the hover light (default is 1.0)
  68535. */
  68536. hoverRadius: number;
  68537. /**
  68538. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  68539. */
  68540. hoverColor: BABYLON.Color4;
  68541. /**
  68542. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  68543. */
  68544. hoverPosition: BABYLON.Vector3;
  68545. private _albedoTexture;
  68546. /** Gets or sets the texture to use for albedo color */
  68547. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68548. /**
  68549. * Creates a new Fluent material
  68550. * @param name defines the name of the material
  68551. * @param scene defines the hosting scene
  68552. */
  68553. constructor(name: string, scene: BABYLON.Scene);
  68554. needAlphaBlending(): boolean;
  68555. needAlphaTesting(): boolean;
  68556. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68557. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68558. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68559. getActiveTextures(): BABYLON.BaseTexture[];
  68560. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68561. dispose(forceDisposeEffect?: boolean): void;
  68562. clone(name: string): FluentMaterial;
  68563. serialize(): any;
  68564. getClassName(): string;
  68565. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  68566. }
  68567. }
  68568. declare module BABYLON.GUI {
  68569. /**
  68570. * Class used to create a holographic button in 3D
  68571. */
  68572. export class HolographicButton extends Button3D {
  68573. private _backPlate;
  68574. private _textPlate;
  68575. private _frontPlate;
  68576. private _text;
  68577. private _imageUrl;
  68578. private _shareMaterials;
  68579. private _frontMaterial;
  68580. private _backMaterial;
  68581. private _plateMaterial;
  68582. private _pickedPointObserver;
  68583. private _tooltipFade;
  68584. private _tooltipTextBlock;
  68585. private _tooltipTexture;
  68586. private _tooltipMesh;
  68587. private _tooltipHoverObserver;
  68588. private _tooltipOutObserver;
  68589. private _disposeTooltip;
  68590. /**
  68591. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  68592. */
  68593. tooltipText: BABYLON.Nullable<string>;
  68594. /**
  68595. * Gets or sets text for the button
  68596. */
  68597. text: string;
  68598. /**
  68599. * Gets or sets the image url for the button
  68600. */
  68601. imageUrl: string;
  68602. /**
  68603. * Gets the back material used by this button
  68604. */
  68605. readonly backMaterial: FluentMaterial;
  68606. /**
  68607. * Gets the front material used by this button
  68608. */
  68609. readonly frontMaterial: FluentMaterial;
  68610. /**
  68611. * Gets the plate material used by this button
  68612. */
  68613. readonly plateMaterial: BABYLON.StandardMaterial;
  68614. /**
  68615. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  68616. */
  68617. readonly shareMaterials: boolean;
  68618. /**
  68619. * Creates a new button
  68620. * @param name defines the control name
  68621. */
  68622. constructor(name?: string, shareMaterials?: boolean);
  68623. protected _getTypeName(): string;
  68624. private _rebuildContent;
  68625. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68626. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68627. private _createBackMaterial;
  68628. private _createFrontMaterial;
  68629. private _createPlateMaterial;
  68630. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  68631. /**
  68632. * Releases all associated resources
  68633. */
  68634. dispose(): void;
  68635. }
  68636. }
  68637. declare module BABYLON.GUI {
  68638. /**
  68639. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  68640. */
  68641. export class MeshButton3D extends Button3D {
  68642. /** @hidden */
  68643. protected _currentMesh: BABYLON.Mesh;
  68644. /**
  68645. * Creates a new 3D button based on a mesh
  68646. * @param mesh mesh to become a 3D button
  68647. * @param name defines the control name
  68648. */
  68649. constructor(mesh: BABYLON.Mesh, name?: string);
  68650. protected _getTypeName(): string;
  68651. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68652. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68653. }
  68654. }
  68655. declare module BABYLON.GUI {
  68656. /**
  68657. * Class used to create a container panel deployed on the surface of a plane
  68658. */
  68659. export class PlanePanel extends VolumeBasedPanel {
  68660. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68661. }
  68662. }
  68663. declare module BABYLON.GUI {
  68664. /**
  68665. * Class used to create a container panel where items get randomized planar mapping
  68666. */
  68667. export class ScatterPanel extends VolumeBasedPanel {
  68668. private _iteration;
  68669. /**
  68670. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  68671. */
  68672. iteration: BABYLON.float;
  68673. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68674. private _scatterMapping;
  68675. protected _finalProcessing(): void;
  68676. }
  68677. }
  68678. declare module BABYLON.GUI {
  68679. /**
  68680. * Class used to create a container panel deployed on the surface of a sphere
  68681. */
  68682. export class SpherePanel extends VolumeBasedPanel {
  68683. private _radius;
  68684. /**
  68685. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68686. */
  68687. radius: BABYLON.float;
  68688. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68689. private _sphericalMapping;
  68690. }
  68691. }
  68692. declare module BABYLON.GUI {
  68693. /**
  68694. * Class used to create a stack panel in 3D on XY plane
  68695. */
  68696. export class StackPanel3D extends Container3D {
  68697. private _isVertical;
  68698. /**
  68699. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68700. */
  68701. isVertical: boolean;
  68702. /**
  68703. * Gets or sets the distance between elements
  68704. */
  68705. margin: number;
  68706. /**
  68707. * Creates new StackPanel
  68708. * @param isVertical
  68709. */
  68710. constructor(isVertical?: boolean);
  68711. protected _arrangeChildren(): void;
  68712. }
  68713. }
  68714. declare module BABYLON {
  68715. /**
  68716. * Mode that determines the coordinate system to use.
  68717. */
  68718. export enum GLTFLoaderCoordinateSystemMode {
  68719. /**
  68720. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68721. */
  68722. AUTO = 0,
  68723. /**
  68724. * Sets the useRightHandedSystem flag on the scene.
  68725. */
  68726. FORCE_RIGHT_HANDED = 1
  68727. }
  68728. /**
  68729. * Mode that determines what animations will start.
  68730. */
  68731. export enum GLTFLoaderAnimationStartMode {
  68732. /**
  68733. * No animation will start.
  68734. */
  68735. NONE = 0,
  68736. /**
  68737. * The first animation will start.
  68738. */
  68739. FIRST = 1,
  68740. /**
  68741. * All animations will start.
  68742. */
  68743. ALL = 2
  68744. }
  68745. /**
  68746. * Interface that contains the data for the glTF asset.
  68747. */
  68748. export interface IGLTFLoaderData {
  68749. /**
  68750. * The object that represents the glTF JSON.
  68751. */
  68752. json: Object;
  68753. /**
  68754. * The BIN chunk of a binary glTF.
  68755. */
  68756. bin: Nullable<IDataBuffer>;
  68757. }
  68758. /**
  68759. * Interface for extending the loader.
  68760. */
  68761. export interface IGLTFLoaderExtension {
  68762. /**
  68763. * The name of this extension.
  68764. */
  68765. readonly name: string;
  68766. /**
  68767. * Defines whether this extension is enabled.
  68768. */
  68769. enabled: boolean;
  68770. /**
  68771. * Defines the order of this extension.
  68772. * The loader sorts the extensions using these values when loading.
  68773. */
  68774. order?: number;
  68775. }
  68776. /**
  68777. * Loader state.
  68778. */
  68779. export enum GLTFLoaderState {
  68780. /**
  68781. * The asset is loading.
  68782. */
  68783. LOADING = 0,
  68784. /**
  68785. * The asset is ready for rendering.
  68786. */
  68787. READY = 1,
  68788. /**
  68789. * The asset is completely loaded.
  68790. */
  68791. COMPLETE = 2
  68792. }
  68793. /** @hidden */
  68794. export interface IGLTFLoader extends IDisposable {
  68795. readonly state: Nullable<GLTFLoaderState>;
  68796. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68797. meshes: AbstractMesh[];
  68798. particleSystems: IParticleSystem[];
  68799. skeletons: Skeleton[];
  68800. animationGroups: AnimationGroup[];
  68801. }>;
  68802. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68803. }
  68804. /**
  68805. * File loader for loading glTF files into a scene.
  68806. */
  68807. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68808. /** @hidden */
  68809. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68810. /** @hidden */
  68811. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68812. /**
  68813. * Raised when the asset has been parsed
  68814. */
  68815. onParsedObservable: Observable<IGLTFLoaderData>;
  68816. private _onParsedObserver;
  68817. /**
  68818. * Raised when the asset has been parsed
  68819. */
  68820. onParsed: (loaderData: IGLTFLoaderData) => void;
  68821. /**
  68822. * 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.
  68823. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68824. * Defaults to true.
  68825. * @hidden
  68826. */
  68827. static IncrementalLoading: boolean;
  68828. /**
  68829. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68830. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68831. * @hidden
  68832. */
  68833. static HomogeneousCoordinates: boolean;
  68834. /**
  68835. * The coordinate system mode. Defaults to AUTO.
  68836. */
  68837. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68838. /**
  68839. * The animation start mode. Defaults to FIRST.
  68840. */
  68841. animationStartMode: GLTFLoaderAnimationStartMode;
  68842. /**
  68843. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68844. */
  68845. compileMaterials: boolean;
  68846. /**
  68847. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68848. */
  68849. useClipPlane: boolean;
  68850. /**
  68851. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68852. */
  68853. compileShadowGenerators: boolean;
  68854. /**
  68855. * Defines if the Alpha blended materials are only applied as coverage.
  68856. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68857. * If true, no extra effects are applied to transparent pixels.
  68858. */
  68859. transparencyAsCoverage: boolean;
  68860. /**
  68861. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68862. * Enabling will disable offline support and glTF validator.
  68863. * Defaults to false.
  68864. */
  68865. useRangeRequests: boolean;
  68866. /**
  68867. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68868. */
  68869. createInstances: boolean;
  68870. /**
  68871. * Function called before loading a url referenced by the asset.
  68872. */
  68873. preprocessUrlAsync: (url: string) => Promise<string>;
  68874. /**
  68875. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68876. */
  68877. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68878. private _onMeshLoadedObserver;
  68879. /**
  68880. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68881. */
  68882. onMeshLoaded: (mesh: AbstractMesh) => void;
  68883. /**
  68884. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68885. */
  68886. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68887. private _onTextureLoadedObserver;
  68888. /**
  68889. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68890. */
  68891. onTextureLoaded: (texture: BaseTexture) => void;
  68892. /**
  68893. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68894. */
  68895. readonly onMaterialLoadedObservable: Observable<Material>;
  68896. private _onMaterialLoadedObserver;
  68897. /**
  68898. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68899. */
  68900. onMaterialLoaded: (material: Material) => void;
  68901. /**
  68902. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68903. */
  68904. readonly onCameraLoadedObservable: Observable<Camera>;
  68905. private _onCameraLoadedObserver;
  68906. /**
  68907. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68908. */
  68909. onCameraLoaded: (camera: Camera) => void;
  68910. /**
  68911. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68912. * For assets with LODs, raised when all of the LODs are complete.
  68913. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68914. */
  68915. readonly onCompleteObservable: Observable<void>;
  68916. private _onCompleteObserver;
  68917. /**
  68918. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68919. * For assets with LODs, raised when all of the LODs are complete.
  68920. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68921. */
  68922. onComplete: () => void;
  68923. /**
  68924. * Observable raised when an error occurs.
  68925. */
  68926. readonly onErrorObservable: Observable<any>;
  68927. private _onErrorObserver;
  68928. /**
  68929. * Callback raised when an error occurs.
  68930. */
  68931. onError: (reason: any) => void;
  68932. /**
  68933. * Observable raised after the loader is disposed.
  68934. */
  68935. readonly onDisposeObservable: Observable<void>;
  68936. private _onDisposeObserver;
  68937. /**
  68938. * Callback raised after the loader is disposed.
  68939. */
  68940. onDispose: () => void;
  68941. /**
  68942. * Observable raised after a loader extension is created.
  68943. * Set additional options for a loader extension in this event.
  68944. */
  68945. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68946. private _onExtensionLoadedObserver;
  68947. /**
  68948. * Callback raised after a loader extension is created.
  68949. */
  68950. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68951. /**
  68952. * Defines if the loader logging is enabled.
  68953. */
  68954. loggingEnabled: boolean;
  68955. /**
  68956. * Defines if the loader should capture performance counters.
  68957. */
  68958. capturePerformanceCounters: boolean;
  68959. /**
  68960. * Defines if the loader should validate the asset.
  68961. */
  68962. validate: boolean;
  68963. /**
  68964. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68965. */
  68966. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68967. private _onValidatedObserver;
  68968. /**
  68969. * Callback raised after a loader extension is created.
  68970. */
  68971. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68972. private _loader;
  68973. /**
  68974. * Name of the loader ("gltf")
  68975. */
  68976. name: string;
  68977. /** @hidden */
  68978. extensions: ISceneLoaderPluginExtensions;
  68979. /**
  68980. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68981. */
  68982. dispose(): void;
  68983. /** @hidden */
  68984. _clear(): void;
  68985. /** @hidden */
  68986. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68987. /** @hidden */
  68988. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68989. /** @hidden */
  68990. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68991. meshes: AbstractMesh[];
  68992. particleSystems: IParticleSystem[];
  68993. skeletons: Skeleton[];
  68994. animationGroups: AnimationGroup[];
  68995. }>;
  68996. /** @hidden */
  68997. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68998. /** @hidden */
  68999. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69000. /** @hidden */
  69001. canDirectLoad(data: string): boolean;
  69002. /** @hidden */
  69003. directLoad(scene: Scene, data: string): any;
  69004. /**
  69005. * The callback that allows custom handling of the root url based on the response url.
  69006. * @param rootUrl the original root url
  69007. * @param responseURL the response url if available
  69008. * @returns the new root url
  69009. */
  69010. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  69011. /** @hidden */
  69012. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  69013. /**
  69014. * The loader state or null if the loader is not active.
  69015. */
  69016. readonly loaderState: Nullable<GLTFLoaderState>;
  69017. /**
  69018. * Returns a promise that resolves when the asset is completely loaded.
  69019. * @returns a promise that resolves when the asset is completely loaded.
  69020. */
  69021. whenCompleteAsync(): Promise<void>;
  69022. private _validateAsync;
  69023. private _getLoader;
  69024. private _parseJson;
  69025. private _unpackBinaryAsync;
  69026. private _unpackBinaryV1Async;
  69027. private _unpackBinaryV2Async;
  69028. private static _parseVersion;
  69029. private static _compareVersion;
  69030. private static readonly _logSpaces;
  69031. private _logIndentLevel;
  69032. private _loggingEnabled;
  69033. /** @hidden */
  69034. _log: (message: string) => void;
  69035. /** @hidden */
  69036. _logOpen(message: string): void;
  69037. /** @hidden */
  69038. _logClose(): void;
  69039. private _logEnabled;
  69040. private _logDisabled;
  69041. private _capturePerformanceCounters;
  69042. /** @hidden */
  69043. _startPerformanceCounter: (counterName: string) => void;
  69044. /** @hidden */
  69045. _endPerformanceCounter: (counterName: string) => void;
  69046. private _startPerformanceCounterEnabled;
  69047. private _startPerformanceCounterDisabled;
  69048. private _endPerformanceCounterEnabled;
  69049. private _endPerformanceCounterDisabled;
  69050. }
  69051. }
  69052. declare module BABYLON.GLTF1 {
  69053. /**
  69054. * Enums
  69055. * @hidden
  69056. */
  69057. export enum EComponentType {
  69058. BYTE = 5120,
  69059. UNSIGNED_BYTE = 5121,
  69060. SHORT = 5122,
  69061. UNSIGNED_SHORT = 5123,
  69062. FLOAT = 5126
  69063. }
  69064. /** @hidden */
  69065. export enum EShaderType {
  69066. FRAGMENT = 35632,
  69067. VERTEX = 35633
  69068. }
  69069. /** @hidden */
  69070. export enum EParameterType {
  69071. BYTE = 5120,
  69072. UNSIGNED_BYTE = 5121,
  69073. SHORT = 5122,
  69074. UNSIGNED_SHORT = 5123,
  69075. INT = 5124,
  69076. UNSIGNED_INT = 5125,
  69077. FLOAT = 5126,
  69078. FLOAT_VEC2 = 35664,
  69079. FLOAT_VEC3 = 35665,
  69080. FLOAT_VEC4 = 35666,
  69081. INT_VEC2 = 35667,
  69082. INT_VEC3 = 35668,
  69083. INT_VEC4 = 35669,
  69084. BOOL = 35670,
  69085. BOOL_VEC2 = 35671,
  69086. BOOL_VEC3 = 35672,
  69087. BOOL_VEC4 = 35673,
  69088. FLOAT_MAT2 = 35674,
  69089. FLOAT_MAT3 = 35675,
  69090. FLOAT_MAT4 = 35676,
  69091. SAMPLER_2D = 35678
  69092. }
  69093. /** @hidden */
  69094. export enum ETextureWrapMode {
  69095. CLAMP_TO_EDGE = 33071,
  69096. MIRRORED_REPEAT = 33648,
  69097. REPEAT = 10497
  69098. }
  69099. /** @hidden */
  69100. export enum ETextureFilterType {
  69101. NEAREST = 9728,
  69102. LINEAR = 9728,
  69103. NEAREST_MIPMAP_NEAREST = 9984,
  69104. LINEAR_MIPMAP_NEAREST = 9985,
  69105. NEAREST_MIPMAP_LINEAR = 9986,
  69106. LINEAR_MIPMAP_LINEAR = 9987
  69107. }
  69108. /** @hidden */
  69109. export enum ETextureFormat {
  69110. ALPHA = 6406,
  69111. RGB = 6407,
  69112. RGBA = 6408,
  69113. LUMINANCE = 6409,
  69114. LUMINANCE_ALPHA = 6410
  69115. }
  69116. /** @hidden */
  69117. export enum ECullingType {
  69118. FRONT = 1028,
  69119. BACK = 1029,
  69120. FRONT_AND_BACK = 1032
  69121. }
  69122. /** @hidden */
  69123. export enum EBlendingFunction {
  69124. ZERO = 0,
  69125. ONE = 1,
  69126. SRC_COLOR = 768,
  69127. ONE_MINUS_SRC_COLOR = 769,
  69128. DST_COLOR = 774,
  69129. ONE_MINUS_DST_COLOR = 775,
  69130. SRC_ALPHA = 770,
  69131. ONE_MINUS_SRC_ALPHA = 771,
  69132. DST_ALPHA = 772,
  69133. ONE_MINUS_DST_ALPHA = 773,
  69134. CONSTANT_COLOR = 32769,
  69135. ONE_MINUS_CONSTANT_COLOR = 32770,
  69136. CONSTANT_ALPHA = 32771,
  69137. ONE_MINUS_CONSTANT_ALPHA = 32772,
  69138. SRC_ALPHA_SATURATE = 776
  69139. }
  69140. /** @hidden */
  69141. export interface IGLTFProperty {
  69142. extensions?: {
  69143. [key: string]: any;
  69144. };
  69145. extras?: Object;
  69146. }
  69147. /** @hidden */
  69148. export interface IGLTFChildRootProperty extends IGLTFProperty {
  69149. name?: string;
  69150. }
  69151. /** @hidden */
  69152. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  69153. bufferView: string;
  69154. byteOffset: number;
  69155. byteStride: number;
  69156. count: number;
  69157. type: string;
  69158. componentType: EComponentType;
  69159. max?: number[];
  69160. min?: number[];
  69161. name?: string;
  69162. }
  69163. /** @hidden */
  69164. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  69165. buffer: string;
  69166. byteOffset: number;
  69167. byteLength: number;
  69168. byteStride: number;
  69169. target?: number;
  69170. }
  69171. /** @hidden */
  69172. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  69173. uri: string;
  69174. byteLength?: number;
  69175. type?: string;
  69176. }
  69177. /** @hidden */
  69178. export interface IGLTFShader extends IGLTFChildRootProperty {
  69179. uri: string;
  69180. type: EShaderType;
  69181. }
  69182. /** @hidden */
  69183. export interface IGLTFProgram extends IGLTFChildRootProperty {
  69184. attributes: string[];
  69185. fragmentShader: string;
  69186. vertexShader: string;
  69187. }
  69188. /** @hidden */
  69189. export interface IGLTFTechniqueParameter {
  69190. type: number;
  69191. count?: number;
  69192. semantic?: string;
  69193. node?: string;
  69194. value?: number | boolean | string | Array<any>;
  69195. source?: string;
  69196. babylonValue?: any;
  69197. }
  69198. /** @hidden */
  69199. export interface IGLTFTechniqueCommonProfile {
  69200. lightingModel: string;
  69201. texcoordBindings: Object;
  69202. parameters?: Array<any>;
  69203. }
  69204. /** @hidden */
  69205. export interface IGLTFTechniqueStatesFunctions {
  69206. blendColor?: number[];
  69207. blendEquationSeparate?: number[];
  69208. blendFuncSeparate?: number[];
  69209. colorMask: boolean[];
  69210. cullFace: number[];
  69211. }
  69212. /** @hidden */
  69213. export interface IGLTFTechniqueStates {
  69214. enable: number[];
  69215. functions: IGLTFTechniqueStatesFunctions;
  69216. }
  69217. /** @hidden */
  69218. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  69219. parameters: {
  69220. [key: string]: IGLTFTechniqueParameter;
  69221. };
  69222. program: string;
  69223. attributes: {
  69224. [key: string]: string;
  69225. };
  69226. uniforms: {
  69227. [key: string]: string;
  69228. };
  69229. states: IGLTFTechniqueStates;
  69230. }
  69231. /** @hidden */
  69232. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  69233. technique?: string;
  69234. values: string[];
  69235. }
  69236. /** @hidden */
  69237. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  69238. attributes: {
  69239. [key: string]: string;
  69240. };
  69241. indices: string;
  69242. material: string;
  69243. mode?: number;
  69244. }
  69245. /** @hidden */
  69246. export interface IGLTFMesh extends IGLTFChildRootProperty {
  69247. primitives: IGLTFMeshPrimitive[];
  69248. }
  69249. /** @hidden */
  69250. export interface IGLTFImage extends IGLTFChildRootProperty {
  69251. uri: string;
  69252. }
  69253. /** @hidden */
  69254. export interface IGLTFSampler extends IGLTFChildRootProperty {
  69255. magFilter?: number;
  69256. minFilter?: number;
  69257. wrapS?: number;
  69258. wrapT?: number;
  69259. }
  69260. /** @hidden */
  69261. export interface IGLTFTexture extends IGLTFChildRootProperty {
  69262. sampler: string;
  69263. source: string;
  69264. format?: ETextureFormat;
  69265. internalFormat?: ETextureFormat;
  69266. target?: number;
  69267. type?: number;
  69268. babylonTexture?: Texture;
  69269. }
  69270. /** @hidden */
  69271. export interface IGLTFAmbienLight {
  69272. color?: number[];
  69273. }
  69274. /** @hidden */
  69275. export interface IGLTFDirectionalLight {
  69276. color?: number[];
  69277. }
  69278. /** @hidden */
  69279. export interface IGLTFPointLight {
  69280. color?: number[];
  69281. constantAttenuation?: number;
  69282. linearAttenuation?: number;
  69283. quadraticAttenuation?: number;
  69284. }
  69285. /** @hidden */
  69286. export interface IGLTFSpotLight {
  69287. color?: number[];
  69288. constantAttenuation?: number;
  69289. fallOfAngle?: number;
  69290. fallOffExponent?: number;
  69291. linearAttenuation?: number;
  69292. quadraticAttenuation?: number;
  69293. }
  69294. /** @hidden */
  69295. export interface IGLTFLight extends IGLTFChildRootProperty {
  69296. type: string;
  69297. }
  69298. /** @hidden */
  69299. export interface IGLTFCameraOrthographic {
  69300. xmag: number;
  69301. ymag: number;
  69302. zfar: number;
  69303. znear: number;
  69304. }
  69305. /** @hidden */
  69306. export interface IGLTFCameraPerspective {
  69307. aspectRatio: number;
  69308. yfov: number;
  69309. zfar: number;
  69310. znear: number;
  69311. }
  69312. /** @hidden */
  69313. export interface IGLTFCamera extends IGLTFChildRootProperty {
  69314. type: string;
  69315. }
  69316. /** @hidden */
  69317. export interface IGLTFAnimationChannelTarget {
  69318. id: string;
  69319. path: string;
  69320. }
  69321. /** @hidden */
  69322. export interface IGLTFAnimationChannel {
  69323. sampler: string;
  69324. target: IGLTFAnimationChannelTarget;
  69325. }
  69326. /** @hidden */
  69327. export interface IGLTFAnimationSampler {
  69328. input: string;
  69329. output: string;
  69330. interpolation?: string;
  69331. }
  69332. /** @hidden */
  69333. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  69334. channels?: IGLTFAnimationChannel[];
  69335. parameters?: {
  69336. [key: string]: string;
  69337. };
  69338. samplers?: {
  69339. [key: string]: IGLTFAnimationSampler;
  69340. };
  69341. }
  69342. /** @hidden */
  69343. export interface IGLTFNodeInstanceSkin {
  69344. skeletons: string[];
  69345. skin: string;
  69346. meshes: string[];
  69347. }
  69348. /** @hidden */
  69349. export interface IGLTFSkins extends IGLTFChildRootProperty {
  69350. bindShapeMatrix: number[];
  69351. inverseBindMatrices: string;
  69352. jointNames: string[];
  69353. babylonSkeleton?: Skeleton;
  69354. }
  69355. /** @hidden */
  69356. export interface IGLTFNode extends IGLTFChildRootProperty {
  69357. camera?: string;
  69358. children: string[];
  69359. skin?: string;
  69360. jointName?: string;
  69361. light?: string;
  69362. matrix: number[];
  69363. mesh?: string;
  69364. meshes?: string[];
  69365. rotation?: number[];
  69366. scale?: number[];
  69367. translation?: number[];
  69368. babylonNode?: Node;
  69369. }
  69370. /** @hidden */
  69371. export interface IGLTFScene extends IGLTFChildRootProperty {
  69372. nodes: string[];
  69373. }
  69374. /** @hidden */
  69375. export interface IGLTFRuntime {
  69376. extensions: {
  69377. [key: string]: any;
  69378. };
  69379. accessors: {
  69380. [key: string]: IGLTFAccessor;
  69381. };
  69382. buffers: {
  69383. [key: string]: IGLTFBuffer;
  69384. };
  69385. bufferViews: {
  69386. [key: string]: IGLTFBufferView;
  69387. };
  69388. meshes: {
  69389. [key: string]: IGLTFMesh;
  69390. };
  69391. lights: {
  69392. [key: string]: IGLTFLight;
  69393. };
  69394. cameras: {
  69395. [key: string]: IGLTFCamera;
  69396. };
  69397. nodes: {
  69398. [key: string]: IGLTFNode;
  69399. };
  69400. images: {
  69401. [key: string]: IGLTFImage;
  69402. };
  69403. textures: {
  69404. [key: string]: IGLTFTexture;
  69405. };
  69406. shaders: {
  69407. [key: string]: IGLTFShader;
  69408. };
  69409. programs: {
  69410. [key: string]: IGLTFProgram;
  69411. };
  69412. samplers: {
  69413. [key: string]: IGLTFSampler;
  69414. };
  69415. techniques: {
  69416. [key: string]: IGLTFTechnique;
  69417. };
  69418. materials: {
  69419. [key: string]: IGLTFMaterial;
  69420. };
  69421. animations: {
  69422. [key: string]: IGLTFAnimation;
  69423. };
  69424. skins: {
  69425. [key: string]: IGLTFSkins;
  69426. };
  69427. currentScene?: Object;
  69428. scenes: {
  69429. [key: string]: IGLTFScene;
  69430. };
  69431. extensionsUsed: string[];
  69432. extensionsRequired?: string[];
  69433. buffersCount: number;
  69434. shaderscount: number;
  69435. scene: Scene;
  69436. rootUrl: string;
  69437. loadedBufferCount: number;
  69438. loadedBufferViews: {
  69439. [name: string]: ArrayBufferView;
  69440. };
  69441. loadedShaderCount: number;
  69442. importOnlyMeshes: boolean;
  69443. importMeshesNames?: string[];
  69444. dummyNodes: Node[];
  69445. }
  69446. /** @hidden */
  69447. export interface INodeToRoot {
  69448. bone: Bone;
  69449. node: IGLTFNode;
  69450. id: string;
  69451. }
  69452. /** @hidden */
  69453. export interface IJointNode {
  69454. node: IGLTFNode;
  69455. id: string;
  69456. }
  69457. }
  69458. declare module BABYLON.GLTF1 {
  69459. /**
  69460. * Utils functions for GLTF
  69461. * @hidden
  69462. */
  69463. export class GLTFUtils {
  69464. /**
  69465. * Sets the given "parameter" matrix
  69466. * @param scene: the Scene object
  69467. * @param source: the source node where to pick the matrix
  69468. * @param parameter: the GLTF technique parameter
  69469. * @param uniformName: the name of the shader's uniform
  69470. * @param shaderMaterial: the shader material
  69471. */
  69472. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  69473. /**
  69474. * Sets the given "parameter" matrix
  69475. * @param shaderMaterial: the shader material
  69476. * @param uniform: the name of the shader's uniform
  69477. * @param value: the value of the uniform
  69478. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  69479. */
  69480. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  69481. /**
  69482. * Returns the wrap mode of the texture
  69483. * @param mode: the mode value
  69484. */
  69485. static GetWrapMode(mode: number): number;
  69486. /**
  69487. * Returns the byte stride giving an accessor
  69488. * @param accessor: the GLTF accessor objet
  69489. */
  69490. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  69491. /**
  69492. * Returns the texture filter mode giving a mode value
  69493. * @param mode: the filter mode value
  69494. */
  69495. static GetTextureFilterMode(mode: number): ETextureFilterType;
  69496. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  69497. /**
  69498. * Returns a buffer from its accessor
  69499. * @param gltfRuntime: the GLTF runtime
  69500. * @param accessor: the GLTF accessor
  69501. */
  69502. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  69503. /**
  69504. * Decodes a buffer view into a string
  69505. * @param view: the buffer view
  69506. */
  69507. static DecodeBufferToText(view: ArrayBufferView): string;
  69508. /**
  69509. * Returns the default material of gltf. Related to
  69510. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  69511. * @param scene: the Babylon.js scene
  69512. */
  69513. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  69514. private static _DefaultMaterial;
  69515. }
  69516. }
  69517. declare module BABYLON.GLTF1 {
  69518. /**
  69519. * Implementation of the base glTF spec
  69520. * @hidden
  69521. */
  69522. export class GLTFLoaderBase {
  69523. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  69524. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69525. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  69526. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69527. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  69528. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69529. }
  69530. /**
  69531. * glTF V1 Loader
  69532. * @hidden
  69533. */
  69534. export class GLTFLoader implements IGLTFLoader {
  69535. static Extensions: {
  69536. [name: string]: GLTFLoaderExtension;
  69537. };
  69538. static RegisterExtension(extension: GLTFLoaderExtension): void;
  69539. state: Nullable<GLTFLoaderState>;
  69540. dispose(): void;
  69541. private _importMeshAsync;
  69542. /**
  69543. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  69544. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69545. * @param scene the scene the meshes should be added to
  69546. * @param data gltf data containing information of the meshes in a loaded file
  69547. * @param rootUrl root url to load from
  69548. * @param onProgress event that fires when loading progress has occured
  69549. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69550. */
  69551. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  69552. meshes: AbstractMesh[];
  69553. particleSystems: IParticleSystem[];
  69554. skeletons: Skeleton[];
  69555. animationGroups: AnimationGroup[];
  69556. }>;
  69557. private _loadAsync;
  69558. /**
  69559. * Imports all objects from a loaded gltf file and adds them to the scene
  69560. * @param scene the scene the objects should be added to
  69561. * @param data gltf data containing information of the meshes in a loaded file
  69562. * @param rootUrl root url to load from
  69563. * @param onProgress event that fires when loading progress has occured
  69564. * @returns a promise which completes when objects have been loaded to the scene
  69565. */
  69566. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69567. private _loadShadersAsync;
  69568. private _loadBuffersAsync;
  69569. private _createNodes;
  69570. }
  69571. /** @hidden */
  69572. export abstract class GLTFLoaderExtension {
  69573. private _name;
  69574. constructor(name: string);
  69575. readonly name: string;
  69576. /**
  69577. * Defines an override for loading the runtime
  69578. * Return true to stop further extensions from loading the runtime
  69579. */
  69580. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69581. /**
  69582. * Defines an onverride for creating gltf runtime
  69583. * Return true to stop further extensions from creating the runtime
  69584. */
  69585. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69586. /**
  69587. * Defines an override for loading buffers
  69588. * Return true to stop further extensions from loading this buffer
  69589. */
  69590. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69591. /**
  69592. * Defines an override for loading texture buffers
  69593. * Return true to stop further extensions from loading this texture data
  69594. */
  69595. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69596. /**
  69597. * Defines an override for creating textures
  69598. * Return true to stop further extensions from loading this texture
  69599. */
  69600. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69601. /**
  69602. * Defines an override for loading shader strings
  69603. * Return true to stop further extensions from loading this shader data
  69604. */
  69605. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69606. /**
  69607. * Defines an override for loading materials
  69608. * Return true to stop further extensions from loading this material
  69609. */
  69610. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69611. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69612. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69613. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69614. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69615. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69616. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69617. private static LoadTextureBufferAsync;
  69618. private static CreateTextureAsync;
  69619. private static ApplyExtensions;
  69620. }
  69621. }
  69622. declare module BABYLON.GLTF1 {
  69623. /** @hidden */
  69624. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69625. private _bin;
  69626. constructor();
  69627. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69628. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69629. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69630. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69631. }
  69632. }
  69633. declare module BABYLON.GLTF1 {
  69634. /** @hidden */
  69635. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69636. constructor();
  69637. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69638. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69639. private _loadTexture;
  69640. }
  69641. }
  69642. declare module BABYLON.GLTF2.Loader {
  69643. /**
  69644. * Loader interface with an index field.
  69645. */
  69646. export interface IArrayItem {
  69647. /**
  69648. * The index of this item in the array.
  69649. */
  69650. index: number;
  69651. }
  69652. /**
  69653. * Loader interface with additional members.
  69654. */
  69655. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69656. /** @hidden */
  69657. _data?: Promise<ArrayBufferView>;
  69658. /** @hidden */
  69659. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69660. }
  69661. /**
  69662. * Loader interface with additional members.
  69663. */
  69664. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69665. }
  69666. /** @hidden */
  69667. export interface _IAnimationSamplerData {
  69668. input: Float32Array;
  69669. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69670. output: Float32Array;
  69671. }
  69672. /**
  69673. * Loader interface with additional members.
  69674. */
  69675. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69676. /** @hidden */
  69677. _data?: Promise<_IAnimationSamplerData>;
  69678. }
  69679. /**
  69680. * Loader interface with additional members.
  69681. */
  69682. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69683. channels: IAnimationChannel[];
  69684. samplers: IAnimationSampler[];
  69685. /** @hidden */
  69686. _babylonAnimationGroup?: AnimationGroup;
  69687. }
  69688. /**
  69689. * Loader interface with additional members.
  69690. */
  69691. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69692. /** @hidden */
  69693. _data?: Promise<ArrayBufferView>;
  69694. }
  69695. /**
  69696. * Loader interface with additional members.
  69697. */
  69698. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69699. /** @hidden */
  69700. _data?: Promise<ArrayBufferView>;
  69701. /** @hidden */
  69702. _babylonBuffer?: Promise<Buffer>;
  69703. }
  69704. /**
  69705. * Loader interface with additional members.
  69706. */
  69707. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69708. }
  69709. /**
  69710. * Loader interface with additional members.
  69711. */
  69712. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69713. /** @hidden */
  69714. _data?: Promise<ArrayBufferView>;
  69715. }
  69716. /**
  69717. * Loader interface with additional members.
  69718. */
  69719. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69720. }
  69721. /**
  69722. * Loader interface with additional members.
  69723. */
  69724. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69725. }
  69726. /**
  69727. * Loader interface with additional members.
  69728. */
  69729. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69730. baseColorTexture?: ITextureInfo;
  69731. metallicRoughnessTexture?: ITextureInfo;
  69732. }
  69733. /**
  69734. * Loader interface with additional members.
  69735. */
  69736. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69737. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69738. normalTexture?: IMaterialNormalTextureInfo;
  69739. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69740. emissiveTexture?: ITextureInfo;
  69741. /** @hidden */
  69742. _data?: {
  69743. [babylonDrawMode: number]: {
  69744. babylonMaterial: Material;
  69745. babylonMeshes: AbstractMesh[];
  69746. promise: Promise<void>;
  69747. };
  69748. };
  69749. }
  69750. /**
  69751. * Loader interface with additional members.
  69752. */
  69753. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69754. primitives: IMeshPrimitive[];
  69755. }
  69756. /**
  69757. * Loader interface with additional members.
  69758. */
  69759. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69760. /** @hidden */
  69761. _instanceData?: {
  69762. babylonSourceMesh: Mesh;
  69763. promise: Promise<any>;
  69764. };
  69765. }
  69766. /**
  69767. * Loader interface with additional members.
  69768. */
  69769. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69770. /**
  69771. * The parent glTF node.
  69772. */
  69773. parent?: INode;
  69774. /** @hidden */
  69775. _babylonTransformNode?: TransformNode;
  69776. /** @hidden */
  69777. _primitiveBabylonMeshes?: AbstractMesh[];
  69778. /** @hidden */
  69779. _babylonBones?: Bone[];
  69780. /** @hidden */
  69781. _numMorphTargets?: number;
  69782. }
  69783. /** @hidden */
  69784. export interface _ISamplerData {
  69785. noMipMaps: boolean;
  69786. samplingMode: number;
  69787. wrapU: number;
  69788. wrapV: number;
  69789. }
  69790. /**
  69791. * Loader interface with additional members.
  69792. */
  69793. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69794. /** @hidden */
  69795. _data?: _ISamplerData;
  69796. }
  69797. /**
  69798. * Loader interface with additional members.
  69799. */
  69800. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69801. }
  69802. /**
  69803. * Loader interface with additional members.
  69804. */
  69805. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69806. /** @hidden */
  69807. _data?: {
  69808. babylonSkeleton: Skeleton;
  69809. promise: Promise<void>;
  69810. };
  69811. }
  69812. /**
  69813. * Loader interface with additional members.
  69814. */
  69815. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69816. }
  69817. /**
  69818. * Loader interface with additional members.
  69819. */
  69820. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69821. }
  69822. /**
  69823. * Loader interface with additional members.
  69824. */
  69825. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69826. accessors?: IAccessor[];
  69827. animations?: IAnimation[];
  69828. buffers?: IBuffer[];
  69829. bufferViews?: IBufferView[];
  69830. cameras?: ICamera[];
  69831. images?: IImage[];
  69832. materials?: IMaterial[];
  69833. meshes?: IMesh[];
  69834. nodes?: INode[];
  69835. samplers?: ISampler[];
  69836. scenes?: IScene[];
  69837. skins?: ISkin[];
  69838. textures?: ITexture[];
  69839. }
  69840. }
  69841. declare module BABYLON.GLTF2 {
  69842. /**
  69843. * Interface for a glTF loader extension.
  69844. */
  69845. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69846. /**
  69847. * Called after the loader state changes to LOADING.
  69848. */
  69849. onLoading?(): void;
  69850. /**
  69851. * Called after the loader state changes to READY.
  69852. */
  69853. onReady?(): void;
  69854. /**
  69855. * Define this method to modify the default behavior when loading scenes.
  69856. * @param context The context when loading the asset
  69857. * @param scene The glTF scene property
  69858. * @returns A promise that resolves when the load is complete or null if not handled
  69859. */
  69860. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69861. /**
  69862. * Define this method to modify the default behavior when loading nodes.
  69863. * @param context The context when loading the asset
  69864. * @param node The glTF node property
  69865. * @param assign A function called synchronously after parsing the glTF properties
  69866. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69867. */
  69868. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69869. /**
  69870. * Define this method to modify the default behavior when loading cameras.
  69871. * @param context The context when loading the asset
  69872. * @param camera The glTF camera property
  69873. * @param assign A function called synchronously after parsing the glTF properties
  69874. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69875. */
  69876. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69877. /**
  69878. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69879. * @param context The context when loading the asset
  69880. * @param primitive The glTF mesh primitive property
  69881. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69882. */
  69883. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69884. /**
  69885. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69886. * @param context The context when loading the asset
  69887. * @param name The mesh name when loading the asset
  69888. * @param node The glTF node when loading the asset
  69889. * @param mesh The glTF mesh when loading the asset
  69890. * @param primitive The glTF mesh primitive property
  69891. * @param assign A function called synchronously after parsing the glTF properties
  69892. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69893. */
  69894. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69895. /**
  69896. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69897. * @param context The context when loading the asset
  69898. * @param material The glTF material property
  69899. * @param assign A function called synchronously after parsing the glTF properties
  69900. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69901. */
  69902. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69903. /**
  69904. * Define this method to modify the default behavior when creating materials.
  69905. * @param context The context when loading the asset
  69906. * @param material The glTF material property
  69907. * @param babylonDrawMode The draw mode for the Babylon material
  69908. * @returns The Babylon material or null if not handled
  69909. */
  69910. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69911. /**
  69912. * Define this method to modify the default behavior when loading material properties.
  69913. * @param context The context when loading the asset
  69914. * @param material The glTF material property
  69915. * @param babylonMaterial The Babylon material
  69916. * @returns A promise that resolves when the load is complete or null if not handled
  69917. */
  69918. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69919. /**
  69920. * Define this method to modify the default behavior when loading texture infos.
  69921. * @param context The context when loading the asset
  69922. * @param textureInfo The glTF texture info property
  69923. * @param assign A function called synchronously after parsing the glTF properties
  69924. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69925. */
  69926. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69927. /**
  69928. * Define this method to modify the default behavior when loading animations.
  69929. * @param context The context when loading the asset
  69930. * @param animation The glTF animation property
  69931. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69932. */
  69933. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69934. /**
  69935. * @hidden Define this method to modify the default behavior when loading skins.
  69936. * @param context The context when loading the asset
  69937. * @param node The glTF node property
  69938. * @param skin The glTF skin property
  69939. * @returns A promise that resolves when the load is complete or null if not handled
  69940. */
  69941. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69942. /**
  69943. * @hidden Define this method to modify the default behavior when loading uris.
  69944. * @param context The context when loading the asset
  69945. * @param property The glTF property associated with the uri
  69946. * @param uri The uri to load
  69947. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69948. */
  69949. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69950. /**
  69951. * Define this method to modify the default behavior when loading buffer views.
  69952. * @param context The context when loading the asset
  69953. * @param bufferView The glTF buffer view property
  69954. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69955. */
  69956. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69957. /**
  69958. * Define this method to modify the default behavior when loading buffers.
  69959. * @param context The context when loading the asset
  69960. * @param buffer The glTF buffer property
  69961. * @param byteOffset The byte offset to load
  69962. * @param byteLength The byte length to load
  69963. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69964. */
  69965. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69966. }
  69967. }
  69968. declare module BABYLON.GLTF2 {
  69969. /**
  69970. * Helper class for working with arrays when loading the glTF asset
  69971. */
  69972. export class ArrayItem {
  69973. /**
  69974. * Gets an item from the given array.
  69975. * @param context The context when loading the asset
  69976. * @param array The array to get the item from
  69977. * @param index The index to the array
  69978. * @returns The array item
  69979. */
  69980. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69981. /**
  69982. * Assign an `index` field to each item of the given array.
  69983. * @param array The array of items
  69984. */
  69985. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69986. }
  69987. /**
  69988. * The glTF 2.0 loader
  69989. */
  69990. export class GLTFLoader implements IGLTFLoader {
  69991. /** @hidden */
  69992. _completePromises: Promise<any>[];
  69993. private _disposed;
  69994. private _parent;
  69995. private _state;
  69996. private _extensions;
  69997. private _rootUrl;
  69998. private _fileName;
  69999. private _uniqueRootUrl;
  70000. private _gltf;
  70001. private _bin;
  70002. private _babylonScene;
  70003. private _rootBabylonMesh;
  70004. private _defaultBabylonMaterialData;
  70005. private _progressCallback?;
  70006. private _requests;
  70007. private static readonly _DefaultSampler;
  70008. private static _RegisteredExtensions;
  70009. /**
  70010. * Registers a loader extension.
  70011. * @param name The name of the loader extension.
  70012. * @param factory The factory function that creates the loader extension.
  70013. */
  70014. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  70015. /**
  70016. * Unregisters a loader extension.
  70017. * @param name The name of the loader extension.
  70018. * @returns A boolean indicating whether the extension has been unregistered
  70019. */
  70020. static UnregisterExtension(name: string): boolean;
  70021. /**
  70022. * Gets the loader state.
  70023. */
  70024. readonly state: Nullable<GLTFLoaderState>;
  70025. /**
  70026. * The object that represents the glTF JSON.
  70027. */
  70028. readonly gltf: IGLTF;
  70029. /**
  70030. * The BIN chunk of a binary glTF.
  70031. */
  70032. readonly bin: Nullable<IDataBuffer>;
  70033. /**
  70034. * The parent file loader.
  70035. */
  70036. readonly parent: GLTFFileLoader;
  70037. /**
  70038. * The Babylon scene when loading the asset.
  70039. */
  70040. readonly babylonScene: Scene;
  70041. /**
  70042. * The root Babylon mesh when loading the asset.
  70043. */
  70044. readonly rootBabylonMesh: Mesh;
  70045. /** @hidden */
  70046. constructor(parent: GLTFFileLoader);
  70047. /** @hidden */
  70048. dispose(): void;
  70049. /** @hidden */
  70050. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70051. meshes: AbstractMesh[];
  70052. particleSystems: IParticleSystem[];
  70053. skeletons: Skeleton[];
  70054. animationGroups: AnimationGroup[];
  70055. }>;
  70056. /** @hidden */
  70057. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70058. private _loadAsync;
  70059. private _loadData;
  70060. private _setupData;
  70061. private _loadExtensions;
  70062. private _checkExtensions;
  70063. private _setState;
  70064. private _createRootNode;
  70065. /**
  70066. * Loads a glTF scene.
  70067. * @param context The context when loading the asset
  70068. * @param scene The glTF scene property
  70069. * @returns A promise that resolves when the load is complete
  70070. */
  70071. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  70072. private _forEachPrimitive;
  70073. private _getMeshes;
  70074. private _getSkeletons;
  70075. private _getAnimationGroups;
  70076. private _startAnimations;
  70077. /**
  70078. * Loads a glTF node.
  70079. * @param context The context when loading the asset
  70080. * @param node The glTF node property
  70081. * @param assign A function called synchronously after parsing the glTF properties
  70082. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  70083. */
  70084. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  70085. private _loadMeshAsync;
  70086. /**
  70087. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  70088. * @param context The context when loading the asset
  70089. * @param name The mesh name when loading the asset
  70090. * @param node The glTF node when loading the asset
  70091. * @param mesh The glTF mesh when loading the asset
  70092. * @param primitive The glTF mesh primitive property
  70093. * @param assign A function called synchronously after parsing the glTF properties
  70094. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  70095. */
  70096. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  70097. private _loadVertexDataAsync;
  70098. private _createMorphTargets;
  70099. private _loadMorphTargetsAsync;
  70100. private _loadMorphTargetVertexDataAsync;
  70101. private static _LoadTransform;
  70102. private _loadSkinAsync;
  70103. private _loadBones;
  70104. private _loadBone;
  70105. private _loadSkinInverseBindMatricesDataAsync;
  70106. private _updateBoneMatrices;
  70107. private _getNodeMatrix;
  70108. /**
  70109. * Loads a glTF camera.
  70110. * @param context The context when loading the asset
  70111. * @param camera The glTF camera property
  70112. * @param assign A function called synchronously after parsing the glTF properties
  70113. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  70114. */
  70115. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  70116. private _loadAnimationsAsync;
  70117. /**
  70118. * Loads a glTF animation.
  70119. * @param context The context when loading the asset
  70120. * @param animation The glTF animation property
  70121. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  70122. */
  70123. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  70124. /**
  70125. * @hidden Loads a glTF animation channel.
  70126. * @param context The context when loading the asset
  70127. * @param animationContext The context of the animation when loading the asset
  70128. * @param animation The glTF animation property
  70129. * @param channel The glTF animation channel property
  70130. * @param babylonAnimationGroup The babylon animation group property
  70131. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  70132. * @returns A void promise when the channel load is complete
  70133. */
  70134. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  70135. private _loadAnimationSamplerAsync;
  70136. private _loadBufferAsync;
  70137. /**
  70138. * Loads a glTF buffer view.
  70139. * @param context The context when loading the asset
  70140. * @param bufferView The glTF buffer view property
  70141. * @returns A promise that resolves with the loaded data when the load is complete
  70142. */
  70143. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  70144. private _loadAccessorAsync;
  70145. private _loadFloatAccessorAsync;
  70146. private _loadIndicesAccessorAsync;
  70147. private _loadVertexBufferViewAsync;
  70148. private _loadVertexAccessorAsync;
  70149. private _loadMaterialMetallicRoughnessPropertiesAsync;
  70150. /** @hidden */
  70151. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  70152. private _createDefaultMaterial;
  70153. /**
  70154. * Creates a Babylon material from a glTF material.
  70155. * @param context The context when loading the asset
  70156. * @param material The glTF material property
  70157. * @param babylonDrawMode The draw mode for the Babylon material
  70158. * @returns The Babylon material
  70159. */
  70160. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  70161. /**
  70162. * Loads properties from a glTF material into a Babylon material.
  70163. * @param context The context when loading the asset
  70164. * @param material The glTF material property
  70165. * @param babylonMaterial The Babylon material
  70166. * @returns A promise that resolves when the load is complete
  70167. */
  70168. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70169. /**
  70170. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  70171. * @param context The context when loading the asset
  70172. * @param material The glTF material property
  70173. * @param babylonMaterial The Babylon material
  70174. * @returns A promise that resolves when the load is complete
  70175. */
  70176. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70177. /**
  70178. * Loads the alpha properties from a glTF material into a Babylon material.
  70179. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  70180. * @param context The context when loading the asset
  70181. * @param material The glTF material property
  70182. * @param babylonMaterial The Babylon material
  70183. */
  70184. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  70185. /**
  70186. * Loads a glTF texture info.
  70187. * @param context The context when loading the asset
  70188. * @param textureInfo The glTF texture info property
  70189. * @param assign A function called synchronously after parsing the glTF properties
  70190. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  70191. */
  70192. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  70193. private _loadTextureAsync;
  70194. private _loadSampler;
  70195. /**
  70196. * Loads a glTF image.
  70197. * @param context The context when loading the asset
  70198. * @param image The glTF image property
  70199. * @returns A promise that resolves with the loaded data when the load is complete
  70200. */
  70201. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  70202. /**
  70203. * Loads a glTF uri.
  70204. * @param context The context when loading the asset
  70205. * @param property The glTF property associated with the uri
  70206. * @param uri The base64 or relative uri
  70207. * @returns A promise that resolves with the loaded data when the load is complete
  70208. */
  70209. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  70210. private _onProgress;
  70211. /**
  70212. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  70213. * @param babylonObject the Babylon object with metadata
  70214. * @param pointer the JSON pointer
  70215. */
  70216. static AddPointerMetadata(babylonObject: {
  70217. metadata: any;
  70218. }, pointer: string): void;
  70219. private static _GetTextureWrapMode;
  70220. private static _GetTextureSamplingMode;
  70221. private static _GetTypedArrayConstructor;
  70222. private static _GetTypedArray;
  70223. private static _GetNumComponents;
  70224. private static _ValidateUri;
  70225. private static _GetDrawMode;
  70226. private _compileMaterialsAsync;
  70227. private _compileShadowGeneratorsAsync;
  70228. private _forEachExtensions;
  70229. private _applyExtensions;
  70230. private _extensionsOnLoading;
  70231. private _extensionsOnReady;
  70232. private _extensionsLoadSceneAsync;
  70233. private _extensionsLoadNodeAsync;
  70234. private _extensionsLoadCameraAsync;
  70235. private _extensionsLoadVertexDataAsync;
  70236. private _extensionsLoadMeshPrimitiveAsync;
  70237. private _extensionsLoadMaterialAsync;
  70238. private _extensionsCreateMaterial;
  70239. private _extensionsLoadMaterialPropertiesAsync;
  70240. private _extensionsLoadTextureInfoAsync;
  70241. private _extensionsLoadAnimationAsync;
  70242. private _extensionsLoadSkinAsync;
  70243. private _extensionsLoadUriAsync;
  70244. private _extensionsLoadBufferViewAsync;
  70245. private _extensionsLoadBufferAsync;
  70246. /**
  70247. * Helper method called by a loader extension to load an glTF extension.
  70248. * @param context The context when loading the asset
  70249. * @param property The glTF property to load the extension from
  70250. * @param extensionName The name of the extension to load
  70251. * @param actionAsync The action to run
  70252. * @returns The promise returned by actionAsync or null if the extension does not exist
  70253. */
  70254. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70255. /**
  70256. * Helper method called by a loader extension to load a glTF extra.
  70257. * @param context The context when loading the asset
  70258. * @param property The glTF property to load the extra from
  70259. * @param extensionName The name of the extension to load
  70260. * @param actionAsync The action to run
  70261. * @returns The promise returned by actionAsync or null if the extra does not exist
  70262. */
  70263. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70264. /**
  70265. * Checks for presence of an extension.
  70266. * @param name The name of the extension to check
  70267. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  70268. */
  70269. isExtensionUsed(name: string): boolean;
  70270. /**
  70271. * Increments the indentation level and logs a message.
  70272. * @param message The message to log
  70273. */
  70274. logOpen(message: string): void;
  70275. /**
  70276. * Decrements the indentation level.
  70277. */
  70278. logClose(): void;
  70279. /**
  70280. * Logs a message
  70281. * @param message The message to log
  70282. */
  70283. log(message: string): void;
  70284. /**
  70285. * Starts a performance counter.
  70286. * @param counterName The name of the performance counter
  70287. */
  70288. startPerformanceCounter(counterName: string): void;
  70289. /**
  70290. * Ends a performance counter.
  70291. * @param counterName The name of the performance counter
  70292. */
  70293. endPerformanceCounter(counterName: string): void;
  70294. }
  70295. }
  70296. declare module BABYLON.GLTF2.Loader.Extensions {
  70297. /**
  70298. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  70299. */
  70300. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  70301. /**
  70302. * The name of this extension.
  70303. */
  70304. readonly name: string;
  70305. /**
  70306. * Defines whether this extension is enabled.
  70307. */
  70308. enabled: boolean;
  70309. private _loader;
  70310. private _lights?;
  70311. /** @hidden */
  70312. constructor(loader: GLTFLoader);
  70313. /** @hidden */
  70314. dispose(): void;
  70315. /** @hidden */
  70316. onLoading(): void;
  70317. /** @hidden */
  70318. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70319. private _loadLightAsync;
  70320. }
  70321. }
  70322. declare module BABYLON.GLTF2.Loader.Extensions {
  70323. /**
  70324. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  70325. */
  70326. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  70327. /**
  70328. * The name of this extension.
  70329. */
  70330. readonly name: string;
  70331. /**
  70332. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  70333. */
  70334. dracoCompression?: DracoCompression;
  70335. /**
  70336. * Defines whether this extension is enabled.
  70337. */
  70338. enabled: boolean;
  70339. private _loader;
  70340. /** @hidden */
  70341. constructor(loader: GLTFLoader);
  70342. /** @hidden */
  70343. dispose(): void;
  70344. /** @hidden */
  70345. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70346. }
  70347. }
  70348. declare module BABYLON.GLTF2.Loader.Extensions {
  70349. /**
  70350. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70351. */
  70352. export class KHR_lights implements IGLTFLoaderExtension {
  70353. /**
  70354. * The name of this extension.
  70355. */
  70356. readonly name: string;
  70357. /**
  70358. * Defines whether this extension is enabled.
  70359. */
  70360. enabled: boolean;
  70361. private _loader;
  70362. private _lights?;
  70363. /** @hidden */
  70364. constructor(loader: GLTFLoader);
  70365. /** @hidden */
  70366. dispose(): void;
  70367. /** @hidden */
  70368. onLoading(): void;
  70369. /** @hidden */
  70370. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70371. }
  70372. }
  70373. declare module BABYLON.GLTF2.Loader.Extensions {
  70374. /**
  70375. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  70376. */
  70377. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  70378. /**
  70379. * The name of this extension.
  70380. */
  70381. readonly name: string;
  70382. /**
  70383. * Defines whether this extension is enabled.
  70384. */
  70385. enabled: boolean;
  70386. /**
  70387. * Defines a number that determines the order the extensions are applied.
  70388. */
  70389. order: number;
  70390. private _loader;
  70391. /** @hidden */
  70392. constructor(loader: GLTFLoader);
  70393. /** @hidden */
  70394. dispose(): void;
  70395. /** @hidden */
  70396. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70397. private _loadSpecularGlossinessPropertiesAsync;
  70398. }
  70399. }
  70400. declare module BABYLON.GLTF2.Loader.Extensions {
  70401. /**
  70402. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  70403. */
  70404. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  70405. /**
  70406. * The name of this extension.
  70407. */
  70408. readonly name: string;
  70409. /**
  70410. * Defines whether this extension is enabled.
  70411. */
  70412. enabled: boolean;
  70413. /**
  70414. * Defines a number that determines the order the extensions are applied.
  70415. */
  70416. order: number;
  70417. private _loader;
  70418. /** @hidden */
  70419. constructor(loader: GLTFLoader);
  70420. /** @hidden */
  70421. dispose(): void;
  70422. /** @hidden */
  70423. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70424. private _loadUnlitPropertiesAsync;
  70425. }
  70426. }
  70427. declare module BABYLON.GLTF2.Loader.Extensions {
  70428. /**
  70429. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70430. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  70431. * !!! Experimental Extension Subject to Changes !!!
  70432. */
  70433. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  70434. /**
  70435. * The name of this extension.
  70436. */
  70437. readonly name: string;
  70438. /**
  70439. * Defines whether this extension is enabled.
  70440. */
  70441. enabled: boolean;
  70442. /**
  70443. * Defines a number that determines the order the extensions are applied.
  70444. */
  70445. order: number;
  70446. private _loader;
  70447. /** @hidden */
  70448. constructor(loader: GLTFLoader);
  70449. /** @hidden */
  70450. dispose(): void;
  70451. /** @hidden */
  70452. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70453. private _loadClearCoatPropertiesAsync;
  70454. }
  70455. }
  70456. declare module BABYLON.GLTF2.Loader.Extensions {
  70457. /**
  70458. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  70459. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70460. * !!! Experimental Extension Subject to Changes !!!
  70461. */
  70462. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  70463. /**
  70464. * The name of this extension.
  70465. */
  70466. readonly name: string;
  70467. /**
  70468. * Defines whether this extension is enabled.
  70469. */
  70470. enabled: boolean;
  70471. /**
  70472. * Defines a number that determines the order the extensions are applied.
  70473. */
  70474. order: number;
  70475. private _loader;
  70476. /** @hidden */
  70477. constructor(loader: GLTFLoader);
  70478. /** @hidden */
  70479. dispose(): void;
  70480. /** @hidden */
  70481. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70482. private _loadSheenPropertiesAsync;
  70483. }
  70484. }
  70485. declare module BABYLON.GLTF2.Loader.Extensions {
  70486. /**
  70487. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70488. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70489. * !!! Experimental Extension Subject to Changes !!!
  70490. */
  70491. export class KHR_materials_specular implements IGLTFLoaderExtension {
  70492. /**
  70493. * The name of this extension.
  70494. */
  70495. readonly name: string;
  70496. /**
  70497. * Defines whether this extension is enabled.
  70498. */
  70499. enabled: boolean;
  70500. /**
  70501. * Defines a number that determines the order the extensions are applied.
  70502. */
  70503. order: number;
  70504. private _loader;
  70505. /** @hidden */
  70506. constructor(loader: GLTFLoader);
  70507. /** @hidden */
  70508. dispose(): void;
  70509. /** @hidden */
  70510. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70511. private _loadSpecularPropertiesAsync;
  70512. }
  70513. }
  70514. declare module BABYLON.GLTF2.Loader.Extensions {
  70515. /**
  70516. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  70517. */
  70518. export class KHR_texture_transform implements IGLTFLoaderExtension {
  70519. /**
  70520. * The name of this extension.
  70521. */
  70522. readonly name: string;
  70523. /**
  70524. * Defines whether this extension is enabled.
  70525. */
  70526. enabled: boolean;
  70527. private _loader;
  70528. /** @hidden */
  70529. constructor(loader: GLTFLoader);
  70530. /** @hidden */
  70531. dispose(): void;
  70532. /** @hidden */
  70533. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70534. }
  70535. }
  70536. declare module BABYLON.GLTF2.Loader.Extensions {
  70537. /**
  70538. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  70539. */
  70540. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  70541. /**
  70542. * The name of this extension.
  70543. */
  70544. readonly name: string;
  70545. /**
  70546. * Defines whether this extension is enabled.
  70547. */
  70548. enabled: boolean;
  70549. private _loader;
  70550. private _clips;
  70551. private _emitters;
  70552. /** @hidden */
  70553. constructor(loader: GLTFLoader);
  70554. /** @hidden */
  70555. dispose(): void;
  70556. /** @hidden */
  70557. onLoading(): void;
  70558. /** @hidden */
  70559. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70560. /** @hidden */
  70561. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70562. /** @hidden */
  70563. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70564. private _loadClipAsync;
  70565. private _loadEmitterAsync;
  70566. private _getEventAction;
  70567. private _loadAnimationEventAsync;
  70568. }
  70569. }
  70570. declare module BABYLON.GLTF2.Loader.Extensions {
  70571. /**
  70572. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  70573. */
  70574. export class MSFT_lod implements IGLTFLoaderExtension {
  70575. /**
  70576. * The name of this extension.
  70577. */
  70578. readonly name: string;
  70579. /**
  70580. * Defines whether this extension is enabled.
  70581. */
  70582. enabled: boolean;
  70583. /**
  70584. * Defines a number that determines the order the extensions are applied.
  70585. */
  70586. order: number;
  70587. /**
  70588. * Maximum number of LODs to load, starting from the lowest LOD.
  70589. */
  70590. maxLODsToLoad: number;
  70591. /**
  70592. * Observable raised when all node LODs of one level are loaded.
  70593. * The event data is the index of the loaded LOD starting from zero.
  70594. * Dispose the loader to cancel the loading of the next level of LODs.
  70595. */
  70596. onNodeLODsLoadedObservable: Observable<number>;
  70597. /**
  70598. * Observable raised when all material LODs of one level are loaded.
  70599. * The event data is the index of the loaded LOD starting from zero.
  70600. * Dispose the loader to cancel the loading of the next level of LODs.
  70601. */
  70602. onMaterialLODsLoadedObservable: Observable<number>;
  70603. private _loader;
  70604. private _nodeIndexLOD;
  70605. private _nodeSignalLODs;
  70606. private _nodePromiseLODs;
  70607. private _materialIndexLOD;
  70608. private _materialSignalLODs;
  70609. private _materialPromiseLODs;
  70610. private _indexLOD;
  70611. private _bufferLODs;
  70612. /** @hidden */
  70613. constructor(loader: GLTFLoader);
  70614. /** @hidden */
  70615. dispose(): void;
  70616. /** @hidden */
  70617. onReady(): void;
  70618. /** @hidden */
  70619. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70620. /** @hidden */
  70621. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70622. /** @hidden */
  70623. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70624. /** @hidden */
  70625. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70626. private _loadBufferLOD;
  70627. /**
  70628. * Gets an array of LOD properties from lowest to highest.
  70629. */
  70630. private _getLODs;
  70631. private _disposeUnusedMaterials;
  70632. }
  70633. }
  70634. declare module BABYLON.GLTF2.Loader.Extensions {
  70635. /** @hidden */
  70636. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  70637. readonly name: string;
  70638. enabled: boolean;
  70639. private _loader;
  70640. constructor(loader: GLTFLoader);
  70641. dispose(): void;
  70642. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70643. }
  70644. }
  70645. declare module BABYLON.GLTF2.Loader.Extensions {
  70646. /** @hidden */
  70647. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  70648. readonly name: string;
  70649. enabled: boolean;
  70650. private _loader;
  70651. constructor(loader: GLTFLoader);
  70652. dispose(): void;
  70653. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70654. }
  70655. }
  70656. declare module BABYLON.GLTF2.Loader.Extensions {
  70657. /**
  70658. * Store glTF extras (if present) in BJS objects' metadata
  70659. */
  70660. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  70661. /**
  70662. * The name of this extension.
  70663. */
  70664. readonly name: string;
  70665. /**
  70666. * Defines whether this extension is enabled.
  70667. */
  70668. enabled: boolean;
  70669. private _loader;
  70670. private _assignExtras;
  70671. /** @hidden */
  70672. constructor(loader: GLTFLoader);
  70673. /** @hidden */
  70674. dispose(): void;
  70675. /** @hidden */
  70676. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70677. /** @hidden */
  70678. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70679. /** @hidden */
  70680. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70681. }
  70682. }
  70683. declare module BABYLON {
  70684. /**
  70685. * Class reading and parsing the MTL file bundled with the obj file.
  70686. */
  70687. export class MTLFileLoader {
  70688. /**
  70689. * All material loaded from the mtl will be set here
  70690. */
  70691. materials: StandardMaterial[];
  70692. /**
  70693. * This function will read the mtl file and create each material described inside
  70694. * This function could be improve by adding :
  70695. * -some component missing (Ni, Tf...)
  70696. * -including the specific options available
  70697. *
  70698. * @param scene defines the scene the material will be created in
  70699. * @param data defines the mtl data to parse
  70700. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70701. */
  70702. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70703. /**
  70704. * Gets the texture for the material.
  70705. *
  70706. * If the material is imported from input file,
  70707. * We sanitize the url to ensure it takes the textre from aside the material.
  70708. *
  70709. * @param rootUrl The root url to load from
  70710. * @param value The value stored in the mtl
  70711. * @return The Texture
  70712. */
  70713. private static _getTexture;
  70714. }
  70715. /**
  70716. * Options for loading OBJ/MTL files
  70717. */
  70718. type MeshLoadOptions = {
  70719. /**
  70720. * Defines if UVs are optimized by default during load.
  70721. */
  70722. OptimizeWithUV: boolean;
  70723. /**
  70724. * Defines custom scaling of UV coordinates of loaded meshes.
  70725. */
  70726. UVScaling: Vector2;
  70727. /**
  70728. * Invert model on y-axis (does a model scaling inversion)
  70729. */
  70730. InvertY: boolean;
  70731. /**
  70732. * Invert Y-Axis of referenced textures on load
  70733. */
  70734. InvertTextureY: boolean;
  70735. /**
  70736. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70737. */
  70738. ImportVertexColors: boolean;
  70739. /**
  70740. * Compute the normals for the model, even if normals are present in the file.
  70741. */
  70742. ComputeNormals: boolean;
  70743. /**
  70744. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70745. */
  70746. SkipMaterials: boolean;
  70747. /**
  70748. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70749. */
  70750. MaterialLoadingFailsSilently: boolean;
  70751. };
  70752. /**
  70753. * OBJ file type loader.
  70754. * This is a babylon scene loader plugin.
  70755. */
  70756. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70757. /**
  70758. * Defines if UVs are optimized by default during load.
  70759. */
  70760. static OPTIMIZE_WITH_UV: boolean;
  70761. /**
  70762. * Invert model on y-axis (does a model scaling inversion)
  70763. */
  70764. static INVERT_Y: boolean;
  70765. /**
  70766. * Invert Y-Axis of referenced textures on load
  70767. */
  70768. static INVERT_TEXTURE_Y: boolean;
  70769. /**
  70770. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70771. */
  70772. static IMPORT_VERTEX_COLORS: boolean;
  70773. /**
  70774. * Compute the normals for the model, even if normals are present in the file.
  70775. */
  70776. static COMPUTE_NORMALS: boolean;
  70777. /**
  70778. * Defines custom scaling of UV coordinates of loaded meshes.
  70779. */
  70780. static UV_SCALING: Vector2;
  70781. /**
  70782. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70783. */
  70784. static SKIP_MATERIALS: boolean;
  70785. /**
  70786. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70787. *
  70788. * Defaults to true for backwards compatibility.
  70789. */
  70790. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70791. /**
  70792. * Defines the name of the plugin.
  70793. */
  70794. name: string;
  70795. /**
  70796. * Defines the extension the plugin is able to load.
  70797. */
  70798. extensions: string;
  70799. /** @hidden */
  70800. obj: RegExp;
  70801. /** @hidden */
  70802. group: RegExp;
  70803. /** @hidden */
  70804. mtllib: RegExp;
  70805. /** @hidden */
  70806. usemtl: RegExp;
  70807. /** @hidden */
  70808. smooth: RegExp;
  70809. /** @hidden */
  70810. vertexPattern: RegExp;
  70811. /** @hidden */
  70812. normalPattern: RegExp;
  70813. /** @hidden */
  70814. uvPattern: RegExp;
  70815. /** @hidden */
  70816. facePattern1: RegExp;
  70817. /** @hidden */
  70818. facePattern2: RegExp;
  70819. /** @hidden */
  70820. facePattern3: RegExp;
  70821. /** @hidden */
  70822. facePattern4: RegExp;
  70823. /** @hidden */
  70824. facePattern5: RegExp;
  70825. private _meshLoadOptions;
  70826. /**
  70827. * Creates loader for .OBJ files
  70828. *
  70829. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70830. */
  70831. constructor(meshLoadOptions?: MeshLoadOptions);
  70832. private static readonly currentMeshLoadOptions;
  70833. /**
  70834. * Calls synchronously the MTL file attached to this obj.
  70835. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70836. * Without this function materials are not displayed in the first frame (but displayed after).
  70837. * In consequence it is impossible to get material information in your HTML file
  70838. *
  70839. * @param url The URL of the MTL file
  70840. * @param rootUrl
  70841. * @param onSuccess Callback function to be called when the MTL file is loaded
  70842. * @private
  70843. */
  70844. private _loadMTL;
  70845. /**
  70846. * Instantiates a OBJ file loader plugin.
  70847. * @returns the created plugin
  70848. */
  70849. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70850. /**
  70851. * If the data string can be loaded directly.
  70852. *
  70853. * @param data string containing the file data
  70854. * @returns if the data can be loaded directly
  70855. */
  70856. canDirectLoad(data: string): boolean;
  70857. /**
  70858. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70859. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70860. * @param scene the scene the meshes should be added to
  70861. * @param data the OBJ data to load
  70862. * @param rootUrl root url to load from
  70863. * @param onProgress event that fires when loading progress has occured
  70864. * @param fileName Defines the name of the file to load
  70865. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70866. */
  70867. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70868. meshes: AbstractMesh[];
  70869. particleSystems: IParticleSystem[];
  70870. skeletons: Skeleton[];
  70871. animationGroups: AnimationGroup[];
  70872. }>;
  70873. /**
  70874. * Imports all objects from the loaded OBJ data and adds them to the scene
  70875. * @param scene the scene the objects should be added to
  70876. * @param data the OBJ data to load
  70877. * @param rootUrl root url to load from
  70878. * @param onProgress event that fires when loading progress has occured
  70879. * @param fileName Defines the name of the file to load
  70880. * @returns a promise which completes when objects have been loaded to the scene
  70881. */
  70882. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70883. /**
  70884. * Load into an asset container.
  70885. * @param scene The scene to load into
  70886. * @param data The data to import
  70887. * @param rootUrl The root url for scene and resources
  70888. * @param onProgress The callback when the load progresses
  70889. * @param fileName Defines the name of the file to load
  70890. * @returns The loaded asset container
  70891. */
  70892. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70893. /**
  70894. * Read the OBJ file and create an Array of meshes.
  70895. * Each mesh contains all information given by the OBJ and the MTL file.
  70896. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70897. *
  70898. * @param meshesNames
  70899. * @param scene Scene The scene where are displayed the data
  70900. * @param data String The content of the obj file
  70901. * @param rootUrl String The path to the folder
  70902. * @returns Array<AbstractMesh>
  70903. * @private
  70904. */
  70905. private _parseSolid;
  70906. }
  70907. }
  70908. declare module BABYLON {
  70909. /**
  70910. * STL file type loader.
  70911. * This is a babylon scene loader plugin.
  70912. */
  70913. export class STLFileLoader implements ISceneLoaderPlugin {
  70914. /** @hidden */
  70915. solidPattern: RegExp;
  70916. /** @hidden */
  70917. facetsPattern: RegExp;
  70918. /** @hidden */
  70919. normalPattern: RegExp;
  70920. /** @hidden */
  70921. vertexPattern: RegExp;
  70922. /**
  70923. * Defines the name of the plugin.
  70924. */
  70925. name: string;
  70926. /**
  70927. * Defines the extensions the stl loader is able to load.
  70928. * force data to come in as an ArrayBuffer
  70929. * we'll convert to string if it looks like it's an ASCII .stl
  70930. */
  70931. extensions: ISceneLoaderPluginExtensions;
  70932. /**
  70933. * Import meshes into a scene.
  70934. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70935. * @param scene The scene to import into
  70936. * @param data The data to import
  70937. * @param rootUrl The root url for scene and resources
  70938. * @param meshes The meshes array to import into
  70939. * @param particleSystems The particle systems array to import into
  70940. * @param skeletons The skeletons array to import into
  70941. * @param onError The callback when import fails
  70942. * @returns True if successful or false otherwise
  70943. */
  70944. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70945. /**
  70946. * Load into a scene.
  70947. * @param scene The scene to load into
  70948. * @param data The data to import
  70949. * @param rootUrl The root url for scene and resources
  70950. * @param onError The callback when import fails
  70951. * @returns true if successful or false otherwise
  70952. */
  70953. load(scene: Scene, data: any, rootUrl: string): boolean;
  70954. /**
  70955. * Load into an asset container.
  70956. * @param scene The scene to load into
  70957. * @param data The data to import
  70958. * @param rootUrl The root url for scene and resources
  70959. * @param onError The callback when import fails
  70960. * @returns The loaded asset container
  70961. */
  70962. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70963. private _isBinary;
  70964. private _parseBinary;
  70965. private _parseASCII;
  70966. }
  70967. }
  70968. declare module BABYLON {
  70969. /**
  70970. * Class for generating OBJ data from a Babylon scene.
  70971. */
  70972. export class OBJExport {
  70973. /**
  70974. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70975. * @param mesh defines the list of meshes to serialize
  70976. * @param materials defines if materials should be exported
  70977. * @param matlibname defines the name of the associated mtl file
  70978. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70979. * @returns the OBJ content
  70980. */
  70981. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70982. /**
  70983. * Exports the material(s) of a mesh in .MTL file format (text)
  70984. * @param mesh defines the mesh to extract the material from
  70985. * @returns the mtl content
  70986. */
  70987. static MTL(mesh: Mesh): string;
  70988. }
  70989. }
  70990. declare module BABYLON {
  70991. /** @hidden */
  70992. export var __IGLTFExporterExtension: number;
  70993. /**
  70994. * Interface for extending the exporter
  70995. * @hidden
  70996. */
  70997. export interface IGLTFExporterExtension {
  70998. /**
  70999. * The name of this extension
  71000. */
  71001. readonly name: string;
  71002. /**
  71003. * Defines whether this extension is enabled
  71004. */
  71005. enabled: boolean;
  71006. /**
  71007. * Defines whether this extension is required
  71008. */
  71009. required: boolean;
  71010. }
  71011. }
  71012. declare module BABYLON.GLTF2.Exporter {
  71013. /** @hidden */
  71014. export var __IGLTFExporterExtensionV2: number;
  71015. /**
  71016. * Interface for a glTF exporter extension
  71017. * @hidden
  71018. */
  71019. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  71020. /**
  71021. * Define this method to modify the default behavior before exporting a texture
  71022. * @param context The context when loading the asset
  71023. * @param babylonTexture The glTF texture info property
  71024. * @param mimeType The mime-type of the generated image
  71025. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  71026. */
  71027. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71028. /**
  71029. * Define this method to modify the default behavior when exporting texture info
  71030. * @param context The context when loading the asset
  71031. * @param meshPrimitive glTF mesh primitive
  71032. * @param babylonSubMesh Babylon submesh
  71033. * @param binaryWriter glTF serializer binary writer instance
  71034. * @returns nullable IMeshPrimitive promise
  71035. */
  71036. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71037. /**
  71038. * Define this method to modify the default behavior when exporting a node
  71039. * @param context The context when exporting the node
  71040. * @param node glTF node
  71041. * @param babylonNode BabylonJS node
  71042. * @returns nullable INode promise
  71043. */
  71044. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71045. /**
  71046. * Called after the exporter state changes to EXPORTING
  71047. */
  71048. onExporting?(): void;
  71049. }
  71050. }
  71051. declare module BABYLON.GLTF2.Exporter {
  71052. /**
  71053. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  71054. * @hidden
  71055. */
  71056. export class _GLTFMaterialExporter {
  71057. /**
  71058. * Represents the dielectric specular values for R, G and B
  71059. */
  71060. private static readonly _DielectricSpecular;
  71061. /**
  71062. * Allows the maximum specular power to be defined for material calculations
  71063. */
  71064. private static readonly _MaxSpecularPower;
  71065. /**
  71066. * Mapping to store textures
  71067. */
  71068. private _textureMap;
  71069. /**
  71070. * Numeric tolerance value
  71071. */
  71072. private static readonly _Epsilon;
  71073. /**
  71074. * Reference to the glTF Exporter
  71075. */
  71076. private _exporter;
  71077. constructor(exporter: _Exporter);
  71078. /**
  71079. * Specifies if two colors are approximately equal in value
  71080. * @param color1 first color to compare to
  71081. * @param color2 second color to compare to
  71082. * @param epsilon threshold value
  71083. */
  71084. private static FuzzyEquals;
  71085. /**
  71086. * Gets the materials from a Babylon scene and converts them to glTF materials
  71087. * @param scene babylonjs scene
  71088. * @param mimeType texture mime type
  71089. * @param images array of images
  71090. * @param textures array of textures
  71091. * @param materials array of materials
  71092. * @param imageData mapping of texture names to base64 textures
  71093. * @param hasTextureCoords specifies if texture coordinates are present on the material
  71094. */
  71095. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71096. /**
  71097. * Makes a copy of the glTF material without the texture parameters
  71098. * @param originalMaterial original glTF material
  71099. * @returns glTF material without texture parameters
  71100. */
  71101. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  71102. /**
  71103. * Specifies if the material has any texture parameters present
  71104. * @param material glTF Material
  71105. * @returns boolean specifying if texture parameters are present
  71106. */
  71107. _hasTexturesPresent(material: IMaterial): boolean;
  71108. /**
  71109. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  71110. * @param babylonStandardMaterial
  71111. * @returns glTF Metallic Roughness Material representation
  71112. */
  71113. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  71114. /**
  71115. * Computes the metallic factor
  71116. * @param diffuse diffused value
  71117. * @param specular specular value
  71118. * @param oneMinusSpecularStrength one minus the specular strength
  71119. * @returns metallic value
  71120. */
  71121. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  71122. /**
  71123. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  71124. * @param glTFMaterial glTF material
  71125. * @param babylonMaterial Babylon material
  71126. */
  71127. private static _SetAlphaMode;
  71128. /**
  71129. * Converts a Babylon Standard Material to a glTF Material
  71130. * @param babylonStandardMaterial BJS Standard Material
  71131. * @param mimeType mime type to use for the textures
  71132. * @param images array of glTF image interfaces
  71133. * @param textures array of glTF texture interfaces
  71134. * @param materials array of glTF material interfaces
  71135. * @param imageData map of image file name to data
  71136. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71137. */
  71138. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71139. /**
  71140. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71141. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  71142. * @param mimeType mime type to use for the textures
  71143. * @param images array of glTF image interfaces
  71144. * @param textures array of glTF texture interfaces
  71145. * @param materials array of glTF material interfaces
  71146. * @param imageData map of image file name to data
  71147. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71148. */
  71149. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71150. /**
  71151. * Converts an image typed array buffer to a base64 image
  71152. * @param buffer typed array buffer
  71153. * @param width width of the image
  71154. * @param height height of the image
  71155. * @param mimeType mimetype of the image
  71156. * @returns base64 image string
  71157. */
  71158. private _createBase64FromCanvasAsync;
  71159. /**
  71160. * Generates a white texture based on the specified width and height
  71161. * @param width width of the texture in pixels
  71162. * @param height height of the texture in pixels
  71163. * @param scene babylonjs scene
  71164. * @returns white texture
  71165. */
  71166. private _createWhiteTexture;
  71167. /**
  71168. * 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
  71169. * @param texture1 first texture to resize
  71170. * @param texture2 second texture to resize
  71171. * @param scene babylonjs scene
  71172. * @returns resized textures or null
  71173. */
  71174. private _resizeTexturesToSameDimensions;
  71175. /**
  71176. * Converts an array of pixels to a Float32Array
  71177. * Throws an error if the pixel format is not supported
  71178. * @param pixels - array buffer containing pixel values
  71179. * @returns Float32 of pixels
  71180. */
  71181. private _convertPixelArrayToFloat32;
  71182. /**
  71183. * Convert Specular Glossiness Textures to Metallic Roughness
  71184. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  71185. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  71186. * @param diffuseTexture texture used to store diffuse information
  71187. * @param specularGlossinessTexture texture used to store specular and glossiness information
  71188. * @param factors specular glossiness material factors
  71189. * @param mimeType the mime type to use for the texture
  71190. * @returns pbr metallic roughness interface or null
  71191. */
  71192. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  71193. /**
  71194. * Converts specular glossiness material properties to metallic roughness
  71195. * @param specularGlossiness interface with specular glossiness material properties
  71196. * @returns interface with metallic roughness material properties
  71197. */
  71198. private _convertSpecularGlossinessToMetallicRoughness;
  71199. /**
  71200. * Calculates the surface reflectance, independent of lighting conditions
  71201. * @param color Color source to calculate brightness from
  71202. * @returns number representing the perceived brightness, or zero if color is undefined
  71203. */
  71204. private _getPerceivedBrightness;
  71205. /**
  71206. * Returns the maximum color component value
  71207. * @param color
  71208. * @returns maximum color component value, or zero if color is null or undefined
  71209. */
  71210. private _getMaxComponent;
  71211. /**
  71212. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  71213. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71214. * @param mimeType mime type to use for the textures
  71215. * @param images array of glTF image interfaces
  71216. * @param textures array of glTF texture interfaces
  71217. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71218. * @param imageData map of image file name to data
  71219. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71220. * @returns glTF PBR Metallic Roughness factors
  71221. */
  71222. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  71223. private _getGLTFTextureSampler;
  71224. private _getGLTFTextureWrapMode;
  71225. private _getGLTFTextureWrapModesSampler;
  71226. /**
  71227. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  71228. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71229. * @param mimeType mime type to use for the textures
  71230. * @param images array of glTF image interfaces
  71231. * @param textures array of glTF texture interfaces
  71232. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71233. * @param imageData map of image file name to data
  71234. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71235. * @returns glTF PBR Metallic Roughness factors
  71236. */
  71237. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  71238. /**
  71239. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71240. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71241. * @param mimeType mime type to use for the textures
  71242. * @param images array of glTF image interfaces
  71243. * @param textures array of glTF texture interfaces
  71244. * @param materials array of glTF material interfaces
  71245. * @param imageData map of image file name to data
  71246. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71247. */
  71248. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71249. private setMetallicRoughnessPbrMaterial;
  71250. private getPixelsFromTexture;
  71251. /**
  71252. * Extracts a texture from a Babylon texture into file data and glTF data
  71253. * @param babylonTexture Babylon texture to extract
  71254. * @param mimeType Mime Type of the babylonTexture
  71255. * @return glTF texture info, or null if the texture format is not supported
  71256. */
  71257. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71258. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71259. /**
  71260. * Builds a texture from base64 string
  71261. * @param base64Texture base64 texture string
  71262. * @param baseTextureName Name to use for the texture
  71263. * @param mimeType image mime type for the texture
  71264. * @param images array of images
  71265. * @param textures array of textures
  71266. * @param imageData map of image data
  71267. * @returns glTF texture info, or null if the texture format is not supported
  71268. */
  71269. private _getTextureInfoFromBase64;
  71270. }
  71271. }
  71272. declare module BABYLON {
  71273. /**
  71274. * Class for holding and downloading glTF file data
  71275. */
  71276. export class GLTFData {
  71277. /**
  71278. * Object which contains the file name as the key and its data as the value
  71279. */
  71280. glTFFiles: {
  71281. [fileName: string]: string | Blob;
  71282. };
  71283. /**
  71284. * Initializes the glTF file object
  71285. */
  71286. constructor();
  71287. /**
  71288. * Downloads the glTF data as files based on their names and data
  71289. */
  71290. downloadFiles(): void;
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /**
  71295. * Holds a collection of exporter options and parameters
  71296. */
  71297. export interface IExportOptions {
  71298. /**
  71299. * Function which indicates whether a babylon node should be exported or not
  71300. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  71301. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  71302. */
  71303. shouldExportNode?(node: Node): boolean;
  71304. /**
  71305. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  71306. * @param metadata source metadata to read from
  71307. * @returns the data to store to glTF node extras
  71308. */
  71309. metadataSelector?(metadata: any): any;
  71310. /**
  71311. * The sample rate to bake animation curves
  71312. */
  71313. animationSampleRate?: number;
  71314. /**
  71315. * Begin serialization without waiting for the scene to be ready
  71316. */
  71317. exportWithoutWaitingForScene?: boolean;
  71318. }
  71319. /**
  71320. * Class for generating glTF data from a Babylon scene.
  71321. */
  71322. export class GLTF2Export {
  71323. /**
  71324. * Exports the geometry of the scene to .gltf file format asynchronously
  71325. * @param scene Babylon scene with scene hierarchy information
  71326. * @param filePrefix File prefix to use when generating the glTF file
  71327. * @param options Exporter options
  71328. * @returns Returns an object with a .gltf file and associates texture names
  71329. * as keys and their data and paths as values
  71330. */
  71331. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71332. private static _PreExportAsync;
  71333. private static _PostExportAsync;
  71334. /**
  71335. * Exports the geometry of the scene to .glb file format asychronously
  71336. * @param scene Babylon scene with scene hierarchy information
  71337. * @param filePrefix File prefix to use when generating glb file
  71338. * @param options Exporter options
  71339. * @returns Returns an object with a .glb filename as key and data as value
  71340. */
  71341. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71342. }
  71343. }
  71344. declare module BABYLON.GLTF2.Exporter {
  71345. /**
  71346. * @hidden
  71347. */
  71348. export class _GLTFUtilities {
  71349. /**
  71350. * Creates a buffer view based on the supplied arguments
  71351. * @param bufferIndex index value of the specified buffer
  71352. * @param byteOffset byte offset value
  71353. * @param byteLength byte length of the bufferView
  71354. * @param byteStride byte distance between conequential elements
  71355. * @param name name of the buffer view
  71356. * @returns bufferView for glTF
  71357. */
  71358. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  71359. /**
  71360. * Creates an accessor based on the supplied arguments
  71361. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  71362. * @param name The name of the accessor
  71363. * @param type The type of the accessor
  71364. * @param componentType The datatype of components in the attribute
  71365. * @param count The number of attributes referenced by this accessor
  71366. * @param byteOffset The offset relative to the start of the bufferView in bytes
  71367. * @param min Minimum value of each component in this attribute
  71368. * @param max Maximum value of each component in this attribute
  71369. * @returns accessor for glTF
  71370. */
  71371. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  71372. /**
  71373. * Calculates the minimum and maximum values of an array of position floats
  71374. * @param positions Positions array of a mesh
  71375. * @param vertexStart Starting vertex offset to calculate min and max values
  71376. * @param vertexCount Number of vertices to check for min and max values
  71377. * @returns min number array and max number array
  71378. */
  71379. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  71380. min: number[];
  71381. max: number[];
  71382. };
  71383. /**
  71384. * Converts a new right-handed Vector3
  71385. * @param vector vector3 array
  71386. * @returns right-handed Vector3
  71387. */
  71388. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  71389. /**
  71390. * Converts a Vector3 to right-handed
  71391. * @param vector Vector3 to convert to right-handed
  71392. */
  71393. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  71394. /**
  71395. * Converts a three element number array to right-handed
  71396. * @param vector number array to convert to right-handed
  71397. */
  71398. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  71399. /**
  71400. * Converts a new right-handed Vector3
  71401. * @param vector vector3 array
  71402. * @returns right-handed Vector3
  71403. */
  71404. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  71405. /**
  71406. * Converts a Vector3 to right-handed
  71407. * @param vector Vector3 to convert to right-handed
  71408. */
  71409. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  71410. /**
  71411. * Converts a three element number array to right-handed
  71412. * @param vector number array to convert to right-handed
  71413. */
  71414. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  71415. /**
  71416. * Converts a Vector4 to right-handed
  71417. * @param vector Vector4 to convert to right-handed
  71418. */
  71419. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  71420. /**
  71421. * Converts a Vector4 to right-handed
  71422. * @param vector Vector4 to convert to right-handed
  71423. */
  71424. static _GetRightHandedArray4FromRef(vector: number[]): void;
  71425. /**
  71426. * Converts a Quaternion to right-handed
  71427. * @param quaternion Source quaternion to convert to right-handed
  71428. */
  71429. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  71430. /**
  71431. * Converts a Quaternion to right-handed
  71432. * @param quaternion Source quaternion to convert to right-handed
  71433. */
  71434. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  71435. static _NormalizeTangentFromRef(tangent: Vector4): void;
  71436. }
  71437. }
  71438. declare module BABYLON.GLTF2.Exporter {
  71439. /**
  71440. * Converts Babylon Scene into glTF 2.0.
  71441. * @hidden
  71442. */
  71443. export class _Exporter {
  71444. /**
  71445. * Stores the glTF to export
  71446. */
  71447. _glTF: IGLTF;
  71448. /**
  71449. * Stores all generated buffer views, which represents views into the main glTF buffer data
  71450. */
  71451. _bufferViews: IBufferView[];
  71452. /**
  71453. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  71454. */
  71455. _accessors: IAccessor[];
  71456. /**
  71457. * Stores all the generated nodes, which contains transform and/or mesh information per node
  71458. */
  71459. private _nodes;
  71460. /**
  71461. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  71462. */
  71463. private _scenes;
  71464. /**
  71465. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  71466. */
  71467. private _meshes;
  71468. /**
  71469. * Stores all the generated material information, which represents the appearance of each primitive
  71470. */
  71471. _materials: IMaterial[];
  71472. _materialMap: {
  71473. [materialID: number]: number;
  71474. };
  71475. /**
  71476. * Stores all the generated texture information, which is referenced by glTF materials
  71477. */
  71478. _textures: ITexture[];
  71479. /**
  71480. * Stores all the generated image information, which is referenced by glTF textures
  71481. */
  71482. _images: IImage[];
  71483. /**
  71484. * Stores all the texture samplers
  71485. */
  71486. _samplers: ISampler[];
  71487. /**
  71488. * Stores all the generated animation samplers, which is referenced by glTF animations
  71489. */
  71490. /**
  71491. * Stores the animations for glTF models
  71492. */
  71493. private _animations;
  71494. /**
  71495. * Stores the total amount of bytes stored in the glTF buffer
  71496. */
  71497. private _totalByteLength;
  71498. /**
  71499. * Stores a reference to the Babylon scene containing the source geometry and material information
  71500. */
  71501. _babylonScene: Scene;
  71502. /**
  71503. * Stores a map of the image data, where the key is the file name and the value
  71504. * is the image data
  71505. */
  71506. _imageData: {
  71507. [fileName: string]: {
  71508. data: Uint8Array;
  71509. mimeType: ImageMimeType;
  71510. };
  71511. };
  71512. /**
  71513. * Stores a map of the unique id of a node to its index in the node array
  71514. */
  71515. private _nodeMap;
  71516. /**
  71517. * Specifies if the Babylon scene should be converted to right-handed on export
  71518. */
  71519. _convertToRightHandedSystem: boolean;
  71520. /**
  71521. * Baked animation sample rate
  71522. */
  71523. private _animationSampleRate;
  71524. private _options;
  71525. private _localEngine;
  71526. _glTFMaterialExporter: _GLTFMaterialExporter;
  71527. private _extensions;
  71528. private static _ExtensionNames;
  71529. private static _ExtensionFactories;
  71530. private _applyExtensions;
  71531. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  71532. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71533. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71534. private _forEachExtensions;
  71535. private _extensionsOnExporting;
  71536. /**
  71537. * Load glTF serializer extensions
  71538. */
  71539. private _loadExtensions;
  71540. /**
  71541. * Creates a glTF Exporter instance, which can accept optional exporter options
  71542. * @param babylonScene Babylon scene object
  71543. * @param options Options to modify the behavior of the exporter
  71544. */
  71545. constructor(babylonScene: Scene, options?: IExportOptions);
  71546. /**
  71547. * Registers a glTF exporter extension
  71548. * @param name Name of the extension to export
  71549. * @param factory The factory function that creates the exporter extension
  71550. */
  71551. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  71552. /**
  71553. * Un-registers an exporter extension
  71554. * @param name The name fo the exporter extension
  71555. * @returns A boolean indicating whether the extension has been un-registered
  71556. */
  71557. static UnregisterExtension(name: string): boolean;
  71558. /**
  71559. * Lazy load a local engine with premultiplied alpha set to false
  71560. */
  71561. _getLocalEngine(): Engine;
  71562. private reorderIndicesBasedOnPrimitiveMode;
  71563. /**
  71564. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  71565. * clock-wise during export to glTF
  71566. * @param submesh BabylonJS submesh
  71567. * @param primitiveMode Primitive mode of the mesh
  71568. * @param sideOrientation the winding order of the submesh
  71569. * @param vertexBufferKind The type of vertex attribute
  71570. * @param meshAttributeArray The vertex attribute data
  71571. * @param byteOffset The offset to the binary data
  71572. * @param binaryWriter The binary data for the glTF file
  71573. */
  71574. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  71575. /**
  71576. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  71577. * clock-wise during export to glTF
  71578. * @param submesh BabylonJS submesh
  71579. * @param primitiveMode Primitive mode of the mesh
  71580. * @param sideOrientation the winding order of the submesh
  71581. * @param vertexBufferKind The type of vertex attribute
  71582. * @param meshAttributeArray The vertex attribute data
  71583. * @param byteOffset The offset to the binary data
  71584. * @param binaryWriter The binary data for the glTF file
  71585. */
  71586. private reorderTriangleFillMode;
  71587. /**
  71588. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  71589. * clock-wise during export to glTF
  71590. * @param submesh BabylonJS submesh
  71591. * @param primitiveMode Primitive mode of the mesh
  71592. * @param sideOrientation the winding order of the submesh
  71593. * @param vertexBufferKind The type of vertex attribute
  71594. * @param meshAttributeArray The vertex attribute data
  71595. * @param byteOffset The offset to the binary data
  71596. * @param binaryWriter The binary data for the glTF file
  71597. */
  71598. private reorderTriangleStripDrawMode;
  71599. /**
  71600. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  71601. * clock-wise during export to glTF
  71602. * @param submesh BabylonJS submesh
  71603. * @param primitiveMode Primitive mode of the mesh
  71604. * @param sideOrientation the winding order of the submesh
  71605. * @param vertexBufferKind The type of vertex attribute
  71606. * @param meshAttributeArray The vertex attribute data
  71607. * @param byteOffset The offset to the binary data
  71608. * @param binaryWriter The binary data for the glTF file
  71609. */
  71610. private reorderTriangleFanMode;
  71611. /**
  71612. * Writes the vertex attribute data to binary
  71613. * @param vertices The vertices to write to the binary writer
  71614. * @param byteOffset The offset into the binary writer to overwrite binary data
  71615. * @param vertexAttributeKind The vertex attribute type
  71616. * @param meshAttributeArray The vertex attribute data
  71617. * @param binaryWriter The writer containing the binary data
  71618. */
  71619. private writeVertexAttributeData;
  71620. /**
  71621. * Writes mesh attribute data to a data buffer
  71622. * Returns the bytelength of the data
  71623. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  71624. * @param meshAttributeArray Array containing the attribute data
  71625. * @param binaryWriter The buffer to write the binary data to
  71626. * @param indices Used to specify the order of the vertex data
  71627. */
  71628. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  71629. /**
  71630. * Generates glTF json data
  71631. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  71632. * @param glTFPrefix Text to use when prefixing a glTF file
  71633. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  71634. * @returns json data as string
  71635. */
  71636. private generateJSON;
  71637. /**
  71638. * Generates data for .gltf and .bin files based on the glTF prefix string
  71639. * @param glTFPrefix Text to use when prefixing a glTF file
  71640. * @returns GLTFData with glTF file data
  71641. */
  71642. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  71643. /**
  71644. * Creates a binary buffer for glTF
  71645. * @returns array buffer for binary data
  71646. */
  71647. private _generateBinaryAsync;
  71648. /**
  71649. * Pads the number to a multiple of 4
  71650. * @param num number to pad
  71651. * @returns padded number
  71652. */
  71653. private _getPadding;
  71654. /**
  71655. * Generates a glb file from the json and binary data
  71656. * Returns an object with the glb file name as the key and data as the value
  71657. * @param glTFPrefix
  71658. * @returns object with glb filename as key and data as value
  71659. */
  71660. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  71661. /**
  71662. * Sets the TRS for each node
  71663. * @param node glTF Node for storing the transformation data
  71664. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  71665. */
  71666. private setNodeTransformation;
  71667. private getVertexBufferFromMesh;
  71668. /**
  71669. * Creates a bufferview based on the vertices type for the Babylon mesh
  71670. * @param kind Indicates the type of vertices data
  71671. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  71672. * @param binaryWriter The buffer to write the bufferview data to
  71673. */
  71674. private createBufferViewKind;
  71675. /**
  71676. * The primitive mode of the Babylon mesh
  71677. * @param babylonMesh The BabylonJS mesh
  71678. */
  71679. private getMeshPrimitiveMode;
  71680. /**
  71681. * Sets the primitive mode of the glTF mesh primitive
  71682. * @param meshPrimitive glTF mesh primitive
  71683. * @param primitiveMode The primitive mode
  71684. */
  71685. private setPrimitiveMode;
  71686. /**
  71687. * Sets the vertex attribute accessor based of the glTF mesh primitive
  71688. * @param meshPrimitive glTF mesh primitive
  71689. * @param attributeKind vertex attribute
  71690. * @returns boolean specifying if uv coordinates are present
  71691. */
  71692. private setAttributeKind;
  71693. /**
  71694. * Sets data for the primitive attributes of each submesh
  71695. * @param mesh glTF Mesh object to store the primitive attribute information
  71696. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  71697. * @param binaryWriter Buffer to write the attribute data to
  71698. */
  71699. private setPrimitiveAttributesAsync;
  71700. /**
  71701. * Creates a glTF scene based on the array of meshes
  71702. * Returns the the total byte offset
  71703. * @param babylonScene Babylon scene to get the mesh data from
  71704. * @param binaryWriter Buffer to write binary data to
  71705. */
  71706. private createSceneAsync;
  71707. /**
  71708. * Creates a mapping of Node unique id to node index and handles animations
  71709. * @param babylonScene Babylon Scene
  71710. * @param nodes Babylon transform nodes
  71711. * @param binaryWriter Buffer to write binary data to
  71712. * @returns Node mapping of unique id to index
  71713. */
  71714. private createNodeMapAndAnimationsAsync;
  71715. /**
  71716. * Creates a glTF node from a Babylon mesh
  71717. * @param babylonMesh Source Babylon mesh
  71718. * @param binaryWriter Buffer for storing geometry data
  71719. * @returns glTF node
  71720. */
  71721. private createNodeAsync;
  71722. }
  71723. /**
  71724. * @hidden
  71725. *
  71726. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71727. */
  71728. export class _BinaryWriter {
  71729. /**
  71730. * Array buffer which stores all binary data
  71731. */
  71732. private _arrayBuffer;
  71733. /**
  71734. * View of the array buffer
  71735. */
  71736. private _dataView;
  71737. /**
  71738. * byte offset of data in array buffer
  71739. */
  71740. private _byteOffset;
  71741. /**
  71742. * Initialize binary writer with an initial byte length
  71743. * @param byteLength Initial byte length of the array buffer
  71744. */
  71745. constructor(byteLength: number);
  71746. /**
  71747. * Resize the array buffer to the specified byte length
  71748. * @param byteLength
  71749. */
  71750. private resizeBuffer;
  71751. /**
  71752. * Get an array buffer with the length of the byte offset
  71753. * @returns ArrayBuffer resized to the byte offset
  71754. */
  71755. getArrayBuffer(): ArrayBuffer;
  71756. /**
  71757. * Get the byte offset of the array buffer
  71758. * @returns byte offset
  71759. */
  71760. getByteOffset(): number;
  71761. /**
  71762. * Stores an UInt8 in the array buffer
  71763. * @param entry
  71764. * @param byteOffset If defined, specifies where to set the value as an offset.
  71765. */
  71766. setUInt8(entry: number, byteOffset?: number): void;
  71767. /**
  71768. * Gets an UInt32 in the array buffer
  71769. * @param entry
  71770. * @param byteOffset If defined, specifies where to set the value as an offset.
  71771. */
  71772. getUInt32(byteOffset: number): number;
  71773. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71774. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71775. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71776. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71777. /**
  71778. * Stores a Float32 in the array buffer
  71779. * @param entry
  71780. */
  71781. setFloat32(entry: number, byteOffset?: number): void;
  71782. /**
  71783. * Stores an UInt32 in the array buffer
  71784. * @param entry
  71785. * @param byteOffset If defined, specifies where to set the value as an offset.
  71786. */
  71787. setUInt32(entry: number, byteOffset?: number): void;
  71788. }
  71789. }
  71790. declare module BABYLON.GLTF2.Exporter {
  71791. /**
  71792. * @hidden
  71793. * Interface to store animation data.
  71794. */
  71795. export interface _IAnimationData {
  71796. /**
  71797. * Keyframe data.
  71798. */
  71799. inputs: number[];
  71800. /**
  71801. * Value data.
  71802. */
  71803. outputs: number[][];
  71804. /**
  71805. * Animation interpolation data.
  71806. */
  71807. samplerInterpolation: AnimationSamplerInterpolation;
  71808. /**
  71809. * Minimum keyframe value.
  71810. */
  71811. inputsMin: number;
  71812. /**
  71813. * Maximum keyframe value.
  71814. */
  71815. inputsMax: number;
  71816. }
  71817. /**
  71818. * @hidden
  71819. */
  71820. export interface _IAnimationInfo {
  71821. /**
  71822. * The target channel for the animation
  71823. */
  71824. animationChannelTargetPath: AnimationChannelTargetPath;
  71825. /**
  71826. * The glTF accessor type for the data.
  71827. */
  71828. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71829. /**
  71830. * Specifies if quaternions should be used.
  71831. */
  71832. useQuaternion: boolean;
  71833. }
  71834. /**
  71835. * @hidden
  71836. * Utility class for generating glTF animation data from BabylonJS.
  71837. */
  71838. export class _GLTFAnimation {
  71839. /**
  71840. * @ignore
  71841. *
  71842. * Creates glTF channel animation from BabylonJS animation.
  71843. * @param babylonTransformNode - BabylonJS mesh.
  71844. * @param animation - animation.
  71845. * @param animationChannelTargetPath - The target animation channel.
  71846. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71847. * @param useQuaternion - Specifies if quaternions are used.
  71848. * @returns nullable IAnimationData
  71849. */
  71850. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71851. private static _DeduceAnimationInfo;
  71852. /**
  71853. * @ignore
  71854. * Create node animations from the transform node animations
  71855. * @param babylonNode
  71856. * @param runtimeGLTFAnimation
  71857. * @param idleGLTFAnimations
  71858. * @param nodeMap
  71859. * @param nodes
  71860. * @param binaryWriter
  71861. * @param bufferViews
  71862. * @param accessors
  71863. * @param convertToRightHandedSystem
  71864. */
  71865. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71866. [key: number]: number;
  71867. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71868. /**
  71869. * @ignore
  71870. * Create node animations from the animation groups
  71871. * @param babylonScene
  71872. * @param glTFAnimations
  71873. * @param nodeMap
  71874. * @param nodes
  71875. * @param binaryWriter
  71876. * @param bufferViews
  71877. * @param accessors
  71878. * @param convertToRightHandedSystem
  71879. */
  71880. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71881. [key: number]: number;
  71882. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71883. private static AddAnimation;
  71884. /**
  71885. * Create a baked animation
  71886. * @param babylonTransformNode BabylonJS mesh
  71887. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71888. * @param animationChannelTargetPath animation target channel
  71889. * @param minFrame minimum animation frame
  71890. * @param maxFrame maximum animation frame
  71891. * @param fps frames per second of the animation
  71892. * @param inputs input key frames of the animation
  71893. * @param outputs output key frame data of the animation
  71894. * @param convertToRightHandedSystem converts the values to right-handed
  71895. * @param useQuaternion specifies if quaternions should be used
  71896. */
  71897. private static _CreateBakedAnimation;
  71898. private static _ConvertFactorToVector3OrQuaternion;
  71899. private static _SetInterpolatedValue;
  71900. /**
  71901. * Creates linear animation from the animation key frames
  71902. * @param babylonTransformNode BabylonJS mesh
  71903. * @param animation BabylonJS animation
  71904. * @param animationChannelTargetPath The target animation channel
  71905. * @param frameDelta The difference between the last and first frame of the animation
  71906. * @param inputs Array to store the key frame times
  71907. * @param outputs Array to store the key frame data
  71908. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71909. * @param useQuaternion Specifies if quaternions are used in the animation
  71910. */
  71911. private static _CreateLinearOrStepAnimation;
  71912. /**
  71913. * Creates cubic spline animation from the animation key frames
  71914. * @param babylonTransformNode BabylonJS mesh
  71915. * @param animation BabylonJS animation
  71916. * @param animationChannelTargetPath The target animation channel
  71917. * @param frameDelta The difference between the last and first frame of the animation
  71918. * @param inputs Array to store the key frame times
  71919. * @param outputs Array to store the key frame data
  71920. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71921. * @param useQuaternion Specifies if quaternions are used in the animation
  71922. */
  71923. private static _CreateCubicSplineAnimation;
  71924. private static _GetBasePositionRotationOrScale;
  71925. /**
  71926. * Adds a key frame value
  71927. * @param keyFrame
  71928. * @param animation
  71929. * @param outputs
  71930. * @param animationChannelTargetPath
  71931. * @param basePositionRotationOrScale
  71932. * @param convertToRightHandedSystem
  71933. * @param useQuaternion
  71934. */
  71935. private static _AddKeyframeValue;
  71936. /**
  71937. * Determine the interpolation based on the key frames
  71938. * @param keyFrames
  71939. * @param animationChannelTargetPath
  71940. * @param useQuaternion
  71941. */
  71942. private static _DeduceInterpolation;
  71943. /**
  71944. * Adds an input tangent or output tangent to the output data
  71945. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71946. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71947. * @param outputs The animation data by keyframe
  71948. * @param animationChannelTargetPath The target animation channel
  71949. * @param interpolation The interpolation type
  71950. * @param keyFrame The key frame with the animation data
  71951. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71952. * @param useQuaternion Specifies if quaternions are used
  71953. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71954. */
  71955. private static AddSplineTangent;
  71956. /**
  71957. * Get the minimum and maximum key frames' frame values
  71958. * @param keyFrames animation key frames
  71959. * @returns the minimum and maximum key frame value
  71960. */
  71961. private static calculateMinMaxKeyFrames;
  71962. }
  71963. }
  71964. declare module BABYLON.GLTF2.Exporter {
  71965. /** @hidden */
  71966. export var textureTransformPixelShader: {
  71967. name: string;
  71968. shader: string;
  71969. };
  71970. }
  71971. declare module BABYLON.GLTF2.Exporter.Extensions {
  71972. /**
  71973. * @hidden
  71974. */
  71975. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71976. /** Name of this extension */
  71977. readonly name: string;
  71978. /** Defines whether this extension is enabled */
  71979. enabled: boolean;
  71980. /** Defines whether this extension is required */
  71981. required: boolean;
  71982. /** Reference to the glTF exporter */
  71983. private _exporter;
  71984. constructor(exporter: _Exporter);
  71985. dispose(): void;
  71986. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71987. /**
  71988. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71989. * @param babylonTexture
  71990. * @param offset
  71991. * @param rotation
  71992. * @param scale
  71993. * @param scene
  71994. */
  71995. private _textureTransformTextureAsync;
  71996. }
  71997. }
  71998. declare module BABYLON.GLTF2.Exporter.Extensions {
  71999. /**
  72000. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72001. */
  72002. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  72003. /** The name of this extension. */
  72004. readonly name: string;
  72005. /** Defines whether this extension is enabled. */
  72006. enabled: boolean;
  72007. /** Defines whether this extension is required */
  72008. required: boolean;
  72009. /** Reference to the glTF exporter */
  72010. private _exporter;
  72011. private _lights;
  72012. /** @hidden */
  72013. constructor(exporter: _Exporter);
  72014. /** @hidden */
  72015. dispose(): void;
  72016. /** @hidden */
  72017. onExporting(): void;
  72018. /**
  72019. * Define this method to modify the default behavior when exporting a node
  72020. * @param context The context when exporting the node
  72021. * @param node glTF node
  72022. * @param babylonNode BabylonJS node
  72023. * @returns nullable INode promise
  72024. */
  72025. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. /**
  72030. * Class for generating STL data from a Babylon scene.
  72031. */
  72032. export class STLExport {
  72033. /**
  72034. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  72035. * @param meshes list defines the mesh to serialize
  72036. * @param download triggers the automatic download of the file.
  72037. * @param fileName changes the downloads fileName.
  72038. * @param binary changes the STL to a binary type.
  72039. * @param isLittleEndian toggle for binary type exporter.
  72040. * @returns the STL as UTF8 string
  72041. */
  72042. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  72043. }
  72044. }
  72045. declare module "babylonjs-gltf2interface" {
  72046. export = BABYLON.GLTF2;
  72047. }
  72048. /**
  72049. * Module for glTF 2.0 Interface
  72050. */
  72051. declare module BABYLON.GLTF2 {
  72052. /**
  72053. * The datatype of the components in the attribute
  72054. */
  72055. const enum AccessorComponentType {
  72056. /**
  72057. * Byte
  72058. */
  72059. BYTE = 5120,
  72060. /**
  72061. * Unsigned Byte
  72062. */
  72063. UNSIGNED_BYTE = 5121,
  72064. /**
  72065. * Short
  72066. */
  72067. SHORT = 5122,
  72068. /**
  72069. * Unsigned Short
  72070. */
  72071. UNSIGNED_SHORT = 5123,
  72072. /**
  72073. * Unsigned Int
  72074. */
  72075. UNSIGNED_INT = 5125,
  72076. /**
  72077. * Float
  72078. */
  72079. FLOAT = 5126,
  72080. }
  72081. /**
  72082. * Specifies if the attirbute is a scalar, vector, or matrix
  72083. */
  72084. const enum AccessorType {
  72085. /**
  72086. * Scalar
  72087. */
  72088. SCALAR = "SCALAR",
  72089. /**
  72090. * Vector2
  72091. */
  72092. VEC2 = "VEC2",
  72093. /**
  72094. * Vector3
  72095. */
  72096. VEC3 = "VEC3",
  72097. /**
  72098. * Vector4
  72099. */
  72100. VEC4 = "VEC4",
  72101. /**
  72102. * Matrix2x2
  72103. */
  72104. MAT2 = "MAT2",
  72105. /**
  72106. * Matrix3x3
  72107. */
  72108. MAT3 = "MAT3",
  72109. /**
  72110. * Matrix4x4
  72111. */
  72112. MAT4 = "MAT4",
  72113. }
  72114. /**
  72115. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72116. */
  72117. const enum AnimationChannelTargetPath {
  72118. /**
  72119. * Translation
  72120. */
  72121. TRANSLATION = "translation",
  72122. /**
  72123. * Rotation
  72124. */
  72125. ROTATION = "rotation",
  72126. /**
  72127. * Scale
  72128. */
  72129. SCALE = "scale",
  72130. /**
  72131. * Weights
  72132. */
  72133. WEIGHTS = "weights",
  72134. }
  72135. /**
  72136. * Interpolation algorithm
  72137. */
  72138. const enum AnimationSamplerInterpolation {
  72139. /**
  72140. * The animated values are linearly interpolated between keyframes
  72141. */
  72142. LINEAR = "LINEAR",
  72143. /**
  72144. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  72145. */
  72146. STEP = "STEP",
  72147. /**
  72148. * The animation's interpolation is computed using a cubic spline with specified tangents
  72149. */
  72150. CUBICSPLINE = "CUBICSPLINE",
  72151. }
  72152. /**
  72153. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72154. */
  72155. const enum CameraType {
  72156. /**
  72157. * A perspective camera containing properties to create a perspective projection matrix
  72158. */
  72159. PERSPECTIVE = "perspective",
  72160. /**
  72161. * An orthographic camera containing properties to create an orthographic projection matrix
  72162. */
  72163. ORTHOGRAPHIC = "orthographic",
  72164. }
  72165. /**
  72166. * The mime-type of the image
  72167. */
  72168. const enum ImageMimeType {
  72169. /**
  72170. * JPEG Mime-type
  72171. */
  72172. JPEG = "image/jpeg",
  72173. /**
  72174. * PNG Mime-type
  72175. */
  72176. PNG = "image/png",
  72177. }
  72178. /**
  72179. * The alpha rendering mode of the material
  72180. */
  72181. const enum MaterialAlphaMode {
  72182. /**
  72183. * The alpha value is ignored and the rendered output is fully opaque
  72184. */
  72185. OPAQUE = "OPAQUE",
  72186. /**
  72187. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  72188. */
  72189. MASK = "MASK",
  72190. /**
  72191. * 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)
  72192. */
  72193. BLEND = "BLEND",
  72194. }
  72195. /**
  72196. * The type of the primitives to render
  72197. */
  72198. const enum MeshPrimitiveMode {
  72199. /**
  72200. * Points
  72201. */
  72202. POINTS = 0,
  72203. /**
  72204. * Lines
  72205. */
  72206. LINES = 1,
  72207. /**
  72208. * Line Loop
  72209. */
  72210. LINE_LOOP = 2,
  72211. /**
  72212. * Line Strip
  72213. */
  72214. LINE_STRIP = 3,
  72215. /**
  72216. * Triangles
  72217. */
  72218. TRIANGLES = 4,
  72219. /**
  72220. * Triangle Strip
  72221. */
  72222. TRIANGLE_STRIP = 5,
  72223. /**
  72224. * Triangle Fan
  72225. */
  72226. TRIANGLE_FAN = 6,
  72227. }
  72228. /**
  72229. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72230. */
  72231. const enum TextureMagFilter {
  72232. /**
  72233. * Nearest
  72234. */
  72235. NEAREST = 9728,
  72236. /**
  72237. * Linear
  72238. */
  72239. LINEAR = 9729,
  72240. }
  72241. /**
  72242. * Minification filter. All valid values correspond to WebGL enums
  72243. */
  72244. const enum TextureMinFilter {
  72245. /**
  72246. * Nearest
  72247. */
  72248. NEAREST = 9728,
  72249. /**
  72250. * Linear
  72251. */
  72252. LINEAR = 9729,
  72253. /**
  72254. * Nearest Mip-Map Nearest
  72255. */
  72256. NEAREST_MIPMAP_NEAREST = 9984,
  72257. /**
  72258. * Linear Mipmap Nearest
  72259. */
  72260. LINEAR_MIPMAP_NEAREST = 9985,
  72261. /**
  72262. * Nearest Mipmap Linear
  72263. */
  72264. NEAREST_MIPMAP_LINEAR = 9986,
  72265. /**
  72266. * Linear Mipmap Linear
  72267. */
  72268. LINEAR_MIPMAP_LINEAR = 9987,
  72269. }
  72270. /**
  72271. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72272. */
  72273. const enum TextureWrapMode {
  72274. /**
  72275. * Clamp to Edge
  72276. */
  72277. CLAMP_TO_EDGE = 33071,
  72278. /**
  72279. * Mirrored Repeat
  72280. */
  72281. MIRRORED_REPEAT = 33648,
  72282. /**
  72283. * Repeat
  72284. */
  72285. REPEAT = 10497,
  72286. }
  72287. /**
  72288. * glTF Property
  72289. */
  72290. interface IProperty {
  72291. /**
  72292. * Dictionary object with extension-specific objects
  72293. */
  72294. extensions?: {
  72295. [key: string]: any;
  72296. };
  72297. /**
  72298. * Application-Specific data
  72299. */
  72300. extras?: any;
  72301. }
  72302. /**
  72303. * glTF Child of Root Property
  72304. */
  72305. interface IChildRootProperty extends IProperty {
  72306. /**
  72307. * The user-defined name of this object
  72308. */
  72309. name?: string;
  72310. }
  72311. /**
  72312. * Indices of those attributes that deviate from their initialization value
  72313. */
  72314. interface IAccessorSparseIndices extends IProperty {
  72315. /**
  72316. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72317. */
  72318. bufferView: number;
  72319. /**
  72320. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72321. */
  72322. byteOffset?: number;
  72323. /**
  72324. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  72325. */
  72326. componentType: AccessorComponentType;
  72327. }
  72328. /**
  72329. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  72330. */
  72331. interface IAccessorSparseValues extends IProperty {
  72332. /**
  72333. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72334. */
  72335. bufferView: number;
  72336. /**
  72337. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72338. */
  72339. byteOffset?: number;
  72340. }
  72341. /**
  72342. * Sparse storage of attributes that deviate from their initialization value
  72343. */
  72344. interface IAccessorSparse extends IProperty {
  72345. /**
  72346. * The number of attributes encoded in this sparse accessor
  72347. */
  72348. count: number;
  72349. /**
  72350. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  72351. */
  72352. indices: IAccessorSparseIndices;
  72353. /**
  72354. * 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
  72355. */
  72356. values: IAccessorSparseValues;
  72357. }
  72358. /**
  72359. * 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
  72360. */
  72361. interface IAccessor extends IChildRootProperty {
  72362. /**
  72363. * The index of the bufferview
  72364. */
  72365. bufferView?: number;
  72366. /**
  72367. * The offset relative to the start of the bufferView in bytes
  72368. */
  72369. byteOffset?: number;
  72370. /**
  72371. * The datatype of components in the attribute
  72372. */
  72373. componentType: AccessorComponentType;
  72374. /**
  72375. * Specifies whether integer data values should be normalized
  72376. */
  72377. normalized?: boolean;
  72378. /**
  72379. * The number of attributes referenced by this accessor
  72380. */
  72381. count: number;
  72382. /**
  72383. * Specifies if the attribute is a scalar, vector, or matrix
  72384. */
  72385. type: AccessorType;
  72386. /**
  72387. * Maximum value of each component in this attribute
  72388. */
  72389. max?: number[];
  72390. /**
  72391. * Minimum value of each component in this attribute
  72392. */
  72393. min?: number[];
  72394. /**
  72395. * Sparse storage of attributes that deviate from their initialization value
  72396. */
  72397. sparse?: IAccessorSparse;
  72398. }
  72399. /**
  72400. * Targets an animation's sampler at a node's property
  72401. */
  72402. interface IAnimationChannel extends IProperty {
  72403. /**
  72404. * The index of a sampler in this animation used to compute the value for the target
  72405. */
  72406. sampler: number;
  72407. /**
  72408. * The index of the node and TRS property to target
  72409. */
  72410. target: IAnimationChannelTarget;
  72411. }
  72412. /**
  72413. * The index of the node and TRS property that an animation channel targets
  72414. */
  72415. interface IAnimationChannelTarget extends IProperty {
  72416. /**
  72417. * The index of the node to target
  72418. */
  72419. node: number;
  72420. /**
  72421. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72422. */
  72423. path: AnimationChannelTargetPath;
  72424. }
  72425. /**
  72426. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72427. */
  72428. interface IAnimationSampler extends IProperty {
  72429. /**
  72430. * The index of an accessor containing keyframe input values, e.g., time
  72431. */
  72432. input: number;
  72433. /**
  72434. * Interpolation algorithm
  72435. */
  72436. interpolation?: AnimationSamplerInterpolation;
  72437. /**
  72438. * The index of an accessor, containing keyframe output values
  72439. */
  72440. output: number;
  72441. }
  72442. /**
  72443. * A keyframe animation
  72444. */
  72445. interface IAnimation extends IChildRootProperty {
  72446. /**
  72447. * An array of channels, each of which targets an animation's sampler at a node's property
  72448. */
  72449. channels: IAnimationChannel[];
  72450. /**
  72451. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72452. */
  72453. samplers: IAnimationSampler[];
  72454. }
  72455. /**
  72456. * Metadata about the glTF asset
  72457. */
  72458. interface IAsset extends IChildRootProperty {
  72459. /**
  72460. * A copyright message suitable for display to credit the content creator
  72461. */
  72462. copyright?: string;
  72463. /**
  72464. * Tool that generated this glTF model. Useful for debugging
  72465. */
  72466. generator?: string;
  72467. /**
  72468. * The glTF version that this asset targets
  72469. */
  72470. version: string;
  72471. /**
  72472. * The minimum glTF version that this asset targets
  72473. */
  72474. minVersion?: string;
  72475. }
  72476. /**
  72477. * A buffer points to binary geometry, animation, or skins
  72478. */
  72479. interface IBuffer extends IChildRootProperty {
  72480. /**
  72481. * 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
  72482. */
  72483. uri?: string;
  72484. /**
  72485. * The length of the buffer in bytes
  72486. */
  72487. byteLength: number;
  72488. }
  72489. /**
  72490. * A view into a buffer generally representing a subset of the buffer
  72491. */
  72492. interface IBufferView extends IChildRootProperty {
  72493. /**
  72494. * The index of the buffer
  72495. */
  72496. buffer: number;
  72497. /**
  72498. * The offset into the buffer in bytes
  72499. */
  72500. byteOffset?: number;
  72501. /**
  72502. * The lenth of the bufferView in bytes
  72503. */
  72504. byteLength: number;
  72505. /**
  72506. * The stride, in bytes
  72507. */
  72508. byteStride?: number;
  72509. }
  72510. /**
  72511. * An orthographic camera containing properties to create an orthographic projection matrix
  72512. */
  72513. interface ICameraOrthographic extends IProperty {
  72514. /**
  72515. * The floating-point horizontal magnification of the view. Must not be zero
  72516. */
  72517. xmag: number;
  72518. /**
  72519. * The floating-point vertical magnification of the view. Must not be zero
  72520. */
  72521. ymag: number;
  72522. /**
  72523. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  72524. */
  72525. zfar: number;
  72526. /**
  72527. * The floating-point distance to the near clipping plane
  72528. */
  72529. znear: number;
  72530. }
  72531. /**
  72532. * A perspective camera containing properties to create a perspective projection matrix
  72533. */
  72534. interface ICameraPerspective extends IProperty {
  72535. /**
  72536. * The floating-point aspect ratio of the field of view
  72537. */
  72538. aspectRatio?: number;
  72539. /**
  72540. * The floating-point vertical field of view in radians
  72541. */
  72542. yfov: number;
  72543. /**
  72544. * The floating-point distance to the far clipping plane
  72545. */
  72546. zfar?: number;
  72547. /**
  72548. * The floating-point distance to the near clipping plane
  72549. */
  72550. znear: number;
  72551. }
  72552. /**
  72553. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72554. */
  72555. interface ICamera extends IChildRootProperty {
  72556. /**
  72557. * An orthographic camera containing properties to create an orthographic projection matrix
  72558. */
  72559. orthographic?: ICameraOrthographic;
  72560. /**
  72561. * A perspective camera containing properties to create a perspective projection matrix
  72562. */
  72563. perspective?: ICameraPerspective;
  72564. /**
  72565. * Specifies if the camera uses a perspective or orthographic projection
  72566. */
  72567. type: CameraType;
  72568. }
  72569. /**
  72570. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  72571. */
  72572. interface IImage extends IChildRootProperty {
  72573. /**
  72574. * 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
  72575. */
  72576. uri?: string;
  72577. /**
  72578. * The image's MIME type
  72579. */
  72580. mimeType?: ImageMimeType;
  72581. /**
  72582. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  72583. */
  72584. bufferView?: number;
  72585. }
  72586. /**
  72587. * Material Normal Texture Info
  72588. */
  72589. interface IMaterialNormalTextureInfo extends ITextureInfo {
  72590. /**
  72591. * The scalar multiplier applied to each normal vector of the normal texture
  72592. */
  72593. scale?: number;
  72594. }
  72595. /**
  72596. * Material Occlusion Texture Info
  72597. */
  72598. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  72599. /**
  72600. * A scalar multiplier controlling the amount of occlusion applied
  72601. */
  72602. strength?: number;
  72603. }
  72604. /**
  72605. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  72606. */
  72607. interface IMaterialPbrMetallicRoughness {
  72608. /**
  72609. * The material's base color factor
  72610. */
  72611. baseColorFactor?: number[];
  72612. /**
  72613. * The base color texture
  72614. */
  72615. baseColorTexture?: ITextureInfo;
  72616. /**
  72617. * The metalness of the material
  72618. */
  72619. metallicFactor?: number;
  72620. /**
  72621. * The roughness of the material
  72622. */
  72623. roughnessFactor?: number;
  72624. /**
  72625. * The metallic-roughness texture
  72626. */
  72627. metallicRoughnessTexture?: ITextureInfo;
  72628. }
  72629. /**
  72630. * The material appearance of a primitive
  72631. */
  72632. interface IMaterial extends IChildRootProperty {
  72633. /**
  72634. * 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
  72635. */
  72636. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72637. /**
  72638. * The normal map texture
  72639. */
  72640. normalTexture?: IMaterialNormalTextureInfo;
  72641. /**
  72642. * The occlusion map texture
  72643. */
  72644. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72645. /**
  72646. * The emissive map texture
  72647. */
  72648. emissiveTexture?: ITextureInfo;
  72649. /**
  72650. * 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
  72651. */
  72652. emissiveFactor?: number[];
  72653. /**
  72654. * The alpha rendering mode of the material
  72655. */
  72656. alphaMode?: MaterialAlphaMode;
  72657. /**
  72658. * The alpha cutoff value of the material
  72659. */
  72660. alphaCutoff?: number;
  72661. /**
  72662. * Specifies whether the material is double sided
  72663. */
  72664. doubleSided?: boolean;
  72665. }
  72666. /**
  72667. * Geometry to be rendered with the given material
  72668. */
  72669. interface IMeshPrimitive extends IProperty {
  72670. /**
  72671. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  72672. */
  72673. attributes: {
  72674. [name: string]: number;
  72675. };
  72676. /**
  72677. * The index of the accessor that contains the indices
  72678. */
  72679. indices?: number;
  72680. /**
  72681. * The index of the material to apply to this primitive when rendering
  72682. */
  72683. material?: number;
  72684. /**
  72685. * The type of primitives to render. All valid values correspond to WebGL enums
  72686. */
  72687. mode?: MeshPrimitiveMode;
  72688. /**
  72689. * 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
  72690. */
  72691. targets?: {
  72692. [name: string]: number;
  72693. }[];
  72694. }
  72695. /**
  72696. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  72697. */
  72698. interface IMesh extends IChildRootProperty {
  72699. /**
  72700. * An array of primitives, each defining geometry to be rendered with a material
  72701. */
  72702. primitives: IMeshPrimitive[];
  72703. /**
  72704. * Array of weights to be applied to the Morph Targets
  72705. */
  72706. weights?: number[];
  72707. }
  72708. /**
  72709. * A node in the node hierarchy
  72710. */
  72711. interface INode extends IChildRootProperty {
  72712. /**
  72713. * The index of the camera referenced by this node
  72714. */
  72715. camera?: number;
  72716. /**
  72717. * The indices of this node's children
  72718. */
  72719. children?: number[];
  72720. /**
  72721. * The index of the skin referenced by this node
  72722. */
  72723. skin?: number;
  72724. /**
  72725. * A floating-point 4x4 transformation matrix stored in column-major order
  72726. */
  72727. matrix?: number[];
  72728. /**
  72729. * The index of the mesh in this node
  72730. */
  72731. mesh?: number;
  72732. /**
  72733. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72734. */
  72735. rotation?: number[];
  72736. /**
  72737. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72738. */
  72739. scale?: number[];
  72740. /**
  72741. * The node's translation along the x, y, and z axes
  72742. */
  72743. translation?: number[];
  72744. /**
  72745. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72746. */
  72747. weights?: number[];
  72748. }
  72749. /**
  72750. * Texture sampler properties for filtering and wrapping modes
  72751. */
  72752. interface ISampler extends IChildRootProperty {
  72753. /**
  72754. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72755. */
  72756. magFilter?: TextureMagFilter;
  72757. /**
  72758. * Minification filter. All valid values correspond to WebGL enums
  72759. */
  72760. minFilter?: TextureMinFilter;
  72761. /**
  72762. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72763. */
  72764. wrapS?: TextureWrapMode;
  72765. /**
  72766. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72767. */
  72768. wrapT?: TextureWrapMode;
  72769. }
  72770. /**
  72771. * The root nodes of a scene
  72772. */
  72773. interface IScene extends IChildRootProperty {
  72774. /**
  72775. * The indices of each root node
  72776. */
  72777. nodes: number[];
  72778. }
  72779. /**
  72780. * Joints and matrices defining a skin
  72781. */
  72782. interface ISkin extends IChildRootProperty {
  72783. /**
  72784. * 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
  72785. */
  72786. inverseBindMatrices?: number;
  72787. /**
  72788. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72789. */
  72790. skeleton?: number;
  72791. /**
  72792. * 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)
  72793. */
  72794. joints: number[];
  72795. }
  72796. /**
  72797. * A texture and its sampler
  72798. */
  72799. interface ITexture extends IChildRootProperty {
  72800. /**
  72801. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72802. */
  72803. sampler?: number;
  72804. /**
  72805. * The index of the image used by this texture
  72806. */
  72807. source: number;
  72808. }
  72809. /**
  72810. * Reference to a texture
  72811. */
  72812. interface ITextureInfo extends IProperty {
  72813. /**
  72814. * The index of the texture
  72815. */
  72816. index: number;
  72817. /**
  72818. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72819. */
  72820. texCoord?: number;
  72821. }
  72822. /**
  72823. * The root object for a glTF asset
  72824. */
  72825. interface IGLTF extends IProperty {
  72826. /**
  72827. * An array of accessors. An accessor is a typed view into a bufferView
  72828. */
  72829. accessors?: IAccessor[];
  72830. /**
  72831. * An array of keyframe animations
  72832. */
  72833. animations?: IAnimation[];
  72834. /**
  72835. * Metadata about the glTF asset
  72836. */
  72837. asset: IAsset;
  72838. /**
  72839. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72840. */
  72841. buffers?: IBuffer[];
  72842. /**
  72843. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72844. */
  72845. bufferViews?: IBufferView[];
  72846. /**
  72847. * An array of cameras
  72848. */
  72849. cameras?: ICamera[];
  72850. /**
  72851. * Names of glTF extensions used somewhere in this asset
  72852. */
  72853. extensionsUsed?: string[];
  72854. /**
  72855. * Names of glTF extensions required to properly load this asset
  72856. */
  72857. extensionsRequired?: string[];
  72858. /**
  72859. * An array of images. An image defines data used to create a texture
  72860. */
  72861. images?: IImage[];
  72862. /**
  72863. * An array of materials. A material defines the appearance of a primitive
  72864. */
  72865. materials?: IMaterial[];
  72866. /**
  72867. * An array of meshes. A mesh is a set of primitives to be rendered
  72868. */
  72869. meshes?: IMesh[];
  72870. /**
  72871. * An array of nodes
  72872. */
  72873. nodes?: INode[];
  72874. /**
  72875. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72876. */
  72877. samplers?: ISampler[];
  72878. /**
  72879. * The index of the default scene
  72880. */
  72881. scene?: number;
  72882. /**
  72883. * An array of scenes
  72884. */
  72885. scenes?: IScene[];
  72886. /**
  72887. * An array of skins. A skin is defined by joints and matrices
  72888. */
  72889. skins?: ISkin[];
  72890. /**
  72891. * An array of textures
  72892. */
  72893. textures?: ITexture[];
  72894. }
  72895. /**
  72896. * The glTF validation results
  72897. * @ignore
  72898. */
  72899. interface IGLTFValidationResults {
  72900. info: {
  72901. generator: string;
  72902. hasAnimations: boolean;
  72903. hasDefaultScene: boolean;
  72904. hasMaterials: boolean;
  72905. hasMorphTargets: boolean;
  72906. hasSkins: boolean;
  72907. hasTextures: boolean;
  72908. maxAttributesUsed: number;
  72909. primitivesCount: number
  72910. };
  72911. issues: {
  72912. messages: Array<string>;
  72913. numErrors: number;
  72914. numHints: number;
  72915. numInfos: number;
  72916. numWarnings: number;
  72917. truncated: boolean
  72918. };
  72919. mimeType: string;
  72920. uri: string;
  72921. validatedAt: string;
  72922. validatorVersion: string;
  72923. }
  72924. /**
  72925. * The glTF validation options
  72926. */
  72927. interface IGLTFValidationOptions {
  72928. /** Uri to use */
  72929. uri?: string;
  72930. /** Function used to load external resources */
  72931. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72932. /** Boolean indicating that we need to validate accessor data */
  72933. validateAccessorData?: boolean;
  72934. /** max number of issues allowed */
  72935. maxIssues?: number;
  72936. /** Ignored issues */
  72937. ignoredIssues?: Array<string>;
  72938. /** Value to override severy settings */
  72939. severityOverrides?: Object;
  72940. }
  72941. /**
  72942. * The glTF validator object
  72943. * @ignore
  72944. */
  72945. interface IGLTFValidator {
  72946. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72947. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72948. }
  72949. }
  72950. declare module BABYLON {
  72951. /** @hidden */
  72952. export var cellPixelShader: {
  72953. name: string;
  72954. shader: string;
  72955. };
  72956. }
  72957. declare module BABYLON {
  72958. /** @hidden */
  72959. export var cellVertexShader: {
  72960. name: string;
  72961. shader: string;
  72962. };
  72963. }
  72964. declare module BABYLON {
  72965. export class CellMaterial extends BABYLON.PushMaterial {
  72966. private _diffuseTexture;
  72967. diffuseTexture: BABYLON.BaseTexture;
  72968. diffuseColor: BABYLON.Color3;
  72969. _computeHighLevel: boolean;
  72970. computeHighLevel: boolean;
  72971. private _disableLighting;
  72972. disableLighting: boolean;
  72973. private _maxSimultaneousLights;
  72974. maxSimultaneousLights: number;
  72975. private _renderId;
  72976. constructor(name: string, scene: BABYLON.Scene);
  72977. needAlphaBlending(): boolean;
  72978. needAlphaTesting(): boolean;
  72979. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72980. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72981. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72982. getAnimatables(): BABYLON.IAnimatable[];
  72983. getActiveTextures(): BABYLON.BaseTexture[];
  72984. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72985. dispose(forceDisposeEffect?: boolean): void;
  72986. getClassName(): string;
  72987. clone(name: string): CellMaterial;
  72988. serialize(): any;
  72989. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72990. }
  72991. }
  72992. declare module BABYLON {
  72993. export class CustomShaderStructure {
  72994. FragmentStore: string;
  72995. VertexStore: string;
  72996. constructor();
  72997. }
  72998. export class ShaderSpecialParts {
  72999. constructor();
  73000. Fragment_Begin: string;
  73001. Fragment_Definitions: string;
  73002. Fragment_MainBegin: string;
  73003. Fragment_Custom_Diffuse: string;
  73004. Fragment_Before_Lights: string;
  73005. Fragment_Before_Fog: string;
  73006. Fragment_Custom_Alpha: string;
  73007. Fragment_Before_FragColor: string;
  73008. Vertex_Begin: string;
  73009. Vertex_Definitions: string;
  73010. Vertex_MainBegin: string;
  73011. Vertex_Before_PositionUpdated: string;
  73012. Vertex_Before_NormalUpdated: string;
  73013. Vertex_MainEnd: string;
  73014. }
  73015. export class CustomMaterial extends BABYLON.StandardMaterial {
  73016. static ShaderIndexer: number;
  73017. CustomParts: ShaderSpecialParts;
  73018. _isCreatedShader: boolean;
  73019. _createdShaderName: string;
  73020. _customUniform: string[];
  73021. _newUniforms: string[];
  73022. _newUniformInstances: any[];
  73023. _newSamplerInstances: BABYLON.Texture[];
  73024. FragmentShader: string;
  73025. VertexShader: string;
  73026. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73027. ReviewUniform(name: string, arr: string[]): string[];
  73028. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  73029. constructor(name: string, scene: BABYLON.Scene);
  73030. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  73031. Fragment_Begin(shaderPart: string): CustomMaterial;
  73032. Fragment_Definitions(shaderPart: string): CustomMaterial;
  73033. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  73034. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  73035. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  73036. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  73037. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  73038. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  73039. Vertex_Begin(shaderPart: string): CustomMaterial;
  73040. Vertex_Definitions(shaderPart: string): CustomMaterial;
  73041. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  73042. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  73043. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  73044. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  73045. }
  73046. }
  73047. declare module BABYLON {
  73048. export class ShaderAlebdoParts {
  73049. constructor();
  73050. Fragment_Begin: string;
  73051. Fragment_Definitions: string;
  73052. Fragment_MainBegin: string;
  73053. Fragment_Custom_Albedo: string;
  73054. Fragment_Before_Lights: string;
  73055. Fragment_Custom_MetallicRoughness: string;
  73056. Fragment_Custom_MicroSurface: string;
  73057. Fragment_Before_Fog: string;
  73058. Fragment_Custom_Alpha: string;
  73059. Fragment_Before_FragColor: string;
  73060. Vertex_Begin: string;
  73061. Vertex_Definitions: string;
  73062. Vertex_MainBegin: string;
  73063. Vertex_Before_PositionUpdated: string;
  73064. Vertex_Before_NormalUpdated: string;
  73065. Vertex_MainEnd: string;
  73066. }
  73067. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  73068. static ShaderIndexer: number;
  73069. CustomParts: ShaderAlebdoParts;
  73070. _isCreatedShader: boolean;
  73071. _createdShaderName: string;
  73072. _customUniform: string[];
  73073. _newUniforms: string[];
  73074. _newUniformInstances: any[];
  73075. _newSamplerInstances: BABYLON.Texture[];
  73076. FragmentShader: string;
  73077. VertexShader: string;
  73078. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73079. ReviewUniform(name: string, arr: string[]): string[];
  73080. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  73081. constructor(name: string, scene: BABYLON.Scene);
  73082. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  73083. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  73084. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  73085. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  73086. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  73087. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  73088. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  73089. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  73090. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  73091. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  73092. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  73093. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  73094. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  73095. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  73096. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  73097. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  73098. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  73099. }
  73100. }
  73101. declare module BABYLON {
  73102. /** @hidden */
  73103. export var firePixelShader: {
  73104. name: string;
  73105. shader: string;
  73106. };
  73107. }
  73108. declare module BABYLON {
  73109. /** @hidden */
  73110. export var fireVertexShader: {
  73111. name: string;
  73112. shader: string;
  73113. };
  73114. }
  73115. declare module BABYLON {
  73116. export class FireMaterial extends BABYLON.PushMaterial {
  73117. private _diffuseTexture;
  73118. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73119. private _distortionTexture;
  73120. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73121. private _opacityTexture;
  73122. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73123. diffuseColor: BABYLON.Color3;
  73124. speed: number;
  73125. private _scaledDiffuse;
  73126. private _renderId;
  73127. private _lastTime;
  73128. constructor(name: string, scene: BABYLON.Scene);
  73129. needAlphaBlending(): boolean;
  73130. needAlphaTesting(): boolean;
  73131. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73132. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73133. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73134. getAnimatables(): BABYLON.IAnimatable[];
  73135. getActiveTextures(): BABYLON.BaseTexture[];
  73136. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73137. getClassName(): string;
  73138. dispose(forceDisposeEffect?: boolean): void;
  73139. clone(name: string): FireMaterial;
  73140. serialize(): any;
  73141. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  73142. }
  73143. }
  73144. declare module BABYLON {
  73145. /** @hidden */
  73146. export var furPixelShader: {
  73147. name: string;
  73148. shader: string;
  73149. };
  73150. }
  73151. declare module BABYLON {
  73152. /** @hidden */
  73153. export var furVertexShader: {
  73154. name: string;
  73155. shader: string;
  73156. };
  73157. }
  73158. declare module BABYLON {
  73159. export class FurMaterial extends BABYLON.PushMaterial {
  73160. private _diffuseTexture;
  73161. diffuseTexture: BABYLON.BaseTexture;
  73162. private _heightTexture;
  73163. heightTexture: BABYLON.BaseTexture;
  73164. diffuseColor: BABYLON.Color3;
  73165. furLength: number;
  73166. furAngle: number;
  73167. furColor: BABYLON.Color3;
  73168. furOffset: number;
  73169. furSpacing: number;
  73170. furGravity: BABYLON.Vector3;
  73171. furSpeed: number;
  73172. furDensity: number;
  73173. furOcclusion: number;
  73174. furTexture: BABYLON.DynamicTexture;
  73175. private _disableLighting;
  73176. disableLighting: boolean;
  73177. private _maxSimultaneousLights;
  73178. maxSimultaneousLights: number;
  73179. highLevelFur: boolean;
  73180. _meshes: BABYLON.AbstractMesh[];
  73181. private _renderId;
  73182. private _furTime;
  73183. constructor(name: string, scene: BABYLON.Scene);
  73184. furTime: number;
  73185. needAlphaBlending(): boolean;
  73186. needAlphaTesting(): boolean;
  73187. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73188. updateFur(): void;
  73189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73191. getAnimatables(): BABYLON.IAnimatable[];
  73192. getActiveTextures(): BABYLON.BaseTexture[];
  73193. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73194. dispose(forceDisposeEffect?: boolean): void;
  73195. clone(name: string): FurMaterial;
  73196. serialize(): any;
  73197. getClassName(): string;
  73198. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  73199. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  73200. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  73201. }
  73202. }
  73203. declare module BABYLON {
  73204. /** @hidden */
  73205. export var gradientPixelShader: {
  73206. name: string;
  73207. shader: string;
  73208. };
  73209. }
  73210. declare module BABYLON {
  73211. /** @hidden */
  73212. export var gradientVertexShader: {
  73213. name: string;
  73214. shader: string;
  73215. };
  73216. }
  73217. declare module BABYLON {
  73218. export class GradientMaterial extends BABYLON.PushMaterial {
  73219. private _maxSimultaneousLights;
  73220. maxSimultaneousLights: number;
  73221. topColor: BABYLON.Color3;
  73222. topColorAlpha: number;
  73223. bottomColor: BABYLON.Color3;
  73224. bottomColorAlpha: number;
  73225. offset: number;
  73226. scale: number;
  73227. smoothness: number;
  73228. private _disableLighting;
  73229. disableLighting: boolean;
  73230. private _renderId;
  73231. constructor(name: string, scene: BABYLON.Scene);
  73232. needAlphaBlending(): boolean;
  73233. needAlphaTesting(): boolean;
  73234. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73235. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73236. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73237. getAnimatables(): BABYLON.IAnimatable[];
  73238. dispose(forceDisposeEffect?: boolean): void;
  73239. clone(name: string): GradientMaterial;
  73240. serialize(): any;
  73241. getClassName(): string;
  73242. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  73243. }
  73244. }
  73245. declare module BABYLON {
  73246. /** @hidden */
  73247. export var gridPixelShader: {
  73248. name: string;
  73249. shader: string;
  73250. };
  73251. }
  73252. declare module BABYLON {
  73253. /** @hidden */
  73254. export var gridVertexShader: {
  73255. name: string;
  73256. shader: string;
  73257. };
  73258. }
  73259. declare module BABYLON {
  73260. /**
  73261. * The grid materials allows you to wrap any shape with a grid.
  73262. * Colors are customizable.
  73263. */
  73264. export class GridMaterial extends BABYLON.PushMaterial {
  73265. /**
  73266. * Main color of the grid (e.g. between lines)
  73267. */
  73268. mainColor: BABYLON.Color3;
  73269. /**
  73270. * Color of the grid lines.
  73271. */
  73272. lineColor: BABYLON.Color3;
  73273. /**
  73274. * The scale of the grid compared to unit.
  73275. */
  73276. gridRatio: number;
  73277. /**
  73278. * Allows setting an offset for the grid lines.
  73279. */
  73280. gridOffset: BABYLON.Vector3;
  73281. /**
  73282. * The frequency of thicker lines.
  73283. */
  73284. majorUnitFrequency: number;
  73285. /**
  73286. * The visibility of minor units in the grid.
  73287. */
  73288. minorUnitVisibility: number;
  73289. /**
  73290. * The grid opacity outside of the lines.
  73291. */
  73292. opacity: number;
  73293. /**
  73294. * Determine RBG output is premultiplied by alpha value.
  73295. */
  73296. preMultiplyAlpha: boolean;
  73297. private _opacityTexture;
  73298. opacityTexture: BABYLON.BaseTexture;
  73299. private _gridControl;
  73300. private _renderId;
  73301. /**
  73302. * constructor
  73303. * @param name The name given to the material in order to identify it afterwards.
  73304. * @param scene The scene the material is used in.
  73305. */
  73306. constructor(name: string, scene: BABYLON.Scene);
  73307. /**
  73308. * Returns wehter or not the grid requires alpha blending.
  73309. */
  73310. needAlphaBlending(): boolean;
  73311. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73314. /**
  73315. * Dispose the material and its associated resources.
  73316. * @param forceDisposeEffect will also dispose the used effect when true
  73317. */
  73318. dispose(forceDisposeEffect?: boolean): void;
  73319. clone(name: string): GridMaterial;
  73320. serialize(): any;
  73321. getClassName(): string;
  73322. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  73323. }
  73324. }
  73325. declare module BABYLON {
  73326. /** @hidden */
  73327. export var lavaPixelShader: {
  73328. name: string;
  73329. shader: string;
  73330. };
  73331. }
  73332. declare module BABYLON {
  73333. /** @hidden */
  73334. export var lavaVertexShader: {
  73335. name: string;
  73336. shader: string;
  73337. };
  73338. }
  73339. declare module BABYLON {
  73340. export class LavaMaterial extends BABYLON.PushMaterial {
  73341. private _diffuseTexture;
  73342. diffuseTexture: BABYLON.BaseTexture;
  73343. noiseTexture: BABYLON.BaseTexture;
  73344. fogColor: BABYLON.Color3;
  73345. speed: number;
  73346. movingSpeed: number;
  73347. lowFrequencySpeed: number;
  73348. fogDensity: number;
  73349. private _lastTime;
  73350. diffuseColor: BABYLON.Color3;
  73351. private _disableLighting;
  73352. disableLighting: boolean;
  73353. private _unlit;
  73354. unlit: boolean;
  73355. private _maxSimultaneousLights;
  73356. maxSimultaneousLights: number;
  73357. private _scaledDiffuse;
  73358. private _renderId;
  73359. constructor(name: string, scene: BABYLON.Scene);
  73360. needAlphaBlending(): boolean;
  73361. needAlphaTesting(): boolean;
  73362. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73365. getAnimatables(): BABYLON.IAnimatable[];
  73366. getActiveTextures(): BABYLON.BaseTexture[];
  73367. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73368. dispose(forceDisposeEffect?: boolean): void;
  73369. clone(name: string): LavaMaterial;
  73370. serialize(): any;
  73371. getClassName(): string;
  73372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  73373. }
  73374. }
  73375. declare module BABYLON {
  73376. /** @hidden */
  73377. export var mixPixelShader: {
  73378. name: string;
  73379. shader: string;
  73380. };
  73381. }
  73382. declare module BABYLON {
  73383. /** @hidden */
  73384. export var mixVertexShader: {
  73385. name: string;
  73386. shader: string;
  73387. };
  73388. }
  73389. declare module BABYLON {
  73390. export class MixMaterial extends BABYLON.PushMaterial {
  73391. /**
  73392. * Mix textures
  73393. */
  73394. private _mixTexture1;
  73395. mixTexture1: BABYLON.BaseTexture;
  73396. private _mixTexture2;
  73397. mixTexture2: BABYLON.BaseTexture;
  73398. /**
  73399. * Diffuse textures
  73400. */
  73401. private _diffuseTexture1;
  73402. diffuseTexture1: BABYLON.Texture;
  73403. private _diffuseTexture2;
  73404. diffuseTexture2: BABYLON.Texture;
  73405. private _diffuseTexture3;
  73406. diffuseTexture3: BABYLON.Texture;
  73407. private _diffuseTexture4;
  73408. diffuseTexture4: BABYLON.Texture;
  73409. private _diffuseTexture5;
  73410. diffuseTexture5: BABYLON.Texture;
  73411. private _diffuseTexture6;
  73412. diffuseTexture6: BABYLON.Texture;
  73413. private _diffuseTexture7;
  73414. diffuseTexture7: BABYLON.Texture;
  73415. private _diffuseTexture8;
  73416. diffuseTexture8: BABYLON.Texture;
  73417. /**
  73418. * Uniforms
  73419. */
  73420. diffuseColor: BABYLON.Color3;
  73421. specularColor: BABYLON.Color3;
  73422. specularPower: number;
  73423. private _disableLighting;
  73424. disableLighting: boolean;
  73425. private _maxSimultaneousLights;
  73426. maxSimultaneousLights: number;
  73427. private _renderId;
  73428. constructor(name: string, scene: BABYLON.Scene);
  73429. needAlphaBlending(): boolean;
  73430. needAlphaTesting(): boolean;
  73431. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73432. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73433. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73434. getAnimatables(): BABYLON.IAnimatable[];
  73435. getActiveTextures(): BABYLON.BaseTexture[];
  73436. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73437. dispose(forceDisposeEffect?: boolean): void;
  73438. clone(name: string): MixMaterial;
  73439. serialize(): any;
  73440. getClassName(): string;
  73441. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** @hidden */
  73446. export var normalPixelShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module BABYLON {
  73452. /** @hidden */
  73453. export var normalVertexShader: {
  73454. name: string;
  73455. shader: string;
  73456. };
  73457. }
  73458. declare module BABYLON {
  73459. export class NormalMaterial extends BABYLON.PushMaterial {
  73460. private _diffuseTexture;
  73461. diffuseTexture: BABYLON.BaseTexture;
  73462. diffuseColor: BABYLON.Color3;
  73463. private _disableLighting;
  73464. disableLighting: boolean;
  73465. private _maxSimultaneousLights;
  73466. maxSimultaneousLights: number;
  73467. private _renderId;
  73468. constructor(name: string, scene: BABYLON.Scene);
  73469. needAlphaBlending(): boolean;
  73470. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73471. needAlphaTesting(): boolean;
  73472. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73473. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73474. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73475. getAnimatables(): BABYLON.IAnimatable[];
  73476. getActiveTextures(): BABYLON.BaseTexture[];
  73477. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73478. dispose(forceDisposeEffect?: boolean): void;
  73479. clone(name: string): NormalMaterial;
  73480. serialize(): any;
  73481. getClassName(): string;
  73482. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  73483. }
  73484. }
  73485. declare module BABYLON {
  73486. /** @hidden */
  73487. export var shadowOnlyPixelShader: {
  73488. name: string;
  73489. shader: string;
  73490. };
  73491. }
  73492. declare module BABYLON {
  73493. /** @hidden */
  73494. export var shadowOnlyVertexShader: {
  73495. name: string;
  73496. shader: string;
  73497. };
  73498. }
  73499. declare module BABYLON {
  73500. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  73501. private _renderId;
  73502. private _activeLight;
  73503. constructor(name: string, scene: BABYLON.Scene);
  73504. shadowColor: BABYLON.Color3;
  73505. needAlphaBlending(): boolean;
  73506. needAlphaTesting(): boolean;
  73507. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73508. activeLight: BABYLON.IShadowLight;
  73509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73511. clone(name: string): ShadowOnlyMaterial;
  73512. serialize(): any;
  73513. getClassName(): string;
  73514. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  73515. }
  73516. }
  73517. declare module BABYLON {
  73518. /** @hidden */
  73519. export var simplePixelShader: {
  73520. name: string;
  73521. shader: string;
  73522. };
  73523. }
  73524. declare module BABYLON {
  73525. /** @hidden */
  73526. export var simpleVertexShader: {
  73527. name: string;
  73528. shader: string;
  73529. };
  73530. }
  73531. declare module BABYLON {
  73532. export class SimpleMaterial extends BABYLON.PushMaterial {
  73533. private _diffuseTexture;
  73534. diffuseTexture: BABYLON.BaseTexture;
  73535. diffuseColor: BABYLON.Color3;
  73536. private _disableLighting;
  73537. disableLighting: boolean;
  73538. private _maxSimultaneousLights;
  73539. maxSimultaneousLights: number;
  73540. private _renderId;
  73541. constructor(name: string, scene: BABYLON.Scene);
  73542. needAlphaBlending(): boolean;
  73543. needAlphaTesting(): boolean;
  73544. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73545. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73546. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73547. getAnimatables(): BABYLON.IAnimatable[];
  73548. getActiveTextures(): BABYLON.BaseTexture[];
  73549. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73550. dispose(forceDisposeEffect?: boolean): void;
  73551. clone(name: string): SimpleMaterial;
  73552. serialize(): any;
  73553. getClassName(): string;
  73554. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  73555. }
  73556. }
  73557. declare module BABYLON {
  73558. /** @hidden */
  73559. export var skyPixelShader: {
  73560. name: string;
  73561. shader: string;
  73562. };
  73563. }
  73564. declare module BABYLON {
  73565. /** @hidden */
  73566. export var skyVertexShader: {
  73567. name: string;
  73568. shader: string;
  73569. };
  73570. }
  73571. declare module BABYLON {
  73572. /**
  73573. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  73574. * @see https://doc.babylonjs.com/extensions/sky
  73575. */
  73576. export class SkyMaterial extends BABYLON.PushMaterial {
  73577. /**
  73578. * Defines the overall luminance of sky in interval ]0, 1[.
  73579. */
  73580. luminance: number;
  73581. /**
  73582. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  73583. */
  73584. turbidity: number;
  73585. /**
  73586. * Defines the sky appearance (light intensity).
  73587. */
  73588. rayleigh: number;
  73589. /**
  73590. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  73591. */
  73592. mieCoefficient: number;
  73593. /**
  73594. * Defines the amount of haze particles following the Mie scattering theory.
  73595. */
  73596. mieDirectionalG: number;
  73597. /**
  73598. * Defines the distance of the sun according to the active scene camera.
  73599. */
  73600. distance: number;
  73601. /**
  73602. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  73603. * "inclined".
  73604. */
  73605. inclination: number;
  73606. /**
  73607. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  73608. * an object direction and a reference direction.
  73609. */
  73610. azimuth: number;
  73611. /**
  73612. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  73613. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  73614. */
  73615. sunPosition: BABYLON.Vector3;
  73616. /**
  73617. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  73618. * .sunPosition property.
  73619. */
  73620. useSunPosition: boolean;
  73621. /**
  73622. * Defines an offset vector used to get a horizon offset.
  73623. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  73624. */
  73625. cameraOffset: BABYLON.Vector3;
  73626. private _cameraPosition;
  73627. private _renderId;
  73628. /**
  73629. * Instantiates a new sky material.
  73630. * This material allows to create dynamic and texture free
  73631. * effects for skyboxes by taking care of the atmosphere state.
  73632. * @see https://doc.babylonjs.com/extensions/sky
  73633. * @param name Define the name of the material in the scene
  73634. * @param scene Define the scene the material belong to
  73635. */
  73636. constructor(name: string, scene: BABYLON.Scene);
  73637. /**
  73638. * Specifies if the material will require alpha blending
  73639. * @returns a boolean specifying if alpha blending is needed
  73640. */
  73641. needAlphaBlending(): boolean;
  73642. /**
  73643. * Specifies if this material should be rendered in alpha test mode
  73644. * @returns false as the sky material doesn't need alpha testing.
  73645. */
  73646. needAlphaTesting(): boolean;
  73647. /**
  73648. * Get the texture used for alpha test purpose.
  73649. * @returns null as the sky material has no texture.
  73650. */
  73651. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73652. /**
  73653. * Get if the submesh is ready to be used and all its information available.
  73654. * Child classes can use it to update shaders
  73655. * @param mesh defines the mesh to check
  73656. * @param subMesh defines which submesh to check
  73657. * @param useInstances specifies that instances should be used
  73658. * @returns a boolean indicating that the submesh is ready or not
  73659. */
  73660. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73661. /**
  73662. * Binds the submesh to this material by preparing the effect and shader to draw
  73663. * @param world defines the world transformation matrix
  73664. * @param mesh defines the mesh containing the submesh
  73665. * @param subMesh defines the submesh to bind the material to
  73666. */
  73667. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73668. /**
  73669. * Get the list of animatables in the material.
  73670. * @returns the list of animatables object used in the material
  73671. */
  73672. getAnimatables(): BABYLON.IAnimatable[];
  73673. /**
  73674. * Disposes the material
  73675. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73676. */
  73677. dispose(forceDisposeEffect?: boolean): void;
  73678. /**
  73679. * Makes a duplicate of the material, and gives it a new name
  73680. * @param name defines the new name for the duplicated material
  73681. * @returns the cloned material
  73682. */
  73683. clone(name: string): SkyMaterial;
  73684. /**
  73685. * Serializes this material in a JSON representation
  73686. * @returns the serialized material object
  73687. */
  73688. serialize(): any;
  73689. /**
  73690. * Gets the current class name of the material e.g. "SkyMaterial"
  73691. * Mainly use in serialization.
  73692. * @returns the class name
  73693. */
  73694. getClassName(): string;
  73695. /**
  73696. * Creates a sky material from parsed material data
  73697. * @param source defines the JSON representation of the material
  73698. * @param scene defines the hosting scene
  73699. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73700. * @returns a new sky material
  73701. */
  73702. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73703. }
  73704. }
  73705. declare module BABYLON {
  73706. /** @hidden */
  73707. export var terrainPixelShader: {
  73708. name: string;
  73709. shader: string;
  73710. };
  73711. }
  73712. declare module BABYLON {
  73713. /** @hidden */
  73714. export var terrainVertexShader: {
  73715. name: string;
  73716. shader: string;
  73717. };
  73718. }
  73719. declare module BABYLON {
  73720. export class TerrainMaterial extends BABYLON.PushMaterial {
  73721. private _mixTexture;
  73722. mixTexture: BABYLON.BaseTexture;
  73723. private _diffuseTexture1;
  73724. diffuseTexture1: BABYLON.Texture;
  73725. private _diffuseTexture2;
  73726. diffuseTexture2: BABYLON.Texture;
  73727. private _diffuseTexture3;
  73728. diffuseTexture3: BABYLON.Texture;
  73729. private _bumpTexture1;
  73730. bumpTexture1: BABYLON.Texture;
  73731. private _bumpTexture2;
  73732. bumpTexture2: BABYLON.Texture;
  73733. private _bumpTexture3;
  73734. bumpTexture3: BABYLON.Texture;
  73735. diffuseColor: BABYLON.Color3;
  73736. specularColor: BABYLON.Color3;
  73737. specularPower: number;
  73738. private _disableLighting;
  73739. disableLighting: boolean;
  73740. private _maxSimultaneousLights;
  73741. maxSimultaneousLights: number;
  73742. private _renderId;
  73743. constructor(name: string, scene: BABYLON.Scene);
  73744. needAlphaBlending(): boolean;
  73745. needAlphaTesting(): boolean;
  73746. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73747. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73748. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73749. getAnimatables(): BABYLON.IAnimatable[];
  73750. getActiveTextures(): BABYLON.BaseTexture[];
  73751. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73752. dispose(forceDisposeEffect?: boolean): void;
  73753. clone(name: string): TerrainMaterial;
  73754. serialize(): any;
  73755. getClassName(): string;
  73756. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73757. }
  73758. }
  73759. declare module BABYLON {
  73760. /** @hidden */
  73761. export var triplanarPixelShader: {
  73762. name: string;
  73763. shader: string;
  73764. };
  73765. }
  73766. declare module BABYLON {
  73767. /** @hidden */
  73768. export var triplanarVertexShader: {
  73769. name: string;
  73770. shader: string;
  73771. };
  73772. }
  73773. declare module BABYLON {
  73774. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73775. mixTexture: BABYLON.BaseTexture;
  73776. private _diffuseTextureX;
  73777. diffuseTextureX: BABYLON.BaseTexture;
  73778. private _diffuseTextureY;
  73779. diffuseTextureY: BABYLON.BaseTexture;
  73780. private _diffuseTextureZ;
  73781. diffuseTextureZ: BABYLON.BaseTexture;
  73782. private _normalTextureX;
  73783. normalTextureX: BABYLON.BaseTexture;
  73784. private _normalTextureY;
  73785. normalTextureY: BABYLON.BaseTexture;
  73786. private _normalTextureZ;
  73787. normalTextureZ: BABYLON.BaseTexture;
  73788. tileSize: number;
  73789. diffuseColor: BABYLON.Color3;
  73790. specularColor: BABYLON.Color3;
  73791. specularPower: number;
  73792. private _disableLighting;
  73793. disableLighting: boolean;
  73794. private _maxSimultaneousLights;
  73795. maxSimultaneousLights: number;
  73796. private _renderId;
  73797. constructor(name: string, scene: BABYLON.Scene);
  73798. needAlphaBlending(): boolean;
  73799. needAlphaTesting(): boolean;
  73800. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73801. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73802. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73803. getAnimatables(): BABYLON.IAnimatable[];
  73804. getActiveTextures(): BABYLON.BaseTexture[];
  73805. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73806. dispose(forceDisposeEffect?: boolean): void;
  73807. clone(name: string): TriPlanarMaterial;
  73808. serialize(): any;
  73809. getClassName(): string;
  73810. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /** @hidden */
  73815. export var waterPixelShader: {
  73816. name: string;
  73817. shader: string;
  73818. };
  73819. }
  73820. declare module BABYLON {
  73821. /** @hidden */
  73822. export var waterVertexShader: {
  73823. name: string;
  73824. shader: string;
  73825. };
  73826. }
  73827. declare module BABYLON {
  73828. export class WaterMaterial extends BABYLON.PushMaterial {
  73829. renderTargetSize: BABYLON.Vector2;
  73830. private _bumpTexture;
  73831. bumpTexture: BABYLON.BaseTexture;
  73832. diffuseColor: BABYLON.Color3;
  73833. specularColor: BABYLON.Color3;
  73834. specularPower: number;
  73835. private _disableLighting;
  73836. disableLighting: boolean;
  73837. private _maxSimultaneousLights;
  73838. maxSimultaneousLights: number;
  73839. /**
  73840. * @param {number}: Represents the wind force
  73841. */
  73842. windForce: number;
  73843. /**
  73844. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73845. */
  73846. windDirection: BABYLON.Vector2;
  73847. /**
  73848. * @param {number}: Wave height, represents the height of the waves
  73849. */
  73850. waveHeight: number;
  73851. /**
  73852. * @param {number}: Bump height, represents the bump height related to the bump map
  73853. */
  73854. bumpHeight: number;
  73855. /**
  73856. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73857. */
  73858. private _bumpSuperimpose;
  73859. bumpSuperimpose: boolean;
  73860. /**
  73861. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73862. */
  73863. private _fresnelSeparate;
  73864. fresnelSeparate: boolean;
  73865. /**
  73866. * @param {boolean}: bump Waves modify the reflection.
  73867. */
  73868. private _bumpAffectsReflection;
  73869. bumpAffectsReflection: boolean;
  73870. /**
  73871. * @param {number}: The water color blended with the refraction (near)
  73872. */
  73873. waterColor: BABYLON.Color3;
  73874. /**
  73875. * @param {number}: The blend factor related to the water color
  73876. */
  73877. colorBlendFactor: number;
  73878. /**
  73879. * @param {number}: The water color blended with the reflection (far)
  73880. */
  73881. waterColor2: BABYLON.Color3;
  73882. /**
  73883. * @param {number}: The blend factor related to the water color (reflection, far)
  73884. */
  73885. colorBlendFactor2: number;
  73886. /**
  73887. * @param {number}: Represents the maximum length of a wave
  73888. */
  73889. waveLength: number;
  73890. /**
  73891. * @param {number}: Defines the waves speed
  73892. */
  73893. waveSpeed: number;
  73894. /**
  73895. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73896. * will avoid calculating useless pixels in the pixel shader of the water material.
  73897. */
  73898. disableClipPlane: boolean;
  73899. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73900. private _mesh;
  73901. private _refractionRTT;
  73902. private _reflectionRTT;
  73903. private _reflectionTransform;
  73904. private _lastTime;
  73905. private _lastDeltaTime;
  73906. private _renderId;
  73907. private _useLogarithmicDepth;
  73908. private _waitingRenderList;
  73909. private _imageProcessingConfiguration;
  73910. private _imageProcessingObserver;
  73911. /**
  73912. * Gets a boolean indicating that current material needs to register RTT
  73913. */
  73914. readonly hasRenderTargetTextures: boolean;
  73915. /**
  73916. * Constructor
  73917. */
  73918. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73919. useLogarithmicDepth: boolean;
  73920. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73921. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73922. addToRenderList(node: any): void;
  73923. enableRenderTargets(enable: boolean): void;
  73924. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73925. readonly renderTargetsEnabled: boolean;
  73926. needAlphaBlending(): boolean;
  73927. needAlphaTesting(): boolean;
  73928. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73929. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73930. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73931. private _createRenderTargets;
  73932. getAnimatables(): BABYLON.IAnimatable[];
  73933. getActiveTextures(): BABYLON.BaseTexture[];
  73934. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73935. dispose(forceDisposeEffect?: boolean): void;
  73936. clone(name: string): WaterMaterial;
  73937. serialize(): any;
  73938. getClassName(): string;
  73939. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73940. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73941. }
  73942. }
  73943. declare module BABYLON {
  73944. /** @hidden */
  73945. export var asciiartPixelShader: {
  73946. name: string;
  73947. shader: string;
  73948. };
  73949. }
  73950. declare module BABYLON {
  73951. /**
  73952. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73953. *
  73954. * It basically takes care rendering the font front the given font size to a texture.
  73955. * This is used later on in the postprocess.
  73956. */
  73957. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73958. private _font;
  73959. private _text;
  73960. private _charSize;
  73961. /**
  73962. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73963. */
  73964. readonly charSize: number;
  73965. /**
  73966. * Create a new instance of the Ascii Art FontTexture class
  73967. * @param name the name of the texture
  73968. * @param font the font to use, use the W3C CSS notation
  73969. * @param text the caracter set to use in the rendering.
  73970. * @param scene the scene that owns the texture
  73971. */
  73972. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73973. /**
  73974. * Gets the max char width of a font.
  73975. * @param font the font to use, use the W3C CSS notation
  73976. * @return the max char width
  73977. */
  73978. private getFontWidth;
  73979. /**
  73980. * Gets the max char height of a font.
  73981. * @param font the font to use, use the W3C CSS notation
  73982. * @return the max char height
  73983. */
  73984. private getFontHeight;
  73985. /**
  73986. * Clones the current AsciiArtTexture.
  73987. * @return the clone of the texture.
  73988. */
  73989. clone(): AsciiArtFontTexture;
  73990. /**
  73991. * Parses a json object representing the texture and returns an instance of it.
  73992. * @param source the source JSON representation
  73993. * @param scene the scene to create the texture for
  73994. * @return the parsed texture
  73995. */
  73996. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73997. }
  73998. /**
  73999. * Option available in the Ascii Art Post Process.
  74000. */
  74001. export interface IAsciiArtPostProcessOptions {
  74002. /**
  74003. * The font to use following the w3c font definition.
  74004. */
  74005. font?: string;
  74006. /**
  74007. * The character set to use in the postprocess.
  74008. */
  74009. characterSet?: string;
  74010. /**
  74011. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74012. * This number is defined between 0 and 1;
  74013. */
  74014. mixToTile?: number;
  74015. /**
  74016. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74017. * This number is defined between 0 and 1;
  74018. */
  74019. mixToNormal?: number;
  74020. }
  74021. /**
  74022. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  74023. *
  74024. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74025. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  74026. */
  74027. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  74028. /**
  74029. * The font texture used to render the char in the post process.
  74030. */
  74031. private _asciiArtFontTexture;
  74032. /**
  74033. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74034. * This number is defined between 0 and 1;
  74035. */
  74036. mixToTile: number;
  74037. /**
  74038. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74039. * This number is defined between 0 and 1;
  74040. */
  74041. mixToNormal: number;
  74042. /**
  74043. * Instantiates a new Ascii Art Post Process.
  74044. * @param name the name to give to the postprocess
  74045. * @camera the camera to apply the post process to.
  74046. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  74047. */
  74048. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  74049. }
  74050. }
  74051. declare module BABYLON {
  74052. /** @hidden */
  74053. export var digitalrainPixelShader: {
  74054. name: string;
  74055. shader: string;
  74056. };
  74057. }
  74058. declare module BABYLON {
  74059. /**
  74060. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  74061. *
  74062. * It basically takes care rendering the font front the given font size to a texture.
  74063. * This is used later on in the postprocess.
  74064. */
  74065. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  74066. private _font;
  74067. private _text;
  74068. private _charSize;
  74069. /**
  74070. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  74071. */
  74072. readonly charSize: number;
  74073. /**
  74074. * Create a new instance of the Digital Rain FontTexture class
  74075. * @param name the name of the texture
  74076. * @param font the font to use, use the W3C CSS notation
  74077. * @param text the caracter set to use in the rendering.
  74078. * @param scene the scene that owns the texture
  74079. */
  74080. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  74081. /**
  74082. * Gets the max char width of a font.
  74083. * @param font the font to use, use the W3C CSS notation
  74084. * @return the max char width
  74085. */
  74086. private getFontWidth;
  74087. /**
  74088. * Gets the max char height of a font.
  74089. * @param font the font to use, use the W3C CSS notation
  74090. * @return the max char height
  74091. */
  74092. private getFontHeight;
  74093. /**
  74094. * Clones the current DigitalRainFontTexture.
  74095. * @return the clone of the texture.
  74096. */
  74097. clone(): DigitalRainFontTexture;
  74098. /**
  74099. * Parses a json object representing the texture and returns an instance of it.
  74100. * @param source the source JSON representation
  74101. * @param scene the scene to create the texture for
  74102. * @return the parsed texture
  74103. */
  74104. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  74105. }
  74106. /**
  74107. * Option available in the Digital Rain Post Process.
  74108. */
  74109. export interface IDigitalRainPostProcessOptions {
  74110. /**
  74111. * The font to use following the w3c font definition.
  74112. */
  74113. font?: string;
  74114. /**
  74115. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74116. * This number is defined between 0 and 1;
  74117. */
  74118. mixToTile?: number;
  74119. /**
  74120. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74121. * This number is defined between 0 and 1;
  74122. */
  74123. mixToNormal?: number;
  74124. }
  74125. /**
  74126. * DigitalRainPostProcess helps rendering everithing in digital rain.
  74127. *
  74128. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74129. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  74130. */
  74131. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  74132. /**
  74133. * The font texture used to render the char in the post process.
  74134. */
  74135. private _digitalRainFontTexture;
  74136. /**
  74137. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74138. * This number is defined between 0 and 1;
  74139. */
  74140. mixToTile: number;
  74141. /**
  74142. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74143. * This number is defined between 0 and 1;
  74144. */
  74145. mixToNormal: number;
  74146. /**
  74147. * Instantiates a new Digital Rain Post Process.
  74148. * @param name the name to give to the postprocess
  74149. * @camera the camera to apply the post process to.
  74150. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  74151. */
  74152. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  74153. }
  74154. }
  74155. declare module BABYLON {
  74156. /** @hidden */
  74157. export var oceanPostProcessPixelShader: {
  74158. name: string;
  74159. shader: string;
  74160. };
  74161. }
  74162. declare module BABYLON {
  74163. /**
  74164. * Option available in the Ocean Post Process.
  74165. */
  74166. export interface IOceanPostProcessOptions {
  74167. /**
  74168. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74169. */
  74170. reflectionSize?: number | {
  74171. width: number;
  74172. height: number;
  74173. } | {
  74174. ratio: number;
  74175. };
  74176. /**
  74177. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74178. */
  74179. refractionSize?: number | {
  74180. width: number;
  74181. height: number;
  74182. } | {
  74183. ratio: number;
  74184. };
  74185. }
  74186. /**
  74187. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  74188. *
  74189. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74190. * Example usage:
  74191. * var pp = new OceanPostProcess("myOcean", camera);
  74192. * pp.reflectionEnabled = true;
  74193. * pp.refractionEnabled = true;
  74194. */
  74195. export class OceanPostProcess extends BABYLON.PostProcess {
  74196. /**
  74197. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  74198. */
  74199. /**
  74200. * Sets weither or not the real-time reflection is enabled on the ocean.
  74201. * Is set to true, the reflection mirror texture will be used as reflection texture.
  74202. */
  74203. reflectionEnabled: boolean;
  74204. /**
  74205. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  74206. */
  74207. /**
  74208. * Sets weither or not the real-time refraction is enabled on the ocean.
  74209. * Is set to true, the refraction render target texture will be used as refraction texture.
  74210. */
  74211. refractionEnabled: boolean;
  74212. /**
  74213. * Gets wether or not the post-processes is supported by the running hardware.
  74214. * This requires draw buffer supports.
  74215. */
  74216. readonly isSupported: boolean;
  74217. /**
  74218. * This is the reflection mirror texture used to display reflections on the ocean.
  74219. * By default, render list is empty.
  74220. */
  74221. reflectionTexture: BABYLON.MirrorTexture;
  74222. /**
  74223. * This is the refraction render target texture used to display refraction on the ocean.
  74224. * By default, render list is empty.
  74225. */
  74226. refractionTexture: BABYLON.RenderTargetTexture;
  74227. private _time;
  74228. private _cameraRotation;
  74229. private _cameraViewMatrix;
  74230. private _reflectionEnabled;
  74231. private _refractionEnabled;
  74232. private _geometryRenderer;
  74233. /**
  74234. * Instantiates a new Ocean Post Process.
  74235. * @param name the name to give to the postprocess.
  74236. * @camera the camera to apply the post process to.
  74237. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  74238. */
  74239. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  74240. /**
  74241. * Returns the appropriate defines according to the current configuration.
  74242. */
  74243. private _getDefines;
  74244. /**
  74245. * Computes the current camera rotation as the shader requires a camera rotation.
  74246. */
  74247. private _computeCameraRotation;
  74248. }
  74249. }
  74250. declare module BABYLON {
  74251. /** @hidden */
  74252. export var brickProceduralTexturePixelShader: {
  74253. name: string;
  74254. shader: string;
  74255. };
  74256. }
  74257. declare module BABYLON {
  74258. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  74259. private _numberOfBricksHeight;
  74260. private _numberOfBricksWidth;
  74261. private _jointColor;
  74262. private _brickColor;
  74263. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74264. updateShaderUniforms(): void;
  74265. numberOfBricksHeight: number;
  74266. numberOfBricksWidth: number;
  74267. jointColor: BABYLON.Color3;
  74268. brickColor: BABYLON.Color3;
  74269. /**
  74270. * Serializes this brick procedural texture
  74271. * @returns a serialized brick procedural texture object
  74272. */
  74273. serialize(): any;
  74274. /**
  74275. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  74276. * @param parsedTexture defines parsed texture data
  74277. * @param scene defines the current scene
  74278. * @param rootUrl defines the root URL containing brick procedural texture information
  74279. * @returns a parsed Brick Procedural BABYLON.Texture
  74280. */
  74281. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  74282. }
  74283. }
  74284. declare module BABYLON {
  74285. /** @hidden */
  74286. export var cloudProceduralTexturePixelShader: {
  74287. name: string;
  74288. shader: string;
  74289. };
  74290. }
  74291. declare module BABYLON {
  74292. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  74293. private _skyColor;
  74294. private _cloudColor;
  74295. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74296. updateShaderUniforms(): void;
  74297. skyColor: BABYLON.Color4;
  74298. cloudColor: BABYLON.Color4;
  74299. /**
  74300. * Serializes this cloud procedural texture
  74301. * @returns a serialized cloud procedural texture object
  74302. */
  74303. serialize(): any;
  74304. /**
  74305. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  74306. * @param parsedTexture defines parsed texture data
  74307. * @param scene defines the current scene
  74308. * @param rootUrl defines the root URL containing cloud procedural texture information
  74309. * @returns a parsed Cloud Procedural BABYLON.Texture
  74310. */
  74311. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  74312. }
  74313. }
  74314. declare module BABYLON {
  74315. /** @hidden */
  74316. export var fireProceduralTexturePixelShader: {
  74317. name: string;
  74318. shader: string;
  74319. };
  74320. }
  74321. declare module BABYLON {
  74322. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  74323. private _time;
  74324. private _speed;
  74325. private _autoGenerateTime;
  74326. private _fireColors;
  74327. private _alphaThreshold;
  74328. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74329. updateShaderUniforms(): void;
  74330. render(useCameraPostProcess?: boolean): void;
  74331. static readonly PurpleFireColors: BABYLON.Color3[];
  74332. static readonly GreenFireColors: BABYLON.Color3[];
  74333. static readonly RedFireColors: BABYLON.Color3[];
  74334. static readonly BlueFireColors: BABYLON.Color3[];
  74335. autoGenerateTime: boolean;
  74336. fireColors: BABYLON.Color3[];
  74337. time: number;
  74338. speed: BABYLON.Vector2;
  74339. alphaThreshold: number;
  74340. /**
  74341. * Serializes this fire procedural texture
  74342. * @returns a serialized fire procedural texture object
  74343. */
  74344. serialize(): any;
  74345. /**
  74346. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  74347. * @param parsedTexture defines parsed texture data
  74348. * @param scene defines the current scene
  74349. * @param rootUrl defines the root URL containing fire procedural texture information
  74350. * @returns a parsed Fire Procedural BABYLON.Texture
  74351. */
  74352. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  74353. }
  74354. }
  74355. declare module BABYLON {
  74356. /** @hidden */
  74357. export var grassProceduralTexturePixelShader: {
  74358. name: string;
  74359. shader: string;
  74360. };
  74361. }
  74362. declare module BABYLON {
  74363. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  74364. private _grassColors;
  74365. private _groundColor;
  74366. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74367. updateShaderUniforms(): void;
  74368. grassColors: BABYLON.Color3[];
  74369. groundColor: BABYLON.Color3;
  74370. /**
  74371. * Serializes this grass procedural texture
  74372. * @returns a serialized grass procedural texture object
  74373. */
  74374. serialize(): any;
  74375. /**
  74376. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  74377. * @param parsedTexture defines parsed texture data
  74378. * @param scene defines the current scene
  74379. * @param rootUrl defines the root URL containing grass procedural texture information
  74380. * @returns a parsed Grass Procedural BABYLON.Texture
  74381. */
  74382. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /** @hidden */
  74387. export var marbleProceduralTexturePixelShader: {
  74388. name: string;
  74389. shader: string;
  74390. };
  74391. }
  74392. declare module BABYLON {
  74393. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  74394. private _numberOfTilesHeight;
  74395. private _numberOfTilesWidth;
  74396. private _amplitude;
  74397. private _jointColor;
  74398. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74399. updateShaderUniforms(): void;
  74400. numberOfTilesHeight: number;
  74401. amplitude: number;
  74402. numberOfTilesWidth: number;
  74403. jointColor: BABYLON.Color3;
  74404. /**
  74405. * Serializes this marble procedural texture
  74406. * @returns a serialized marble procedural texture object
  74407. */
  74408. serialize(): any;
  74409. /**
  74410. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  74411. * @param parsedTexture defines parsed texture data
  74412. * @param scene defines the current scene
  74413. * @param rootUrl defines the root URL containing marble procedural texture information
  74414. * @returns a parsed Marble Procedural BABYLON.Texture
  74415. */
  74416. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /** @hidden */
  74421. export var normalMapProceduralTexturePixelShader: {
  74422. name: string;
  74423. shader: string;
  74424. };
  74425. }
  74426. declare module BABYLON {
  74427. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  74428. private _baseTexture;
  74429. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74430. updateShaderUniforms(): void;
  74431. render(useCameraPostProcess?: boolean): void;
  74432. resize(size: any, generateMipMaps: any): void;
  74433. baseTexture: BABYLON.Texture;
  74434. /**
  74435. * Serializes this normal map procedural texture
  74436. * @returns a serialized normal map procedural texture object
  74437. */
  74438. serialize(): any;
  74439. /**
  74440. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  74441. * @param parsedTexture defines parsed texture data
  74442. * @param scene defines the current scene
  74443. * @param rootUrl defines the root URL containing normal map procedural texture information
  74444. * @returns a parsed Normal Map Procedural BABYLON.Texture
  74445. */
  74446. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  74447. }
  74448. }
  74449. declare module BABYLON {
  74450. /** @hidden */
  74451. export var perlinNoiseProceduralTexturePixelShader: {
  74452. name: string;
  74453. shader: string;
  74454. };
  74455. }
  74456. declare module BABYLON {
  74457. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  74458. time: number;
  74459. timeScale: number;
  74460. translationSpeed: number;
  74461. private _currentTranslation;
  74462. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74463. updateShaderUniforms(): void;
  74464. render(useCameraPostProcess?: boolean): void;
  74465. resize(size: any, generateMipMaps: any): void;
  74466. /**
  74467. * Serializes this perlin noise procedural texture
  74468. * @returns a serialized perlin noise procedural texture object
  74469. */
  74470. serialize(): any;
  74471. /**
  74472. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  74473. * @param parsedTexture defines parsed texture data
  74474. * @param scene defines the current scene
  74475. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  74476. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  74477. */
  74478. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  74479. }
  74480. }
  74481. declare module BABYLON {
  74482. /** @hidden */
  74483. export var roadProceduralTexturePixelShader: {
  74484. name: string;
  74485. shader: string;
  74486. };
  74487. }
  74488. declare module BABYLON {
  74489. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  74490. private _roadColor;
  74491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74492. updateShaderUniforms(): void;
  74493. roadColor: BABYLON.Color3;
  74494. /**
  74495. * Serializes this road procedural texture
  74496. * @returns a serialized road procedural texture object
  74497. */
  74498. serialize(): any;
  74499. /**
  74500. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  74501. * @param parsedTexture defines parsed texture data
  74502. * @param scene defines the current scene
  74503. * @param rootUrl defines the root URL containing road procedural texture information
  74504. * @returns a parsed Road Procedural BABYLON.Texture
  74505. */
  74506. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  74507. }
  74508. }
  74509. declare module BABYLON {
  74510. /** @hidden */
  74511. export var starfieldProceduralTexturePixelShader: {
  74512. name: string;
  74513. shader: string;
  74514. };
  74515. }
  74516. declare module BABYLON {
  74517. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  74518. private _time;
  74519. private _alpha;
  74520. private _beta;
  74521. private _zoom;
  74522. private _formuparam;
  74523. private _stepsize;
  74524. private _tile;
  74525. private _brightness;
  74526. private _darkmatter;
  74527. private _distfading;
  74528. private _saturation;
  74529. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74530. updateShaderUniforms(): void;
  74531. time: number;
  74532. alpha: number;
  74533. beta: number;
  74534. formuparam: number;
  74535. stepsize: number;
  74536. zoom: number;
  74537. tile: number;
  74538. brightness: number;
  74539. darkmatter: number;
  74540. distfading: number;
  74541. saturation: number;
  74542. /**
  74543. * Serializes this starfield procedural texture
  74544. * @returns a serialized starfield procedural texture object
  74545. */
  74546. serialize(): any;
  74547. /**
  74548. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  74549. * @param parsedTexture defines parsed texture data
  74550. * @param scene defines the current scene
  74551. * @param rootUrl defines the root URL containing startfield procedural texture information
  74552. * @returns a parsed Starfield Procedural BABYLON.Texture
  74553. */
  74554. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  74555. }
  74556. }
  74557. declare module BABYLON {
  74558. /** @hidden */
  74559. export var woodProceduralTexturePixelShader: {
  74560. name: string;
  74561. shader: string;
  74562. };
  74563. }
  74564. declare module BABYLON {
  74565. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  74566. private _ampScale;
  74567. private _woodColor;
  74568. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74569. updateShaderUniforms(): void;
  74570. ampScale: number;
  74571. woodColor: BABYLON.Color3;
  74572. /**
  74573. * Serializes this wood procedural texture
  74574. * @returns a serialized wood procedural texture object
  74575. */
  74576. serialize(): any;
  74577. /**
  74578. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  74579. * @param parsedTexture defines parsed texture data
  74580. * @param scene defines the current scene
  74581. * @param rootUrl defines the root URL containing wood procedural texture information
  74582. * @returns a parsed Wood Procedural BABYLON.Texture
  74583. */
  74584. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  74585. }
  74586. }