documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484
  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. get 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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * 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".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  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. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @param rightHandedSystem is the scene right-handed (negative z)
  2762. * @returns a new forward Vector3
  2763. */
  2764. static Forward(rightHandedSystem?: boolean): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2767. * @param rightHandedSystem is the scene right-handed (negative-z)
  2768. * @returns a new forward Vector3
  2769. */
  2770. static Backward(rightHandedSystem?: boolean): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2773. * @returns a new right Vector3
  2774. */
  2775. static Right(): Vector3;
  2776. /**
  2777. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2778. * @returns a new left Vector3
  2779. */
  2780. static Left(): Vector3;
  2781. /**
  2782. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2783. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @returns the transformed Vector3
  2787. */
  2788. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2789. /**
  2790. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2791. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2792. * @param vector defines the Vector3 to transform
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2799. * This method computes tranformed coordinates only, not transformed direction vectors
  2800. * @param x define the x coordinate of the source vector
  2801. * @param y define the y coordinate of the source vector
  2802. * @param z define the z coordinate of the source vector
  2803. * @param transformation defines the transformation matrix
  2804. * @param result defines the Vector3 where to store the result
  2805. */
  2806. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2807. /**
  2808. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2809. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2810. * @param vector defines the Vector3 to transform
  2811. * @param transformation defines the transformation matrix
  2812. * @returns the new Vector3
  2813. */
  2814. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2815. /**
  2816. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2817. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2818. * @param vector defines the Vector3 to transform
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2825. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2826. * @param x define the x coordinate of the source vector
  2827. * @param y define the y coordinate of the source vector
  2828. * @param z define the z coordinate of the source vector
  2829. * @param transformation defines the transformation matrix
  2830. * @param result defines the Vector3 where to store the result
  2831. */
  2832. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2833. /**
  2834. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2835. * @param value1 defines the first control point
  2836. * @param value2 defines the second control point
  2837. * @param value3 defines the third control point
  2838. * @param value4 defines the fourth control point
  2839. * @param amount defines the amount on the spline to use
  2840. * @returns the new Vector3
  2841. */
  2842. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2843. /**
  2844. * 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"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @returns the new Vector3
  2851. */
  2852. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2853. /**
  2854. * 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"
  2855. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2856. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2857. * @param value defines the current value
  2858. * @param min defines the lower range value
  2859. * @param max defines the upper range value
  2860. * @param result defines the Vector3 where to store the result
  2861. */
  2862. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2863. /**
  2864. * Checks if a given vector is inside a specific range
  2865. * @param v defines the vector to test
  2866. * @param min defines the minimum range
  2867. * @param max defines the maximum range
  2868. */
  2869. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2872. * @param value1 defines the first control point
  2873. * @param tangent1 defines the first tangent vector
  2874. * @param value2 defines the second control point
  2875. * @param tangent2 defines the second tangent vector
  2876. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2877. * @returns the new Vector3
  2878. */
  2879. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2880. /**
  2881. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2882. * @param start defines the start value
  2883. * @param end defines the end value
  2884. * @param amount max defines amount between both (between 0 and 1)
  2885. * @returns the new Vector3
  2886. */
  2887. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2888. /**
  2889. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2890. * @param start defines the start value
  2891. * @param end defines the end value
  2892. * @param amount max defines amount between both (between 0 and 1)
  2893. * @param result defines the Vector3 where to store the result
  2894. */
  2895. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2896. /**
  2897. * Returns the dot product (float) between the vectors "left" and "right"
  2898. * @param left defines the left operand
  2899. * @param right defines the right operand
  2900. * @returns the dot product
  2901. */
  2902. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2903. /**
  2904. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2905. * The cross product is then orthogonal to both "left" and "right"
  2906. * @param left defines the left operand
  2907. * @param right defines the right operand
  2908. * @returns the cross product
  2909. */
  2910. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" with the cross product of "left" and "right"
  2913. * The cross product is then orthogonal to both "left" and "right"
  2914. * @param left defines the left operand
  2915. * @param right defines the right operand
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2919. /**
  2920. * Returns a new Vector3 as the normalization of the given vector
  2921. * @param vector defines the Vector3 to normalize
  2922. * @returns the new Vector3
  2923. */
  2924. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2925. /**
  2926. * Sets the given vector "result" with the normalization of the given first vector
  2927. * @param vector defines the Vector3 to normalize
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2931. /**
  2932. * Project a Vector3 onto screen space
  2933. * @param vector defines the Vector3 to project
  2934. * @param world defines the world matrix to use
  2935. * @param transform defines the transform (view x projection) matrix to use
  2936. * @param viewport defines the screen viewport to use
  2937. * @returns the new Vector3
  2938. */
  2939. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2940. /** @hidden */
  2941. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 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 transform defines the transform (view x projection) matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @param result defines the Vector3 where to store the result
  2972. */
  2973. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param sourceX defines the screen space x coordinate to use
  2977. * @param sourceY defines the screen space y coordinate to use
  2978. * @param sourceZ defines the screen space z coordinate to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @param result defines the Vector3 where to store the result
  2985. */
  2986. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2987. /**
  2988. * Gets the minimal coordinate values between two Vector3
  2989. * @param left defines the first operand
  2990. * @param right defines the second operand
  2991. * @returns the new Vector3
  2992. */
  2993. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Gets the maximal coordinate values between two Vector3
  2996. * @param left defines the first operand
  2997. * @param right defines the second operand
  2998. * @returns the new Vector3
  2999. */
  3000. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3001. /**
  3002. * Returns the distance between the vectors "value1" and "value2"
  3003. * @param value1 defines the first operand
  3004. * @param value2 defines the second operand
  3005. * @returns the distance
  3006. */
  3007. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3008. /**
  3009. * Returns the squared distance between the vectors "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the squared distance
  3013. */
  3014. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3015. /**
  3016. * Returns a new Vector3 located at the center between "value1" and "value2"
  3017. * @param value1 defines the first operand
  3018. * @param value2 defines the second operand
  3019. * @returns the new Vector3
  3020. */
  3021. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3024. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3025. * to something in order to rotate it from its local system to the given target system
  3026. * Note: axis1, axis2 and axis3 are normalized during this operation
  3027. * @param axis1 defines the first axis
  3028. * @param axis2 defines the second axis
  3029. * @param axis3 defines the third axis
  3030. * @returns a new Vector3
  3031. */
  3032. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3035. * @param axis1 defines the first axis
  3036. * @param axis2 defines the second axis
  3037. * @param axis3 defines the third axis
  3038. * @param ref defines the Vector3 where to store the result
  3039. */
  3040. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3041. }
  3042. /**
  3043. * Vector4 class created for EulerAngle class conversion to Quaternion
  3044. */
  3045. export class Vector4 {
  3046. /** x value of the vector */
  3047. x: number;
  3048. /** y value of the vector */
  3049. y: number;
  3050. /** z value of the vector */
  3051. z: number;
  3052. /** w value of the vector */
  3053. w: number;
  3054. /**
  3055. * Creates a Vector4 object from the given floats.
  3056. * @param x x value of the vector
  3057. * @param y y value of the vector
  3058. * @param z z value of the vector
  3059. * @param w w value of the vector
  3060. */
  3061. constructor(
  3062. /** x value of the vector */
  3063. x: number,
  3064. /** y value of the vector */
  3065. y: number,
  3066. /** z value of the vector */
  3067. z: number,
  3068. /** w value of the vector */
  3069. w: number);
  3070. /**
  3071. * Returns the string with the Vector4 coordinates.
  3072. * @returns a string containing all the vector values
  3073. */
  3074. toString(): string;
  3075. /**
  3076. * Returns the string "Vector4".
  3077. * @returns "Vector4"
  3078. */
  3079. getClassName(): string;
  3080. /**
  3081. * Returns the Vector4 hash code.
  3082. * @returns a unique hash code
  3083. */
  3084. getHashCode(): number;
  3085. /**
  3086. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3087. * @returns the resulting array
  3088. */
  3089. asArray(): number[];
  3090. /**
  3091. * Populates the given array from the given index with the Vector4 coordinates.
  3092. * @param array array to populate
  3093. * @param index index of the array to start at (default: 0)
  3094. * @returns the Vector4.
  3095. */
  3096. toArray(array: FloatArray, index?: number): Vector4;
  3097. /**
  3098. * Adds the given vector to the current Vector4.
  3099. * @param otherVector the vector to add
  3100. * @returns the updated Vector4.
  3101. */
  3102. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3103. /**
  3104. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3105. * @param otherVector the vector to add
  3106. * @returns the resulting vector
  3107. */
  3108. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3109. /**
  3110. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3111. * @param otherVector the vector to add
  3112. * @param result the vector to store the result
  3113. * @returns the current Vector4.
  3114. */
  3115. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3116. /**
  3117. * Subtract in place the given vector from the current Vector4.
  3118. * @param otherVector the vector to subtract
  3119. * @returns the updated Vector4.
  3120. */
  3121. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3122. /**
  3123. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3124. * @param otherVector the vector to add
  3125. * @returns the new vector with the result
  3126. */
  3127. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3128. /**
  3129. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3130. * @param otherVector the vector to subtract
  3131. * @param result the vector to store the result
  3132. * @returns the current Vector4.
  3133. */
  3134. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3135. /**
  3136. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3137. */
  3138. /**
  3139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. * @param x value to subtract
  3141. * @param y value to subtract
  3142. * @param z value to subtract
  3143. * @param w value to subtract
  3144. * @returns new vector containing the result
  3145. */
  3146. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3147. /**
  3148. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3149. * @param x value to subtract
  3150. * @param y value to subtract
  3151. * @param z value to subtract
  3152. * @param w value to subtract
  3153. * @param result the vector to store the result in
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3159. * @returns a new vector with the negated values
  3160. */
  3161. negate(): Vector4;
  3162. /**
  3163. * Negate this vector in place
  3164. * @returns this
  3165. */
  3166. negateInPlace(): Vector4;
  3167. /**
  3168. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3169. * @param result defines the Vector3 object where to store the result
  3170. * @returns the current Vector4
  3171. */
  3172. negateToRef(result: Vector4): Vector4;
  3173. /**
  3174. * Multiplies the current Vector4 coordinates by scale (float).
  3175. * @param scale the number to scale with
  3176. * @returns the updated Vector4.
  3177. */
  3178. scaleInPlace(scale: number): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3181. * @param scale the number to scale with
  3182. * @returns a new vector with the result
  3183. */
  3184. scale(scale: number): Vector4;
  3185. /**
  3186. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3187. * @param scale the number to scale with
  3188. * @param result a vector to store the result in
  3189. * @returns the current Vector4.
  3190. */
  3191. scaleToRef(scale: number, result: Vector4): Vector4;
  3192. /**
  3193. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3194. * @param scale defines the scale factor
  3195. * @param result defines the Vector4 object where to store the result
  3196. * @returns the unmodified current Vector4
  3197. */
  3198. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3199. /**
  3200. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3201. * @param otherVector the vector to compare against
  3202. * @returns true if they are equal
  3203. */
  3204. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3205. /**
  3206. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3207. * @param otherVector vector to compare against
  3208. * @param epsilon (Default: very small number)
  3209. * @returns true if they are equal
  3210. */
  3211. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3212. /**
  3213. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3214. * @param x x value to compare against
  3215. * @param y y value to compare against
  3216. * @param z z value to compare against
  3217. * @param w w value to compare against
  3218. * @returns true if equal
  3219. */
  3220. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3221. /**
  3222. * Multiplies in place the current Vector4 by the given one.
  3223. * @param otherVector vector to multiple with
  3224. * @returns the updated Vector4.
  3225. */
  3226. multiplyInPlace(otherVector: Vector4): Vector4;
  3227. /**
  3228. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3229. * @param otherVector vector to multiple with
  3230. * @returns resulting new vector
  3231. */
  3232. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3235. * @param otherVector vector to multiple with
  3236. * @param result vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3242. * @param x x value multiply with
  3243. * @param y y value multiply with
  3244. * @param z z value multiply with
  3245. * @param w w value multiply with
  3246. * @returns resulting new vector
  3247. */
  3248. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3251. * @param otherVector vector to devide with
  3252. * @returns resulting new vector
  3253. */
  3254. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3257. * @param otherVector vector to devide with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Divides the current Vector3 coordinates by the given ones.
  3264. * @param otherVector vector to devide with
  3265. * @returns the updated Vector3.
  3266. */
  3267. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3270. * @param other defines the second operand
  3271. * @returns the current updated Vector4
  3272. */
  3273. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3274. /**
  3275. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3276. * @param other defines the second operand
  3277. * @returns the current updated Vector4
  3278. */
  3279. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Gets a new Vector4 from current Vector4 floored values
  3282. * @returns a new Vector4
  3283. */
  3284. floor(): Vector4;
  3285. /**
  3286. * Gets a new Vector4 from current Vector3 floored values
  3287. * @returns a new Vector4
  3288. */
  3289. fract(): Vector4;
  3290. /**
  3291. * Returns the Vector4 length (float).
  3292. * @returns the length
  3293. */
  3294. length(): number;
  3295. /**
  3296. * Returns the Vector4 squared length (float).
  3297. * @returns the length squared
  3298. */
  3299. lengthSquared(): number;
  3300. /**
  3301. * Normalizes in place the Vector4.
  3302. * @returns the updated Vector4.
  3303. */
  3304. normalize(): Vector4;
  3305. /**
  3306. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3307. * @returns this converted to a new vector3
  3308. */
  3309. toVector3(): Vector3;
  3310. /**
  3311. * Returns a new Vector4 copied from the current one.
  3312. * @returns the new cloned vector
  3313. */
  3314. clone(): Vector4;
  3315. /**
  3316. * Updates the current Vector4 with the given one coordinates.
  3317. * @param source the source vector to copy from
  3318. * @returns the updated Vector4.
  3319. */
  3320. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the current Vector4 coordinates with the given floats.
  3323. * @param x float to copy from
  3324. * @param y float to copy from
  3325. * @param z float to copy from
  3326. * @param w float to copy from
  3327. * @returns the updated Vector4.
  3328. */
  3329. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3330. /**
  3331. * Updates the current Vector4 coordinates with the given floats.
  3332. * @param x float to set from
  3333. * @param y float to set from
  3334. * @param z float to set from
  3335. * @param w float to set from
  3336. * @returns the updated Vector4.
  3337. */
  3338. set(x: number, y: number, z: number, w: number): Vector4;
  3339. /**
  3340. * Copies the given float to the current Vector3 coordinates
  3341. * @param v defines the x, y, z and w coordinates of the operand
  3342. * @returns the current updated Vector3
  3343. */
  3344. setAll(v: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set from the starting index of the given array.
  3347. * @param array the array to pull values from
  3348. * @param offset the offset into the array to start at
  3349. * @returns the new vector
  3350. */
  3351. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3352. /**
  3353. * Updates the given vector "result" from the starting index of the given array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @param result the vector to store the result in
  3357. */
  3358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3359. /**
  3360. * Updates the given vector "result" from the starting index of the given Float32Array.
  3361. * @param array the array to pull values from
  3362. * @param offset the offset into the array to start at
  3363. * @param result the vector to store the result in
  3364. */
  3365. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3366. /**
  3367. * Updates the given vector "result" coordinates from the given floats.
  3368. * @param x float to set from
  3369. * @param y float to set from
  3370. * @param z float to set from
  3371. * @param w float to set from
  3372. * @param result the vector to the floats in
  3373. */
  3374. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3375. /**
  3376. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3377. * @returns the new vector
  3378. */
  3379. static Zero(): Vector4;
  3380. /**
  3381. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3382. * @returns the new vector
  3383. */
  3384. static One(): Vector4;
  3385. /**
  3386. * Returns a new normalized Vector4 from the given one.
  3387. * @param vector the vector to normalize
  3388. * @returns the vector
  3389. */
  3390. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" from the normalization of the given one.
  3393. * @param vector the vector to normalize
  3394. * @param result the vector to store the result in
  3395. */
  3396. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3397. /**
  3398. * Returns a vector with the minimum values from the left and right vectors
  3399. * @param left left vector to minimize
  3400. * @param right right vector to minimize
  3401. * @returns a new vector with the minimum of the left and right vector values
  3402. */
  3403. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Returns a vector with the maximum values from the left and right vectors
  3406. * @param left left vector to maximize
  3407. * @param right right vector to maximize
  3408. * @returns a new vector with the maximum of the left and right vector values
  3409. */
  3410. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns the distance (float) between the vectors "value1" and "value2".
  3413. * @param value1 value to calulate the distance between
  3414. * @param value2 value to calulate the distance between
  3415. * @return the distance between the two vectors
  3416. */
  3417. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3418. /**
  3419. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the distance between
  3421. * @param value2 value to calulate the distance between
  3422. * @return the distance between the two vectors squared
  3423. */
  3424. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3425. /**
  3426. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3427. * @param value1 value to calulate the center between
  3428. * @param value2 value to calulate the center between
  3429. * @return the center between the two vectors
  3430. */
  3431. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3434. * This methods computes transformed normalized direction vectors only.
  3435. * @param vector the vector to transform
  3436. * @param transformation the transformation matrix to apply
  3437. * @returns the new vector
  3438. */
  3439. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param vector the vector to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the result in
  3446. */
  3447. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3450. * This methods computes transformed normalized direction vectors only.
  3451. * @param x value to transform
  3452. * @param y value to transform
  3453. * @param z value to transform
  3454. * @param w value to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the results in
  3457. */
  3458. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Creates a new Vector4 from a Vector3
  3461. * @param source defines the source data
  3462. * @param w defines the 4th component (default is 0)
  3463. * @returns a new Vector4
  3464. */
  3465. static FromVector3(source: Vector3, w?: number): Vector4;
  3466. }
  3467. /**
  3468. * Class used to store quaternion data
  3469. * @see https://en.wikipedia.org/wiki/Quaternion
  3470. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3471. */
  3472. export class Quaternion {
  3473. /** defines the first component (0 by default) */
  3474. x: number;
  3475. /** defines the second component (0 by default) */
  3476. y: number;
  3477. /** defines the third component (0 by default) */
  3478. z: number;
  3479. /** defines the fourth component (1.0 by default) */
  3480. w: number;
  3481. /**
  3482. * Creates a new Quaternion from the given floats
  3483. * @param x defines the first component (0 by default)
  3484. * @param y defines the second component (0 by default)
  3485. * @param z defines the third component (0 by default)
  3486. * @param w defines the fourth component (1.0 by default)
  3487. */
  3488. constructor(
  3489. /** defines the first component (0 by default) */
  3490. x?: number,
  3491. /** defines the second component (0 by default) */
  3492. y?: number,
  3493. /** defines the third component (0 by default) */
  3494. z?: number,
  3495. /** defines the fourth component (1.0 by default) */
  3496. w?: number);
  3497. /**
  3498. * Gets a string representation for the current quaternion
  3499. * @returns a string with the Quaternion coordinates
  3500. */
  3501. toString(): string;
  3502. /**
  3503. * Gets the class name of the quaternion
  3504. * @returns the string "Quaternion"
  3505. */
  3506. getClassName(): string;
  3507. /**
  3508. * Gets a hash code for this quaternion
  3509. * @returns the quaternion hash code
  3510. */
  3511. getHashCode(): number;
  3512. /**
  3513. * Copy the quaternion to an array
  3514. * @returns a new array populated with 4 elements from the quaternion coordinates
  3515. */
  3516. asArray(): number[];
  3517. /**
  3518. * Check if two quaternions are equals
  3519. * @param otherQuaternion defines the second operand
  3520. * @return true if the current quaternion and the given one coordinates are strictly equals
  3521. */
  3522. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3523. /**
  3524. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3525. * @param otherQuaternion defines the other quaternion
  3526. * @param epsilon defines the minimal distance to consider equality
  3527. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3528. */
  3529. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3530. /**
  3531. * Clone the current quaternion
  3532. * @returns a new quaternion copied from the current one
  3533. */
  3534. clone(): Quaternion;
  3535. /**
  3536. * Copy a quaternion to the current one
  3537. * @param other defines the other quaternion
  3538. * @returns the updated current quaternion
  3539. */
  3540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3541. /**
  3542. * Updates the current quaternion with the given float coordinates
  3543. * @param x defines the x coordinate
  3544. * @param y defines the y coordinate
  3545. * @param z defines the z coordinate
  3546. * @param w defines the w coordinate
  3547. * @returns the updated current quaternion
  3548. */
  3549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3550. /**
  3551. * Updates the current quaternion from the given float coordinates
  3552. * @param x defines the x coordinate
  3553. * @param y defines the y coordinate
  3554. * @param z defines the z coordinate
  3555. * @param w defines the w coordinate
  3556. * @returns the updated current quaternion
  3557. */
  3558. set(x: number, y: number, z: number, w: number): Quaternion;
  3559. /**
  3560. * Adds two quaternions
  3561. * @param other defines the second operand
  3562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3563. */
  3564. add(other: DeepImmutable<Quaternion>): Quaternion;
  3565. /**
  3566. * Add a quaternion to the current one
  3567. * @param other defines the quaternion to add
  3568. * @returns the current quaternion
  3569. */
  3570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3571. /**
  3572. * Subtract two quaternions
  3573. * @param other defines the second operand
  3574. * @returns a new quaternion as the subtraction result of the given one from the current one
  3575. */
  3576. subtract(other: Quaternion): Quaternion;
  3577. /**
  3578. * Multiplies the current quaternion by a scale factor
  3579. * @param value defines the scale factor
  3580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3581. */
  3582. scale(value: number): Quaternion;
  3583. /**
  3584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3585. * @param scale defines the scale factor
  3586. * @param result defines the Quaternion object where to store the result
  3587. * @returns the unmodified current quaternion
  3588. */
  3589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies in place the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns the current modified quaternion
  3594. */
  3595. scaleInPlace(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies two quaternions
  3605. * @param q1 defines the second operand
  3606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3607. */
  3608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3609. /**
  3610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3611. * @param q1 defines the second operand
  3612. * @param result defines the target quaternion
  3613. * @returns the current quaternion
  3614. */
  3615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3616. /**
  3617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3618. * @param q1 defines the second operand
  3619. * @returns the currentupdated quaternion
  3620. */
  3621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3624. * @param ref defines the target quaternion
  3625. * @returns the current quaternion
  3626. */
  3627. conjugateToRef(ref: Quaternion): Quaternion;
  3628. /**
  3629. * Conjugates in place (1-q) the current quaternion
  3630. * @returns the current updated quaternion
  3631. */
  3632. conjugateInPlace(): Quaternion;
  3633. /**
  3634. * Conjugates in place (1-q) the current quaternion
  3635. * @returns a new quaternion
  3636. */
  3637. conjugate(): Quaternion;
  3638. /**
  3639. * Gets length of current quaternion
  3640. * @returns the quaternion length (float)
  3641. */
  3642. length(): number;
  3643. /**
  3644. * Normalize in place the current quaternion
  3645. * @returns the current updated quaternion
  3646. */
  3647. normalize(): Quaternion;
  3648. /**
  3649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3650. * @param order is a reserved parameter and is ignore for now
  3651. * @returns a new Vector3 containing the Euler angles
  3652. */
  3653. toEulerAngles(order?: string): Vector3;
  3654. /**
  3655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3656. * @param result defines the vector which will be filled with the Euler angles
  3657. * @param order is a reserved parameter and is ignore for now
  3658. * @returns the current unchanged quaternion
  3659. */
  3660. toEulerAnglesToRef(result: Vector3): Quaternion;
  3661. /**
  3662. * Updates the given rotation matrix with the current quaternion values
  3663. * @param result defines the target matrix
  3664. * @returns the current unchanged quaternion
  3665. */
  3666. toRotationMatrix(result: Matrix): Quaternion;
  3667. /**
  3668. * Updates the current quaternion from the given rotation matrix values
  3669. * @param matrix defines the source matrix
  3670. * @returns the current updated quaternion
  3671. */
  3672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3673. /**
  3674. * Creates a new quaternion from a rotation matrix
  3675. * @param matrix defines the source matrix
  3676. * @returns a new quaternion created from the given rotation matrix values
  3677. */
  3678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3679. /**
  3680. * Updates the given quaternion with the given rotation matrix values
  3681. * @param matrix defines the source matrix
  3682. * @param result defines the target quaternion
  3683. */
  3684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3685. /**
  3686. * Returns the dot product (float) between the quaternions "left" and "right"
  3687. * @param left defines the left operand
  3688. * @param right defines the right operand
  3689. * @returns the dot product
  3690. */
  3691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3692. /**
  3693. * Checks if the two quaternions are close to each other
  3694. * @param quat0 defines the first quaternion to check
  3695. * @param quat1 defines the second quaternion to check
  3696. * @returns true if the two quaternions are close to each other
  3697. */
  3698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3699. /**
  3700. * Creates an empty quaternion
  3701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3702. */
  3703. static Zero(): Quaternion;
  3704. /**
  3705. * Inverse a given quaternion
  3706. * @param q defines the source quaternion
  3707. * @returns a new quaternion as the inverted current quaternion
  3708. */
  3709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3710. /**
  3711. * Inverse a given quaternion
  3712. * @param q defines the source quaternion
  3713. * @param result the quaternion the result will be stored in
  3714. * @returns the result quaternion
  3715. */
  3716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3717. /**
  3718. * Creates an identity quaternion
  3719. * @returns the identity quaternion
  3720. */
  3721. static Identity(): Quaternion;
  3722. /**
  3723. * Gets a boolean indicating if the given quaternion is identity
  3724. * @param quaternion defines the quaternion to check
  3725. * @returns true if the quaternion is identity
  3726. */
  3727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates a quaternion from a rotation around an axis
  3730. * @param axis defines the axis to use
  3731. * @param angle defines the angle to use
  3732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3733. */
  3734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3735. /**
  3736. * Creates a rotation around an axis and stores it into the given quaternion
  3737. * @param axis defines the axis to use
  3738. * @param angle defines the angle to use
  3739. * @param result defines the target quaternion
  3740. * @returns the target quaternion
  3741. */
  3742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3743. /**
  3744. * Creates a new quaternion from data stored into an array
  3745. * @param array defines the data source
  3746. * @param offset defines the offset in the source array where the data starts
  3747. * @returns a new quaternion
  3748. */
  3749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3750. /**
  3751. * Updates the given quaternion "result" from the starting index of the given array.
  3752. * @param array the array to pull values from
  3753. * @param offset the offset into the array to start at
  3754. * @param result the quaternion to store the result in
  3755. */
  3756. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3757. /**
  3758. * Create a quaternion from Euler rotation angles
  3759. * @param x Pitch
  3760. * @param y Yaw
  3761. * @param z Roll
  3762. * @returns the new Quaternion
  3763. */
  3764. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3765. /**
  3766. * Updates a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @param result the quaternion to store the result
  3771. * @returns the updated quaternion
  3772. */
  3773. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Create a quaternion from Euler rotation vector
  3776. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3777. * @returns the new Quaternion
  3778. */
  3779. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3780. /**
  3781. * Updates a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @param result the quaternion to store the result
  3784. * @returns the updated quaternion
  3785. */
  3786. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3789. * @param yaw defines the rotation around Y axis
  3790. * @param pitch defines the rotation around X axis
  3791. * @param roll defines the rotation around Z axis
  3792. * @returns the new quaternion
  3793. */
  3794. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3795. /**
  3796. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @param result defines the target quaternion
  3801. */
  3802. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3803. /**
  3804. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3805. * @param alpha defines the rotation around first axis
  3806. * @param beta defines the rotation around second axis
  3807. * @param gamma defines the rotation around third axis
  3808. * @returns the new quaternion
  3809. */
  3810. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @param result defines the target quaternion
  3817. */
  3818. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3819. /**
  3820. * 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)
  3821. * @param axis1 defines the first axis
  3822. * @param axis2 defines the second axis
  3823. * @param axis3 defines the third axis
  3824. * @returns the new quaternion
  3825. */
  3826. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3827. /**
  3828. * 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
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @param ref defines the target quaternion
  3833. */
  3834. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3835. /**
  3836. * Interpolates between two quaternions
  3837. * @param left defines first quaternion
  3838. * @param right defines second quaternion
  3839. * @param amount defines the gradient to use
  3840. * @returns the new interpolated quaternion
  3841. */
  3842. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3843. /**
  3844. * Interpolates between two quaternions and stores it into a target quaternion
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @param result defines the target quaternion
  3849. */
  3850. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3851. /**
  3852. * Interpolate between two quaternions using Hermite interpolation
  3853. * @param value1 defines first quaternion
  3854. * @param tangent1 defines the incoming tangent
  3855. * @param value2 defines second quaternion
  3856. * @param tangent2 defines the outgoing tangent
  3857. * @param amount defines the target quaternion
  3858. * @returns the new interpolated quaternion
  3859. */
  3860. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3861. }
  3862. /**
  3863. * Class used to store matrix data (4x4)
  3864. */
  3865. export class Matrix {
  3866. private static _updateFlagSeed;
  3867. private static _identityReadOnly;
  3868. private _isIdentity;
  3869. private _isIdentityDirty;
  3870. private _isIdentity3x2;
  3871. private _isIdentity3x2Dirty;
  3872. /**
  3873. * Gets the update flag of the matrix which is an unique number for the matrix.
  3874. * It will be incremented every time the matrix data change.
  3875. * You can use it to speed the comparison between two versions of the same matrix.
  3876. */
  3877. updateFlag: number;
  3878. private readonly _m;
  3879. /**
  3880. * Gets the internal data of the matrix
  3881. */
  3882. get m(): DeepImmutable<Float32Array>;
  3883. /** @hidden */
  3884. _markAsUpdated(): void;
  3885. /** @hidden */
  3886. private _updateIdentityStatus;
  3887. /**
  3888. * Creates an empty matrix (filled with zeros)
  3889. */
  3890. constructor();
  3891. /**
  3892. * Check if the current matrix is identity
  3893. * @returns true is the matrix is the identity matrix
  3894. */
  3895. isIdentity(): boolean;
  3896. /**
  3897. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3898. * @returns true is the matrix is the identity matrix
  3899. */
  3900. isIdentityAs3x2(): boolean;
  3901. /**
  3902. * Gets the determinant of the matrix
  3903. * @returns the matrix determinant
  3904. */
  3905. determinant(): number;
  3906. /**
  3907. * Returns the matrix as a Float32Array
  3908. * @returns the matrix underlying array
  3909. */
  3910. toArray(): DeepImmutable<Float32Array>;
  3911. /**
  3912. * Returns the matrix as a Float32Array
  3913. * @returns the matrix underlying array.
  3914. */
  3915. asArray(): DeepImmutable<Float32Array>;
  3916. /**
  3917. * Inverts the current matrix in place
  3918. * @returns the current inverted matrix
  3919. */
  3920. invert(): Matrix;
  3921. /**
  3922. * Sets all the matrix elements to zero
  3923. * @returns the current matrix
  3924. */
  3925. reset(): Matrix;
  3926. /**
  3927. * Adds the current matrix with a second one
  3928. * @param other defines the matrix to add
  3929. * @returns a new matrix as the addition of the current matrix and the given one
  3930. */
  3931. add(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3934. * @param other defines the matrix to add
  3935. * @param result defines the target matrix
  3936. * @returns the current matrix
  3937. */
  3938. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3939. /**
  3940. * Adds in place the given matrix to the current matrix
  3941. * @param other defines the second operand
  3942. * @returns the current updated matrix
  3943. */
  3944. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3945. /**
  3946. * Sets the given matrix to the current inverted Matrix
  3947. * @param other defines the target matrix
  3948. * @returns the unmodified current matrix
  3949. */
  3950. invertToRef(other: Matrix): Matrix;
  3951. /**
  3952. * add a value at the specified position in the current Matrix
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. addAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * mutiply the specified position in the current Matrix by a value
  3960. * @param index the index of the value within the matrix. between 0 and 15.
  3961. * @param value the value to be added
  3962. * @returns the current updated matrix
  3963. */
  3964. multiplyAtIndex(index: number, value: number): Matrix;
  3965. /**
  3966. * Inserts the translation vector (using 3 floats) in the current matrix
  3967. * @param x defines the 1st component of the translation
  3968. * @param y defines the 2nd component of the translation
  3969. * @param z defines the 3rd component of the translation
  3970. * @returns the current updated matrix
  3971. */
  3972. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3973. /**
  3974. * Adds the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Inserts the translation vector in the current matrix
  3983. * @param vector3 defines the translation to insert
  3984. * @returns the current updated matrix
  3985. */
  3986. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3987. /**
  3988. * Gets the translation value of the current matrix
  3989. * @returns a new Vector3 as the extracted translation from the matrix
  3990. */
  3991. getTranslation(): Vector3;
  3992. /**
  3993. * Fill a Vector3 with the extracted translation from the matrix
  3994. * @param result defines the Vector3 where to store the translation
  3995. * @returns the current matrix
  3996. */
  3997. getTranslationToRef(result: Vector3): Matrix;
  3998. /**
  3999. * Remove rotation and scaling part from the matrix
  4000. * @returns the updated matrix
  4001. */
  4002. removeRotationAndScaling(): Matrix;
  4003. /**
  4004. * Multiply two matrices
  4005. * @param other defines the second operand
  4006. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4007. */
  4008. multiply(other: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Copy the current matrix from the given one
  4011. * @param other defines the source matrix
  4012. * @returns the current updated matrix
  4013. */
  4014. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Populates the given array from the starting index with the current matrix values
  4017. * @param array defines the target array
  4018. * @param offset defines the offset in the target array where to start storing values
  4019. * @returns the current matrix
  4020. */
  4021. copyToArray(array: Float32Array, offset?: number): Matrix;
  4022. /**
  4023. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the matrix where to store the multiplication
  4026. * @returns the current matrix
  4027. */
  4028. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4029. /**
  4030. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4031. * @param other defines the second operand
  4032. * @param result defines the array where to store the multiplication
  4033. * @param offset defines the offset in the target array where to start storing values
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4037. /**
  4038. * Check equality between this matrix and a second one
  4039. * @param value defines the second matrix to compare
  4040. * @returns true is the current matrix and the given one values are strictly equal
  4041. */
  4042. equals(value: DeepImmutable<Matrix>): boolean;
  4043. /**
  4044. * Clone the current matrix
  4045. * @returns a new matrix from the current matrix
  4046. */
  4047. clone(): Matrix;
  4048. /**
  4049. * Returns the name of the current matrix class
  4050. * @returns the string "Matrix"
  4051. */
  4052. getClassName(): string;
  4053. /**
  4054. * Gets the hash code of the current matrix
  4055. * @returns the hash code
  4056. */
  4057. getHashCode(): number;
  4058. /**
  4059. * Decomposes the current Matrix into a translation, rotation and scaling components
  4060. * @param scale defines the scale vector3 given as a reference to update
  4061. * @param rotation defines the rotation quaternion given as a reference to update
  4062. * @param translation defines the translation vector3 given as a reference to update
  4063. * @returns true if operation was successful
  4064. */
  4065. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4066. /**
  4067. * Gets specific row of the matrix
  4068. * @param index defines the number of the row to get
  4069. * @returns the index-th row of the current matrix as a new Vector4
  4070. */
  4071. getRow(index: number): Nullable<Vector4>;
  4072. /**
  4073. * Sets the index-th row of the current matrix to the vector4 values
  4074. * @param index defines the number of the row to set
  4075. * @param row defines the target vector4
  4076. * @returns the updated current matrix
  4077. */
  4078. setRow(index: number, row: Vector4): Matrix;
  4079. /**
  4080. * Compute the transpose of the matrix
  4081. * @returns the new transposed matrix
  4082. */
  4083. transpose(): Matrix;
  4084. /**
  4085. * Compute the transpose of the matrix and store it in a given matrix
  4086. * @param result defines the target matrix
  4087. * @returns the current matrix
  4088. */
  4089. transposeToRef(result: Matrix): Matrix;
  4090. /**
  4091. * Sets the index-th row of the current matrix with the given 4 x float values
  4092. * @param index defines the row index
  4093. * @param x defines the x component to set
  4094. * @param y defines the y component to set
  4095. * @param z defines the z component to set
  4096. * @param w defines the w component to set
  4097. * @returns the updated current matrix
  4098. */
  4099. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4100. /**
  4101. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4102. * @param scale defines the scale factor
  4103. * @returns a new matrix
  4104. */
  4105. scale(scale: number): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor to a given result matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Scale the current matrix values by a factor and add the result to a given matrix
  4115. * @param scale defines the scale factor
  4116. * @param result defines the Matrix to store the result
  4117. * @returns the current matrix
  4118. */
  4119. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4120. /**
  4121. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4122. * @param ref matrix to store the result
  4123. */
  4124. toNormalMatrix(ref: Matrix): void;
  4125. /**
  4126. * Gets only rotation part of the current matrix
  4127. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4128. */
  4129. getRotationMatrix(): Matrix;
  4130. /**
  4131. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4132. * @param result defines the target matrix to store data to
  4133. * @returns the current matrix
  4134. */
  4135. getRotationMatrixToRef(result: Matrix): Matrix;
  4136. /**
  4137. * Toggles model matrix from being right handed to left handed in place and vice versa
  4138. */
  4139. toggleModelMatrixHandInPlace(): void;
  4140. /**
  4141. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleProjectionMatrixHandInPlace(): void;
  4144. /**
  4145. * Creates a matrix from an array
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @returns a new Matrix set from the starting index of the given array
  4149. */
  4150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4151. /**
  4152. * Copy the content of an array into a given matrix
  4153. * @param array defines the source array
  4154. * @param offset defines an offset in the source array
  4155. * @param result defines the target matrix
  4156. */
  4157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4158. /**
  4159. * Stores an array into a matrix after having multiplied each component by a given factor
  4160. * @param array defines the source array
  4161. * @param offset defines the offset in the source array
  4162. * @param scale defines the scaling factor
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4166. /**
  4167. * Gets an identity matrix that must not be updated
  4168. */
  4169. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4170. /**
  4171. * Stores a list of values (16) inside a given matrix
  4172. * @param initialM11 defines 1st value of 1st row
  4173. * @param initialM12 defines 2nd value of 1st row
  4174. * @param initialM13 defines 3rd value of 1st row
  4175. * @param initialM14 defines 4th value of 1st row
  4176. * @param initialM21 defines 1st value of 2nd row
  4177. * @param initialM22 defines 2nd value of 2nd row
  4178. * @param initialM23 defines 3rd value of 2nd row
  4179. * @param initialM24 defines 4th value of 2nd row
  4180. * @param initialM31 defines 1st value of 3rd row
  4181. * @param initialM32 defines 2nd value of 3rd row
  4182. * @param initialM33 defines 3rd value of 3rd row
  4183. * @param initialM34 defines 4th value of 3rd row
  4184. * @param initialM41 defines 1st value of 4th row
  4185. * @param initialM42 defines 2nd value of 4th row
  4186. * @param initialM43 defines 3rd value of 4th row
  4187. * @param initialM44 defines 4th value of 4th row
  4188. * @param result defines the target matrix
  4189. */
  4190. 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;
  4191. /**
  4192. * Creates new matrix from a list of values (16)
  4193. * @param initialM11 defines 1st value of 1st row
  4194. * @param initialM12 defines 2nd value of 1st row
  4195. * @param initialM13 defines 3rd value of 1st row
  4196. * @param initialM14 defines 4th value of 1st row
  4197. * @param initialM21 defines 1st value of 2nd row
  4198. * @param initialM22 defines 2nd value of 2nd row
  4199. * @param initialM23 defines 3rd value of 2nd row
  4200. * @param initialM24 defines 4th value of 2nd row
  4201. * @param initialM31 defines 1st value of 3rd row
  4202. * @param initialM32 defines 2nd value of 3rd row
  4203. * @param initialM33 defines 3rd value of 3rd row
  4204. * @param initialM34 defines 4th value of 3rd row
  4205. * @param initialM41 defines 1st value of 4th row
  4206. * @param initialM42 defines 2nd value of 4th row
  4207. * @param initialM43 defines 3rd value of 4th row
  4208. * @param initialM44 defines 4th value of 4th row
  4209. * @returns the new matrix
  4210. */
  4211. 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;
  4212. /**
  4213. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4214. * @param scale defines the scale vector3
  4215. * @param rotation defines the rotation quaternion
  4216. * @param translation defines the translation vector3
  4217. * @returns a new matrix
  4218. */
  4219. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4220. /**
  4221. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @param result defines the target matrix
  4226. */
  4227. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4228. /**
  4229. * Creates a new identity matrix
  4230. * @returns a new identity matrix
  4231. */
  4232. static Identity(): Matrix;
  4233. /**
  4234. * Creates a new identity matrix and stores the result in a given matrix
  4235. * @param result defines the target matrix
  4236. */
  4237. static IdentityToRef(result: Matrix): void;
  4238. /**
  4239. * Creates a new zero matrix
  4240. * @returns a new zero matrix
  4241. */
  4242. static Zero(): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the X axis
  4245. * @param angle defines the angle (in radians) to use
  4246. * @return the new matrix
  4247. */
  4248. static RotationX(angle: number): Matrix;
  4249. /**
  4250. * Creates a new matrix as the invert of a given matrix
  4251. * @param source defines the source matrix
  4252. * @returns the new matrix
  4253. */
  4254. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationXToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the Y axis
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationY(angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4269. * @param angle defines the angle (in radians) to use
  4270. * @param result defines the target matrix
  4271. */
  4272. static RotationYToRef(angle: number, result: Matrix): void;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Z axis
  4275. * @param angle defines the angle (in radians) to use
  4276. * @return the new matrix
  4277. */
  4278. static RotationZ(angle: number): Matrix;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4281. * @param angle defines the angle (in radians) to use
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationZToRef(angle: number, result: Matrix): void;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @return the new matrix
  4290. */
  4291. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4294. * @param axis defines the axis to use
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4299. /**
  4300. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4301. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4302. * @param from defines the vector to align
  4303. * @param to defines the vector to align to
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4307. /**
  4308. * Creates a rotation matrix
  4309. * @param yaw defines the yaw angle in radians (Y axis)
  4310. * @param pitch defines the pitch angle in radians (X axis)
  4311. * @param roll defines the roll angle in radians (X axis)
  4312. * @returns the new rotation matrix
  4313. */
  4314. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4315. /**
  4316. * Creates a rotation matrix and stores it in a given matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @param result defines the target matrix
  4321. */
  4322. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4323. /**
  4324. * Creates a scaling matrix
  4325. * @param x defines the scale factor on X axis
  4326. * @param y defines the scale factor on Y axis
  4327. * @param z defines the scale factor on Z axis
  4328. * @returns the new matrix
  4329. */
  4330. static Scaling(x: number, y: number, z: number): Matrix;
  4331. /**
  4332. * Creates a scaling matrix and stores it in a given matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @param result defines the target matrix
  4337. */
  4338. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4339. /**
  4340. * Creates a translation matrix
  4341. * @param x defines the translation on X axis
  4342. * @param y defines the translation on Y axis
  4343. * @param z defines the translationon Z axis
  4344. * @returns the new matrix
  4345. */
  4346. static Translation(x: number, y: number, z: number): Matrix;
  4347. /**
  4348. * Creates a translation matrix and stores it in a given matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @param result defines the target matrix
  4353. */
  4354. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4355. /**
  4356. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4357. * @param startValue defines the start value
  4358. * @param endValue defines the end value
  4359. * @param gradient defines the gradient factor
  4360. * @returns the new matrix
  4361. */
  4362. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4363. /**
  4364. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @param result defines the Matrix object where to store data
  4369. */
  4370. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * Builds a new matrix whose values are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @returns the new matrix
  4380. */
  4381. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4382. /**
  4383. * Update a matrix to values which are computed by:
  4384. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4385. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4386. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4387. * @param startValue defines the first matrix
  4388. * @param endValue defines the second matrix
  4389. * @param gradient defines the gradient between the two matrices
  4390. * @param result defines the target matrix
  4391. */
  4392. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * 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"
  4395. * This function works in left handed mode
  4396. * @param eye defines the final position of the entity
  4397. * @param target defines where the entity should look at
  4398. * @param up defines the up vector for the entity
  4399. * @returns the new matrix
  4400. */
  4401. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4402. /**
  4403. * 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".
  4404. * This function works in left handed mode
  4405. * @param eye defines the final position of the entity
  4406. * @param target defines where the entity should look at
  4407. * @param up defines the up vector for the entity
  4408. * @param result defines the target matrix
  4409. */
  4410. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4411. /**
  4412. * 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"
  4413. * This function works in right handed mode
  4414. * @param eye defines the final position of the entity
  4415. * @param target defines where the entity should look at
  4416. * @param up defines the up vector for the entity
  4417. * @returns the new matrix
  4418. */
  4419. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4420. /**
  4421. * 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".
  4422. * This function works in right handed mode
  4423. * @param eye defines the final position of the entity
  4424. * @param target defines where the entity should look at
  4425. * @param up defines the up vector for the entity
  4426. * @param result defines the target matrix
  4427. */
  4428. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Create a left-handed orthographic projection matrix
  4431. * @param width defines the viewport width
  4432. * @param height defines the viewport height
  4433. * @param znear defines the near clip plane
  4434. * @param zfar defines the far clip plane
  4435. * @returns a new matrix as a left-handed orthographic projection matrix
  4436. */
  4437. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4438. /**
  4439. * Store a left-handed orthographic projection to a given matrix
  4440. * @param width defines the viewport width
  4441. * @param height defines the viewport height
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Create a left-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a left-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a left-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a right-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a right-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a right-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a left-handed perspective projection matrix
  4493. * @param width defines the viewport width
  4494. * @param height defines the viewport height
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @returns a new matrix as a left-handed perspective projection matrix
  4498. */
  4499. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4500. /**
  4501. * Creates a left-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a left-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a left-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Creates a right-handed perspective projection matrix
  4531. * @param fov defines the horizontal field of view
  4532. * @param aspect defines the aspect ratio
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @returns a new matrix as a right-handed perspective projection matrix
  4536. */
  4537. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4538. /**
  4539. * Stores a right-handed perspective projection into a given matrix
  4540. * @param fov defines the horizontal field of view
  4541. * @param aspect defines the aspect ratio
  4542. * @param znear defines the near clip plane
  4543. * @param zfar defines the far clip plane
  4544. * @param result defines the target matrix
  4545. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4546. */
  4547. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4548. /**
  4549. * Stores a right-handed perspective projection into a given matrix
  4550. * @param fov defines the horizontal field of view
  4551. * @param aspect defines the aspect ratio
  4552. * @param znear defines the near clip plane
  4553. * @param zfar not used as infinity is used as far clip
  4554. * @param result defines the target matrix
  4555. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4556. */
  4557. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4558. /**
  4559. * Stores a perspective projection for WebVR info a given matrix
  4560. * @param fov defines the field of view
  4561. * @param znear defines the near clip plane
  4562. * @param zfar defines the far clip plane
  4563. * @param result defines the target matrix
  4564. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4565. */
  4566. static PerspectiveFovWebVRToRef(fov: {
  4567. upDegrees: number;
  4568. downDegrees: number;
  4569. leftDegrees: number;
  4570. rightDegrees: number;
  4571. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4572. /**
  4573. * Computes a complete transformation matrix
  4574. * @param viewport defines the viewport to use
  4575. * @param world defines the world matrix
  4576. * @param view defines the view matrix
  4577. * @param projection defines the projection matrix
  4578. * @param zmin defines the near clip plane
  4579. * @param zmax defines the far clip plane
  4580. * @returns the transformation matrix
  4581. */
  4582. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4583. /**
  4584. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4585. * @param matrix defines the matrix to use
  4586. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4587. */
  4588. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4589. /**
  4590. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Compute the transpose of a given matrix
  4597. * @param matrix defines the matrix to transpose
  4598. * @returns the new matrix
  4599. */
  4600. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4601. /**
  4602. * Compute the transpose of a matrix and store it in a target matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @param result defines the target matrix
  4605. */
  4606. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4607. /**
  4608. * Computes a reflection matrix from a plane
  4609. * @param plane defines the reflection plane
  4610. * @returns a new matrix
  4611. */
  4612. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @param result defines the target matrix
  4617. */
  4618. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4619. /**
  4620. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4621. * @param xaxis defines the value of the 1st axis
  4622. * @param yaxis defines the value of the 2nd axis
  4623. * @param zaxis defines the value of the 3rd axis
  4624. * @param result defines the target matrix
  4625. */
  4626. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4627. /**
  4628. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4629. * @param quat defines the quaternion to use
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4633. }
  4634. /**
  4635. * @hidden
  4636. */
  4637. export class TmpVectors {
  4638. static Vector2: Vector2[];
  4639. static Vector3: Vector3[];
  4640. static Vector4: Vector4[];
  4641. static Quaternion: Quaternion[];
  4642. static Matrix: Matrix[];
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. /**
  4647. * Defines potential orientation for back face culling
  4648. */
  4649. export enum Orientation {
  4650. /**
  4651. * Clockwise
  4652. */
  4653. CW = 0,
  4654. /** Counter clockwise */
  4655. CCW = 1
  4656. }
  4657. /** Class used to represent a Bezier curve */
  4658. export class BezierCurve {
  4659. /**
  4660. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4661. * @param t defines the time
  4662. * @param x1 defines the left coordinate on X axis
  4663. * @param y1 defines the left coordinate on Y axis
  4664. * @param x2 defines the right coordinate on X axis
  4665. * @param y2 defines the right coordinate on Y axis
  4666. * @returns the interpolated value
  4667. */
  4668. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4669. }
  4670. /**
  4671. * Defines angle representation
  4672. */
  4673. export class Angle {
  4674. private _radians;
  4675. /**
  4676. * Creates an Angle object of "radians" radians (float).
  4677. * @param radians the angle in radians
  4678. */
  4679. constructor(radians: number);
  4680. /**
  4681. * Get value in degrees
  4682. * @returns the Angle value in degrees (float)
  4683. */
  4684. degrees(): number;
  4685. /**
  4686. * Get value in radians
  4687. * @returns the Angle value in radians (float)
  4688. */
  4689. radians(): number;
  4690. /**
  4691. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4692. * @param a defines first vector
  4693. * @param b defines second vector
  4694. * @returns a new Angle
  4695. */
  4696. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4697. /**
  4698. * Gets a new Angle object from the given float in radians
  4699. * @param radians defines the angle value in radians
  4700. * @returns a new Angle
  4701. */
  4702. static FromRadians(radians: number): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in degrees
  4705. * @param degrees defines the angle value in degrees
  4706. * @returns a new Angle
  4707. */
  4708. static FromDegrees(degrees: number): Angle;
  4709. }
  4710. /**
  4711. * This represents an arc in a 2d space.
  4712. */
  4713. export class Arc2 {
  4714. /** Defines the start point of the arc */
  4715. startPoint: Vector2;
  4716. /** Defines the mid point of the arc */
  4717. midPoint: Vector2;
  4718. /** Defines the end point of the arc */
  4719. endPoint: Vector2;
  4720. /**
  4721. * Defines the center point of the arc.
  4722. */
  4723. centerPoint: Vector2;
  4724. /**
  4725. * Defines the radius of the arc.
  4726. */
  4727. radius: number;
  4728. /**
  4729. * Defines the angle of the arc (from mid point to end point).
  4730. */
  4731. angle: Angle;
  4732. /**
  4733. * Defines the start angle of the arc (from start point to middle point).
  4734. */
  4735. startAngle: Angle;
  4736. /**
  4737. * Defines the orientation of the arc (clock wise/counter clock wise).
  4738. */
  4739. orientation: Orientation;
  4740. /**
  4741. * Creates an Arc object from the three given points : start, middle and end.
  4742. * @param startPoint Defines the start point of the arc
  4743. * @param midPoint Defines the midlle point of the arc
  4744. * @param endPoint Defines the end point of the arc
  4745. */
  4746. constructor(
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2,
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2,
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2);
  4753. }
  4754. /**
  4755. * Represents a 2D path made up of multiple 2D points
  4756. */
  4757. export class Path2 {
  4758. private _points;
  4759. private _length;
  4760. /**
  4761. * If the path start and end point are the same
  4762. */
  4763. closed: boolean;
  4764. /**
  4765. * Creates a Path2 object from the starting 2D coordinates x and y.
  4766. * @param x the starting points x value
  4767. * @param y the starting points y value
  4768. */
  4769. constructor(x: number, y: number);
  4770. /**
  4771. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4772. * @param x the added points x value
  4773. * @param y the added points y value
  4774. * @returns the updated Path2.
  4775. */
  4776. addLineTo(x: number, y: number): Path2;
  4777. /**
  4778. * 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.
  4779. * @param midX middle point x value
  4780. * @param midY middle point y value
  4781. * @param endX end point x value
  4782. * @param endY end point y value
  4783. * @param numberOfSegments (default: 36)
  4784. * @returns the updated Path2.
  4785. */
  4786. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4787. /**
  4788. * Closes the Path2.
  4789. * @returns the Path2.
  4790. */
  4791. close(): Path2;
  4792. /**
  4793. * Gets the sum of the distance between each sequential point in the path
  4794. * @returns the Path2 total length (float).
  4795. */
  4796. length(): number;
  4797. /**
  4798. * Gets the points which construct the path
  4799. * @returns the Path2 internal array of points.
  4800. */
  4801. getPoints(): Vector2[];
  4802. /**
  4803. * Retreives the point at the distance aways from the starting point
  4804. * @param normalizedLengthPosition the length along the path to retreive the point from
  4805. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4806. */
  4807. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4808. /**
  4809. * Creates a new path starting from an x and y position
  4810. * @param x starting x value
  4811. * @param y starting y value
  4812. * @returns a new Path2 starting at the coordinates (x, y).
  4813. */
  4814. static StartingAt(x: number, y: number): Path2;
  4815. }
  4816. /**
  4817. * Represents a 3D path made up of multiple 3D points
  4818. */
  4819. export class Path3D {
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[];
  4824. private _curve;
  4825. private _distances;
  4826. private _tangents;
  4827. private _normals;
  4828. private _binormals;
  4829. private _raw;
  4830. private _alignTangentsWithPath;
  4831. private readonly _pointAtData;
  4832. /**
  4833. * new Path3D(path, normal, raw)
  4834. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4835. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4836. * @param path an array of Vector3, the curve axis of the Path3D
  4837. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4838. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4839. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4840. */
  4841. constructor(
  4842. /**
  4843. * an array of Vector3, the curve axis of the Path3D
  4844. */
  4845. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4846. /**
  4847. * Returns the Path3D array of successive Vector3 designing its curve.
  4848. * @returns the Path3D array of successive Vector3 designing its curve.
  4849. */
  4850. getCurve(): Vector3[];
  4851. /**
  4852. * Returns the Path3D array of successive Vector3 designing its curve.
  4853. * @returns the Path3D array of successive Vector3 designing its curve.
  4854. */
  4855. getPoints(): Vector3[];
  4856. /**
  4857. * @returns the computed length (float) of the path.
  4858. */
  4859. length(): number;
  4860. /**
  4861. * Returns an array populated with tangent vectors on each Path3D curve point.
  4862. * @returns an array populated with tangent vectors on each Path3D curve point.
  4863. */
  4864. getTangents(): Vector3[];
  4865. /**
  4866. * Returns an array populated with normal vectors on each Path3D curve point.
  4867. * @returns an array populated with normal vectors on each Path3D curve point.
  4868. */
  4869. getNormals(): Vector3[];
  4870. /**
  4871. * Returns an array populated with binormal vectors on each Path3D curve point.
  4872. * @returns an array populated with binormal vectors on each Path3D curve point.
  4873. */
  4874. getBinormals(): Vector3[];
  4875. /**
  4876. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4877. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4878. */
  4879. getDistances(): number[];
  4880. /**
  4881. * Returns an interpolated point along this path
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns a new Vector3 as the point
  4884. */
  4885. getPointAt(position: number): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4890. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4891. */
  4892. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4897. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4898. */
  4899. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4904. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4905. */
  4906. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4907. /**
  4908. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4909. * @param position the position of the point along this path, from 0.0 to 1.0
  4910. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4911. */
  4912. getDistanceAt(position: number): number;
  4913. /**
  4914. * Returns the array index of the previous point of an interpolated point along this path
  4915. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4916. * @returns the array index
  4917. */
  4918. getPreviousPointIndexAt(position: number): number;
  4919. /**
  4920. * 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)
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the sub position
  4923. */
  4924. getSubPositionAt(position: number): number;
  4925. /**
  4926. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4927. * @param target the vector of which to get the closest position to
  4928. * @returns the position of the closest virtual point on this path to the target vector
  4929. */
  4930. getClosestPositionTo(target: Vector3): number;
  4931. /**
  4932. * Returns a sub path (slice) of this path
  4933. * @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
  4934. * @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
  4935. * @returns a sub path (slice) of this path
  4936. */
  4937. slice(start?: number, end?: number): Path3D;
  4938. /**
  4939. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4940. * @param path path which all values are copied into the curves points
  4941. * @param firstNormal which should be projected onto the curve
  4942. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4943. * @returns the same object updated.
  4944. */
  4945. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4946. private _compute;
  4947. private _getFirstNonNullVector;
  4948. private _getLastNonNullVector;
  4949. private _normalVector;
  4950. /**
  4951. * Updates the point at data for an interpolated point along this curve
  4952. * @param position the position of the point along this curve, from 0.0 to 1.0
  4953. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4954. * @returns the (updated) point at data
  4955. */
  4956. private _updatePointAtData;
  4957. /**
  4958. * Updates the point at data from the specified parameters
  4959. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4960. * @param point the interpolated point
  4961. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4962. */
  4963. private _setPointAtData;
  4964. /**
  4965. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4966. */
  4967. private _updateInterpolationMatrix;
  4968. }
  4969. /**
  4970. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4971. * A Curve3 is designed from a series of successive Vector3.
  4972. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4973. */
  4974. export class Curve3 {
  4975. private _points;
  4976. private _length;
  4977. /**
  4978. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4979. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4980. * @param v1 (Vector3) the control point
  4981. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4989. * @param v1 (Vector3) the first control point
  4990. * @param v2 (Vector3) the second control point
  4991. * @param v3 (Vector3) the end point of the Cubic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4998. * @param p1 (Vector3) the origin point of the Hermite Spline
  4999. * @param t1 (Vector3) the tangent vector at the origin point
  5000. * @param p2 (Vector3) the end point of the Hermite Spline
  5001. * @param t2 (Vector3) the tangent vector at the end point
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a CatmullRom Spline curve :
  5008. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5009. * @param nbPoints (integer) the wanted number of points between each curve control points
  5010. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5014. /**
  5015. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5016. * A Curve3 is designed from a series of successive Vector3.
  5017. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5018. * @param points points which make up the curve
  5019. */
  5020. constructor(points: Vector3[]);
  5021. /**
  5022. * @returns the Curve3 stored array of successive Vector3
  5023. */
  5024. getPoints(): Vector3[];
  5025. /**
  5026. * @returns the computed length (float) of the curve.
  5027. */
  5028. length(): number;
  5029. /**
  5030. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5031. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5032. * curveA and curveB keep unchanged.
  5033. * @param curve the curve to continue from this curve
  5034. * @returns the newly constructed curve
  5035. */
  5036. continue(curve: DeepImmutable<Curve3>): Curve3;
  5037. private _computeLength;
  5038. }
  5039. }
  5040. declare module BABYLON {
  5041. /**
  5042. * This represents the main contract an easing function should follow.
  5043. * Easing functions are used throughout the animation system.
  5044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5045. */
  5046. export interface IEasingFunction {
  5047. /**
  5048. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5049. * of the easing function.
  5050. * The link below provides some of the most common examples of easing functions.
  5051. * @see https://easings.net/
  5052. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5053. * @returns the corresponding value on the curve defined by the easing function
  5054. */
  5055. ease(gradient: number): number;
  5056. }
  5057. /**
  5058. * Base class used for every default easing function.
  5059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5060. */
  5061. export class EasingFunction implements IEasingFunction {
  5062. /**
  5063. * Interpolation follows the mathematical formula associated with the easing function.
  5064. */
  5065. static readonly EASINGMODE_EASEIN: number;
  5066. /**
  5067. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5068. */
  5069. static readonly EASINGMODE_EASEOUT: number;
  5070. /**
  5071. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5072. */
  5073. static readonly EASINGMODE_EASEINOUT: number;
  5074. private _easingMode;
  5075. /**
  5076. * Sets the easing mode of the current function.
  5077. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5078. */
  5079. setEasingMode(easingMode: number): void;
  5080. /**
  5081. * Gets the current easing mode.
  5082. * @returns the easing mode
  5083. */
  5084. getEasingMode(): number;
  5085. /**
  5086. * @hidden
  5087. */
  5088. easeInCore(gradient: number): number;
  5089. /**
  5090. * Given an input gradient between 0 and 1, this returns the corresponding value
  5091. * of the easing function.
  5092. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5093. * @returns the corresponding value on the curve defined by the easing function
  5094. */
  5095. ease(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a circle shape (see link below).
  5099. * @see https://easings.net/#easeInCirc
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CircleEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with a ease back shape (see link below).
  5108. * @see https://easings.net/#easeInBack
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class BackEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the amplitude of the function */
  5113. amplitude: number;
  5114. /**
  5115. * Instantiates a back ease easing
  5116. * @see https://easings.net/#easeInBack
  5117. * @param amplitude Defines the amplitude of the function
  5118. */
  5119. constructor(
  5120. /** Defines the amplitude of the function */
  5121. amplitude?: number);
  5122. /** @hidden */
  5123. easeInCore(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a bouncing shape (see link below).
  5127. * @see https://easings.net/#easeInBounce
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class BounceEase extends EasingFunction implements IEasingFunction {
  5131. /** Defines the number of bounces */
  5132. bounces: number;
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness: number;
  5135. /**
  5136. * Instantiates a bounce easing
  5137. * @see https://easings.net/#easeInBounce
  5138. * @param bounces Defines the number of bounces
  5139. * @param bounciness Defines the amplitude of the bounce
  5140. */
  5141. constructor(
  5142. /** Defines the number of bounces */
  5143. bounces?: number,
  5144. /** Defines the amplitude of the bounce */
  5145. bounciness?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power of 3 shape (see link below).
  5151. * @see https://easings.net/#easeInCubic
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class CubicEase extends EasingFunction implements IEasingFunction {
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with an elastic shape (see link below).
  5160. * @see https://easings.net/#easeInElastic
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of oscillations*/
  5165. oscillations: number;
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness: number;
  5168. /**
  5169. * Instantiates an elastic easing function
  5170. * @see https://easings.net/#easeInElastic
  5171. * @param oscillations Defines the number of oscillations
  5172. * @param springiness Defines the amplitude of the oscillations
  5173. */
  5174. constructor(
  5175. /** Defines the number of oscillations*/
  5176. oscillations?: number,
  5177. /** Defines the amplitude of the oscillations*/
  5178. springiness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an exponential shape (see link below).
  5184. * @see https://easings.net/#easeInExpo
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the exponent of the function */
  5189. exponent: number;
  5190. /**
  5191. * Instantiates an exponential easing function
  5192. * @see https://easings.net/#easeInExpo
  5193. * @param exponent Defines the exponent of the function
  5194. */
  5195. constructor(
  5196. /** Defines the exponent of the function */
  5197. exponent?: number);
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power shape (see link below).
  5203. * @see https://easings.net/#easeInQuad
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class PowerEase extends EasingFunction implements IEasingFunction {
  5207. /** Defines the power of the function */
  5208. power: number;
  5209. /**
  5210. * Instantiates an power base easing function
  5211. * @see https://easings.net/#easeInQuad
  5212. * @param power Defines the power of the function
  5213. */
  5214. constructor(
  5215. /** Defines the power of the function */
  5216. power?: number);
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a power of 2 shape (see link below).
  5222. * @see https://easings.net/#easeInQuad
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power of 4 shape (see link below).
  5231. * @see https://easings.net/#easeInQuart
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. /**
  5239. * Easing function with a power of 5 shape (see link below).
  5240. * @see https://easings.net/#easeInQuint
  5241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5242. */
  5243. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a sin shape (see link below).
  5249. * @see https://easings.net/#easeInSine
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class SineEase extends EasingFunction implements IEasingFunction {
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a bezier shape (see link below).
  5258. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5262. /** Defines the x component of the start tangent in the bezier curve */
  5263. x1: number;
  5264. /** Defines the y component of the start tangent in the bezier curve */
  5265. y1: number;
  5266. /** Defines the x component of the end tangent in the bezier curve */
  5267. x2: number;
  5268. /** Defines the y component of the end tangent in the bezier curve */
  5269. y2: number;
  5270. /**
  5271. * Instantiates a bezier function
  5272. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5273. * @param x1 Defines the x component of the start tangent in the bezier curve
  5274. * @param y1 Defines the y component of the start tangent in the bezier curve
  5275. * @param x2 Defines the x component of the end tangent in the bezier curve
  5276. * @param y2 Defines the y component of the end tangent in the bezier curve
  5277. */
  5278. constructor(
  5279. /** Defines the x component of the start tangent in the bezier curve */
  5280. x1?: number,
  5281. /** Defines the y component of the start tangent in the bezier curve */
  5282. y1?: number,
  5283. /** Defines the x component of the end tangent in the bezier curve */
  5284. x2?: number,
  5285. /** Defines the y component of the end tangent in the bezier curve */
  5286. y2?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. }
  5291. declare module BABYLON {
  5292. /**
  5293. * Class used to hold a RBG color
  5294. */
  5295. export class Color3 {
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r: number;
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g: number;
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b: number;
  5308. /**
  5309. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5310. * @param r defines the red component (between 0 and 1, default is 0)
  5311. * @param g defines the green component (between 0 and 1, default is 0)
  5312. * @param b defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. constructor(
  5315. /**
  5316. * Defines the red component (between 0 and 1, default is 0)
  5317. */
  5318. r?: number,
  5319. /**
  5320. * Defines the green component (between 0 and 1, default is 0)
  5321. */
  5322. g?: number,
  5323. /**
  5324. * Defines the blue component (between 0 and 1, default is 0)
  5325. */
  5326. b?: number);
  5327. /**
  5328. * Creates a string with the Color3 current values
  5329. * @returns the string representation of the Color3 object
  5330. */
  5331. toString(): string;
  5332. /**
  5333. * Returns the string "Color3"
  5334. * @returns "Color3"
  5335. */
  5336. getClassName(): string;
  5337. /**
  5338. * Compute the Color3 hash code
  5339. * @returns an unique number that can be used to hash Color3 objects
  5340. */
  5341. getHashCode(): number;
  5342. /**
  5343. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5344. * @param array defines the array where to store the r,g,b components
  5345. * @param index defines an optional index in the target array to define where to start storing values
  5346. * @returns the current Color3 object
  5347. */
  5348. toArray(array: FloatArray, index?: number): Color3;
  5349. /**
  5350. * Returns a new Color4 object from the current Color3 and the given alpha
  5351. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5352. * @returns a new Color4 object
  5353. */
  5354. toColor4(alpha?: number): Color4;
  5355. /**
  5356. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5357. * @returns the new array
  5358. */
  5359. asArray(): number[];
  5360. /**
  5361. * Returns the luminance value
  5362. * @returns a float value
  5363. */
  5364. toLuminance(): number;
  5365. /**
  5366. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5367. * @param otherColor defines the second operand
  5368. * @returns the new Color3 object
  5369. */
  5370. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5371. /**
  5372. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5373. * @param otherColor defines the second operand
  5374. * @param result defines the Color3 object where to store the result
  5375. * @returns the current Color3
  5376. */
  5377. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5378. /**
  5379. * Determines equality between Color3 objects
  5380. * @param otherColor defines the second operand
  5381. * @returns true if the rgb values are equal to the given ones
  5382. */
  5383. equals(otherColor: DeepImmutable<Color3>): boolean;
  5384. /**
  5385. * Determines equality between the current Color3 object and a set of r,b,g values
  5386. * @param r defines the red component to check
  5387. * @param g defines the green component to check
  5388. * @param b defines the blue component to check
  5389. * @returns true if the rgb values are equal to the given ones
  5390. */
  5391. equalsFloats(r: number, g: number, b: number): boolean;
  5392. /**
  5393. * Multiplies in place each rgb value by scale
  5394. * @param scale defines the scaling factor
  5395. * @returns the updated Color3
  5396. */
  5397. scale(scale: number): Color3;
  5398. /**
  5399. * Multiplies the rgb values by scale and stores the result into "result"
  5400. * @param scale defines the scaling factor
  5401. * @param result defines the Color3 object where to store the result
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Scale the current Color3 values by a factor and add the result to a given Color3
  5407. * @param scale defines the scale factor
  5408. * @param result defines color to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Clamps the rgb values by the min and max values and stores the result into "result"
  5414. * @param min defines minimum clamping value (default is 0)
  5415. * @param max defines maximum clamping value (default is 1)
  5416. * @param result defines color to store the result into
  5417. * @returns the original Color3
  5418. */
  5419. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5420. /**
  5421. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5422. * @param otherColor defines the second operand
  5423. * @returns the new Color3
  5424. */
  5425. add(otherColor: DeepImmutable<Color3>): Color3;
  5426. /**
  5427. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5428. * @param otherColor defines the second operand
  5429. * @param result defines Color3 object to store the result into
  5430. * @returns the unmodified current Color3
  5431. */
  5432. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5433. /**
  5434. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5435. * @param otherColor defines the second operand
  5436. * @returns the new Color3
  5437. */
  5438. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5439. /**
  5440. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5441. * @param otherColor defines the second operand
  5442. * @param result defines Color3 object to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5446. /**
  5447. * Copy the current object
  5448. * @returns a new Color3 copied the current one
  5449. */
  5450. clone(): Color3;
  5451. /**
  5452. * Copies the rgb values from the source in the current Color3
  5453. * @param source defines the source Color3 object
  5454. * @returns the updated Color3 object
  5455. */
  5456. copyFrom(source: DeepImmutable<Color3>): Color3;
  5457. /**
  5458. * Updates the Color3 rgb values from the given floats
  5459. * @param r defines the red component to read from
  5460. * @param g defines the green component to read from
  5461. * @param b defines the blue component to read from
  5462. * @returns the current Color3 object
  5463. */
  5464. copyFromFloats(r: number, g: number, b: number): Color3;
  5465. /**
  5466. * Updates the Color3 rgb values from the given floats
  5467. * @param r defines the red component to read from
  5468. * @param g defines the green component to read from
  5469. * @param b defines the blue component to read from
  5470. * @returns the current Color3 object
  5471. */
  5472. set(r: number, g: number, b: number): Color3;
  5473. /**
  5474. * Compute the Color3 hexadecimal code as a string
  5475. * @returns a string containing the hexadecimal representation of the Color3 object
  5476. */
  5477. toHexString(): string;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to linear space
  5480. * @returns a new Color3 object
  5481. */
  5482. toLinearSpace(): Color3;
  5483. /**
  5484. * Converts current color in rgb space to HSV values
  5485. * @returns a new color3 representing the HSV values
  5486. */
  5487. toHSV(): Color3;
  5488. /**
  5489. * Converts current color in rgb space to HSV values
  5490. * @param result defines the Color3 where to store the HSV values
  5491. */
  5492. toHSVToRef(result: Color3): void;
  5493. /**
  5494. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the linear space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5499. /**
  5500. * Computes a new Color3 converted from the current one to gamma space
  5501. * @returns a new Color3 object
  5502. */
  5503. toGammaSpace(): Color3;
  5504. /**
  5505. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the gamma space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5510. private static _BlackReadOnly;
  5511. /**
  5512. * Convert Hue, saturation and value to a Color3 (RGB)
  5513. * @param hue defines the hue
  5514. * @param saturation defines the saturation
  5515. * @param value defines the value
  5516. * @param result defines the Color3 where to store the RGB values
  5517. */
  5518. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5519. /**
  5520. * Creates a new Color3 from the string containing valid hexadecimal values
  5521. * @param hex defines a string containing valid hexadecimal values
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromHexString(hex: string): Color3;
  5525. /**
  5526. * Creates a new Color3 from the starting index of the given array
  5527. * @param array defines the source array
  5528. * @param offset defines an offset in the source array
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5532. /**
  5533. * Creates a new Color3 from integer values (< 256)
  5534. * @param r defines the red component to read from (value between 0 and 255)
  5535. * @param g defines the green component to read from (value between 0 and 255)
  5536. * @param b defines the blue component to read from (value between 0 and 255)
  5537. * @returns a new Color3 object
  5538. */
  5539. static FromInts(r: number, g: number, b: number): Color3;
  5540. /**
  5541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5542. * @param start defines the start Color3 value
  5543. * @param end defines the end Color3 value
  5544. * @param amount defines the gradient value between start and end
  5545. * @returns a new Color3 object
  5546. */
  5547. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5548. /**
  5549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5550. * @param left defines the start value
  5551. * @param right defines the end value
  5552. * @param amount defines the gradient factor
  5553. * @param result defines the Color3 object where to store the result
  5554. */
  5555. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5556. /**
  5557. * Returns a Color3 value containing a red color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Red(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a green color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Green(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a blue color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Blue(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a black color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Black(): Color3;
  5576. /**
  5577. * Gets a Color3 value containing a black color that must not be updated
  5578. */
  5579. static get BlackReadOnly(): DeepImmutable<Color3>;
  5580. /**
  5581. * Returns a Color3 value containing a white color
  5582. * @returns a new Color3 object
  5583. */
  5584. static White(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a purple color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Purple(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a magenta color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Magenta(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a yellow color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Yellow(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a gray color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Gray(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a teal color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Teal(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a random color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Random(): Color3;
  5615. }
  5616. /**
  5617. * Class used to hold a RBGA color
  5618. */
  5619. export class Color4 {
  5620. /**
  5621. * Defines the red component (between 0 and 1, default is 0)
  5622. */
  5623. r: number;
  5624. /**
  5625. * Defines the green component (between 0 and 1, default is 0)
  5626. */
  5627. g: number;
  5628. /**
  5629. * Defines the blue component (between 0 and 1, default is 0)
  5630. */
  5631. b: number;
  5632. /**
  5633. * Defines the alpha component (between 0 and 1, default is 1)
  5634. */
  5635. a: number;
  5636. /**
  5637. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5638. * @param r defines the red component (between 0 and 1, default is 0)
  5639. * @param g defines the green component (between 0 and 1, default is 0)
  5640. * @param b defines the blue component (between 0 and 1, default is 0)
  5641. * @param a defines the alpha component (between 0 and 1, default is 1)
  5642. */
  5643. constructor(
  5644. /**
  5645. * Defines the red component (between 0 and 1, default is 0)
  5646. */
  5647. r?: number,
  5648. /**
  5649. * Defines the green component (between 0 and 1, default is 0)
  5650. */
  5651. g?: number,
  5652. /**
  5653. * Defines the blue component (between 0 and 1, default is 0)
  5654. */
  5655. b?: number,
  5656. /**
  5657. * Defines the alpha component (between 0 and 1, default is 1)
  5658. */
  5659. a?: number);
  5660. /**
  5661. * Adds in place the given Color4 values to the current Color4 object
  5662. * @param right defines the second operand
  5663. * @returns the current updated Color4 object
  5664. */
  5665. addInPlace(right: DeepImmutable<Color4>): Color4;
  5666. /**
  5667. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5668. * @returns the new array
  5669. */
  5670. asArray(): number[];
  5671. /**
  5672. * Stores from the starting index in the given array the Color4 successive values
  5673. * @param array defines the array where to store the r,g,b components
  5674. * @param index defines an optional index in the target array to define where to start storing values
  5675. * @returns the current Color4 object
  5676. */
  5677. toArray(array: number[], index?: number): Color4;
  5678. /**
  5679. * Determines equality between Color4 objects
  5680. * @param otherColor defines the second operand
  5681. * @returns true if the rgba values are equal to the given ones
  5682. */
  5683. equals(otherColor: DeepImmutable<Color4>): boolean;
  5684. /**
  5685. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5686. * @param right defines the second operand
  5687. * @returns a new Color4 object
  5688. */
  5689. add(right: DeepImmutable<Color4>): Color4;
  5690. /**
  5691. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5692. * @param right defines the second operand
  5693. * @returns a new Color4 object
  5694. */
  5695. subtract(right: DeepImmutable<Color4>): Color4;
  5696. /**
  5697. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5698. * @param right defines the second operand
  5699. * @param result defines the Color4 object where to store the result
  5700. * @returns the current Color4 object
  5701. */
  5702. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5703. /**
  5704. * Creates a new Color4 with the current Color4 values multiplied by scale
  5705. * @param scale defines the scaling factor to apply
  5706. * @returns a new Color4 object
  5707. */
  5708. scale(scale: number): Color4;
  5709. /**
  5710. * Multiplies the current Color4 values by scale and stores the result in "result"
  5711. * @param scale defines the scaling factor to apply
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the current unmodified Color4
  5714. */
  5715. scaleToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Scale the current Color4 values by a factor and add the result to a given Color4
  5718. * @param scale defines the scale factor
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the unmodified current Color4
  5721. */
  5722. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Clamps the rgb values by the min and max values and stores the result into "result"
  5725. * @param min defines minimum clamping value (default is 0)
  5726. * @param max defines maximum clamping value (default is 1)
  5727. * @param result defines color to store the result into.
  5728. * @returns the cuurent Color4
  5729. */
  5730. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5731. /**
  5732. * Multipy an Color4 value by another and return a new Color4 object
  5733. * @param color defines the Color4 value to multiply by
  5734. * @returns a new Color4 object
  5735. */
  5736. multiply(color: Color4): Color4;
  5737. /**
  5738. * Multipy a Color4 value by another and push the result in a reference value
  5739. * @param color defines the Color4 value to multiply by
  5740. * @param result defines the Color4 to fill the result in
  5741. * @returns the result Color4
  5742. */
  5743. multiplyToRef(color: Color4, result: Color4): Color4;
  5744. /**
  5745. * Creates a string with the Color4 current values
  5746. * @returns the string representation of the Color4 object
  5747. */
  5748. toString(): string;
  5749. /**
  5750. * Returns the string "Color4"
  5751. * @returns "Color4"
  5752. */
  5753. getClassName(): string;
  5754. /**
  5755. * Compute the Color4 hash code
  5756. * @returns an unique number that can be used to hash Color4 objects
  5757. */
  5758. getHashCode(): number;
  5759. /**
  5760. * Creates a new Color4 copied from the current one
  5761. * @returns a new Color4 object
  5762. */
  5763. clone(): Color4;
  5764. /**
  5765. * Copies the given Color4 values into the current one
  5766. * @param source defines the source Color4 object
  5767. * @returns the current updated Color4 object
  5768. */
  5769. copyFrom(source: Color4): Color4;
  5770. /**
  5771. * Copies the given float values into the current one
  5772. * @param r defines the red component to read from
  5773. * @param g defines the green component to read from
  5774. * @param b defines the blue component to read from
  5775. * @param a defines the alpha component to read from
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. set(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Compute the Color4 hexadecimal code as a string
  5790. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5791. * @returns a string containing the hexadecimal representation of the Color4 object
  5792. */
  5793. toHexString(returnAsColor3?: boolean): string;
  5794. /**
  5795. * Computes a new Color4 converted from the current one to linear space
  5796. * @returns a new Color4 object
  5797. */
  5798. toLinearSpace(): Color4;
  5799. /**
  5800. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5801. * @param convertedColor defines the Color4 object where to store the linear space version
  5802. * @returns the unmodified Color4
  5803. */
  5804. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5805. /**
  5806. * Computes a new Color4 converted from the current one to gamma space
  5807. * @returns a new Color4 object
  5808. */
  5809. toGammaSpace(): Color4;
  5810. /**
  5811. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5812. * @param convertedColor defines the Color4 object where to store the gamma space version
  5813. * @returns the unmodified Color4
  5814. */
  5815. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5816. /**
  5817. * Creates a new Color4 from the string containing valid hexadecimal values
  5818. * @param hex defines a string containing valid hexadecimal values
  5819. * @returns a new Color4 object
  5820. */
  5821. static FromHexString(hex: string): Color4;
  5822. /**
  5823. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5824. * @param left defines the start value
  5825. * @param right defines the end value
  5826. * @param amount defines the gradient factor
  5827. * @returns a new Color4 object
  5828. */
  5829. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5830. /**
  5831. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @param result defines the Color4 object where to store data
  5836. */
  5837. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5838. /**
  5839. * Creates a new Color4 from a Color3 and an alpha value
  5840. * @param color3 defines the source Color3 to read from
  5841. * @param alpha defines the alpha component (1.0 by default)
  5842. * @returns a new Color4 object
  5843. */
  5844. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5845. /**
  5846. * Creates a new Color4 from the starting index element of the given array
  5847. * @param array defines the source array to read from
  5848. * @param offset defines the offset in the source array
  5849. * @returns a new Color4 object
  5850. */
  5851. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5852. /**
  5853. * Creates a new Color3 from integer values (< 256)
  5854. * @param r defines the red component to read from (value between 0 and 255)
  5855. * @param g defines the green component to read from (value between 0 and 255)
  5856. * @param b defines the blue component to read from (value between 0 and 255)
  5857. * @param a defines the alpha component to read from (value between 0 and 255)
  5858. * @returns a new Color3 object
  5859. */
  5860. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5861. /**
  5862. * Check the content of a given array and convert it to an array containing RGBA data
  5863. * If the original array was already containing count * 4 values then it is returned directly
  5864. * @param colors defines the array to check
  5865. * @param count defines the number of RGBA data to expect
  5866. * @returns an array containing count * 4 values (RGBA)
  5867. */
  5868. static CheckColors4(colors: number[], count: number): number[];
  5869. }
  5870. /**
  5871. * @hidden
  5872. */
  5873. export class TmpColors {
  5874. static Color3: Color3[];
  5875. static Color4: Color4[];
  5876. }
  5877. }
  5878. declare module BABYLON {
  5879. /**
  5880. * Defines an interface which represents an animation key frame
  5881. */
  5882. export interface IAnimationKey {
  5883. /**
  5884. * Frame of the key frame
  5885. */
  5886. frame: number;
  5887. /**
  5888. * Value at the specifies key frame
  5889. */
  5890. value: any;
  5891. /**
  5892. * The input tangent for the cubic hermite spline
  5893. */
  5894. inTangent?: any;
  5895. /**
  5896. * The output tangent for the cubic hermite spline
  5897. */
  5898. outTangent?: any;
  5899. /**
  5900. * The animation interpolation type
  5901. */
  5902. interpolation?: AnimationKeyInterpolation;
  5903. }
  5904. /**
  5905. * Enum for the animation key frame interpolation type
  5906. */
  5907. export enum AnimationKeyInterpolation {
  5908. /**
  5909. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5910. */
  5911. STEP = 1
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Represents the range of an animation
  5917. */
  5918. export class AnimationRange {
  5919. /**The name of the animation range**/
  5920. name: string;
  5921. /**The starting frame of the animation */
  5922. from: number;
  5923. /**The ending frame of the animation*/
  5924. to: number;
  5925. /**
  5926. * Initializes the range of an animation
  5927. * @param name The name of the animation range
  5928. * @param from The starting frame of the animation
  5929. * @param to The ending frame of the animation
  5930. */
  5931. constructor(
  5932. /**The name of the animation range**/
  5933. name: string,
  5934. /**The starting frame of the animation */
  5935. from: number,
  5936. /**The ending frame of the animation*/
  5937. to: number);
  5938. /**
  5939. * Makes a copy of the animation range
  5940. * @returns A copy of the animation range
  5941. */
  5942. clone(): AnimationRange;
  5943. }
  5944. }
  5945. declare module BABYLON {
  5946. /**
  5947. * Composed of a frame, and an action function
  5948. */
  5949. export class AnimationEvent {
  5950. /** The frame for which the event is triggered **/
  5951. frame: number;
  5952. /** The event to perform when triggered **/
  5953. action: (currentFrame: number) => void;
  5954. /** Specifies if the event should be triggered only once**/
  5955. onlyOnce?: boolean | undefined;
  5956. /**
  5957. * Specifies if the animation event is done
  5958. */
  5959. isDone: boolean;
  5960. /**
  5961. * Initializes the animation event
  5962. * @param frame The frame for which the event is triggered
  5963. * @param action The event to perform when triggered
  5964. * @param onlyOnce Specifies if the event should be triggered only once
  5965. */
  5966. constructor(
  5967. /** The frame for which the event is triggered **/
  5968. frame: number,
  5969. /** The event to perform when triggered **/
  5970. action: (currentFrame: number) => void,
  5971. /** Specifies if the event should be triggered only once**/
  5972. onlyOnce?: boolean | undefined);
  5973. /** @hidden */
  5974. _clone(): AnimationEvent;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. export interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. export interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Defines an array and its length.
  6025. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6026. */
  6027. export interface ISmartArrayLike<T> {
  6028. /**
  6029. * The data of the array.
  6030. */
  6031. data: Array<T>;
  6032. /**
  6033. * The active length of the array.
  6034. */
  6035. length: number;
  6036. }
  6037. /**
  6038. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6039. */
  6040. export class SmartArray<T> implements ISmartArrayLike<T> {
  6041. /**
  6042. * The full set of data from the array.
  6043. */
  6044. data: Array<T>;
  6045. /**
  6046. * The active length of the array.
  6047. */
  6048. length: number;
  6049. protected _id: number;
  6050. /**
  6051. * Instantiates a Smart Array.
  6052. * @param capacity defines the default capacity of the array.
  6053. */
  6054. constructor(capacity: number);
  6055. /**
  6056. * Pushes a value at the end of the active data.
  6057. * @param value defines the object to push in the array.
  6058. */
  6059. push(value: T): void;
  6060. /**
  6061. * Iterates over the active data and apply the lambda to them.
  6062. * @param func defines the action to apply on each value.
  6063. */
  6064. forEach(func: (content: T) => void): void;
  6065. /**
  6066. * Sorts the full sets of data.
  6067. * @param compareFn defines the comparison function to apply.
  6068. */
  6069. sort(compareFn: (a: T, b: T) => number): void;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Releases all the data from the array as well as the array.
  6076. */
  6077. dispose(): void;
  6078. /**
  6079. * Concats the active data with a given array.
  6080. * @param array defines the data to concatenate with.
  6081. */
  6082. concat(array: any): void;
  6083. /**
  6084. * Returns the position of a value in the active data.
  6085. * @param value defines the value to find the index for
  6086. * @returns the index if found in the active data otherwise -1
  6087. */
  6088. indexOf(value: T): number;
  6089. /**
  6090. * Returns whether an element is part of the active data.
  6091. * @param value defines the value to look for
  6092. * @returns true if found in the active data otherwise false
  6093. */
  6094. contains(value: T): boolean;
  6095. private static _GlobalId;
  6096. }
  6097. /**
  6098. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6099. * The data in this array can only be present once
  6100. */
  6101. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6102. private _duplicateId;
  6103. /**
  6104. * Pushes a value at the end of the active data.
  6105. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6106. * @param value defines the object to push in the array.
  6107. */
  6108. push(value: T): void;
  6109. /**
  6110. * Pushes a value at the end of the active data.
  6111. * If the data is already present, it won t be added again
  6112. * @param value defines the object to push in the array.
  6113. * @returns true if added false if it was already present
  6114. */
  6115. pushNoDuplicate(value: T): boolean;
  6116. /**
  6117. * Resets the active data to an empty array.
  6118. */
  6119. reset(): void;
  6120. /**
  6121. * Concats the active data with a given array.
  6122. * This ensures no dupplicate will be present in the result.
  6123. * @param array defines the data to concatenate with.
  6124. */
  6125. concatWithNoDuplicate(array: any): void;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * @ignore
  6131. * This is a list of all the different input types that are available in the application.
  6132. * Fo instance: ArcRotateCameraGamepadInput...
  6133. */
  6134. export var CameraInputTypes: {};
  6135. /**
  6136. * This is the contract to implement in order to create a new input class.
  6137. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6138. */
  6139. export interface ICameraInput<TCamera extends Camera> {
  6140. /**
  6141. * Defines the camera the input is attached to.
  6142. */
  6143. camera: Nullable<TCamera>;
  6144. /**
  6145. * Gets the class name of the current intput.
  6146. * @returns the class name
  6147. */
  6148. getClassName(): string;
  6149. /**
  6150. * Get the friendly name associated with the input class.
  6151. * @returns the input friendly name
  6152. */
  6153. getSimpleName(): string;
  6154. /**
  6155. * Attach the input controls to a specific dom element to get the input from.
  6156. * @param element Defines the element the controls should be listened from
  6157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6158. */
  6159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6160. /**
  6161. * Detach the current controls from the specified dom element.
  6162. * @param element Defines the element to stop listening the inputs from
  6163. */
  6164. detachControl(element: Nullable<HTMLElement>): void;
  6165. /**
  6166. * Update the current camera state depending on the inputs that have been used this frame.
  6167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6168. */
  6169. checkInputs?: () => void;
  6170. }
  6171. /**
  6172. * Represents a map of input types to input instance or input index to input instance.
  6173. */
  6174. export interface CameraInputsMap<TCamera extends Camera> {
  6175. /**
  6176. * Accessor to the input by input type.
  6177. */
  6178. [name: string]: ICameraInput<TCamera>;
  6179. /**
  6180. * Accessor to the input by input index.
  6181. */
  6182. [idx: number]: ICameraInput<TCamera>;
  6183. }
  6184. /**
  6185. * This represents the input manager used within a camera.
  6186. * It helps dealing with all the different kind of input attached to a camera.
  6187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6188. */
  6189. export class CameraInputsManager<TCamera extends Camera> {
  6190. /**
  6191. * Defines the list of inputs attahed to the camera.
  6192. */
  6193. attached: CameraInputsMap<TCamera>;
  6194. /**
  6195. * Defines the dom element the camera is collecting inputs from.
  6196. * This is null if the controls have not been attached.
  6197. */
  6198. attachedElement: Nullable<HTMLElement>;
  6199. /**
  6200. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. noPreventDefault: boolean;
  6203. /**
  6204. * Defined the camera the input manager belongs to.
  6205. */
  6206. camera: TCamera;
  6207. /**
  6208. * Update the current camera state depending on the inputs that have been used this frame.
  6209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6210. */
  6211. checkInputs: () => void;
  6212. /**
  6213. * Instantiate a new Camera Input Manager.
  6214. * @param camera Defines the camera the input manager blongs to
  6215. */
  6216. constructor(camera: TCamera);
  6217. /**
  6218. * Add an input method to a camera
  6219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6220. * @param input camera input method
  6221. */
  6222. add(input: ICameraInput<TCamera>): void;
  6223. /**
  6224. * Remove a specific input method from a camera
  6225. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6226. * @param inputToRemove camera input method
  6227. */
  6228. remove(inputToRemove: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Remove a specific input type from a camera
  6231. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6232. * @param inputType the type of the input to remove
  6233. */
  6234. removeByType(inputType: string): void;
  6235. private _addCheckInputs;
  6236. /**
  6237. * Attach the input controls to the currently attached dom element to listen the events from.
  6238. * @param input Defines the input to attach
  6239. */
  6240. attachInput(input: ICameraInput<TCamera>): void;
  6241. /**
  6242. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6243. * @param element Defines the dom element to collect the events from
  6244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6245. */
  6246. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6247. /**
  6248. * Detach the current manager inputs controls from a specific dom element.
  6249. * @param element Defines the dom element to collect the events from
  6250. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6251. */
  6252. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6253. /**
  6254. * Rebuild the dynamic inputCheck function from the current list of
  6255. * defined inputs in the manager.
  6256. */
  6257. rebuildInputCheck(): void;
  6258. /**
  6259. * Remove all attached input methods from a camera
  6260. */
  6261. clear(): void;
  6262. /**
  6263. * Serialize the current input manager attached to a camera.
  6264. * This ensures than once parsed,
  6265. * the input associated to the camera will be identical to the current ones
  6266. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6267. */
  6268. serialize(serializedCamera: any): void;
  6269. /**
  6270. * Parses an input manager serialized JSON to restore the previous list of inputs
  6271. * and states associated to a camera.
  6272. * @param parsedCamera Defines the JSON to parse
  6273. */
  6274. parse(parsedCamera: any): void;
  6275. }
  6276. }
  6277. declare module BABYLON {
  6278. /**
  6279. * Class used to store data that will be store in GPU memory
  6280. */
  6281. export class Buffer {
  6282. private _engine;
  6283. private _buffer;
  6284. /** @hidden */
  6285. _data: Nullable<DataArray>;
  6286. private _updatable;
  6287. private _instanced;
  6288. private _divisor;
  6289. /**
  6290. * Gets the byte stride.
  6291. */
  6292. readonly byteStride: number;
  6293. /**
  6294. * Constructor
  6295. * @param engine the engine
  6296. * @param data the data to use for this buffer
  6297. * @param updatable whether the data is updatable
  6298. * @param stride the stride (optional)
  6299. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param useBytes set to true if the stride in in bytes (optional)
  6302. * @param divisor sets an optional divisor for instances (1 by default)
  6303. */
  6304. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6305. /**
  6306. * Create a new VertexBuffer based on the current buffer
  6307. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6308. * @param offset defines offset in the buffer (0 by default)
  6309. * @param size defines the size in floats of attributes (position is 3 for instance)
  6310. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6311. * @param instanced defines if the vertex buffer contains indexed data
  6312. * @param useBytes defines if the offset and stride are in bytes *
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. * @returns the new vertex buffer
  6315. */
  6316. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6317. /**
  6318. * Gets a boolean indicating if the Buffer is updatable?
  6319. * @returns true if the buffer is updatable
  6320. */
  6321. isUpdatable(): boolean;
  6322. /**
  6323. * Gets current buffer's data
  6324. * @returns a DataArray or null
  6325. */
  6326. getData(): Nullable<DataArray>;
  6327. /**
  6328. * Gets underlying native buffer
  6329. * @returns underlying native buffer
  6330. */
  6331. getBuffer(): Nullable<DataBuffer>;
  6332. /**
  6333. * Gets the stride in float32 units (i.e. byte stride / 4).
  6334. * May not be an integer if the byte stride is not divisible by 4.
  6335. * @returns the stride in float32 units
  6336. * @deprecated Please use byteStride instead.
  6337. */
  6338. getStrideSize(): number;
  6339. /**
  6340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6341. * @param data defines the data to store
  6342. */
  6343. create(data?: Nullable<DataArray>): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /**
  6347. * Update current buffer data
  6348. * @param data defines the data to store
  6349. */
  6350. update(data: DataArray): void;
  6351. /**
  6352. * Updates the data directly.
  6353. * @param data the new data
  6354. * @param offset the new offset
  6355. * @param vertexCount the vertex count (optional)
  6356. * @param useBytes set to true if the offset is in bytes
  6357. */
  6358. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6359. /**
  6360. * Release all resources
  6361. */
  6362. dispose(): void;
  6363. }
  6364. /**
  6365. * Specialized buffer used to store vertex data
  6366. */
  6367. export class VertexBuffer {
  6368. /** @hidden */
  6369. _buffer: Buffer;
  6370. private _kind;
  6371. private _size;
  6372. private _ownsBuffer;
  6373. private _instanced;
  6374. private _instanceDivisor;
  6375. /**
  6376. * The byte type.
  6377. */
  6378. static readonly BYTE: number;
  6379. /**
  6380. * The unsigned byte type.
  6381. */
  6382. static readonly UNSIGNED_BYTE: number;
  6383. /**
  6384. * The short type.
  6385. */
  6386. static readonly SHORT: number;
  6387. /**
  6388. * The unsigned short type.
  6389. */
  6390. static readonly UNSIGNED_SHORT: number;
  6391. /**
  6392. * The integer type.
  6393. */
  6394. static readonly INT: number;
  6395. /**
  6396. * The unsigned integer type.
  6397. */
  6398. static readonly UNSIGNED_INT: number;
  6399. /**
  6400. * The float type.
  6401. */
  6402. static readonly FLOAT: number;
  6403. /**
  6404. * Gets or sets the instance divisor when in instanced mode
  6405. */
  6406. get instanceDivisor(): number;
  6407. set instanceDivisor(value: number);
  6408. /**
  6409. * Gets the byte stride.
  6410. */
  6411. readonly byteStride: number;
  6412. /**
  6413. * Gets the byte offset.
  6414. */
  6415. readonly byteOffset: number;
  6416. /**
  6417. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6418. */
  6419. readonly normalized: boolean;
  6420. /**
  6421. * Gets the data type of each component in the array.
  6422. */
  6423. readonly type: number;
  6424. /**
  6425. * Constructor
  6426. * @param engine the engine
  6427. * @param data the data to use for this vertex buffer
  6428. * @param kind the vertex buffer kind
  6429. * @param updatable whether the data is updatable
  6430. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6431. * @param stride the stride (optional)
  6432. * @param instanced whether the buffer is instanced (optional)
  6433. * @param offset the offset of the data (optional)
  6434. * @param size the number of components (optional)
  6435. * @param type the type of the component (optional)
  6436. * @param normalized whether the data contains normalized data (optional)
  6437. * @param useBytes set to true if stride and offset are in bytes (optional)
  6438. * @param divisor defines the instance divisor to use (1 by default)
  6439. */
  6440. 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);
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /**
  6444. * Returns the kind of the VertexBuffer (string)
  6445. * @returns a string
  6446. */
  6447. getKind(): string;
  6448. /**
  6449. * Gets a boolean indicating if the VertexBuffer is updatable?
  6450. * @returns true if the buffer is updatable
  6451. */
  6452. isUpdatable(): boolean;
  6453. /**
  6454. * Gets current buffer's data
  6455. * @returns a DataArray or null
  6456. */
  6457. getData(): Nullable<DataArray>;
  6458. /**
  6459. * Gets underlying native buffer
  6460. * @returns underlying native buffer
  6461. */
  6462. getBuffer(): Nullable<DataBuffer>;
  6463. /**
  6464. * Gets the stride in float32 units (i.e. byte stride / 4).
  6465. * May not be an integer if the byte stride is not divisible by 4.
  6466. * @returns the stride in float32 units
  6467. * @deprecated Please use byteStride instead.
  6468. */
  6469. getStrideSize(): number;
  6470. /**
  6471. * Returns the offset as a multiple of the type byte length.
  6472. * @returns the offset in bytes
  6473. * @deprecated Please use byteOffset instead.
  6474. */
  6475. getOffset(): number;
  6476. /**
  6477. * Returns the number of components per vertex attribute (integer)
  6478. * @returns the size in float
  6479. */
  6480. getSize(): number;
  6481. /**
  6482. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6483. * @returns true if this buffer is instanced
  6484. */
  6485. getIsInstanced(): boolean;
  6486. /**
  6487. * Returns the instancing divisor, zero for non-instanced (integer).
  6488. * @returns a number
  6489. */
  6490. getInstanceDivisor(): number;
  6491. /**
  6492. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6493. * @param data defines the data to store
  6494. */
  6495. create(data?: DataArray): void;
  6496. /**
  6497. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6498. * This function will create a new buffer if the current one is not updatable
  6499. * @param data defines the data to store
  6500. */
  6501. update(data: DataArray): void;
  6502. /**
  6503. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6504. * Returns the directly updated WebGLBuffer.
  6505. * @param data the new data
  6506. * @param offset the new offset
  6507. * @param useBytes set to true if the offset is in bytes
  6508. */
  6509. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6510. /**
  6511. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6512. */
  6513. dispose(): void;
  6514. /**
  6515. * Enumerates each value of this vertex buffer as numbers.
  6516. * @param count the number of values to enumerate
  6517. * @param callback the callback function called for each value
  6518. */
  6519. forEach(count: number, callback: (value: number, index: number) => void): void;
  6520. /**
  6521. * Positions
  6522. */
  6523. static readonly PositionKind: string;
  6524. /**
  6525. * Normals
  6526. */
  6527. static readonly NormalKind: string;
  6528. /**
  6529. * Tangents
  6530. */
  6531. static readonly TangentKind: string;
  6532. /**
  6533. * Texture coordinates
  6534. */
  6535. static readonly UVKind: string;
  6536. /**
  6537. * Texture coordinates 2
  6538. */
  6539. static readonly UV2Kind: string;
  6540. /**
  6541. * Texture coordinates 3
  6542. */
  6543. static readonly UV3Kind: string;
  6544. /**
  6545. * Texture coordinates 4
  6546. */
  6547. static readonly UV4Kind: string;
  6548. /**
  6549. * Texture coordinates 5
  6550. */
  6551. static readonly UV5Kind: string;
  6552. /**
  6553. * Texture coordinates 6
  6554. */
  6555. static readonly UV6Kind: string;
  6556. /**
  6557. * Colors
  6558. */
  6559. static readonly ColorKind: string;
  6560. /**
  6561. * Matrix indices (for bones)
  6562. */
  6563. static readonly MatricesIndicesKind: string;
  6564. /**
  6565. * Matrix weights (for bones)
  6566. */
  6567. static readonly MatricesWeightsKind: string;
  6568. /**
  6569. * Additional matrix indices (for bones)
  6570. */
  6571. static readonly MatricesIndicesExtraKind: string;
  6572. /**
  6573. * Additional matrix weights (for bones)
  6574. */
  6575. static readonly MatricesWeightsExtraKind: string;
  6576. /**
  6577. * Deduces the stride given a kind.
  6578. * @param kind The kind string to deduce
  6579. * @returns The deduced stride
  6580. */
  6581. static DeduceStride(kind: string): number;
  6582. /**
  6583. * Gets the byte length of the given type.
  6584. * @param type the type
  6585. * @returns the number of bytes
  6586. */
  6587. static GetTypeByteLength(type: number): number;
  6588. /**
  6589. * Enumerates each value of the given parameters as numbers.
  6590. * @param data the data to enumerate
  6591. * @param byteOffset the byte offset of the data
  6592. * @param byteStride the byte stride of the data
  6593. * @param componentCount the number of components per element
  6594. * @param componentType the type of the component
  6595. * @param count the number of values to enumerate
  6596. * @param normalized whether the data is normalized
  6597. * @param callback the callback function called for each value
  6598. */
  6599. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6600. private static _GetFloatValue;
  6601. }
  6602. }
  6603. declare module BABYLON {
  6604. /**
  6605. * @hidden
  6606. */
  6607. export class IntersectionInfo {
  6608. bu: Nullable<number>;
  6609. bv: Nullable<number>;
  6610. distance: number;
  6611. faceId: number;
  6612. subMeshId: number;
  6613. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6614. }
  6615. }
  6616. declare module BABYLON {
  6617. /**
  6618. * Represens a plane by the equation ax + by + cz + d = 0
  6619. */
  6620. export class Plane {
  6621. private static _TmpMatrix;
  6622. /**
  6623. * Normal of the plane (a,b,c)
  6624. */
  6625. normal: Vector3;
  6626. /**
  6627. * d component of the plane
  6628. */
  6629. d: number;
  6630. /**
  6631. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6632. * @param a a component of the plane
  6633. * @param b b component of the plane
  6634. * @param c c component of the plane
  6635. * @param d d component of the plane
  6636. */
  6637. constructor(a: number, b: number, c: number, d: number);
  6638. /**
  6639. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6640. */
  6641. asArray(): number[];
  6642. /**
  6643. * @returns a new plane copied from the current Plane.
  6644. */
  6645. clone(): Plane;
  6646. /**
  6647. * @returns the string "Plane".
  6648. */
  6649. getClassName(): string;
  6650. /**
  6651. * @returns the Plane hash code.
  6652. */
  6653. getHashCode(): number;
  6654. /**
  6655. * Normalize the current Plane in place.
  6656. * @returns the updated Plane.
  6657. */
  6658. normalize(): Plane;
  6659. /**
  6660. * Applies a transformation the plane and returns the result
  6661. * @param transformation the transformation matrix to be applied to the plane
  6662. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6663. */
  6664. transform(transformation: DeepImmutable<Matrix>): Plane;
  6665. /**
  6666. * Calcualtte the dot product between the point and the plane normal
  6667. * @param point point to calculate the dot product with
  6668. * @returns the dot product (float) of the point coordinates and the plane normal.
  6669. */
  6670. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6671. /**
  6672. * Updates the current Plane from the plane defined by the three given points.
  6673. * @param point1 one of the points used to contruct the plane
  6674. * @param point2 one of the points used to contruct the plane
  6675. * @param point3 one of the points used to contruct the plane
  6676. * @returns the updated Plane.
  6677. */
  6678. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6679. /**
  6680. * Checks if the plane is facing a given direction
  6681. * @param direction the direction to check if the plane is facing
  6682. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6683. * @returns True is the vector "direction" is the same side than the plane normal.
  6684. */
  6685. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6686. /**
  6687. * Calculates the distance to a point
  6688. * @param point point to calculate distance to
  6689. * @returns the signed distance (float) from the given point to the Plane.
  6690. */
  6691. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6692. /**
  6693. * Creates a plane from an array
  6694. * @param array the array to create a plane from
  6695. * @returns a new Plane from the given array.
  6696. */
  6697. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6698. /**
  6699. * Creates a plane from three points
  6700. * @param point1 point used to create the plane
  6701. * @param point2 point used to create the plane
  6702. * @param point3 point used to create the plane
  6703. * @returns a new Plane defined by the three given points.
  6704. */
  6705. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6706. /**
  6707. * Creates a plane from an origin point and a normal
  6708. * @param origin origin of the plane to be constructed
  6709. * @param normal normal of the plane to be constructed
  6710. * @returns a new Plane the normal vector to this plane at the given origin point.
  6711. * Note : the vector "normal" is updated because normalized.
  6712. */
  6713. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6714. /**
  6715. * Calculates the distance from a plane and a point
  6716. * @param origin origin of the plane to be constructed
  6717. * @param normal normal of the plane to be constructed
  6718. * @param point point to calculate distance to
  6719. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6720. */
  6721. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6722. }
  6723. }
  6724. declare module BABYLON {
  6725. /**
  6726. * Class used to store bounding sphere information
  6727. */
  6728. export class BoundingSphere {
  6729. /**
  6730. * Gets the center of the bounding sphere in local space
  6731. */
  6732. readonly center: Vector3;
  6733. /**
  6734. * Radius of the bounding sphere in local space
  6735. */
  6736. radius: number;
  6737. /**
  6738. * Gets the center of the bounding sphere in world space
  6739. */
  6740. readonly centerWorld: Vector3;
  6741. /**
  6742. * Radius of the bounding sphere in world space
  6743. */
  6744. radiusWorld: number;
  6745. /**
  6746. * Gets the minimum vector in local space
  6747. */
  6748. readonly minimum: Vector3;
  6749. /**
  6750. * Gets the maximum vector in local space
  6751. */
  6752. readonly maximum: Vector3;
  6753. private _worldMatrix;
  6754. private static readonly TmpVector3;
  6755. /**
  6756. * Creates a new bounding sphere
  6757. * @param min defines the minimum vector (in local space)
  6758. * @param max defines the maximum vector (in local space)
  6759. * @param worldMatrix defines the new world matrix
  6760. */
  6761. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6762. /**
  6763. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6764. * @param min defines the new minimum vector (in local space)
  6765. * @param max defines the new maximum vector (in local space)
  6766. * @param worldMatrix defines the new world matrix
  6767. */
  6768. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6769. /**
  6770. * Scale the current bounding sphere by applying a scale factor
  6771. * @param factor defines the scale factor to apply
  6772. * @returns the current bounding box
  6773. */
  6774. scale(factor: number): BoundingSphere;
  6775. /**
  6776. * Gets the world matrix of the bounding box
  6777. * @returns a matrix
  6778. */
  6779. getWorldMatrix(): DeepImmutable<Matrix>;
  6780. /** @hidden */
  6781. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6782. /**
  6783. * Tests if the bounding sphere is intersecting the frustum planes
  6784. * @param frustumPlanes defines the frustum planes to test
  6785. * @returns true if there is an intersection
  6786. */
  6787. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6788. /**
  6789. * Tests if the bounding sphere center is in between the frustum planes.
  6790. * Used for optimistic fast inclusion.
  6791. * @param frustumPlanes defines the frustum planes to test
  6792. * @returns true if the sphere center is in between the frustum planes
  6793. */
  6794. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6795. /**
  6796. * Tests if a point is inside the bounding sphere
  6797. * @param point defines the point to test
  6798. * @returns true if the point is inside the bounding sphere
  6799. */
  6800. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6801. /**
  6802. * Checks if two sphere intersct
  6803. * @param sphere0 sphere 0
  6804. * @param sphere1 sphere 1
  6805. * @returns true if the speres intersect
  6806. */
  6807. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6808. }
  6809. }
  6810. declare module BABYLON {
  6811. /**
  6812. * Class used to store bounding box information
  6813. */
  6814. export class BoundingBox implements ICullable {
  6815. /**
  6816. * Gets the 8 vectors representing the bounding box in local space
  6817. */
  6818. readonly vectors: Vector3[];
  6819. /**
  6820. * Gets the center of the bounding box in local space
  6821. */
  6822. readonly center: Vector3;
  6823. /**
  6824. * Gets the center of the bounding box in world space
  6825. */
  6826. readonly centerWorld: Vector3;
  6827. /**
  6828. * Gets the extend size in local space
  6829. */
  6830. readonly extendSize: Vector3;
  6831. /**
  6832. * Gets the extend size in world space
  6833. */
  6834. readonly extendSizeWorld: Vector3;
  6835. /**
  6836. * Gets the OBB (object bounding box) directions
  6837. */
  6838. readonly directions: Vector3[];
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in world space
  6841. */
  6842. readonly vectorsWorld: Vector3[];
  6843. /**
  6844. * Gets the minimum vector in world space
  6845. */
  6846. readonly minimumWorld: Vector3;
  6847. /**
  6848. * Gets the maximum vector in world space
  6849. */
  6850. readonly maximumWorld: Vector3;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * @hidden
  6863. */
  6864. _tag: number;
  6865. /**
  6866. * Creates a new bounding box
  6867. * @param min defines the minimum vector (in local space)
  6868. * @param max defines the maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6872. /**
  6873. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6874. * @param min defines the new minimum vector (in local space)
  6875. * @param max defines the new maximum vector (in local space)
  6876. * @param worldMatrix defines the new world matrix
  6877. */
  6878. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6879. /**
  6880. * Scale the current bounding box by applying a scale factor
  6881. * @param factor defines the scale factor to apply
  6882. * @returns the current bounding box
  6883. */
  6884. scale(factor: number): BoundingBox;
  6885. /**
  6886. * Gets the world matrix of the bounding box
  6887. * @returns a matrix
  6888. */
  6889. getWorldMatrix(): DeepImmutable<Matrix>;
  6890. /** @hidden */
  6891. _update(world: DeepImmutable<Matrix>): void;
  6892. /**
  6893. * Tests if the bounding box is intersecting the frustum planes
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if the bounding box is entirely inside the frustum planes
  6900. * @param frustumPlanes defines the frustum planes to test
  6901. * @returns true if there is an inclusion
  6902. */
  6903. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6904. /**
  6905. * Tests if a point is inside the bounding box
  6906. * @param point defines the point to test
  6907. * @returns true if the point is inside the bounding box
  6908. */
  6909. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6910. /**
  6911. * Tests if the bounding box intersects with a bounding sphere
  6912. * @param sphere defines the sphere to test
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6916. /**
  6917. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6918. * @param min defines the min vector to use
  6919. * @param max defines the max vector to use
  6920. * @returns true if there is an intersection
  6921. */
  6922. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6923. /**
  6924. * Tests if two bounding boxes are intersections
  6925. * @param box0 defines the first box to test
  6926. * @param box1 defines the second box to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6930. /**
  6931. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6932. * @param minPoint defines the minimum vector of the bounding box
  6933. * @param maxPoint defines the maximum vector of the bounding box
  6934. * @param sphereCenter defines the sphere center
  6935. * @param sphereRadius defines the sphere radius
  6936. * @returns true if there is an intersection
  6937. */
  6938. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an inclusion
  6944. */
  6945. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6948. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @return true if there is an intersection
  6951. */
  6952. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. }
  6954. }
  6955. declare module BABYLON {
  6956. /** @hidden */
  6957. export class Collider {
  6958. /** Define if a collision was found */
  6959. collisionFound: boolean;
  6960. /**
  6961. * Define last intersection point in local space
  6962. */
  6963. intersectionPoint: Vector3;
  6964. /**
  6965. * Define last collided mesh
  6966. */
  6967. collidedMesh: Nullable<AbstractMesh>;
  6968. private _collisionPoint;
  6969. private _planeIntersectionPoint;
  6970. private _tempVector;
  6971. private _tempVector2;
  6972. private _tempVector3;
  6973. private _tempVector4;
  6974. private _edge;
  6975. private _baseToVertex;
  6976. private _destinationPoint;
  6977. private _slidePlaneNormal;
  6978. private _displacementVector;
  6979. /** @hidden */
  6980. _radius: Vector3;
  6981. /** @hidden */
  6982. _retry: number;
  6983. private _velocity;
  6984. private _basePoint;
  6985. private _epsilon;
  6986. /** @hidden */
  6987. _velocityWorldLength: number;
  6988. /** @hidden */
  6989. _basePointWorld: Vector3;
  6990. private _velocityWorld;
  6991. private _normalizedVelocity;
  6992. /** @hidden */
  6993. _initialVelocity: Vector3;
  6994. /** @hidden */
  6995. _initialPosition: Vector3;
  6996. private _nearestDistance;
  6997. private _collisionMask;
  6998. get collisionMask(): number;
  6999. set collisionMask(mask: number);
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. get slidePlaneNormal(): Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module BABYLON {
  7019. /**
  7020. * Interface for cullable objects
  7021. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7022. */
  7023. export interface ICullable {
  7024. /**
  7025. * Checks if the object or part of the object is in the frustum
  7026. * @param frustumPlanes Camera near/planes
  7027. * @returns true if the object is in frustum otherwise false
  7028. */
  7029. isInFrustum(frustumPlanes: Plane[]): boolean;
  7030. /**
  7031. * Checks if a cullable object (mesh...) is in the camera frustum
  7032. * Unlike isInFrustum this cheks the full bounding box
  7033. * @param frustumPlanes Camera near/planes
  7034. * @returns true if the object is in frustum otherwise false
  7035. */
  7036. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7037. }
  7038. /**
  7039. * Info for a bounding data of a mesh
  7040. */
  7041. export class BoundingInfo implements ICullable {
  7042. /**
  7043. * Bounding box for the mesh
  7044. */
  7045. readonly boundingBox: BoundingBox;
  7046. /**
  7047. * Bounding sphere for the mesh
  7048. */
  7049. readonly boundingSphere: BoundingSphere;
  7050. private _isLocked;
  7051. private static readonly TmpVector3;
  7052. /**
  7053. * Constructs bounding info
  7054. * @param minimum min vector of the bounding box/sphere
  7055. * @param maximum max vector of the bounding box/sphere
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7059. /**
  7060. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7061. * @param min defines the new minimum vector (in local space)
  7062. * @param max defines the new maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * min vector of the bounding box/sphere
  7068. */
  7069. get minimum(): Vector3;
  7070. /**
  7071. * max vector of the bounding box/sphere
  7072. */
  7073. get maximum(): Vector3;
  7074. /**
  7075. * If the info is locked and won't be updated to avoid perf overhead
  7076. */
  7077. get isLocked(): boolean;
  7078. set isLocked(value: boolean);
  7079. /**
  7080. * Updates the bounding sphere and box
  7081. * @param world world matrix to be used to update
  7082. */
  7083. update(world: DeepImmutable<Matrix>): void;
  7084. /**
  7085. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7086. * @param center New center of the bounding info
  7087. * @param extend New extend of the bounding info
  7088. * @returns the current bounding info
  7089. */
  7090. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7091. /**
  7092. * Scale the current bounding info by applying a scale factor
  7093. * @param factor defines the scale factor to apply
  7094. * @returns the current bounding info
  7095. */
  7096. scale(factor: number): BoundingInfo;
  7097. /**
  7098. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7099. * @param frustumPlanes defines the frustum to test
  7100. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7101. * @returns true if the bounding info is in the frustum planes
  7102. */
  7103. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7104. /**
  7105. * Gets the world distance between the min and max points of the bounding box
  7106. */
  7107. get diagonalLength(): number;
  7108. /**
  7109. * Checks if a cullable object (mesh...) is in the camera frustum
  7110. * Unlike isInFrustum this cheks the full bounding box
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7115. /** @hidden */
  7116. _checkCollision(collider: Collider): boolean;
  7117. /**
  7118. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7119. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7120. * @param point the point to check intersection with
  7121. * @returns if the point intersects
  7122. */
  7123. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7124. /**
  7125. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7126. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7127. * @param boundingInfo the bounding info to check intersection with
  7128. * @param precise if the intersection should be done using OBB
  7129. * @returns if the bounding info intersects
  7130. */
  7131. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7132. }
  7133. }
  7134. declare module BABYLON {
  7135. /**
  7136. * Extracts minimum and maximum values from a list of indexed positions
  7137. * @param positions defines the positions to use
  7138. * @param indices defines the indices to the positions
  7139. * @param indexStart defines the start index
  7140. * @param indexCount defines the end index
  7141. * @param bias defines bias value to add to the result
  7142. * @return minimum and maximum values
  7143. */
  7144. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7145. minimum: Vector3;
  7146. maximum: Vector3;
  7147. };
  7148. /**
  7149. * Extracts minimum and maximum values from a list of positions
  7150. * @param positions defines the positions to use
  7151. * @param start defines the start index in the positions array
  7152. * @param count defines the number of positions to handle
  7153. * @param bias defines bias value to add to the result
  7154. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7155. * @return minimum and maximum values
  7156. */
  7157. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7158. minimum: Vector3;
  7159. maximum: Vector3;
  7160. };
  7161. }
  7162. declare module BABYLON {
  7163. /** @hidden */
  7164. export class WebGLDataBuffer extends DataBuffer {
  7165. private _buffer;
  7166. constructor(resource: WebGLBuffer);
  7167. get underlyingResource(): any;
  7168. }
  7169. }
  7170. declare module BABYLON {
  7171. /** @hidden */
  7172. export class WebGLPipelineContext implements IPipelineContext {
  7173. engine: ThinEngine;
  7174. program: Nullable<WebGLProgram>;
  7175. context?: WebGLRenderingContext;
  7176. vertexShader?: WebGLShader;
  7177. fragmentShader?: WebGLShader;
  7178. isParallelCompiled: boolean;
  7179. onCompiled?: () => void;
  7180. transformFeedback?: WebGLTransformFeedback | null;
  7181. vertexCompilationError: Nullable<string>;
  7182. fragmentCompilationError: Nullable<string>;
  7183. programLinkError: Nullable<string>;
  7184. programValidationError: Nullable<string>;
  7185. get isAsync(): boolean;
  7186. get isReady(): boolean;
  7187. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7188. _getVertexShaderCode(): string | null;
  7189. _getFragmentShaderCode(): string | null;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. declare module BABYLON {
  7238. /**
  7239. * Uniform buffer objects.
  7240. *
  7241. * Handles blocks of uniform on the GPU.
  7242. *
  7243. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7244. *
  7245. * For more information, please refer to :
  7246. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7247. */
  7248. export class UniformBuffer {
  7249. private _engine;
  7250. private _buffer;
  7251. private _data;
  7252. private _bufferData;
  7253. private _dynamic?;
  7254. private _uniformLocations;
  7255. private _uniformSizes;
  7256. private _uniformLocationPointer;
  7257. private _needSync;
  7258. private _noUBO;
  7259. private _currentEffect;
  7260. /** @hidden */
  7261. _alreadyBound: boolean;
  7262. private static _MAX_UNIFORM_SIZE;
  7263. private static _tempBuffer;
  7264. /**
  7265. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7270. /**
  7271. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7276. /**
  7277. * Lambda to Update a single float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat: (name: string, x: number) => void;
  7282. /**
  7283. * Lambda to Update a vec2 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a vec3 of float in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7294. /**
  7295. * Lambda to Update a vec4 of float in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7300. /**
  7301. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateMatrix: (name: string, mat: Matrix) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateVector3: (name: string, vector: Vector3) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateVector4: (name: string, vector: Vector4) => void;
  7318. /**
  7319. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7320. * This is dynamic to allow compat with webgl 1 and 2.
  7321. * You will need to pass the name of the uniform as well as the value.
  7322. */
  7323. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7324. /**
  7325. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7326. * This is dynamic to allow compat with webgl 1 and 2.
  7327. * You will need to pass the name of the uniform as well as the value.
  7328. */
  7329. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7330. /**
  7331. * Instantiates a new Uniform buffer objects.
  7332. *
  7333. * Handles blocks of uniform on the GPU.
  7334. *
  7335. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7336. *
  7337. * For more information, please refer to :
  7338. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7339. * @param engine Define the engine the buffer is associated with
  7340. * @param data Define the data contained in the buffer
  7341. * @param dynamic Define if the buffer is updatable
  7342. */
  7343. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7344. /**
  7345. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7346. * or just falling back on setUniformXXX calls.
  7347. */
  7348. get useUbo(): boolean;
  7349. /**
  7350. * Indicates if the WebGL underlying uniform buffer is in sync
  7351. * with the javascript cache data.
  7352. */
  7353. get isSync(): boolean;
  7354. /**
  7355. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7356. * Also, a dynamic UniformBuffer will disable cache verification and always
  7357. * update the underlying WebGL uniform buffer to the GPU.
  7358. * @returns if Dynamic, otherwise false
  7359. */
  7360. isDynamic(): boolean;
  7361. /**
  7362. * The data cache on JS side.
  7363. * @returns the underlying data as a float array
  7364. */
  7365. getData(): Float32Array;
  7366. /**
  7367. * The underlying WebGL Uniform buffer.
  7368. * @returns the webgl buffer
  7369. */
  7370. getBuffer(): Nullable<DataBuffer>;
  7371. /**
  7372. * std140 layout specifies how to align data within an UBO structure.
  7373. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7374. * for specs.
  7375. */
  7376. private _fillAlignment;
  7377. /**
  7378. * Adds an uniform in the buffer.
  7379. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7380. * for the layout to be correct !
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param size Data size, or data directly.
  7383. */
  7384. addUniform(name: string, size: number | number[]): void;
  7385. /**
  7386. * Adds a Matrix 4x4 to the uniform buffer.
  7387. * @param name Name of the uniform, as used in the uniform block in the shader.
  7388. * @param mat A 4x4 matrix.
  7389. */
  7390. addMatrix(name: string, mat: Matrix): void;
  7391. /**
  7392. * Adds a vec2 to the uniform buffer.
  7393. * @param name Name of the uniform, as used in the uniform block in the shader.
  7394. * @param x Define the x component value of the vec2
  7395. * @param y Define the y component value of the vec2
  7396. */
  7397. addFloat2(name: string, x: number, y: number): void;
  7398. /**
  7399. * Adds a vec3 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param x Define the x component value of the vec3
  7402. * @param y Define the y component value of the vec3
  7403. * @param z Define the z component value of the vec3
  7404. */
  7405. addFloat3(name: string, x: number, y: number, z: number): void;
  7406. /**
  7407. * Adds a vec3 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param color Define the vec3 from a Color
  7410. */
  7411. addColor3(name: string, color: Color3): void;
  7412. /**
  7413. * Adds a vec4 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param color Define the rgb components from a Color
  7416. * @param alpha Define the a component of the vec4
  7417. */
  7418. addColor4(name: string, color: Color3, alpha: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param vector Define the vec3 components from a Vector
  7423. */
  7424. addVector3(name: string, vector: Vector3): void;
  7425. /**
  7426. * Adds a Matrix 3x3 to the uniform buffer.
  7427. * @param name Name of the uniform, as used in the uniform block in the shader.
  7428. */
  7429. addMatrix3x3(name: string): void;
  7430. /**
  7431. * Adds a Matrix 2x2 to the uniform buffer.
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. */
  7434. addMatrix2x2(name: string): void;
  7435. /**
  7436. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7437. */
  7438. create(): void;
  7439. /** @hidden */
  7440. _rebuild(): void;
  7441. /**
  7442. * Updates the WebGL Uniform Buffer on the GPU.
  7443. * If the `dynamic` flag is set to true, no cache comparison is done.
  7444. * Otherwise, the buffer will be updated only if the cache differs.
  7445. */
  7446. update(): void;
  7447. /**
  7448. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7449. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7450. * @param data Define the flattened data
  7451. * @param size Define the size of the data.
  7452. */
  7453. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7454. private _valueCache;
  7455. private _cacheMatrix;
  7456. private _updateMatrix3x3ForUniform;
  7457. private _updateMatrix3x3ForEffect;
  7458. private _updateMatrix2x2ForEffect;
  7459. private _updateMatrix2x2ForUniform;
  7460. private _updateFloatForEffect;
  7461. private _updateFloatForUniform;
  7462. private _updateFloat2ForEffect;
  7463. private _updateFloat2ForUniform;
  7464. private _updateFloat3ForEffect;
  7465. private _updateFloat3ForUniform;
  7466. private _updateFloat4ForEffect;
  7467. private _updateFloat4ForUniform;
  7468. private _updateMatrixForEffect;
  7469. private _updateMatrixForUniform;
  7470. private _updateVector3ForEffect;
  7471. private _updateVector3ForUniform;
  7472. private _updateVector4ForEffect;
  7473. private _updateVector4ForUniform;
  7474. private _updateColor3ForEffect;
  7475. private _updateColor3ForUniform;
  7476. private _updateColor4ForEffect;
  7477. private _updateColor4ForUniform;
  7478. /**
  7479. * Sets a sampler uniform on the effect.
  7480. * @param name Define the name of the sampler.
  7481. * @param texture Define the texture to set in the sampler
  7482. */
  7483. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7484. /**
  7485. * Directly updates the value of the uniform in the cache AND on the GPU.
  7486. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7487. * @param data Define the flattened data
  7488. */
  7489. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7490. /**
  7491. * Binds this uniform buffer to an effect.
  7492. * @param effect Define the effect to bind the buffer to
  7493. * @param name Name of the uniform block in the shader.
  7494. */
  7495. bindToEffect(effect: Effect, name: string): void;
  7496. /**
  7497. * Disposes the uniform buffer.
  7498. */
  7499. dispose(): void;
  7500. }
  7501. }
  7502. declare module BABYLON {
  7503. /**
  7504. * Enum that determines the text-wrapping mode to use.
  7505. */
  7506. export enum InspectableType {
  7507. /**
  7508. * Checkbox for booleans
  7509. */
  7510. Checkbox = 0,
  7511. /**
  7512. * Sliders for numbers
  7513. */
  7514. Slider = 1,
  7515. /**
  7516. * Vector3
  7517. */
  7518. Vector3 = 2,
  7519. /**
  7520. * Quaternions
  7521. */
  7522. Quaternion = 3,
  7523. /**
  7524. * Color3
  7525. */
  7526. Color3 = 4,
  7527. /**
  7528. * String
  7529. */
  7530. String = 5
  7531. }
  7532. /**
  7533. * Interface used to define custom inspectable properties.
  7534. * This interface is used by the inspector to display custom property grids
  7535. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7536. */
  7537. export interface IInspectable {
  7538. /**
  7539. * Gets the label to display
  7540. */
  7541. label: string;
  7542. /**
  7543. * Gets the name of the property to edit
  7544. */
  7545. propertyName: string;
  7546. /**
  7547. * Gets the type of the editor to use
  7548. */
  7549. type: InspectableType;
  7550. /**
  7551. * Gets the minimum value of the property when using in "slider" mode
  7552. */
  7553. min?: number;
  7554. /**
  7555. * Gets the maximum value of the property when using in "slider" mode
  7556. */
  7557. max?: number;
  7558. /**
  7559. * Gets the setp to use when using in "slider" mode
  7560. */
  7561. step?: number;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to provide helper for timing
  7567. */
  7568. export class TimingTools {
  7569. /**
  7570. * Polyfill for setImmediate
  7571. * @param action defines the action to execute after the current execution block
  7572. */
  7573. static SetImmediate(action: () => void): void;
  7574. }
  7575. }
  7576. declare module BABYLON {
  7577. /**
  7578. * Class used to enable instatition of objects by class name
  7579. */
  7580. export class InstantiationTools {
  7581. /**
  7582. * Use this object to register external classes like custom textures or material
  7583. * to allow the laoders to instantiate them
  7584. */
  7585. static RegisteredExternalClasses: {
  7586. [key: string]: Object;
  7587. };
  7588. /**
  7589. * Tries to instantiate a new object from a given class name
  7590. * @param className defines the class name to instantiate
  7591. * @returns the new object or null if the system was not able to do the instantiation
  7592. */
  7593. static Instantiate(className: string): any;
  7594. }
  7595. }
  7596. declare module BABYLON {
  7597. /**
  7598. * Define options used to create a depth texture
  7599. */
  7600. export class DepthTextureCreationOptions {
  7601. /** Specifies whether or not a stencil should be allocated in the texture */
  7602. generateStencil?: boolean;
  7603. /** Specifies whether or not bilinear filtering is enable on the texture */
  7604. bilinearFiltering?: boolean;
  7605. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7606. comparisonFunction?: number;
  7607. /** Specifies if the created texture is a cube texture */
  7608. isCube?: boolean;
  7609. }
  7610. }
  7611. declare module BABYLON {
  7612. interface ThinEngine {
  7613. /**
  7614. * Creates a depth stencil cube texture.
  7615. * This is only available in WebGL 2.
  7616. * @param size The size of face edge in the cube texture.
  7617. * @param options The options defining the cube texture.
  7618. * @returns The cube texture
  7619. */
  7620. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. 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>): InternalTexture;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @returns the cube texture as an InternalTexture
  7649. */
  7650. 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;
  7651. /**
  7652. * Creates a cube texture
  7653. * @param rootUrl defines the url where the files to load is located
  7654. * @param scene defines the current scene
  7655. * @param files defines the list of files to load (1 per face)
  7656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7657. * @param onLoad defines an optional callback raised when the texture is loaded
  7658. * @param onError defines an optional callback raised if there is an issue to load the texture
  7659. * @param format defines the format of the data
  7660. * @param forcedExtension defines the extension to use to pick the right loader
  7661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /** @hidden */
  7668. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7671. /** @hidden */
  7672. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /** @hidden */
  7674. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7675. /**
  7676. * @hidden
  7677. */
  7678. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7679. }
  7680. }
  7681. declare module BABYLON {
  7682. /**
  7683. * Class for creating a cube texture
  7684. */
  7685. export class CubeTexture extends BaseTexture {
  7686. private _delayedOnLoad;
  7687. /**
  7688. * Observable triggered once the texture has been loaded.
  7689. */
  7690. onLoadObservable: Observable<CubeTexture>;
  7691. /**
  7692. * The url of the texture
  7693. */
  7694. url: string;
  7695. /**
  7696. * Gets or sets the center of the bounding box associated with the cube texture.
  7697. * It must define where the camera used to render the texture was set
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. boundingBoxPosition: Vector3;
  7701. private _boundingBoxSize;
  7702. /**
  7703. * Gets or sets the size of the bounding box associated with the cube texture
  7704. * When defined, the cubemap will switch to local mode
  7705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7706. * @example https://www.babylonjs-playground.com/#RNASML
  7707. */
  7708. set boundingBoxSize(value: Vector3);
  7709. /**
  7710. * Returns the bounding box size
  7711. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7712. */
  7713. get boundingBoxSize(): Vector3;
  7714. protected _rotationY: number;
  7715. /**
  7716. * Sets texture matrix rotation angle around Y axis in radians.
  7717. */
  7718. set rotationY(value: number);
  7719. /**
  7720. * Gets texture matrix rotation angle around Y axis radians.
  7721. */
  7722. get rotationY(): number;
  7723. /**
  7724. * Are mip maps generated for this texture or not.
  7725. */
  7726. get noMipmap(): boolean;
  7727. private _noMipmap;
  7728. private _files;
  7729. protected _forcedExtension: Nullable<string>;
  7730. private _extensions;
  7731. private _textureMatrix;
  7732. private _format;
  7733. private _createPolynomials;
  7734. /** @hidden */
  7735. _prefiltered: boolean;
  7736. /**
  7737. * Creates a cube texture from an array of image urls
  7738. * @param files defines an array of image urls
  7739. * @param scene defines the hosting scene
  7740. * @param noMipmap specifies if mip maps are not used
  7741. * @returns a cube texture
  7742. */
  7743. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7744. /**
  7745. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7746. * @param url defines the url of the prefiltered texture
  7747. * @param scene defines the scene the texture is attached to
  7748. * @param forcedExtension defines the extension of the file if different from the url
  7749. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7750. * @return the prefiltered texture
  7751. */
  7752. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7753. /**
  7754. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7755. * as prefiltered data.
  7756. * @param rootUrl defines the url of the texture or the root name of the six images
  7757. * @param scene defines the scene the texture is attached to
  7758. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7759. * @param noMipmap defines if mipmaps should be created or not
  7760. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7761. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7762. * @param onError defines a callback triggered in case of error during load
  7763. * @param format defines the internal format to use for the texture once loaded
  7764. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7765. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7766. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7767. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7768. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7769. * @return the cube texture
  7770. */
  7771. 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);
  7772. /**
  7773. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7774. */
  7775. get isPrefiltered(): boolean;
  7776. /**
  7777. * Get the current class name of the texture useful for serialization or dynamic coding.
  7778. * @returns "CubeTexture"
  7779. */
  7780. getClassName(): string;
  7781. /**
  7782. * Update the url (and optional buffer) of this texture if url was null during construction.
  7783. * @param url the url of the texture
  7784. * @param forcedExtension defines the extension to use
  7785. * @param onLoad callback called when the texture is loaded (defaults to null)
  7786. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7787. */
  7788. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7789. /**
  7790. * Delays loading of the cube texture
  7791. * @param forcedExtension defines the extension to use
  7792. */
  7793. delayLoad(forcedExtension?: string): void;
  7794. /**
  7795. * Returns the reflection texture matrix
  7796. * @returns the reflection texture matrix
  7797. */
  7798. getReflectionTextureMatrix(): Matrix;
  7799. /**
  7800. * Sets the reflection texture matrix
  7801. * @param value Reflection texture matrix
  7802. */
  7803. setReflectionTextureMatrix(value: Matrix): void;
  7804. /**
  7805. * Parses text to create a cube texture
  7806. * @param parsedTexture define the serialized text to read from
  7807. * @param scene defines the hosting scene
  7808. * @param rootUrl defines the root url of the cube texture
  7809. * @returns a cube texture
  7810. */
  7811. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7812. /**
  7813. * Makes a clone, or deep copy, of the cube texture
  7814. * @returns a new cube texture
  7815. */
  7816. clone(): CubeTexture;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * Manages the defines for the Material
  7822. */
  7823. export class MaterialDefines {
  7824. /** @hidden */
  7825. protected _keys: string[];
  7826. private _isDirty;
  7827. /** @hidden */
  7828. _renderId: number;
  7829. /** @hidden */
  7830. _areLightsDirty: boolean;
  7831. /** @hidden */
  7832. _areLightsDisposed: boolean;
  7833. /** @hidden */
  7834. _areAttributesDirty: boolean;
  7835. /** @hidden */
  7836. _areTexturesDirty: boolean;
  7837. /** @hidden */
  7838. _areFresnelDirty: boolean;
  7839. /** @hidden */
  7840. _areMiscDirty: boolean;
  7841. /** @hidden */
  7842. _areImageProcessingDirty: boolean;
  7843. /** @hidden */
  7844. _normals: boolean;
  7845. /** @hidden */
  7846. _uvs: boolean;
  7847. /** @hidden */
  7848. _needNormals: boolean;
  7849. /** @hidden */
  7850. _needUVs: boolean;
  7851. [id: string]: any;
  7852. /**
  7853. * Specifies if the material needs to be re-calculated
  7854. */
  7855. get isDirty(): boolean;
  7856. /**
  7857. * Marks the material to indicate that it has been re-calculated
  7858. */
  7859. markAsProcessed(): void;
  7860. /**
  7861. * Marks the material to indicate that it needs to be re-calculated
  7862. */
  7863. markAsUnprocessed(): void;
  7864. /**
  7865. * Marks the material to indicate all of its defines need to be re-calculated
  7866. */
  7867. markAllAsDirty(): void;
  7868. /**
  7869. * Marks the material to indicate that image processing needs to be re-calculated
  7870. */
  7871. markAsImageProcessingDirty(): void;
  7872. /**
  7873. * Marks the material to indicate the lights need to be re-calculated
  7874. * @param disposed Defines whether the light is dirty due to dispose or not
  7875. */
  7876. markAsLightDirty(disposed?: boolean): void;
  7877. /**
  7878. * Marks the attribute state as changed
  7879. */
  7880. markAsAttributesDirty(): void;
  7881. /**
  7882. * Marks the texture state as changed
  7883. */
  7884. markAsTexturesDirty(): void;
  7885. /**
  7886. * Marks the fresnel state as changed
  7887. */
  7888. markAsFresnelDirty(): void;
  7889. /**
  7890. * Marks the misc state as changed
  7891. */
  7892. markAsMiscDirty(): void;
  7893. /**
  7894. * Rebuilds the material defines
  7895. */
  7896. rebuild(): void;
  7897. /**
  7898. * Specifies if two material defines are equal
  7899. * @param other - A material define instance to compare to
  7900. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7901. */
  7902. isEqual(other: MaterialDefines): boolean;
  7903. /**
  7904. * Clones this instance's defines to another instance
  7905. * @param other - material defines to clone values to
  7906. */
  7907. cloneTo(other: MaterialDefines): void;
  7908. /**
  7909. * Resets the material define values
  7910. */
  7911. reset(): void;
  7912. /**
  7913. * Converts the material define values to a string
  7914. * @returns - String of material define information
  7915. */
  7916. toString(): string;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7923. * 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;
  7924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7925. */
  7926. export class ColorCurves {
  7927. private _dirty;
  7928. private _tempColor;
  7929. private _globalCurve;
  7930. private _highlightsCurve;
  7931. private _midtonesCurve;
  7932. private _shadowsCurve;
  7933. private _positiveCurve;
  7934. private _negativeCurve;
  7935. private _globalHue;
  7936. private _globalDensity;
  7937. private _globalSaturation;
  7938. private _globalExposure;
  7939. /**
  7940. * Gets the global Hue value.
  7941. * 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).
  7942. */
  7943. get globalHue(): number;
  7944. /**
  7945. * Sets the global Hue value.
  7946. * 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).
  7947. */
  7948. set globalHue(value: number);
  7949. /**
  7950. * Gets the global Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. get globalDensity(): number;
  7955. /**
  7956. * Sets the global Density value.
  7957. * 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.
  7958. * Values less than zero provide a filter of opposite hue.
  7959. */
  7960. set globalDensity(value: number);
  7961. /**
  7962. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  7964. */
  7965. get globalSaturation(): number;
  7966. /**
  7967. * Sets the global Saturation value.
  7968. * 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.
  7969. */
  7970. set globalSaturation(value: number);
  7971. /**
  7972. * Gets the global Exposure value.
  7973. * 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.
  7974. */
  7975. get globalExposure(): number;
  7976. /**
  7977. * Sets the global Exposure value.
  7978. * 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.
  7979. */
  7980. set globalExposure(value: number);
  7981. private _highlightsHue;
  7982. private _highlightsDensity;
  7983. private _highlightsSaturation;
  7984. private _highlightsExposure;
  7985. /**
  7986. * Gets the highlights Hue value.
  7987. * 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).
  7988. */
  7989. get highlightsHue(): number;
  7990. /**
  7991. * Sets the highlights Hue value.
  7992. * 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).
  7993. */
  7994. set highlightsHue(value: number);
  7995. /**
  7996. * Gets the highlights Density value.
  7997. * 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.
  7998. * Values less than zero provide a filter of opposite hue.
  7999. */
  8000. get highlightsDensity(): number;
  8001. /**
  8002. * Sets the highlights Density value.
  8003. * 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.
  8004. * Values less than zero provide a filter of opposite hue.
  8005. */
  8006. set highlightsDensity(value: number);
  8007. /**
  8008. * Gets the highlights Saturation value.
  8009. * 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.
  8010. */
  8011. get highlightsSaturation(): number;
  8012. /**
  8013. * Sets the highlights Saturation value.
  8014. * 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.
  8015. */
  8016. set highlightsSaturation(value: number);
  8017. /**
  8018. * Gets the highlights Exposure value.
  8019. * 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.
  8020. */
  8021. get highlightsExposure(): number;
  8022. /**
  8023. * Sets the highlights Exposure value.
  8024. * 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.
  8025. */
  8026. set highlightsExposure(value: number);
  8027. private _midtonesHue;
  8028. private _midtonesDensity;
  8029. private _midtonesSaturation;
  8030. private _midtonesExposure;
  8031. /**
  8032. * Gets the midtones Hue value.
  8033. * 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).
  8034. */
  8035. get midtonesHue(): number;
  8036. /**
  8037. * Sets the midtones Hue value.
  8038. * 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).
  8039. */
  8040. set midtonesHue(value: number);
  8041. /**
  8042. * Gets the midtones Density value.
  8043. * 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.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. get midtonesDensity(): number;
  8047. /**
  8048. * Sets the midtones Density value.
  8049. * 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.
  8050. * Values less than zero provide a filter of opposite hue.
  8051. */
  8052. set midtonesDensity(value: number);
  8053. /**
  8054. * Gets the midtones Saturation value.
  8055. * 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.
  8056. */
  8057. get midtonesSaturation(): number;
  8058. /**
  8059. * Sets the midtones Saturation value.
  8060. * 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.
  8061. */
  8062. set midtonesSaturation(value: number);
  8063. /**
  8064. * Gets the midtones Exposure value.
  8065. * 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.
  8066. */
  8067. get midtonesExposure(): number;
  8068. /**
  8069. * Sets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. set midtonesExposure(value: number);
  8073. private _shadowsHue;
  8074. private _shadowsDensity;
  8075. private _shadowsSaturation;
  8076. private _shadowsExposure;
  8077. /**
  8078. * Gets the shadows Hue value.
  8079. * 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).
  8080. */
  8081. get shadowsHue(): number;
  8082. /**
  8083. * Sets the shadows Hue value.
  8084. * 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).
  8085. */
  8086. set shadowsHue(value: number);
  8087. /**
  8088. * Gets the shadows Density value.
  8089. * 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.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. get shadowsDensity(): number;
  8093. /**
  8094. * Sets the shadows Density value.
  8095. * 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.
  8096. * Values less than zero provide a filter of opposite hue.
  8097. */
  8098. set shadowsDensity(value: number);
  8099. /**
  8100. * Gets the shadows Saturation value.
  8101. * 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.
  8102. */
  8103. get shadowsSaturation(): number;
  8104. /**
  8105. * Sets the shadows Saturation value.
  8106. * 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.
  8107. */
  8108. set shadowsSaturation(value: number);
  8109. /**
  8110. * Gets the shadows Exposure value.
  8111. * 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.
  8112. */
  8113. get shadowsExposure(): number;
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. set shadowsExposure(value: number);
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module BABYLON {
  8188. /**
  8189. * Interface to follow in your material defines to integrate easily the
  8190. * Image proccessing functions.
  8191. * @hidden
  8192. */
  8193. export interface IImageProcessingConfigurationDefines {
  8194. IMAGEPROCESSING: boolean;
  8195. VIGNETTE: boolean;
  8196. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8197. VIGNETTEBLENDMODEOPAQUE: boolean;
  8198. TONEMAPPING: boolean;
  8199. TONEMAPPING_ACES: boolean;
  8200. CONTRAST: boolean;
  8201. EXPOSURE: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. }
  8209. /**
  8210. * @hidden
  8211. */
  8212. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8213. IMAGEPROCESSING: boolean;
  8214. VIGNETTE: boolean;
  8215. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8216. VIGNETTEBLENDMODEOPAQUE: boolean;
  8217. TONEMAPPING: boolean;
  8218. TONEMAPPING_ACES: boolean;
  8219. CONTRAST: boolean;
  8220. COLORCURVES: boolean;
  8221. COLORGRADING: boolean;
  8222. COLORGRADING3D: boolean;
  8223. SAMPLER3DGREENDEPTH: boolean;
  8224. SAMPLER3DBGRMAP: boolean;
  8225. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8226. EXPOSURE: boolean;
  8227. constructor();
  8228. }
  8229. /**
  8230. * This groups together the common properties used for image processing either in direct forward pass
  8231. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8232. * or not.
  8233. */
  8234. export class ImageProcessingConfiguration {
  8235. /**
  8236. * Default tone mapping applied in BabylonJS.
  8237. */
  8238. static readonly TONEMAPPING_STANDARD: number;
  8239. /**
  8240. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8241. * to other engines rendering to increase portability.
  8242. */
  8243. static readonly TONEMAPPING_ACES: number;
  8244. /**
  8245. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8246. */
  8247. colorCurves: Nullable<ColorCurves>;
  8248. private _colorCurvesEnabled;
  8249. /**
  8250. * Gets wether the color curves effect is enabled.
  8251. */
  8252. get colorCurvesEnabled(): boolean;
  8253. /**
  8254. * Sets wether the color curves effect is enabled.
  8255. */
  8256. set colorCurvesEnabled(value: boolean);
  8257. private _colorGradingTexture;
  8258. /**
  8259. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8260. */
  8261. get colorGradingTexture(): Nullable<BaseTexture>;
  8262. /**
  8263. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8264. */
  8265. set colorGradingTexture(value: Nullable<BaseTexture>);
  8266. private _colorGradingEnabled;
  8267. /**
  8268. * Gets wether the color grading effect is enabled.
  8269. */
  8270. get colorGradingEnabled(): boolean;
  8271. /**
  8272. * Sets wether the color grading effect is enabled.
  8273. */
  8274. set colorGradingEnabled(value: boolean);
  8275. private _colorGradingWithGreenDepth;
  8276. /**
  8277. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8278. */
  8279. get colorGradingWithGreenDepth(): boolean;
  8280. /**
  8281. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. set colorGradingWithGreenDepth(value: boolean);
  8284. private _colorGradingBGR;
  8285. /**
  8286. * Gets wether the color grading texture contains BGR values.
  8287. */
  8288. get colorGradingBGR(): boolean;
  8289. /**
  8290. * Sets wether the color grading texture contains BGR values.
  8291. */
  8292. set colorGradingBGR(value: boolean);
  8293. /** @hidden */
  8294. _exposure: number;
  8295. /**
  8296. * Gets the Exposure used in the effect.
  8297. */
  8298. get exposure(): number;
  8299. /**
  8300. * Sets the Exposure used in the effect.
  8301. */
  8302. set exposure(value: number);
  8303. private _toneMappingEnabled;
  8304. /**
  8305. * Gets wether the tone mapping effect is enabled.
  8306. */
  8307. get toneMappingEnabled(): boolean;
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. set toneMappingEnabled(value: boolean);
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. get toneMappingType(): number;
  8317. /**
  8318. * Sets the type of tone mapping effect used in BabylonJS.
  8319. */
  8320. set toneMappingType(value: number);
  8321. protected _contrast: number;
  8322. /**
  8323. * Gets the contrast used in the effect.
  8324. */
  8325. get contrast(): number;
  8326. /**
  8327. * Sets the contrast used in the effect.
  8328. */
  8329. set contrast(value: number);
  8330. /**
  8331. * Vignette stretch size.
  8332. */
  8333. vignetteStretch: number;
  8334. /**
  8335. * Vignette centre X Offset.
  8336. */
  8337. vignetteCentreX: number;
  8338. /**
  8339. * Vignette centre Y Offset.
  8340. */
  8341. vignetteCentreY: number;
  8342. /**
  8343. * Vignette weight or intensity of the vignette effect.
  8344. */
  8345. vignetteWeight: number;
  8346. /**
  8347. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8348. * if vignetteEnabled is set to true.
  8349. */
  8350. vignetteColor: Color4;
  8351. /**
  8352. * Camera field of view used by the Vignette effect.
  8353. */
  8354. vignetteCameraFov: number;
  8355. private _vignetteBlendMode;
  8356. /**
  8357. * Gets the vignette blend mode allowing different kind of effect.
  8358. */
  8359. get vignetteBlendMode(): number;
  8360. /**
  8361. * Sets the vignette blend mode allowing different kind of effect.
  8362. */
  8363. set vignetteBlendMode(value: number);
  8364. private _vignetteEnabled;
  8365. /**
  8366. * Gets wether the vignette effect is enabled.
  8367. */
  8368. get vignetteEnabled(): boolean;
  8369. /**
  8370. * Sets wether the vignette effect is enabled.
  8371. */
  8372. set vignetteEnabled(value: boolean);
  8373. private _applyByPostProcess;
  8374. /**
  8375. * Gets wether the image processing is applied through a post process or not.
  8376. */
  8377. get applyByPostProcess(): boolean;
  8378. /**
  8379. * Sets wether the image processing is applied through a post process or not.
  8380. */
  8381. set applyByPostProcess(value: boolean);
  8382. private _isEnabled;
  8383. /**
  8384. * Gets wether the image processing is enabled or not.
  8385. */
  8386. get isEnabled(): boolean;
  8387. /**
  8388. * Sets wether the image processing is enabled or not.
  8389. */
  8390. set isEnabled(value: boolean);
  8391. /**
  8392. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8393. */
  8394. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8395. /**
  8396. * Method called each time the image processing information changes requires to recompile the effect.
  8397. */
  8398. protected _updateParameters(): void;
  8399. /**
  8400. * Gets the current class name.
  8401. * @return "ImageProcessingConfiguration"
  8402. */
  8403. getClassName(): string;
  8404. /**
  8405. * Prepare the list of uniforms associated with the Image Processing effects.
  8406. * @param uniforms The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of samplers associated with the Image Processing effects.
  8412. * @param samplersList The list of uniforms used in the effect
  8413. * @param defines the list of defines currently in use
  8414. */
  8415. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8416. /**
  8417. * Prepare the list of defines associated to the shader.
  8418. * @param defines the list of defines to complete
  8419. * @param forPostProcess Define if we are currently in post process mode or not
  8420. */
  8421. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8422. /**
  8423. * Returns true if all the image processing information are ready.
  8424. * @returns True if ready, otherwise, false
  8425. */
  8426. isReady(): boolean;
  8427. /**
  8428. * Binds the image processing to the shader.
  8429. * @param effect The effect to bind to
  8430. * @param overrideAspectRatio Override the aspect ratio of the effect
  8431. */
  8432. bind(effect: Effect, overrideAspectRatio?: number): void;
  8433. /**
  8434. * Clones the current image processing instance.
  8435. * @return The cloned image processing
  8436. */
  8437. clone(): ImageProcessingConfiguration;
  8438. /**
  8439. * Serializes the current image processing instance to a json representation.
  8440. * @return a JSON representation
  8441. */
  8442. serialize(): any;
  8443. /**
  8444. * Parses the image processing from a json representation.
  8445. * @param source the JSON source to parse
  8446. * @return The parsed image processing
  8447. */
  8448. static Parse(source: any): ImageProcessingConfiguration;
  8449. private static _VIGNETTEMODE_MULTIPLY;
  8450. private static _VIGNETTEMODE_OPAQUE;
  8451. /**
  8452. * Used to apply the vignette as a mix with the pixel color.
  8453. */
  8454. static get VIGNETTEMODE_MULTIPLY(): number;
  8455. /**
  8456. * Used to apply the vignette as a replacement of the pixel color.
  8457. */
  8458. static get VIGNETTEMODE_OPAQUE(): number;
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /** @hidden */
  8463. export var postprocessVertexShader: {
  8464. name: string;
  8465. shader: string;
  8466. };
  8467. }
  8468. declare module BABYLON {
  8469. interface ThinEngine {
  8470. /**
  8471. * Creates a new render target texture
  8472. * @param size defines the size of the texture
  8473. * @param options defines the options used to create the texture
  8474. * @returns a new render target texture stored in an InternalTexture
  8475. */
  8476. createRenderTargetTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8481. /**
  8482. * Creates a depth stencil texture.
  8483. * This is only available in WebGL 2 or with the depth texture extension available.
  8484. * @param size The size of face edge in the texture.
  8485. * @param options The options defining the texture.
  8486. * @returns The texture
  8487. */
  8488. createDepthStencilTexture(size: number | {
  8489. width: number;
  8490. height: number;
  8491. layers?: number;
  8492. }, options: DepthTextureCreationOptions): InternalTexture;
  8493. /** @hidden */
  8494. _createDepthStencilTexture(size: number | {
  8495. width: number;
  8496. height: number;
  8497. layers?: number;
  8498. }, options: DepthTextureCreationOptions): InternalTexture;
  8499. }
  8500. }
  8501. declare module BABYLON {
  8502. /** Defines supported spaces */
  8503. export enum Space {
  8504. /** Local (object) space */
  8505. LOCAL = 0,
  8506. /** World space */
  8507. WORLD = 1,
  8508. /** Bone space */
  8509. BONE = 2
  8510. }
  8511. /** Defines the 3 main axes */
  8512. export class Axis {
  8513. /** X axis */
  8514. static X: Vector3;
  8515. /** Y axis */
  8516. static Y: Vector3;
  8517. /** Z axis */
  8518. static Z: Vector3;
  8519. }
  8520. }
  8521. declare module BABYLON {
  8522. /**
  8523. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. */
  8527. export class TargetCamera extends Camera {
  8528. private static _RigCamTransformMatrix;
  8529. private static _TargetTransformMatrix;
  8530. private static _TargetFocalPoint;
  8531. /**
  8532. * Define the current direction the camera is moving to
  8533. */
  8534. cameraDirection: Vector3;
  8535. /**
  8536. * Define the current rotation the camera is rotating to
  8537. */
  8538. cameraRotation: Vector2;
  8539. /**
  8540. * When set, the up vector of the camera will be updated by the rotation of the camera
  8541. */
  8542. updateUpVectorFromRotation: boolean;
  8543. private _tmpQuaternion;
  8544. /**
  8545. * Define the current rotation of the camera
  8546. */
  8547. rotation: Vector3;
  8548. /**
  8549. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8550. */
  8551. rotationQuaternion: Quaternion;
  8552. /**
  8553. * Define the current speed of the camera
  8554. */
  8555. speed: number;
  8556. /**
  8557. * Add constraint to the camera to prevent it to move freely in all directions and
  8558. * around all axis.
  8559. */
  8560. noRotationConstraint: boolean;
  8561. /**
  8562. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8563. * panning
  8564. */
  8565. invertRotation: boolean;
  8566. /**
  8567. * Speed multiplier for inverse camera panning
  8568. */
  8569. inverseRotationSpeed: number;
  8570. /**
  8571. * Define the current target of the camera as an object or a position.
  8572. */
  8573. lockedTarget: any;
  8574. /** @hidden */
  8575. _currentTarget: Vector3;
  8576. /** @hidden */
  8577. _initialFocalDistance: number;
  8578. /** @hidden */
  8579. _viewMatrix: Matrix;
  8580. /** @hidden */
  8581. _camMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraTransformMatrix: Matrix;
  8584. /** @hidden */
  8585. _cameraRotationMatrix: Matrix;
  8586. /** @hidden */
  8587. _referencePoint: Vector3;
  8588. /** @hidden */
  8589. _transformedReferencePoint: Vector3;
  8590. protected _globalCurrentTarget: Vector3;
  8591. protected _globalCurrentUpVector: Vector3;
  8592. /** @hidden */
  8593. _reset: () => void;
  8594. private _defaultUp;
  8595. /**
  8596. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8597. * This is the base of the follow, arc rotate cameras and Free camera
  8598. * @see http://doc.babylonjs.com/features/cameras
  8599. * @param name Defines the name of the camera in the scene
  8600. * @param position Defines the start position of the camera in the scene
  8601. * @param scene Defines the scene the camera belongs to
  8602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8603. */
  8604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8605. /**
  8606. * Gets the position in front of the camera at a given distance.
  8607. * @param distance The distance from the camera we want the position to be
  8608. * @returns the position
  8609. */
  8610. getFrontPosition(distance: number): Vector3;
  8611. /** @hidden */
  8612. _getLockedTargetPosition(): Nullable<Vector3>;
  8613. private _storedPosition;
  8614. private _storedRotation;
  8615. private _storedRotationQuaternion;
  8616. /**
  8617. * Store current camera state of the camera (fov, position, rotation, etc..)
  8618. * @returns the camera
  8619. */
  8620. storeState(): Camera;
  8621. /**
  8622. * Restored camera state. You must call storeState() first
  8623. * @returns whether it was successful or not
  8624. * @hidden
  8625. */
  8626. _restoreStateValues(): boolean;
  8627. /** @hidden */
  8628. _initCache(): void;
  8629. /** @hidden */
  8630. _updateCache(ignoreParentClass?: boolean): void;
  8631. /** @hidden */
  8632. _isSynchronizedViewMatrix(): boolean;
  8633. /** @hidden */
  8634. _computeLocalCameraSpeed(): number;
  8635. /**
  8636. * Defines the target the camera should look at.
  8637. * @param target Defines the new target as a Vector or a mesh
  8638. */
  8639. setTarget(target: Vector3): void;
  8640. /**
  8641. * Return the current target position of the camera. This value is expressed in local space.
  8642. * @returns the target position
  8643. */
  8644. getTarget(): Vector3;
  8645. /** @hidden */
  8646. _decideIfNeedsToMove(): boolean;
  8647. /** @hidden */
  8648. _updatePosition(): void;
  8649. /** @hidden */
  8650. _checkInputs(): void;
  8651. protected _updateCameraRotationMatrix(): void;
  8652. /**
  8653. * 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)
  8654. * @returns the current camera
  8655. */
  8656. private _rotateUpVectorWithCameraRotationMatrix;
  8657. private _cachedRotationZ;
  8658. private _cachedQuaternionRotationZ;
  8659. /** @hidden */
  8660. _getViewMatrix(): Matrix;
  8661. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8662. /**
  8663. * @hidden
  8664. */
  8665. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8666. /**
  8667. * @hidden
  8668. */
  8669. _updateRigCameras(): void;
  8670. private _getRigCamPositionAndTarget;
  8671. /**
  8672. * Gets the current object class name.
  8673. * @return the class name
  8674. */
  8675. getClassName(): string;
  8676. }
  8677. }
  8678. declare module BABYLON {
  8679. /**
  8680. * Gather the list of keyboard event types as constants.
  8681. */
  8682. export class KeyboardEventTypes {
  8683. /**
  8684. * The keydown event is fired when a key becomes active (pressed).
  8685. */
  8686. static readonly KEYDOWN: number;
  8687. /**
  8688. * The keyup event is fired when a key has been released.
  8689. */
  8690. static readonly KEYUP: number;
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8694. */
  8695. export class KeyboardInfo {
  8696. /**
  8697. * Defines the type of event (KeyboardEventTypes)
  8698. */
  8699. type: number;
  8700. /**
  8701. * Defines the related dom event
  8702. */
  8703. event: KeyboardEvent;
  8704. /**
  8705. * Instantiates a new keyboard info.
  8706. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8707. * @param type Defines the type of event (KeyboardEventTypes)
  8708. * @param event Defines the related dom event
  8709. */
  8710. constructor(
  8711. /**
  8712. * Defines the type of event (KeyboardEventTypes)
  8713. */
  8714. type: number,
  8715. /**
  8716. * Defines the related dom event
  8717. */
  8718. event: KeyboardEvent);
  8719. }
  8720. /**
  8721. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8722. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8723. */
  8724. export class KeyboardInfoPre extends KeyboardInfo {
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number;
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent;
  8733. /**
  8734. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8735. */
  8736. skipOnPointerObservable: boolean;
  8737. /**
  8738. * Instantiates a new keyboard pre info.
  8739. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8740. * @param type Defines the type of event (KeyboardEventTypes)
  8741. * @param event Defines the related dom event
  8742. */
  8743. constructor(
  8744. /**
  8745. * Defines the type of event (KeyboardEventTypes)
  8746. */
  8747. type: number,
  8748. /**
  8749. * Defines the related dom event
  8750. */
  8751. event: KeyboardEvent);
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * Manage the keyboard inputs to control the movement of a free camera.
  8757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8758. */
  8759. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8760. /**
  8761. * Defines the camera the input is attached to.
  8762. */
  8763. camera: FreeCamera;
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8766. */
  8767. keysUp: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8770. */
  8771. keysUpward: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8774. */
  8775. keysDown: number[];
  8776. /**
  8777. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8778. */
  8779. keysDownward: number[];
  8780. /**
  8781. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8782. */
  8783. keysLeft: number[];
  8784. /**
  8785. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8786. */
  8787. keysRight: number[];
  8788. private _keys;
  8789. private _onCanvasBlurObserver;
  8790. private _onKeyboardObserver;
  8791. private _engine;
  8792. private _scene;
  8793. /**
  8794. * Attach the input controls to a specific dom element to get the input from.
  8795. * @param element Defines the element the controls should be listened from
  8796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8797. */
  8798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8799. /**
  8800. * Detach the current controls from the specified dom element.
  8801. * @param element Defines the element to stop listening the inputs from
  8802. */
  8803. detachControl(element: Nullable<HTMLElement>): void;
  8804. /**
  8805. * Update the current camera state depending on the inputs that have been used this frame.
  8806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8807. */
  8808. checkInputs(): void;
  8809. /**
  8810. * Gets the class name of the current intput.
  8811. * @returns the class name
  8812. */
  8813. getClassName(): string;
  8814. /** @hidden */
  8815. _onLostFocus(): void;
  8816. /**
  8817. * Get the friendly name associated with the input class.
  8818. * @returns the input friendly name
  8819. */
  8820. getSimpleName(): string;
  8821. }
  8822. }
  8823. declare module BABYLON {
  8824. /**
  8825. * Interface describing all the common properties and methods a shadow light needs to implement.
  8826. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8827. * as well as binding the different shadow properties to the effects.
  8828. */
  8829. export interface IShadowLight extends Light {
  8830. /**
  8831. * The light id in the scene (used in scene.findLighById for instance)
  8832. */
  8833. id: string;
  8834. /**
  8835. * The position the shdow will be casted from.
  8836. */
  8837. position: Vector3;
  8838. /**
  8839. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8840. */
  8841. direction: Vector3;
  8842. /**
  8843. * The transformed position. Position of the light in world space taking parenting in account.
  8844. */
  8845. transformedPosition: Vector3;
  8846. /**
  8847. * The transformed direction. Direction of the light in world space taking parenting in account.
  8848. */
  8849. transformedDirection: Vector3;
  8850. /**
  8851. * The friendly name of the light in the scene.
  8852. */
  8853. name: string;
  8854. /**
  8855. * Defines the shadow projection clipping minimum z value.
  8856. */
  8857. shadowMinZ: number;
  8858. /**
  8859. * Defines the shadow projection clipping maximum z value.
  8860. */
  8861. shadowMaxZ: number;
  8862. /**
  8863. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8864. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8865. */
  8866. computeTransformedInformation(): boolean;
  8867. /**
  8868. * Gets the scene the light belongs to.
  8869. * @returns The scene
  8870. */
  8871. getScene(): Scene;
  8872. /**
  8873. * Callback defining a custom Projection Matrix Builder.
  8874. * This can be used to override the default projection matrix computation.
  8875. */
  8876. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8877. /**
  8878. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8879. * @param matrix The materix to updated with the projection information
  8880. * @param viewMatrix The transform matrix of the light
  8881. * @param renderList The list of mesh to render in the map
  8882. * @returns The current light
  8883. */
  8884. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8885. /**
  8886. * Gets the current depth scale used in ESM.
  8887. * @returns The scale
  8888. */
  8889. getDepthScale(): number;
  8890. /**
  8891. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8892. * @returns true if a cube texture needs to be use
  8893. */
  8894. needCube(): boolean;
  8895. /**
  8896. * Detects if the projection matrix requires to be recomputed this frame.
  8897. * @returns true if it requires to be recomputed otherwise, false.
  8898. */
  8899. needProjectionMatrixCompute(): boolean;
  8900. /**
  8901. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8902. */
  8903. forceProjectionMatrixCompute(): void;
  8904. /**
  8905. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8908. */
  8909. getShadowDirection(faceIndex?: number): Vector3;
  8910. /**
  8911. * Gets the minZ used for shadow according to both the scene and the light.
  8912. * @param activeCamera The camera we are returning the min for
  8913. * @returns the depth min z
  8914. */
  8915. getDepthMinZ(activeCamera: Camera): number;
  8916. /**
  8917. * Gets the maxZ used for shadow according to both the scene and the light.
  8918. * @param activeCamera The camera we are returning the max for
  8919. * @returns the depth max z
  8920. */
  8921. getDepthMaxZ(activeCamera: Camera): number;
  8922. }
  8923. /**
  8924. * Base implementation IShadowLight
  8925. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8926. */
  8927. export abstract class ShadowLight extends Light implements IShadowLight {
  8928. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8929. protected _position: Vector3;
  8930. protected _setPosition(value: Vector3): void;
  8931. /**
  8932. * Sets the position the shadow will be casted from. Also use as the light position for both
  8933. * point and spot lights.
  8934. */
  8935. get position(): Vector3;
  8936. /**
  8937. * Sets the position the shadow will be casted from. Also use as the light position for both
  8938. * point and spot lights.
  8939. */
  8940. set position(value: Vector3);
  8941. protected _direction: Vector3;
  8942. protected _setDirection(value: Vector3): void;
  8943. /**
  8944. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8945. * Also use as the light direction on spot and directional lights.
  8946. */
  8947. get direction(): Vector3;
  8948. /**
  8949. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. set direction(value: Vector3);
  8953. protected _shadowMinZ: number;
  8954. /**
  8955. * Gets the shadow projection clipping minimum z value.
  8956. */
  8957. get shadowMinZ(): number;
  8958. /**
  8959. * Sets the shadow projection clipping minimum z value.
  8960. */
  8961. set shadowMinZ(value: number);
  8962. protected _shadowMaxZ: number;
  8963. /**
  8964. * Sets the shadow projection clipping maximum z value.
  8965. */
  8966. get shadowMaxZ(): number;
  8967. /**
  8968. * Gets the shadow projection clipping maximum z value.
  8969. */
  8970. set shadowMaxZ(value: number);
  8971. /**
  8972. * Callback defining a custom Projection Matrix Builder.
  8973. * This can be used to override the default projection matrix computation.
  8974. */
  8975. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8976. /**
  8977. * The transformed position. Position of the light in world space taking parenting in account.
  8978. */
  8979. transformedPosition: Vector3;
  8980. /**
  8981. * The transformed direction. Direction of the light in world space taking parenting in account.
  8982. */
  8983. transformedDirection: Vector3;
  8984. private _needProjectionMatrixCompute;
  8985. /**
  8986. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8987. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8988. */
  8989. computeTransformedInformation(): boolean;
  8990. /**
  8991. * Return the depth scale used for the shadow map.
  8992. * @returns the depth scale.
  8993. */
  8994. getDepthScale(): number;
  8995. /**
  8996. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8997. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8998. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8999. */
  9000. getShadowDirection(faceIndex?: number): Vector3;
  9001. /**
  9002. * Returns the ShadowLight absolute position in the World.
  9003. * @returns the position vector in world space
  9004. */
  9005. getAbsolutePosition(): Vector3;
  9006. /**
  9007. * Sets the ShadowLight direction toward the passed target.
  9008. * @param target The point to target in local space
  9009. * @returns the updated ShadowLight direction
  9010. */
  9011. setDirectionToTarget(target: Vector3): Vector3;
  9012. /**
  9013. * Returns the light rotation in euler definition.
  9014. * @returns the x y z rotation in local space.
  9015. */
  9016. getRotation(): Vector3;
  9017. /**
  9018. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9019. * @returns true if a cube texture needs to be use
  9020. */
  9021. needCube(): boolean;
  9022. /**
  9023. * Detects if the projection matrix requires to be recomputed this frame.
  9024. * @returns true if it requires to be recomputed otherwise, false.
  9025. */
  9026. needProjectionMatrixCompute(): boolean;
  9027. /**
  9028. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9029. */
  9030. forceProjectionMatrixCompute(): void;
  9031. /** @hidden */
  9032. _initCache(): void;
  9033. /** @hidden */
  9034. _isSynchronized(): boolean;
  9035. /**
  9036. * Computes the world matrix of the node
  9037. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9038. * @returns the world matrix
  9039. */
  9040. computeWorldMatrix(force?: boolean): Matrix;
  9041. /**
  9042. * Gets the minZ used for shadow according to both the scene and the light.
  9043. * @param activeCamera The camera we are returning the min for
  9044. * @returns the depth min z
  9045. */
  9046. getDepthMinZ(activeCamera: Camera): number;
  9047. /**
  9048. * Gets the maxZ used for shadow according to both the scene and the light.
  9049. * @param activeCamera The camera we are returning the max for
  9050. * @returns the depth max z
  9051. */
  9052. getDepthMaxZ(activeCamera: Camera): number;
  9053. /**
  9054. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9055. * @param matrix The materix to updated with the projection information
  9056. * @param viewMatrix The transform matrix of the light
  9057. * @param renderList The list of mesh to render in the map
  9058. * @returns The current light
  9059. */
  9060. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9061. }
  9062. }
  9063. declare module BABYLON {
  9064. /**
  9065. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9066. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9067. */
  9068. export class EffectFallbacks implements IEffectFallbacks {
  9069. private _defines;
  9070. private _currentRank;
  9071. private _maxRank;
  9072. private _mesh;
  9073. /**
  9074. * Removes the fallback from the bound mesh.
  9075. */
  9076. unBindMesh(): void;
  9077. /**
  9078. * Adds a fallback on the specified property.
  9079. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9080. * @param define The name of the define in the shader
  9081. */
  9082. addFallback(rank: number, define: string): void;
  9083. /**
  9084. * Sets the mesh to use CPU skinning when needing to fallback.
  9085. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9086. * @param mesh The mesh to use the fallbacks.
  9087. */
  9088. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9089. /**
  9090. * Checks to see if more fallbacks are still availible.
  9091. */
  9092. get hasMoreFallbacks(): boolean;
  9093. /**
  9094. * Removes the defines that should be removed when falling back.
  9095. * @param currentDefines defines the current define statements for the shader.
  9096. * @param effect defines the current effect we try to compile
  9097. * @returns The resulting defines with defines of the current rank removed.
  9098. */
  9099. reduce(currentDefines: string, effect: Effect): string;
  9100. }
  9101. }
  9102. declare module BABYLON {
  9103. /**
  9104. * "Static Class" containing the most commonly used helper while dealing with material for
  9105. * rendering purpose.
  9106. *
  9107. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9108. *
  9109. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9110. */
  9111. export class MaterialHelper {
  9112. /**
  9113. * Bind the current view position to an effect.
  9114. * @param effect The effect to be bound
  9115. * @param scene The scene the eyes position is used from
  9116. */
  9117. static BindEyePosition(effect: Effect, scene: Scene): void;
  9118. /**
  9119. * Helps preparing the defines values about the UVs in used in the effect.
  9120. * UVs are shared as much as we can accross channels in the shaders.
  9121. * @param texture The texture we are preparing the UVs for
  9122. * @param defines The defines to update
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9126. /**
  9127. * Binds a texture matrix value to its corrsponding uniform
  9128. * @param texture The texture to bind the matrix for
  9129. * @param uniformBuffer The uniform buffer receivin the data
  9130. * @param key The channel key "diffuse", "specular"... used in the shader
  9131. */
  9132. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9133. /**
  9134. * Gets the current status of the fog (should it be enabled?)
  9135. * @param mesh defines the mesh to evaluate for fog support
  9136. * @param scene defines the hosting scene
  9137. * @returns true if fog must be enabled
  9138. */
  9139. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9140. /**
  9141. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9142. * @param mesh defines the current mesh
  9143. * @param scene defines the current scene
  9144. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9145. * @param pointsCloud defines if point cloud rendering has to be turned on
  9146. * @param fogEnabled defines if fog has to be turned on
  9147. * @param alphaTest defines if alpha testing has to be turned on
  9148. * @param defines defines the current list of defines
  9149. */
  9150. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9151. /**
  9152. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9153. * @param scene defines the current scene
  9154. * @param engine defines the current engine
  9155. * @param defines specifies the list of active defines
  9156. * @param useInstances defines if instances have to be turned on
  9157. * @param useClipPlane defines if clip plane have to be turned on
  9158. */
  9159. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9160. /**
  9161. * Prepares the defines for bones
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. */
  9165. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9166. /**
  9167. * Prepares the defines for morph targets
  9168. * @param mesh The mesh containing the geometry data we will draw
  9169. * @param defines The defines to update
  9170. */
  9171. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9174. * @param mesh The mesh containing the geometry data we will draw
  9175. * @param defines The defines to update
  9176. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9177. * @param useBones Precise whether bones should be used or not (override mesh info)
  9178. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9179. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9180. * @returns false if defines are considered not dirty and have not been checked
  9181. */
  9182. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9183. /**
  9184. * Prepares the defines related to multiview
  9185. * @param scene The scene we are intending to draw
  9186. * @param defines The defines to update
  9187. */
  9188. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9189. /**
  9190. * Prepares the defines related to the light information passed in parameter
  9191. * @param scene The scene we are intending to draw
  9192. * @param mesh The mesh the effect is compiling for
  9193. * @param light The light the effect is compiling for
  9194. * @param lightIndex The index of the light
  9195. * @param defines The defines to update
  9196. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9197. * @param state Defines the current state regarding what is needed (normals, etc...)
  9198. */
  9199. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9200. needNormals: boolean;
  9201. needRebuild: boolean;
  9202. shadowEnabled: boolean;
  9203. specularEnabled: boolean;
  9204. lightmapMode: boolean;
  9205. }): void;
  9206. /**
  9207. * Prepares the defines related to the light information passed in parameter
  9208. * @param scene The scene we are intending to draw
  9209. * @param mesh The mesh the effect is compiling for
  9210. * @param defines The defines to update
  9211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9212. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9213. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9214. * @returns true if normals will be required for the rest of the effect
  9215. */
  9216. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9217. /**
  9218. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9219. * @param lightIndex defines the light index
  9220. * @param uniformsList The uniform list
  9221. * @param samplersList The sampler list
  9222. * @param projectedLightTexture defines if projected texture must be used
  9223. * @param uniformBuffersList defines an optional list of uniform buffers
  9224. */
  9225. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9226. /**
  9227. * Prepares the uniforms and samplers list to be used in the effect
  9228. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9229. * @param samplersList The sampler list
  9230. * @param defines The defines helping in the list generation
  9231. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9232. */
  9233. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9234. /**
  9235. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9236. * @param defines The defines to update while falling back
  9237. * @param fallbacks The authorized effect fallbacks
  9238. * @param maxSimultaneousLights The maximum number of lights allowed
  9239. * @param rank the current rank of the Effect
  9240. * @returns The newly affected rank
  9241. */
  9242. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9243. private static _TmpMorphInfluencers;
  9244. /**
  9245. * Prepares the list of attributes required for morph targets according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the morph targets attributes for
  9248. * @param influencers The number of influencers
  9249. */
  9250. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9251. /**
  9252. * Prepares the list of attributes required for morph targets according to the effect defines.
  9253. * @param attribs The current list of supported attribs
  9254. * @param mesh The mesh to prepare the morph targets attributes for
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9258. /**
  9259. * Prepares the list of attributes required for bones according to the effect defines.
  9260. * @param attribs The current list of supported attribs
  9261. * @param mesh The mesh to prepare the bones attributes for
  9262. * @param defines The current Defines of the effect
  9263. * @param fallbacks The current efffect fallback strategy
  9264. */
  9265. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9266. /**
  9267. * Check and prepare the list of attributes required for instances according to the effect defines.
  9268. * @param attribs The current list of supported attribs
  9269. * @param defines The current MaterialDefines of the effect
  9270. */
  9271. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9272. /**
  9273. * Add the list of attributes required for instances to the attribs array.
  9274. * @param attribs The current list of supported attribs
  9275. */
  9276. static PushAttributesForInstances(attribs: string[]): void;
  9277. /**
  9278. * Binds the light information to the effect.
  9279. * @param light The light containing the generator
  9280. * @param effect The effect we are binding the data to
  9281. * @param lightIndex The light index in the effect used to render
  9282. */
  9283. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9284. /**
  9285. * Binds the lights information from the scene to the effect for the given mesh.
  9286. * @param light Light to bind
  9287. * @param lightIndex Light index
  9288. * @param scene The scene where the light belongs to
  9289. * @param effect The effect we are binding the data to
  9290. * @param useSpecular Defines if specular is supported
  9291. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9292. */
  9293. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9294. /**
  9295. * Binds the lights information from the scene to the effect for the given mesh.
  9296. * @param scene The scene the lights belongs to
  9297. * @param mesh The mesh we are binding the information to render
  9298. * @param effect The effect we are binding the data to
  9299. * @param defines The generated defines for the effect
  9300. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9301. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9302. */
  9303. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9304. private static _tempFogColor;
  9305. /**
  9306. * Binds the fog information from the scene to the effect for the given mesh.
  9307. * @param scene The scene the lights belongs to
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. * @param linearSpace Defines if the fog effect is applied in linear space
  9311. */
  9312. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9313. /**
  9314. * Binds the bones information from the mesh to the effect.
  9315. * @param mesh The mesh we are binding the information to render
  9316. * @param effect The effect we are binding the data to
  9317. */
  9318. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9319. /**
  9320. * Binds the morph targets information from the mesh to the effect.
  9321. * @param abstractMesh The mesh we are binding the information to render
  9322. * @param effect The effect we are binding the data to
  9323. */
  9324. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9325. /**
  9326. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9327. * @param defines The generated defines used in the effect
  9328. * @param effect The effect we are binding the data to
  9329. * @param scene The scene we are willing to render with logarithmic scale for
  9330. */
  9331. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9332. /**
  9333. * Binds the clip plane information from the scene to the effect.
  9334. * @param scene The scene the clip plane information are extracted from
  9335. * @param effect The effect we are binding the data to
  9336. */
  9337. static BindClipPlane(effect: Effect, scene: Scene): void;
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var packingFunctions: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var shadowMapFragmentDeclaration: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneFragmentDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var clipPlaneFragment: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var shadowMapFragment: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapPixelShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var bonesDeclaration: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var morphTargetsVertexGlobalDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var morphTargetsVertexDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var instancesDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var helperFunctions: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var shadowMapVertexDeclaration: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var clipPlaneVertexDeclaration: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var morphTargetsVertex: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var instancesVertex: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /** @hidden */
  9447. export var bonesVertex: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module BABYLON {
  9453. /** @hidden */
  9454. export var shadowMapVertexNormalBias: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module BABYLON {
  9460. /** @hidden */
  9461. export var shadowMapVertexMetric: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module BABYLON {
  9467. /** @hidden */
  9468. export var clipPlaneVertex: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module BABYLON {
  9474. /** @hidden */
  9475. export var shadowMapVertexShader: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module BABYLON {
  9481. /** @hidden */
  9482. export var depthBoxBlurPixelShader: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module BABYLON {
  9488. /**
  9489. * Class representing a ray with position and direction
  9490. */
  9491. export class Ray {
  9492. /** origin point */
  9493. origin: Vector3;
  9494. /** direction */
  9495. direction: Vector3;
  9496. /** length of the ray */
  9497. length: number;
  9498. private static readonly TmpVector3;
  9499. private _tmpRay;
  9500. /**
  9501. * Creates a new ray
  9502. * @param origin origin point
  9503. * @param direction direction
  9504. * @param length length of the ray
  9505. */
  9506. constructor(
  9507. /** origin point */
  9508. origin: Vector3,
  9509. /** direction */
  9510. direction: Vector3,
  9511. /** length of the ray */
  9512. length?: number);
  9513. /**
  9514. * Checks if the ray intersects a box
  9515. * This does not account for the ray lenght by design to improve perfs.
  9516. * @param minimum bound of the box
  9517. * @param maximum bound of the box
  9518. * @param intersectionTreshold extra extend to be added to the box in all direction
  9519. * @returns if the box was hit
  9520. */
  9521. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9522. /**
  9523. * Checks if the ray intersects a box
  9524. * This does not account for the ray lenght by design to improve perfs.
  9525. * @param box the bounding box to check
  9526. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9527. * @returns if the box was hit
  9528. */
  9529. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9530. /**
  9531. * If the ray hits a sphere
  9532. * @param sphere the bounding sphere to check
  9533. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9534. * @returns true if it hits the sphere
  9535. */
  9536. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9537. /**
  9538. * If the ray hits a triange
  9539. * @param vertex0 triangle vertex
  9540. * @param vertex1 triangle vertex
  9541. * @param vertex2 triangle vertex
  9542. * @returns intersection information if hit
  9543. */
  9544. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9545. /**
  9546. * Checks if ray intersects a plane
  9547. * @param plane the plane to check
  9548. * @returns the distance away it was hit
  9549. */
  9550. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9551. /**
  9552. * Calculate the intercept of a ray on a given axis
  9553. * @param axis to check 'x' | 'y' | 'z'
  9554. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9555. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9556. */
  9557. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9558. /**
  9559. * Checks if ray intersects a mesh
  9560. * @param mesh the mesh to check
  9561. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9562. * @returns picking info of the intersecton
  9563. */
  9564. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9565. /**
  9566. * Checks if ray intersects a mesh
  9567. * @param meshes the meshes to check
  9568. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9569. * @param results array to store result in
  9570. * @returns Array of picking infos
  9571. */
  9572. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9573. private _comparePickingInfo;
  9574. private static smallnum;
  9575. private static rayl;
  9576. /**
  9577. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9578. * @param sega the first point of the segment to test the intersection against
  9579. * @param segb the second point of the segment to test the intersection against
  9580. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9581. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9582. */
  9583. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9584. /**
  9585. * Update the ray from viewport position
  9586. * @param x position
  9587. * @param y y position
  9588. * @param viewportWidth viewport width
  9589. * @param viewportHeight viewport height
  9590. * @param world world matrix
  9591. * @param view view matrix
  9592. * @param projection projection matrix
  9593. * @returns this ray updated
  9594. */
  9595. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9596. /**
  9597. * Creates a ray with origin and direction of 0,0,0
  9598. * @returns the new ray
  9599. */
  9600. static Zero(): Ray;
  9601. /**
  9602. * Creates a new ray from screen space and viewport
  9603. * @param x position
  9604. * @param y y position
  9605. * @param viewportWidth viewport width
  9606. * @param viewportHeight viewport height
  9607. * @param world world matrix
  9608. * @param view view matrix
  9609. * @param projection projection matrix
  9610. * @returns new ray
  9611. */
  9612. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9613. /**
  9614. * 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
  9615. * transformed to the given world matrix.
  9616. * @param origin The origin point
  9617. * @param end The end point
  9618. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9619. * @returns the new ray
  9620. */
  9621. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9622. /**
  9623. * Transforms a ray by a matrix
  9624. * @param ray ray to transform
  9625. * @param matrix matrix to apply
  9626. * @returns the resulting new ray
  9627. */
  9628. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9629. /**
  9630. * Transforms a ray by a matrix
  9631. * @param ray ray to transform
  9632. * @param matrix matrix to apply
  9633. * @param result ray to store result in
  9634. */
  9635. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9636. /**
  9637. * Unproject a ray from screen space to object space
  9638. * @param sourceX defines the screen space x coordinate to use
  9639. * @param sourceY defines the screen space y coordinate to use
  9640. * @param viewportWidth defines the current width of the viewport
  9641. * @param viewportHeight defines the current height of the viewport
  9642. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9643. * @param view defines the view matrix to use
  9644. * @param projection defines the projection matrix to use
  9645. */
  9646. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9647. }
  9648. /**
  9649. * Type used to define predicate used to select faces when a mesh intersection is detected
  9650. */
  9651. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9652. interface Scene {
  9653. /** @hidden */
  9654. _tempPickingRay: Nullable<Ray>;
  9655. /** @hidden */
  9656. _cachedRayForTransform: Ray;
  9657. /** @hidden */
  9658. _pickWithRayInverseMatrix: Matrix;
  9659. /** @hidden */
  9660. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9661. /** @hidden */
  9662. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9663. }
  9664. }
  9665. declare module BABYLON {
  9666. /**
  9667. * Groups all the scene component constants in one place to ease maintenance.
  9668. * @hidden
  9669. */
  9670. export class SceneComponentConstants {
  9671. static readonly NAME_EFFECTLAYER: string;
  9672. static readonly NAME_LAYER: string;
  9673. static readonly NAME_LENSFLARESYSTEM: string;
  9674. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9675. static readonly NAME_PARTICLESYSTEM: string;
  9676. static readonly NAME_GAMEPAD: string;
  9677. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9678. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9679. static readonly NAME_DEPTHRENDERER: string;
  9680. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9681. static readonly NAME_SPRITE: string;
  9682. static readonly NAME_OUTLINERENDERER: string;
  9683. static readonly NAME_PROCEDURALTEXTURE: string;
  9684. static readonly NAME_SHADOWGENERATOR: string;
  9685. static readonly NAME_OCTREE: string;
  9686. static readonly NAME_PHYSICSENGINE: string;
  9687. static readonly NAME_AUDIO: string;
  9688. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9689. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9690. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9691. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9692. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9693. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9694. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9695. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9696. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9697. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9698. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9699. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9700. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9701. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9702. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9703. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9704. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9705. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9706. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9707. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9708. static readonly STEP_AFTERRENDER_AUDIO: number;
  9709. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9710. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9711. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9712. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9713. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9714. static readonly STEP_POINTERMOVE_SPRITE: number;
  9715. static readonly STEP_POINTERDOWN_SPRITE: number;
  9716. static readonly STEP_POINTERUP_SPRITE: number;
  9717. }
  9718. /**
  9719. * This represents a scene component.
  9720. *
  9721. * This is used to decouple the dependency the scene is having on the different workloads like
  9722. * layers, post processes...
  9723. */
  9724. export interface ISceneComponent {
  9725. /**
  9726. * The name of the component. Each component must have a unique name.
  9727. */
  9728. name: string;
  9729. /**
  9730. * The scene the component belongs to.
  9731. */
  9732. scene: Scene;
  9733. /**
  9734. * Register the component to one instance of a scene.
  9735. */
  9736. register(): void;
  9737. /**
  9738. * Rebuilds the elements related to this component in case of
  9739. * context lost for instance.
  9740. */
  9741. rebuild(): void;
  9742. /**
  9743. * Disposes the component and the associated ressources.
  9744. */
  9745. dispose(): void;
  9746. }
  9747. /**
  9748. * This represents a SERIALIZABLE scene component.
  9749. *
  9750. * This extends Scene Component to add Serialization methods on top.
  9751. */
  9752. export interface ISceneSerializableComponent extends ISceneComponent {
  9753. /**
  9754. * Adds all the elements from the container to the scene
  9755. * @param container the container holding the elements
  9756. */
  9757. addFromContainer(container: AbstractScene): void;
  9758. /**
  9759. * Removes all the elements in the container from the scene
  9760. * @param container contains the elements to remove
  9761. * @param dispose if the removed element should be disposed (default: false)
  9762. */
  9763. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9764. /**
  9765. * Serializes the component data to the specified json object
  9766. * @param serializationObject The object to serialize to
  9767. */
  9768. serialize(serializationObject: any): void;
  9769. }
  9770. /**
  9771. * Strong typing of a Mesh related stage step action
  9772. */
  9773. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9774. /**
  9775. * Strong typing of a Evaluate Sub Mesh related stage step action
  9776. */
  9777. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9778. /**
  9779. * Strong typing of a Active Mesh related stage step action
  9780. */
  9781. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9782. /**
  9783. * Strong typing of a Camera related stage step action
  9784. */
  9785. export type CameraStageAction = (camera: Camera) => void;
  9786. /**
  9787. * Strong typing of a Camera Frame buffer related stage step action
  9788. */
  9789. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9790. /**
  9791. * Strong typing of a Render Target related stage step action
  9792. */
  9793. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9794. /**
  9795. * Strong typing of a RenderingGroup related stage step action
  9796. */
  9797. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9798. /**
  9799. * Strong typing of a Mesh Render related stage step action
  9800. */
  9801. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9802. /**
  9803. * Strong typing of a simple stage step action
  9804. */
  9805. export type SimpleStageAction = () => void;
  9806. /**
  9807. * Strong typing of a render target action.
  9808. */
  9809. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9810. /**
  9811. * Strong typing of a pointer move action.
  9812. */
  9813. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9814. /**
  9815. * Strong typing of a pointer up/down action.
  9816. */
  9817. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9818. /**
  9819. * Representation of a stage in the scene (Basically a list of ordered steps)
  9820. * @hidden
  9821. */
  9822. export class Stage<T extends Function> extends Array<{
  9823. index: number;
  9824. component: ISceneComponent;
  9825. action: T;
  9826. }> {
  9827. /**
  9828. * Hide ctor from the rest of the world.
  9829. * @param items The items to add.
  9830. */
  9831. private constructor();
  9832. /**
  9833. * Creates a new Stage.
  9834. * @returns A new instance of a Stage
  9835. */
  9836. static Create<T extends Function>(): Stage<T>;
  9837. /**
  9838. * Registers a step in an ordered way in the targeted stage.
  9839. * @param index Defines the position to register the step in
  9840. * @param component Defines the component attached to the step
  9841. * @param action Defines the action to launch during the step
  9842. */
  9843. registerStep(index: number, component: ISceneComponent, action: T): void;
  9844. /**
  9845. * Clears all the steps from the stage.
  9846. */
  9847. clear(): void;
  9848. }
  9849. }
  9850. declare module BABYLON {
  9851. interface Scene {
  9852. /** @hidden */
  9853. _pointerOverSprite: Nullable<Sprite>;
  9854. /** @hidden */
  9855. _pickedDownSprite: Nullable<Sprite>;
  9856. /** @hidden */
  9857. _tempSpritePickingRay: Nullable<Ray>;
  9858. /**
  9859. * All of the sprite managers added to this scene
  9860. * @see http://doc.babylonjs.com/babylon101/sprites
  9861. */
  9862. spriteManagers: Array<ISpriteManager>;
  9863. /**
  9864. * An event triggered when sprites rendering is about to start
  9865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9866. */
  9867. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9868. /**
  9869. * An event triggered when sprites rendering is done
  9870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9871. */
  9872. onAfterSpritesRenderingObservable: Observable<Scene>;
  9873. /** @hidden */
  9874. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9875. /** Launch a ray to try to pick a sprite in the scene
  9876. * @param x position on screen
  9877. * @param y position on screen
  9878. * @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
  9879. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9880. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9881. * @returns a PickingInfo
  9882. */
  9883. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9884. /** Use the given ray to pick a sprite in the scene
  9885. * @param ray The ray (in world space) to use to pick meshes
  9886. * @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
  9887. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9888. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9889. * @returns a PickingInfo
  9890. */
  9891. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9892. /** @hidden */
  9893. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9894. /** Launch a ray to try to pick sprites in the scene
  9895. * @param x position on screen
  9896. * @param y position on screen
  9897. * @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
  9898. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9899. * @returns a PickingInfo array
  9900. */
  9901. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9902. /** Use the given ray to pick sprites in the scene
  9903. * @param ray The ray (in world space) to use to pick meshes
  9904. * @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
  9905. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9906. * @returns a PickingInfo array
  9907. */
  9908. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9909. /**
  9910. * Force the sprite under the pointer
  9911. * @param sprite defines the sprite to use
  9912. */
  9913. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9914. /**
  9915. * Gets the sprite under the pointer
  9916. * @returns a Sprite or null if no sprite is under the pointer
  9917. */
  9918. getPointerOverSprite(): Nullable<Sprite>;
  9919. }
  9920. /**
  9921. * Defines the sprite scene component responsible to manage sprites
  9922. * in a given scene.
  9923. */
  9924. export class SpriteSceneComponent implements ISceneComponent {
  9925. /**
  9926. * The component name helpfull to identify the component in the list of scene components.
  9927. */
  9928. readonly name: string;
  9929. /**
  9930. * The scene the component belongs to.
  9931. */
  9932. scene: Scene;
  9933. /** @hidden */
  9934. private _spritePredicate;
  9935. /**
  9936. * Creates a new instance of the component for the given scene
  9937. * @param scene Defines the scene to register the component in
  9938. */
  9939. constructor(scene: Scene);
  9940. /**
  9941. * Registers the component in a given scene
  9942. */
  9943. register(): void;
  9944. /**
  9945. * Rebuilds the elements related to this component in case of
  9946. * context lost for instance.
  9947. */
  9948. rebuild(): void;
  9949. /**
  9950. * Disposes the component and the associated ressources.
  9951. */
  9952. dispose(): void;
  9953. private _pickSpriteButKeepRay;
  9954. private _pointerMove;
  9955. private _pointerDown;
  9956. private _pointerUp;
  9957. }
  9958. }
  9959. declare module BABYLON {
  9960. /** @hidden */
  9961. export var fogFragmentDeclaration: {
  9962. name: string;
  9963. shader: string;
  9964. };
  9965. }
  9966. declare module BABYLON {
  9967. /** @hidden */
  9968. export var fogFragment: {
  9969. name: string;
  9970. shader: string;
  9971. };
  9972. }
  9973. declare module BABYLON {
  9974. /** @hidden */
  9975. export var spritesPixelShader: {
  9976. name: string;
  9977. shader: string;
  9978. };
  9979. }
  9980. declare module BABYLON {
  9981. /** @hidden */
  9982. export var fogVertexDeclaration: {
  9983. name: string;
  9984. shader: string;
  9985. };
  9986. }
  9987. declare module BABYLON {
  9988. /** @hidden */
  9989. export var spritesVertexShader: {
  9990. name: string;
  9991. shader: string;
  9992. };
  9993. }
  9994. declare module BABYLON {
  9995. /**
  9996. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9997. */
  9998. export interface ISpriteManager extends IDisposable {
  9999. /**
  10000. * Restricts the camera to viewing objects with the same layerMask.
  10001. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10002. */
  10003. layerMask: number;
  10004. /**
  10005. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10006. */
  10007. isPickable: boolean;
  10008. /**
  10009. * Specifies the rendering group id for this mesh (0 by default)
  10010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10011. */
  10012. renderingGroupId: number;
  10013. /**
  10014. * Defines the list of sprites managed by the manager.
  10015. */
  10016. sprites: Array<Sprite>;
  10017. /**
  10018. * Tests the intersection of a sprite with a specific ray.
  10019. * @param ray The ray we are sending to test the collision
  10020. * @param camera The camera space we are sending rays in
  10021. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10022. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10023. * @returns picking info or null.
  10024. */
  10025. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10026. /**
  10027. * Intersects the sprites with a ray
  10028. * @param ray defines the ray to intersect with
  10029. * @param camera defines the current active camera
  10030. * @param predicate defines a predicate used to select candidate sprites
  10031. * @returns null if no hit or a PickingInfo array
  10032. */
  10033. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10034. /**
  10035. * Renders the list of sprites on screen.
  10036. */
  10037. render(): void;
  10038. }
  10039. /**
  10040. * Class used to manage multiple sprites on the same spritesheet
  10041. * @see http://doc.babylonjs.com/babylon101/sprites
  10042. */
  10043. export class SpriteManager implements ISpriteManager {
  10044. /** defines the manager's name */
  10045. name: string;
  10046. /** Gets the list of sprites */
  10047. sprites: Sprite[];
  10048. /** Gets or sets the rendering group id (0 by default) */
  10049. renderingGroupId: number;
  10050. /** Gets or sets camera layer mask */
  10051. layerMask: number;
  10052. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10053. fogEnabled: boolean;
  10054. /** Gets or sets a boolean indicating if the sprites are pickable */
  10055. isPickable: boolean;
  10056. /** Defines the default width of a cell in the spritesheet */
  10057. cellWidth: number;
  10058. /** Defines the default height of a cell in the spritesheet */
  10059. cellHeight: number;
  10060. /** Associative array from JSON sprite data file */
  10061. private _cellData;
  10062. /** Array of sprite names from JSON sprite data file */
  10063. private _spriteMap;
  10064. /** True when packed cell data from JSON file is ready*/
  10065. private _packedAndReady;
  10066. private _textureContent;
  10067. /**
  10068. * An event triggered when the manager is disposed.
  10069. */
  10070. onDisposeObservable: Observable<SpriteManager>;
  10071. private _onDisposeObserver;
  10072. /**
  10073. * Callback called when the manager is disposed
  10074. */
  10075. set onDispose(callback: () => void);
  10076. private _capacity;
  10077. private _fromPacked;
  10078. private _spriteTexture;
  10079. private _epsilon;
  10080. private _scene;
  10081. private _vertexData;
  10082. private _buffer;
  10083. private _vertexBuffers;
  10084. private _indexBuffer;
  10085. private _effectBase;
  10086. private _effectFog;
  10087. /**
  10088. * Gets or sets the spritesheet texture
  10089. */
  10090. get texture(): Texture;
  10091. set texture(value: Texture);
  10092. private _blendMode;
  10093. /**
  10094. * Blend mode use to render the particle, it can be any of
  10095. * the static Constants.ALPHA_x properties provided in this class.
  10096. * Default value is Constants.ALPHA_COMBINE
  10097. */
  10098. get blendMode(): number;
  10099. set blendMode(blendMode: number);
  10100. /** Disables writing to the depth buffer when rendering the sprites.
  10101. * It can be handy to disable depth writing when using textures without alpha channel
  10102. * and setting some specific blend modes.
  10103. */
  10104. disableDepthWrite: boolean;
  10105. /**
  10106. * Creates a new sprite manager
  10107. * @param name defines the manager's name
  10108. * @param imgUrl defines the sprite sheet url
  10109. * @param capacity defines the maximum allowed number of sprites
  10110. * @param cellSize defines the size of a sprite cell
  10111. * @param scene defines the hosting scene
  10112. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10113. * @param samplingMode defines the smapling mode to use with spritesheet
  10114. * @param fromPacked set to false; do not alter
  10115. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10116. */
  10117. constructor(
  10118. /** defines the manager's name */
  10119. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10120. private _makePacked;
  10121. private _appendSpriteVertex;
  10122. private _checkTextureAlpha;
  10123. /**
  10124. * Intersects the sprites with a ray
  10125. * @param ray defines the ray to intersect with
  10126. * @param camera defines the current active camera
  10127. * @param predicate defines a predicate used to select candidate sprites
  10128. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10129. * @returns null if no hit or a PickingInfo
  10130. */
  10131. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10132. /**
  10133. * Intersects the sprites with a ray
  10134. * @param ray defines the ray to intersect with
  10135. * @param camera defines the current active camera
  10136. * @param predicate defines a predicate used to select candidate sprites
  10137. * @returns null if no hit or a PickingInfo array
  10138. */
  10139. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10140. /**
  10141. * Render all child sprites
  10142. */
  10143. render(): void;
  10144. /**
  10145. * Release associated resources
  10146. */
  10147. dispose(): void;
  10148. }
  10149. }
  10150. declare module BABYLON {
  10151. /** Interface used by value gradients (color, factor, ...) */
  10152. export interface IValueGradient {
  10153. /**
  10154. * Gets or sets the gradient value (between 0 and 1)
  10155. */
  10156. gradient: number;
  10157. }
  10158. /** Class used to store color4 gradient */
  10159. export class ColorGradient implements IValueGradient {
  10160. /**
  10161. * Gets or sets the gradient value (between 0 and 1)
  10162. */
  10163. gradient: number;
  10164. /**
  10165. * Gets or sets first associated color
  10166. */
  10167. color1: Color4;
  10168. /**
  10169. * Gets or sets second associated color
  10170. */
  10171. color2?: Color4 | undefined;
  10172. /**
  10173. * Creates a new color4 gradient
  10174. * @param gradient gets or sets the gradient value (between 0 and 1)
  10175. * @param color1 gets or sets first associated color
  10176. * @param color2 gets or sets first second color
  10177. */
  10178. constructor(
  10179. /**
  10180. * Gets or sets the gradient value (between 0 and 1)
  10181. */
  10182. gradient: number,
  10183. /**
  10184. * Gets or sets first associated color
  10185. */
  10186. color1: Color4,
  10187. /**
  10188. * Gets or sets second associated color
  10189. */
  10190. color2?: Color4 | undefined);
  10191. /**
  10192. * Will get a color picked randomly between color1 and color2.
  10193. * If color2 is undefined then color1 will be used
  10194. * @param result defines the target Color4 to store the result in
  10195. */
  10196. getColorToRef(result: Color4): void;
  10197. }
  10198. /** Class used to store color 3 gradient */
  10199. export class Color3Gradient implements IValueGradient {
  10200. /**
  10201. * Gets or sets the gradient value (between 0 and 1)
  10202. */
  10203. gradient: number;
  10204. /**
  10205. * Gets or sets the associated color
  10206. */
  10207. color: Color3;
  10208. /**
  10209. * Creates a new color3 gradient
  10210. * @param gradient gets or sets the gradient value (between 0 and 1)
  10211. * @param color gets or sets associated color
  10212. */
  10213. constructor(
  10214. /**
  10215. * Gets or sets the gradient value (between 0 and 1)
  10216. */
  10217. gradient: number,
  10218. /**
  10219. * Gets or sets the associated color
  10220. */
  10221. color: Color3);
  10222. }
  10223. /** Class used to store factor gradient */
  10224. export class FactorGradient implements IValueGradient {
  10225. /**
  10226. * Gets or sets the gradient value (between 0 and 1)
  10227. */
  10228. gradient: number;
  10229. /**
  10230. * Gets or sets first associated factor
  10231. */
  10232. factor1: number;
  10233. /**
  10234. * Gets or sets second associated factor
  10235. */
  10236. factor2?: number | undefined;
  10237. /**
  10238. * Creates a new factor gradient
  10239. * @param gradient gets or sets the gradient value (between 0 and 1)
  10240. * @param factor1 gets or sets first associated factor
  10241. * @param factor2 gets or sets second associated factor
  10242. */
  10243. constructor(
  10244. /**
  10245. * Gets or sets the gradient value (between 0 and 1)
  10246. */
  10247. gradient: number,
  10248. /**
  10249. * Gets or sets first associated factor
  10250. */
  10251. factor1: number,
  10252. /**
  10253. * Gets or sets second associated factor
  10254. */
  10255. factor2?: number | undefined);
  10256. /**
  10257. * Will get a number picked randomly between factor1 and factor2.
  10258. * If factor2 is undefined then factor1 will be used
  10259. * @returns the picked number
  10260. */
  10261. getFactor(): number;
  10262. }
  10263. /**
  10264. * Helper used to simplify some generic gradient tasks
  10265. */
  10266. export class GradientHelper {
  10267. /**
  10268. * Gets the current gradient from an array of IValueGradient
  10269. * @param ratio defines the current ratio to get
  10270. * @param gradients defines the array of IValueGradient
  10271. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10272. */
  10273. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Interface for the size containing width and height
  10279. */
  10280. export interface ISize {
  10281. /**
  10282. * Width
  10283. */
  10284. width: number;
  10285. /**
  10286. * Heighht
  10287. */
  10288. height: number;
  10289. }
  10290. /**
  10291. * Size containing widht and height
  10292. */
  10293. export class Size implements ISize {
  10294. /**
  10295. * Width
  10296. */
  10297. width: number;
  10298. /**
  10299. * Height
  10300. */
  10301. height: number;
  10302. /**
  10303. * Creates a Size object from the given width and height (floats).
  10304. * @param width width of the new size
  10305. * @param height height of the new size
  10306. */
  10307. constructor(width: number, height: number);
  10308. /**
  10309. * Returns a string with the Size width and height
  10310. * @returns a string with the Size width and height
  10311. */
  10312. toString(): string;
  10313. /**
  10314. * "Size"
  10315. * @returns the string "Size"
  10316. */
  10317. getClassName(): string;
  10318. /**
  10319. * Returns the Size hash code.
  10320. * @returns a hash code for a unique width and height
  10321. */
  10322. getHashCode(): number;
  10323. /**
  10324. * Updates the current size from the given one.
  10325. * @param src the given size
  10326. */
  10327. copyFrom(src: Size): void;
  10328. /**
  10329. * Updates in place the current Size from the given floats.
  10330. * @param width width of the new size
  10331. * @param height height of the new size
  10332. * @returns the updated Size.
  10333. */
  10334. copyFromFloats(width: number, height: number): Size;
  10335. /**
  10336. * Updates in place the current Size from the given floats.
  10337. * @param width width to set
  10338. * @param height height to set
  10339. * @returns the updated Size.
  10340. */
  10341. set(width: number, height: number): Size;
  10342. /**
  10343. * Multiplies the width and height by numbers
  10344. * @param w factor to multiple the width by
  10345. * @param h factor to multiple the height by
  10346. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10347. */
  10348. multiplyByFloats(w: number, h: number): Size;
  10349. /**
  10350. * Clones the size
  10351. * @returns a new Size copied from the given one.
  10352. */
  10353. clone(): Size;
  10354. /**
  10355. * True if the current Size and the given one width and height are strictly equal.
  10356. * @param other the other size to compare against
  10357. * @returns True if the current Size and the given one width and height are strictly equal.
  10358. */
  10359. equals(other: Size): boolean;
  10360. /**
  10361. * The surface of the Size : width * height (float).
  10362. */
  10363. get surface(): number;
  10364. /**
  10365. * Create a new size of zero
  10366. * @returns a new Size set to (0.0, 0.0)
  10367. */
  10368. static Zero(): Size;
  10369. /**
  10370. * Sums the width and height of two sizes
  10371. * @param otherSize size to add to this size
  10372. * @returns a new Size set as the addition result of the current Size and the given one.
  10373. */
  10374. add(otherSize: Size): Size;
  10375. /**
  10376. * Subtracts the width and height of two
  10377. * @param otherSize size to subtract to this size
  10378. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10379. */
  10380. subtract(otherSize: Size): Size;
  10381. /**
  10382. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10383. * @param start starting size to lerp between
  10384. * @param end end size to lerp between
  10385. * @param amount amount to lerp between the start and end values
  10386. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10387. */
  10388. static Lerp(start: Size, end: Size, amount: number): Size;
  10389. }
  10390. }
  10391. declare module BABYLON {
  10392. interface ThinEngine {
  10393. /**
  10394. * Creates a dynamic texture
  10395. * @param width defines the width of the texture
  10396. * @param height defines the height of the texture
  10397. * @param generateMipMaps defines if the engine should generate the mip levels
  10398. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10399. * @returns the dynamic texture inside an InternalTexture
  10400. */
  10401. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10402. /**
  10403. * Update the content of a dynamic texture
  10404. * @param texture defines the texture to update
  10405. * @param canvas defines the canvas containing the source
  10406. * @param invertY defines if data must be stored with Y axis inverted
  10407. * @param premulAlpha defines if alpha is stored as premultiplied
  10408. * @param format defines the format of the data
  10409. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10410. */
  10411. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10412. }
  10413. }
  10414. declare module BABYLON {
  10415. /**
  10416. * Helper class used to generate a canvas to manipulate images
  10417. */
  10418. export class CanvasGenerator {
  10419. /**
  10420. * Create a new canvas (or offscreen canvas depending on the context)
  10421. * @param width defines the expected width
  10422. * @param height defines the expected height
  10423. * @return a new canvas or offscreen canvas
  10424. */
  10425. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10426. }
  10427. }
  10428. declare module BABYLON {
  10429. /**
  10430. * A class extending Texture allowing drawing on a texture
  10431. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10432. */
  10433. export class DynamicTexture extends Texture {
  10434. private _generateMipMaps;
  10435. private _canvas;
  10436. private _context;
  10437. private _engine;
  10438. /**
  10439. * Creates a DynamicTexture
  10440. * @param name defines the name of the texture
  10441. * @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
  10442. * @param scene defines the scene where you want the texture
  10443. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10444. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10445. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10446. */
  10447. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10448. /**
  10449. * Get the current class name of the texture useful for serialization or dynamic coding.
  10450. * @returns "DynamicTexture"
  10451. */
  10452. getClassName(): string;
  10453. /**
  10454. * Gets the current state of canRescale
  10455. */
  10456. get canRescale(): boolean;
  10457. private _recreate;
  10458. /**
  10459. * Scales the texture
  10460. * @param ratio the scale factor to apply to both width and height
  10461. */
  10462. scale(ratio: number): void;
  10463. /**
  10464. * Resizes the texture
  10465. * @param width the new width
  10466. * @param height the new height
  10467. */
  10468. scaleTo(width: number, height: number): void;
  10469. /**
  10470. * Gets the context of the canvas used by the texture
  10471. * @returns the canvas context of the dynamic texture
  10472. */
  10473. getContext(): CanvasRenderingContext2D;
  10474. /**
  10475. * Clears the texture
  10476. */
  10477. clear(): void;
  10478. /**
  10479. * Updates the texture
  10480. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10481. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10482. */
  10483. update(invertY?: boolean, premulAlpha?: boolean): void;
  10484. /**
  10485. * Draws text onto the texture
  10486. * @param text defines the text to be drawn
  10487. * @param x defines the placement of the text from the left
  10488. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10489. * @param font defines the font to be used with font-style, font-size, font-name
  10490. * @param color defines the color used for the text
  10491. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10492. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10493. * @param update defines whether texture is immediately update (default is true)
  10494. */
  10495. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10496. /**
  10497. * Clones the texture
  10498. * @returns the clone of the texture.
  10499. */
  10500. clone(): DynamicTexture;
  10501. /**
  10502. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10503. * @returns a serialized dynamic texture object
  10504. */
  10505. serialize(): any;
  10506. /** @hidden */
  10507. _rebuild(): void;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. interface ThinEngine {
  10512. /**
  10513. * Creates a raw texture
  10514. * @param data defines the data to store in the texture
  10515. * @param width defines the width of the texture
  10516. * @param height defines the height of the texture
  10517. * @param format defines the format of the data
  10518. * @param generateMipMaps defines if the engine should generate the mip levels
  10519. * @param invertY defines if data must be stored with Y axis inverted
  10520. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10521. * @param compression defines the compression used (null by default)
  10522. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10523. * @returns the raw texture inside an InternalTexture
  10524. */
  10525. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10526. /**
  10527. * Update a raw texture
  10528. * @param texture defines the texture to update
  10529. * @param data defines the data to store in the texture
  10530. * @param format defines the format of the data
  10531. * @param invertY defines if data must be stored with Y axis inverted
  10532. */
  10533. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10534. /**
  10535. * Update a raw texture
  10536. * @param texture defines the texture to update
  10537. * @param data defines the data to store in the texture
  10538. * @param format defines the format of the data
  10539. * @param invertY defines if data must be stored with Y axis inverted
  10540. * @param compression defines the compression used (null by default)
  10541. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10542. */
  10543. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10544. /**
  10545. * Creates a new raw cube texture
  10546. * @param data defines the array of data to use to create each face
  10547. * @param size defines the size of the textures
  10548. * @param format defines the format of the data
  10549. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10550. * @param generateMipMaps defines if the engine should generate the mip levels
  10551. * @param invertY defines if data must be stored with Y axis inverted
  10552. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10553. * @param compression defines the compression used (null by default)
  10554. * @returns the cube texture as an InternalTexture
  10555. */
  10556. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10557. /**
  10558. * Update a raw cube texture
  10559. * @param texture defines the texture to udpdate
  10560. * @param data defines the data to store
  10561. * @param format defines the data format
  10562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10563. * @param invertY defines if data must be stored with Y axis inverted
  10564. */
  10565. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10566. /**
  10567. * Update a raw cube texture
  10568. * @param texture defines the texture to udpdate
  10569. * @param data defines the data to store
  10570. * @param format defines the data format
  10571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10572. * @param invertY defines if data must be stored with Y axis inverted
  10573. * @param compression defines the compression used (null by default)
  10574. */
  10575. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10576. /**
  10577. * Update a raw cube texture
  10578. * @param texture defines the texture to udpdate
  10579. * @param data defines the data to store
  10580. * @param format defines the data format
  10581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10582. * @param invertY defines if data must be stored with Y axis inverted
  10583. * @param compression defines the compression used (null by default)
  10584. * @param level defines which level of the texture to update
  10585. */
  10586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10587. /**
  10588. * Creates a new raw cube texture from a specified url
  10589. * @param url defines the url where the data is located
  10590. * @param scene defines the current scene
  10591. * @param size defines the size of the textures
  10592. * @param format defines the format of the data
  10593. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10594. * @param noMipmap defines if the engine should avoid generating the mip levels
  10595. * @param callback defines a callback used to extract texture data from loaded data
  10596. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10597. * @param onLoad defines a callback called when texture is loaded
  10598. * @param onError defines a callback called if there is an error
  10599. * @returns the cube texture as an InternalTexture
  10600. */
  10601. 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;
  10602. /**
  10603. * Creates a new raw cube texture from a specified url
  10604. * @param url defines the url where the data is located
  10605. * @param scene defines the current scene
  10606. * @param size defines the size of the textures
  10607. * @param format defines the format of the data
  10608. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10609. * @param noMipmap defines if the engine should avoid generating the mip levels
  10610. * @param callback defines a callback used to extract texture data from loaded data
  10611. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10612. * @param onLoad defines a callback called when texture is loaded
  10613. * @param onError defines a callback called if there is an error
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param invertY defines if data must be stored with Y axis inverted
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. 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;
  10619. /**
  10620. * Creates a new raw 3D texture
  10621. * @param data defines the data used to create the texture
  10622. * @param width defines the width of the texture
  10623. * @param height defines the height of the texture
  10624. * @param depth defines the depth of the texture
  10625. * @param format defines the format of the texture
  10626. * @param generateMipMaps defines if the engine must generate mip levels
  10627. * @param invertY defines if data must be stored with Y axis inverted
  10628. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10629. * @param compression defines the compressed used (can be null)
  10630. * @param textureType defines the compressed used (can be null)
  10631. * @returns a new raw 3D texture (stored in an InternalTexture)
  10632. */
  10633. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10634. /**
  10635. * Update a raw 3D texture
  10636. * @param texture defines the texture to update
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param invertY defines if data must be stored with Y axis inverted
  10640. */
  10641. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10642. /**
  10643. * Update a raw 3D texture
  10644. * @param texture defines the texture to update
  10645. * @param data defines the data to store
  10646. * @param format defines the data format
  10647. * @param invertY defines if data must be stored with Y axis inverted
  10648. * @param compression defines the used compression (can be null)
  10649. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10650. */
  10651. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10652. /**
  10653. * Creates a new raw 2D array texture
  10654. * @param data defines the data used to create the texture
  10655. * @param width defines the width of the texture
  10656. * @param height defines the height of the texture
  10657. * @param depth defines the number of layers of the texture
  10658. * @param format defines the format of the texture
  10659. * @param generateMipMaps defines if the engine must generate mip levels
  10660. * @param invertY defines if data must be stored with Y axis inverted
  10661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10662. * @param compression defines the compressed used (can be null)
  10663. * @param textureType defines the compressed used (can be null)
  10664. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10665. */
  10666. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10667. /**
  10668. * Update a raw 2D array texture
  10669. * @param texture defines the texture to update
  10670. * @param data defines the data to store
  10671. * @param format defines the data format
  10672. * @param invertY defines if data must be stored with Y axis inverted
  10673. */
  10674. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10675. /**
  10676. * Update a raw 2D array texture
  10677. * @param texture defines the texture to update
  10678. * @param data defines the data to store
  10679. * @param format defines the data format
  10680. * @param invertY defines if data must be stored with Y axis inverted
  10681. * @param compression defines the used compression (can be null)
  10682. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10683. */
  10684. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10685. }
  10686. }
  10687. declare module BABYLON {
  10688. /**
  10689. * Raw texture can help creating a texture directly from an array of data.
  10690. * This can be super useful if you either get the data from an uncompressed source or
  10691. * if you wish to create your texture pixel by pixel.
  10692. */
  10693. export class RawTexture extends Texture {
  10694. /**
  10695. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10696. */
  10697. format: number;
  10698. private _engine;
  10699. /**
  10700. * Instantiates a new RawTexture.
  10701. * Raw texture can help creating a texture directly from an array of data.
  10702. * This can be super useful if you either get the data from an uncompressed source or
  10703. * if you wish to create your texture pixel by pixel.
  10704. * @param data define the array of data to use to create the texture
  10705. * @param width define the width of the texture
  10706. * @param height define the height of the texture
  10707. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10708. * @param scene define the scene the texture belongs to
  10709. * @param generateMipMaps define whether mip maps should be generated or not
  10710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10713. */
  10714. constructor(data: ArrayBufferView, width: number, height: number,
  10715. /**
  10716. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10717. */
  10718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10719. /**
  10720. * Updates the texture underlying data.
  10721. * @param data Define the new data of the texture
  10722. */
  10723. update(data: ArrayBufferView): void;
  10724. /**
  10725. * Creates a luminance texture from some data.
  10726. * @param data Define the texture data
  10727. * @param width Define the width of the texture
  10728. * @param height Define the height of the texture
  10729. * @param scene Define the scene the texture belongs to
  10730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10733. * @returns the luminance texture
  10734. */
  10735. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10736. /**
  10737. * Creates a luminance alpha texture from some data.
  10738. * @param data Define the texture data
  10739. * @param width Define the width of the texture
  10740. * @param height Define the height of the texture
  10741. * @param scene Define the scene the texture belongs to
  10742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10745. * @returns the luminance alpha texture
  10746. */
  10747. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10748. /**
  10749. * Creates an alpha texture from some data.
  10750. * @param data Define the texture data
  10751. * @param width Define the width of the texture
  10752. * @param height Define the height of the texture
  10753. * @param scene Define the scene the texture belongs to
  10754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10757. * @returns the alpha texture
  10758. */
  10759. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10760. /**
  10761. * Creates a RGB texture from some data.
  10762. * @param data Define the texture data
  10763. * @param width Define the width of the texture
  10764. * @param height Define the height of the texture
  10765. * @param scene Define the scene the texture belongs to
  10766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10770. * @returns the RGB alpha texture
  10771. */
  10772. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10773. /**
  10774. * Creates a RGBA texture from some data.
  10775. * @param data Define the texture data
  10776. * @param width Define the width of the texture
  10777. * @param height Define the height of the texture
  10778. * @param scene Define the scene the texture belongs to
  10779. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10780. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10781. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10782. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10783. * @returns the RGBA texture
  10784. */
  10785. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10786. /**
  10787. * Creates a R texture from some data.
  10788. * @param data Define the texture data
  10789. * @param width Define the width of the texture
  10790. * @param height Define the height of the texture
  10791. * @param scene Define the scene the texture belongs to
  10792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10796. * @returns the R texture
  10797. */
  10798. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10799. }
  10800. }
  10801. declare module BABYLON {
  10802. interface AbstractScene {
  10803. /**
  10804. * The list of procedural textures added to the scene
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10806. */
  10807. proceduralTextures: Array<ProceduralTexture>;
  10808. }
  10809. /**
  10810. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10811. * in a given scene.
  10812. */
  10813. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10814. /**
  10815. * The component name helpfull to identify the component in the list of scene components.
  10816. */
  10817. readonly name: string;
  10818. /**
  10819. * The scene the component belongs to.
  10820. */
  10821. scene: Scene;
  10822. /**
  10823. * Creates a new instance of the component for the given scene
  10824. * @param scene Defines the scene to register the component in
  10825. */
  10826. constructor(scene: Scene);
  10827. /**
  10828. * Registers the component in a given scene
  10829. */
  10830. register(): void;
  10831. /**
  10832. * Rebuilds the elements related to this component in case of
  10833. * context lost for instance.
  10834. */
  10835. rebuild(): void;
  10836. /**
  10837. * Disposes the component and the associated ressources.
  10838. */
  10839. dispose(): void;
  10840. private _beforeClear;
  10841. }
  10842. }
  10843. declare module BABYLON {
  10844. interface ThinEngine {
  10845. /**
  10846. * Creates a new render target cube texture
  10847. * @param size defines the size of the texture
  10848. * @param options defines the options used to create the texture
  10849. * @returns a new render target cube texture stored in an InternalTexture
  10850. */
  10851. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10852. }
  10853. }
  10854. declare module BABYLON {
  10855. /** @hidden */
  10856. export var proceduralVertexShader: {
  10857. name: string;
  10858. shader: string;
  10859. };
  10860. }
  10861. declare module BABYLON {
  10862. /**
  10863. * 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.
  10864. * This is the base class of any Procedural texture and contains most of the shareable code.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10866. */
  10867. export class ProceduralTexture extends Texture {
  10868. isCube: boolean;
  10869. /**
  10870. * Define if the texture is enabled or not (disabled texture will not render)
  10871. */
  10872. isEnabled: boolean;
  10873. /**
  10874. * Define if the texture must be cleared before rendering (default is true)
  10875. */
  10876. autoClear: boolean;
  10877. /**
  10878. * Callback called when the texture is generated
  10879. */
  10880. onGenerated: () => void;
  10881. /**
  10882. * Event raised when the texture is generated
  10883. */
  10884. onGeneratedObservable: Observable<ProceduralTexture>;
  10885. /** @hidden */
  10886. _generateMipMaps: boolean;
  10887. /** @hidden **/
  10888. _effect: Effect;
  10889. /** @hidden */
  10890. _textures: {
  10891. [key: string]: Texture;
  10892. };
  10893. /** @hidden */
  10894. protected _fallbackTexture: Nullable<Texture>;
  10895. private _size;
  10896. private _currentRefreshId;
  10897. private _frameId;
  10898. private _refreshRate;
  10899. private _vertexBuffers;
  10900. private _indexBuffer;
  10901. private _uniforms;
  10902. private _samplers;
  10903. private _fragment;
  10904. private _floats;
  10905. private _ints;
  10906. private _floatsArrays;
  10907. private _colors3;
  10908. private _colors4;
  10909. private _vectors2;
  10910. private _vectors3;
  10911. private _matrices;
  10912. private _fallbackTextureUsed;
  10913. private _engine;
  10914. private _cachedDefines;
  10915. private _contentUpdateId;
  10916. private _contentData;
  10917. /**
  10918. * Instantiates a new procedural texture.
  10919. * 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.
  10920. * This is the base class of any Procedural texture and contains most of the shareable code.
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10922. * @param name Define the name of the texture
  10923. * @param size Define the size of the texture to create
  10924. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10925. * @param scene Define the scene the texture belongs to
  10926. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10927. * @param generateMipMaps Define if the texture should creates mip maps or not
  10928. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10929. */
  10930. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10931. /**
  10932. * The effect that is created when initializing the post process.
  10933. * @returns The created effect corresponding the the postprocess.
  10934. */
  10935. getEffect(): Effect;
  10936. /**
  10937. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10938. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10939. */
  10940. getContent(): Nullable<ArrayBufferView>;
  10941. private _createIndexBuffer;
  10942. /** @hidden */
  10943. _rebuild(): void;
  10944. /**
  10945. * Resets the texture in order to recreate its associated resources.
  10946. * This can be called in case of context loss
  10947. */
  10948. reset(): void;
  10949. protected _getDefines(): string;
  10950. /**
  10951. * Is the texture ready to be used ? (rendered at least once)
  10952. * @returns true if ready, otherwise, false.
  10953. */
  10954. isReady(): boolean;
  10955. /**
  10956. * Resets the refresh counter of the texture and start bak from scratch.
  10957. * Could be useful to regenerate the texture if it is setup to render only once.
  10958. */
  10959. resetRefreshCounter(): void;
  10960. /**
  10961. * Set the fragment shader to use in order to render the texture.
  10962. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10963. */
  10964. setFragment(fragment: any): void;
  10965. /**
  10966. * Define the refresh rate of the texture or the rendering frequency.
  10967. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10968. */
  10969. get refreshRate(): number;
  10970. set refreshRate(value: number);
  10971. /** @hidden */
  10972. _shouldRender(): boolean;
  10973. /**
  10974. * Get the size the texture is rendering at.
  10975. * @returns the size (texture is always squared)
  10976. */
  10977. getRenderSize(): number;
  10978. /**
  10979. * Resize the texture to new value.
  10980. * @param size Define the new size the texture should have
  10981. * @param generateMipMaps Define whether the new texture should create mip maps
  10982. */
  10983. resize(size: number, generateMipMaps: boolean): void;
  10984. private _checkUniform;
  10985. /**
  10986. * Set a texture in the shader program used to render.
  10987. * @param name Define the name of the uniform samplers as defined in the shader
  10988. * @param texture Define the texture to bind to this sampler
  10989. * @return the texture itself allowing "fluent" like uniform updates
  10990. */
  10991. setTexture(name: string, texture: Texture): ProceduralTexture;
  10992. /**
  10993. * Set a float in the shader.
  10994. * @param name Define the name of the uniform as defined in the shader
  10995. * @param value Define the value to give to the uniform
  10996. * @return the texture itself allowing "fluent" like uniform updates
  10997. */
  10998. setFloat(name: string, value: number): ProceduralTexture;
  10999. /**
  11000. * Set a int in the shader.
  11001. * @param name Define the name of the uniform as defined in the shader
  11002. * @param value Define the value to give to the uniform
  11003. * @return the texture itself allowing "fluent" like uniform updates
  11004. */
  11005. setInt(name: string, value: number): ProceduralTexture;
  11006. /**
  11007. * Set an array of floats in the shader.
  11008. * @param name Define the name of the uniform as defined in the shader
  11009. * @param value Define the value to give to the uniform
  11010. * @return the texture itself allowing "fluent" like uniform updates
  11011. */
  11012. setFloats(name: string, value: number[]): ProceduralTexture;
  11013. /**
  11014. * Set a vec3 in the shader from a Color3.
  11015. * @param name Define the name of the uniform as defined in the shader
  11016. * @param value Define the value to give to the uniform
  11017. * @return the texture itself allowing "fluent" like uniform updates
  11018. */
  11019. setColor3(name: string, value: Color3): ProceduralTexture;
  11020. /**
  11021. * Set a vec4 in the shader from a Color4.
  11022. * @param name Define the name of the uniform as defined in the shader
  11023. * @param value Define the value to give to the uniform
  11024. * @return the texture itself allowing "fluent" like uniform updates
  11025. */
  11026. setColor4(name: string, value: Color4): ProceduralTexture;
  11027. /**
  11028. * Set a vec2 in the shader from a Vector2.
  11029. * @param name Define the name of the uniform as defined in the shader
  11030. * @param value Define the value to give to the uniform
  11031. * @return the texture itself allowing "fluent" like uniform updates
  11032. */
  11033. setVector2(name: string, value: Vector2): ProceduralTexture;
  11034. /**
  11035. * Set a vec3 in the shader from a Vector3.
  11036. * @param name Define the name of the uniform as defined in the shader
  11037. * @param value Define the value to give to the uniform
  11038. * @return the texture itself allowing "fluent" like uniform updates
  11039. */
  11040. setVector3(name: string, value: Vector3): ProceduralTexture;
  11041. /**
  11042. * Set a mat4 in the shader from a MAtrix.
  11043. * @param name Define the name of the uniform as defined in the shader
  11044. * @param value Define the value to give to the uniform
  11045. * @return the texture itself allowing "fluent" like uniform updates
  11046. */
  11047. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11048. /**
  11049. * Render the texture to its associated render target.
  11050. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11051. */
  11052. render(useCameraPostProcess?: boolean): void;
  11053. /**
  11054. * Clone the texture.
  11055. * @returns the cloned texture
  11056. */
  11057. clone(): ProceduralTexture;
  11058. /**
  11059. * Dispose the texture and release its asoociated resources.
  11060. */
  11061. dispose(): void;
  11062. }
  11063. }
  11064. declare module BABYLON {
  11065. /**
  11066. * This represents the base class for particle system in Babylon.
  11067. * 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.
  11068. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11069. * @example https://doc.babylonjs.com/babylon101/particles
  11070. */
  11071. export class BaseParticleSystem {
  11072. /**
  11073. * Source color is added to the destination color without alpha affecting the result
  11074. */
  11075. static BLENDMODE_ONEONE: number;
  11076. /**
  11077. * Blend current color and particle color using particle’s alpha
  11078. */
  11079. static BLENDMODE_STANDARD: number;
  11080. /**
  11081. * Add current color and particle color multiplied by particle’s alpha
  11082. */
  11083. static BLENDMODE_ADD: number;
  11084. /**
  11085. * Multiply current color with particle color
  11086. */
  11087. static BLENDMODE_MULTIPLY: number;
  11088. /**
  11089. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11090. */
  11091. static BLENDMODE_MULTIPLYADD: number;
  11092. /**
  11093. * List of animations used by the particle system.
  11094. */
  11095. animations: Animation[];
  11096. /**
  11097. * Gets or sets the unique id of the particle system
  11098. */
  11099. uniqueId: number;
  11100. /**
  11101. * The id of the Particle system.
  11102. */
  11103. id: string;
  11104. /**
  11105. * The friendly name of the Particle system.
  11106. */
  11107. name: string;
  11108. /**
  11109. * Snippet ID if the particle system was created from the snippet server
  11110. */
  11111. snippetId: string;
  11112. /**
  11113. * The rendering group used by the Particle system to chose when to render.
  11114. */
  11115. renderingGroupId: number;
  11116. /**
  11117. * The emitter represents the Mesh or position we are attaching the particle system to.
  11118. */
  11119. emitter: Nullable<AbstractMesh | Vector3>;
  11120. /**
  11121. * The maximum number of particles to emit per frame
  11122. */
  11123. emitRate: number;
  11124. /**
  11125. * If you want to launch only a few particles at once, that can be done, as well.
  11126. */
  11127. manualEmitCount: number;
  11128. /**
  11129. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11130. */
  11131. updateSpeed: number;
  11132. /**
  11133. * The amount of time the particle system is running (depends of the overall update speed).
  11134. */
  11135. targetStopDuration: number;
  11136. /**
  11137. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11138. */
  11139. disposeOnStop: boolean;
  11140. /**
  11141. * Minimum power of emitting particles.
  11142. */
  11143. minEmitPower: number;
  11144. /**
  11145. * Maximum power of emitting particles.
  11146. */
  11147. maxEmitPower: number;
  11148. /**
  11149. * Minimum life time of emitting particles.
  11150. */
  11151. minLifeTime: number;
  11152. /**
  11153. * Maximum life time of emitting particles.
  11154. */
  11155. maxLifeTime: number;
  11156. /**
  11157. * Minimum Size of emitting particles.
  11158. */
  11159. minSize: number;
  11160. /**
  11161. * Maximum Size of emitting particles.
  11162. */
  11163. maxSize: number;
  11164. /**
  11165. * Minimum scale of emitting particles on X axis.
  11166. */
  11167. minScaleX: number;
  11168. /**
  11169. * Maximum scale of emitting particles on X axis.
  11170. */
  11171. maxScaleX: number;
  11172. /**
  11173. * Minimum scale of emitting particles on Y axis.
  11174. */
  11175. minScaleY: number;
  11176. /**
  11177. * Maximum scale of emitting particles on Y axis.
  11178. */
  11179. maxScaleY: number;
  11180. /**
  11181. * Gets or sets the minimal initial rotation in radians.
  11182. */
  11183. minInitialRotation: number;
  11184. /**
  11185. * Gets or sets the maximal initial rotation in radians.
  11186. */
  11187. maxInitialRotation: number;
  11188. /**
  11189. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11190. */
  11191. minAngularSpeed: number;
  11192. /**
  11193. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11194. */
  11195. maxAngularSpeed: number;
  11196. /**
  11197. * The texture used to render each particle. (this can be a spritesheet)
  11198. */
  11199. particleTexture: Nullable<Texture>;
  11200. /**
  11201. * The layer mask we are rendering the particles through.
  11202. */
  11203. layerMask: number;
  11204. /**
  11205. * This can help using your own shader to render the particle system.
  11206. * The according effect will be created
  11207. */
  11208. customShader: any;
  11209. /**
  11210. * By default particle system starts as soon as they are created. This prevents the
  11211. * automatic start to happen and let you decide when to start emitting particles.
  11212. */
  11213. preventAutoStart: boolean;
  11214. private _noiseTexture;
  11215. /**
  11216. * Gets or sets a texture used to add random noise to particle positions
  11217. */
  11218. get noiseTexture(): Nullable<ProceduralTexture>;
  11219. set noiseTexture(value: Nullable<ProceduralTexture>);
  11220. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11221. noiseStrength: Vector3;
  11222. /**
  11223. * Callback triggered when the particle animation is ending.
  11224. */
  11225. onAnimationEnd: Nullable<() => void>;
  11226. /**
  11227. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11228. */
  11229. blendMode: number;
  11230. /**
  11231. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11232. * to override the particles.
  11233. */
  11234. forceDepthWrite: boolean;
  11235. /** 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 */
  11236. preWarmCycles: number;
  11237. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11238. preWarmStepOffset: number;
  11239. /**
  11240. * 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)
  11241. */
  11242. spriteCellChangeSpeed: number;
  11243. /**
  11244. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11245. */
  11246. startSpriteCellID: number;
  11247. /**
  11248. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11249. */
  11250. endSpriteCellID: number;
  11251. /**
  11252. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11253. */
  11254. spriteCellWidth: number;
  11255. /**
  11256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11257. */
  11258. spriteCellHeight: number;
  11259. /**
  11260. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11261. */
  11262. spriteRandomStartCell: boolean;
  11263. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11264. translationPivot: Vector2;
  11265. /** @hidden */
  11266. protected _isAnimationSheetEnabled: boolean;
  11267. /**
  11268. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11269. */
  11270. beginAnimationOnStart: boolean;
  11271. /**
  11272. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11273. */
  11274. beginAnimationFrom: number;
  11275. /**
  11276. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11277. */
  11278. beginAnimationTo: number;
  11279. /**
  11280. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11281. */
  11282. beginAnimationLoop: boolean;
  11283. /**
  11284. * Gets or sets a world offset applied to all particles
  11285. */
  11286. worldOffset: Vector3;
  11287. /**
  11288. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11289. */
  11290. get isAnimationSheetEnabled(): boolean;
  11291. set isAnimationSheetEnabled(value: boolean);
  11292. /**
  11293. * Get hosting scene
  11294. * @returns the scene
  11295. */
  11296. getScene(): Scene;
  11297. /**
  11298. * You can use gravity if you want to give an orientation to your particles.
  11299. */
  11300. gravity: Vector3;
  11301. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11302. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11303. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11304. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11305. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11306. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11307. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11308. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11309. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11310. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11311. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11312. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11313. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11314. /**
  11315. * Defines the delay in milliseconds before starting the system (0 by default)
  11316. */
  11317. startDelay: number;
  11318. /**
  11319. * Gets the current list of drag gradients.
  11320. * You must use addDragGradient and removeDragGradient to udpate this list
  11321. * @returns the list of drag gradients
  11322. */
  11323. getDragGradients(): Nullable<Array<FactorGradient>>;
  11324. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11325. limitVelocityDamping: number;
  11326. /**
  11327. * Gets the current list of limit velocity gradients.
  11328. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11329. * @returns the list of limit velocity gradients
  11330. */
  11331. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11332. /**
  11333. * Gets the current list of color gradients.
  11334. * You must use addColorGradient and removeColorGradient to udpate this list
  11335. * @returns the list of color gradients
  11336. */
  11337. getColorGradients(): Nullable<Array<ColorGradient>>;
  11338. /**
  11339. * Gets the current list of size gradients.
  11340. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11341. * @returns the list of size gradients
  11342. */
  11343. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11344. /**
  11345. * Gets the current list of color remap gradients.
  11346. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11347. * @returns the list of color remap gradients
  11348. */
  11349. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11350. /**
  11351. * Gets the current list of alpha remap gradients.
  11352. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11353. * @returns the list of alpha remap gradients
  11354. */
  11355. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11356. /**
  11357. * Gets the current list of life time gradients.
  11358. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11359. * @returns the list of life time gradients
  11360. */
  11361. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11362. /**
  11363. * Gets the current list of angular speed gradients.
  11364. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11365. * @returns the list of angular speed gradients
  11366. */
  11367. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11368. /**
  11369. * Gets the current list of velocity gradients.
  11370. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11371. * @returns the list of velocity gradients
  11372. */
  11373. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11374. /**
  11375. * Gets the current list of start size gradients.
  11376. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11377. * @returns the list of start size gradients
  11378. */
  11379. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11380. /**
  11381. * Gets the current list of emit rate gradients.
  11382. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11383. * @returns the list of emit rate gradients
  11384. */
  11385. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11386. /**
  11387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11388. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11389. */
  11390. get direction1(): Vector3;
  11391. set direction1(value: Vector3);
  11392. /**
  11393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11394. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11395. */
  11396. get direction2(): Vector3;
  11397. set direction2(value: Vector3);
  11398. /**
  11399. * 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.
  11400. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11401. */
  11402. get minEmitBox(): Vector3;
  11403. set minEmitBox(value: Vector3);
  11404. /**
  11405. * 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.
  11406. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11407. */
  11408. get maxEmitBox(): Vector3;
  11409. set maxEmitBox(value: Vector3);
  11410. /**
  11411. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11412. */
  11413. color1: Color4;
  11414. /**
  11415. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11416. */
  11417. color2: Color4;
  11418. /**
  11419. * Color the particle will have at the end of its lifetime
  11420. */
  11421. colorDead: Color4;
  11422. /**
  11423. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11424. */
  11425. textureMask: Color4;
  11426. /**
  11427. * The particle emitter type defines the emitter used by the particle system.
  11428. * It can be for example box, sphere, or cone...
  11429. */
  11430. particleEmitterType: IParticleEmitterType;
  11431. /** @hidden */
  11432. _isSubEmitter: boolean;
  11433. /**
  11434. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11435. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11436. */
  11437. billboardMode: number;
  11438. protected _isBillboardBased: boolean;
  11439. /**
  11440. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11441. */
  11442. get isBillboardBased(): boolean;
  11443. set isBillboardBased(value: boolean);
  11444. /**
  11445. * The scene the particle system belongs to.
  11446. */
  11447. protected _scene: Scene;
  11448. /**
  11449. * Local cache of defines for image processing.
  11450. */
  11451. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11452. /**
  11453. * Default configuration related to image processing available in the standard Material.
  11454. */
  11455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11456. /**
  11457. * Gets the image processing configuration used either in this material.
  11458. */
  11459. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11460. /**
  11461. * Sets the Default image processing configuration used either in the this material.
  11462. *
  11463. * If sets to null, the scene one is in use.
  11464. */
  11465. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11466. /**
  11467. * Attaches a new image processing configuration to the Standard Material.
  11468. * @param configuration
  11469. */
  11470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11471. /** @hidden */
  11472. protected _reset(): void;
  11473. /** @hidden */
  11474. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11475. /**
  11476. * Instantiates a particle system.
  11477. * 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.
  11478. * @param name The name of the particle system
  11479. */
  11480. constructor(name: string);
  11481. /**
  11482. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11485. * @returns the emitter
  11486. */
  11487. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11488. /**
  11489. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11490. * @param radius The radius of the hemisphere to emit from
  11491. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11492. * @returns the emitter
  11493. */
  11494. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11495. /**
  11496. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11497. * @param radius The radius of the sphere to emit from
  11498. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11499. * @returns the emitter
  11500. */
  11501. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11502. /**
  11503. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11504. * @param radius The radius of the sphere to emit from
  11505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11507. * @returns the emitter
  11508. */
  11509. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11510. /**
  11511. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11512. * @param radius The radius of the emission cylinder
  11513. * @param height The height of the emission cylinder
  11514. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11515. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11516. * @returns the emitter
  11517. */
  11518. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11519. /**
  11520. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11521. * @param radius The radius of the cylinder to emit from
  11522. * @param height The height of the emission cylinder
  11523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11526. * @returns the emitter
  11527. */
  11528. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11529. /**
  11530. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11531. * @param radius The radius of the cone to emit from
  11532. * @param angle The base angle of the cone
  11533. * @returns the emitter
  11534. */
  11535. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11536. /**
  11537. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11540. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11541. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11542. * @returns the emitter
  11543. */
  11544. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Type of sub emitter
  11550. */
  11551. export enum SubEmitterType {
  11552. /**
  11553. * Attached to the particle over it's lifetime
  11554. */
  11555. ATTACHED = 0,
  11556. /**
  11557. * Created when the particle dies
  11558. */
  11559. END = 1
  11560. }
  11561. /**
  11562. * Sub emitter class used to emit particles from an existing particle
  11563. */
  11564. export class SubEmitter {
  11565. /**
  11566. * the particle system to be used by the sub emitter
  11567. */
  11568. particleSystem: ParticleSystem;
  11569. /**
  11570. * Type of the submitter (Default: END)
  11571. */
  11572. type: SubEmitterType;
  11573. /**
  11574. * 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)
  11575. * Note: This only is supported when using an emitter of type Mesh
  11576. */
  11577. inheritDirection: boolean;
  11578. /**
  11579. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11580. */
  11581. inheritedVelocityAmount: number;
  11582. /**
  11583. * Creates a sub emitter
  11584. * @param particleSystem the particle system to be used by the sub emitter
  11585. */
  11586. constructor(
  11587. /**
  11588. * the particle system to be used by the sub emitter
  11589. */
  11590. particleSystem: ParticleSystem);
  11591. /**
  11592. * Clones the sub emitter
  11593. * @returns the cloned sub emitter
  11594. */
  11595. clone(): SubEmitter;
  11596. /**
  11597. * Serialize current object to a JSON object
  11598. * @returns the serialized object
  11599. */
  11600. serialize(): any;
  11601. /** @hidden */
  11602. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11603. /**
  11604. * Creates a new SubEmitter from a serialized JSON version
  11605. * @param serializationObject defines the JSON object to read from
  11606. * @param scene defines the hosting scene
  11607. * @param rootUrl defines the rootUrl for data loading
  11608. * @returns a new SubEmitter
  11609. */
  11610. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11611. /** Release associated resources */
  11612. dispose(): void;
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. /** @hidden */
  11617. export var imageProcessingDeclaration: {
  11618. name: string;
  11619. shader: string;
  11620. };
  11621. }
  11622. declare module BABYLON {
  11623. /** @hidden */
  11624. export var imageProcessingFunctions: {
  11625. name: string;
  11626. shader: string;
  11627. };
  11628. }
  11629. declare module BABYLON {
  11630. /** @hidden */
  11631. export var particlesPixelShader: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module BABYLON {
  11637. /** @hidden */
  11638. export var particlesVertexShader: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module BABYLON {
  11644. /**
  11645. * This represents a particle system in Babylon.
  11646. * 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.
  11647. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11648. * @example https://doc.babylonjs.com/babylon101/particles
  11649. */
  11650. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11651. /**
  11652. * Billboard mode will only apply to Y axis
  11653. */
  11654. static readonly BILLBOARDMODE_Y: number;
  11655. /**
  11656. * Billboard mode will apply to all axes
  11657. */
  11658. static readonly BILLBOARDMODE_ALL: number;
  11659. /**
  11660. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11661. */
  11662. static readonly BILLBOARDMODE_STRETCHED: number;
  11663. /**
  11664. * This function can be defined to provide custom update for active particles.
  11665. * This function will be called instead of regular update (age, position, color, etc.).
  11666. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11667. */
  11668. updateFunction: (particles: Particle[]) => void;
  11669. private _emitterWorldMatrix;
  11670. /**
  11671. * This function can be defined to specify initial direction for every new particle.
  11672. * It by default use the emitterType defined function
  11673. */
  11674. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11675. /**
  11676. * This function can be defined to specify initial position for every new particle.
  11677. * It by default use the emitterType defined function
  11678. */
  11679. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11680. /**
  11681. * @hidden
  11682. */
  11683. _inheritedVelocityOffset: Vector3;
  11684. /**
  11685. * An event triggered when the system is disposed
  11686. */
  11687. onDisposeObservable: Observable<ParticleSystem>;
  11688. private _onDisposeObserver;
  11689. /**
  11690. * Sets a callback that will be triggered when the system is disposed
  11691. */
  11692. set onDispose(callback: () => void);
  11693. private _particles;
  11694. private _epsilon;
  11695. private _capacity;
  11696. private _stockParticles;
  11697. private _newPartsExcess;
  11698. private _vertexData;
  11699. private _vertexBuffer;
  11700. private _vertexBuffers;
  11701. private _spriteBuffer;
  11702. private _indexBuffer;
  11703. private _effect;
  11704. private _customEffect;
  11705. private _cachedDefines;
  11706. private _scaledColorStep;
  11707. private _colorDiff;
  11708. private _scaledDirection;
  11709. private _scaledGravity;
  11710. private _currentRenderId;
  11711. private _alive;
  11712. private _useInstancing;
  11713. private _started;
  11714. private _stopped;
  11715. private _actualFrame;
  11716. private _scaledUpdateSpeed;
  11717. private _vertexBufferSize;
  11718. /** @hidden */
  11719. _currentEmitRateGradient: Nullable<FactorGradient>;
  11720. /** @hidden */
  11721. _currentEmitRate1: number;
  11722. /** @hidden */
  11723. _currentEmitRate2: number;
  11724. /** @hidden */
  11725. _currentStartSizeGradient: Nullable<FactorGradient>;
  11726. /** @hidden */
  11727. _currentStartSize1: number;
  11728. /** @hidden */
  11729. _currentStartSize2: number;
  11730. private readonly _rawTextureWidth;
  11731. private _rampGradientsTexture;
  11732. private _useRampGradients;
  11733. /** Gets or sets a boolean indicating that ramp gradients must be used
  11734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11735. */
  11736. get useRampGradients(): boolean;
  11737. set useRampGradients(value: boolean);
  11738. /**
  11739. * 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.
  11740. * 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: [])
  11741. */
  11742. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11743. private _subEmitters;
  11744. /**
  11745. * @hidden
  11746. * If the particle systems emitter should be disposed when the particle system is disposed
  11747. */
  11748. _disposeEmitterOnDispose: boolean;
  11749. /**
  11750. * The current active Sub-systems, this property is used by the root particle system only.
  11751. */
  11752. activeSubSystems: Array<ParticleSystem>;
  11753. /**
  11754. * Specifies if the particles are updated in emitter local space or world space
  11755. */
  11756. isLocal: boolean;
  11757. private _rootParticleSystem;
  11758. /**
  11759. * Gets the current list of active particles
  11760. */
  11761. get particles(): Particle[];
  11762. /**
  11763. * Gets the number of particles active at the same time.
  11764. * @returns The number of active particles.
  11765. */
  11766. getActiveCount(): number;
  11767. /**
  11768. * Returns the string "ParticleSystem"
  11769. * @returns a string containing the class name
  11770. */
  11771. getClassName(): string;
  11772. /**
  11773. * Gets a boolean indicating that the system is stopping
  11774. * @returns true if the system is currently stopping
  11775. */
  11776. isStopping(): boolean;
  11777. /**
  11778. * Instantiates a particle system.
  11779. * 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.
  11780. * @param name The name of the particle system
  11781. * @param capacity The max number of particles alive at the same time
  11782. * @param scene The scene the particle system belongs to
  11783. * @param customEffect a custom effect used to change the way particles are rendered by default
  11784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11785. * @param epsilon Offset used to render the particles
  11786. */
  11787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11788. private _addFactorGradient;
  11789. private _removeFactorGradient;
  11790. /**
  11791. * Adds a new life time gradient
  11792. * @param gradient defines the gradient to use (between 0 and 1)
  11793. * @param factor defines the life time factor to affect to the specified gradient
  11794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11795. * @returns the current particle system
  11796. */
  11797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11798. /**
  11799. * Remove a specific life time gradient
  11800. * @param gradient defines the gradient to remove
  11801. * @returns the current particle system
  11802. */
  11803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11804. /**
  11805. * Adds a new size gradient
  11806. * @param gradient defines the gradient to use (between 0 and 1)
  11807. * @param factor defines the size factor to affect to the specified gradient
  11808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11809. * @returns the current particle system
  11810. */
  11811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11812. /**
  11813. * Remove a specific size gradient
  11814. * @param gradient defines the gradient to remove
  11815. * @returns the current particle system
  11816. */
  11817. removeSizeGradient(gradient: number): IParticleSystem;
  11818. /**
  11819. * Adds a new color remap gradient
  11820. * @param gradient defines the gradient to use (between 0 and 1)
  11821. * @param min defines the color remap minimal range
  11822. * @param max defines the color remap maximal range
  11823. * @returns the current particle system
  11824. */
  11825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11826. /**
  11827. * Remove a specific color remap gradient
  11828. * @param gradient defines the gradient to remove
  11829. * @returns the current particle system
  11830. */
  11831. removeColorRemapGradient(gradient: number): IParticleSystem;
  11832. /**
  11833. * Adds a new alpha remap gradient
  11834. * @param gradient defines the gradient to use (between 0 and 1)
  11835. * @param min defines the alpha remap minimal range
  11836. * @param max defines the alpha remap maximal range
  11837. * @returns the current particle system
  11838. */
  11839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11840. /**
  11841. * Remove a specific alpha remap gradient
  11842. * @param gradient defines the gradient to remove
  11843. * @returns the current particle system
  11844. */
  11845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11846. /**
  11847. * Adds a new angular speed gradient
  11848. * @param gradient defines the gradient to use (between 0 and 1)
  11849. * @param factor defines the angular speed to affect to the specified gradient
  11850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11851. * @returns the current particle system
  11852. */
  11853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11854. /**
  11855. * Remove a specific angular speed gradient
  11856. * @param gradient defines the gradient to remove
  11857. * @returns the current particle system
  11858. */
  11859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11860. /**
  11861. * Adds a new velocity gradient
  11862. * @param gradient defines the gradient to use (between 0 and 1)
  11863. * @param factor defines the velocity to affect to the specified gradient
  11864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11865. * @returns the current particle system
  11866. */
  11867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11868. /**
  11869. * Remove a specific velocity gradient
  11870. * @param gradient defines the gradient to remove
  11871. * @returns the current particle system
  11872. */
  11873. removeVelocityGradient(gradient: number): IParticleSystem;
  11874. /**
  11875. * Adds a new limit velocity gradient
  11876. * @param gradient defines the gradient to use (between 0 and 1)
  11877. * @param factor defines the limit velocity value to affect to the specified gradient
  11878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11879. * @returns the current particle system
  11880. */
  11881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11882. /**
  11883. * Remove a specific limit velocity gradient
  11884. * @param gradient defines the gradient to remove
  11885. * @returns the current particle system
  11886. */
  11887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11888. /**
  11889. * Adds a new drag gradient
  11890. * @param gradient defines the gradient to use (between 0 and 1)
  11891. * @param factor defines the drag value to affect to the specified gradient
  11892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11893. * @returns the current particle system
  11894. */
  11895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11896. /**
  11897. * Remove a specific drag gradient
  11898. * @param gradient defines the gradient to remove
  11899. * @returns the current particle system
  11900. */
  11901. removeDragGradient(gradient: number): IParticleSystem;
  11902. /**
  11903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11904. * @param gradient defines the gradient to use (between 0 and 1)
  11905. * @param factor defines the emit rate value to affect to the specified gradient
  11906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11907. * @returns the current particle system
  11908. */
  11909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11910. /**
  11911. * Remove a specific emit rate gradient
  11912. * @param gradient defines the gradient to remove
  11913. * @returns the current particle system
  11914. */
  11915. removeEmitRateGradient(gradient: number): IParticleSystem;
  11916. /**
  11917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11918. * @param gradient defines the gradient to use (between 0 and 1)
  11919. * @param factor defines the start size value to affect to the specified gradient
  11920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11921. * @returns the current particle system
  11922. */
  11923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11924. /**
  11925. * Remove a specific start size gradient
  11926. * @param gradient defines the gradient to remove
  11927. * @returns the current particle system
  11928. */
  11929. removeStartSizeGradient(gradient: number): IParticleSystem;
  11930. private _createRampGradientTexture;
  11931. /**
  11932. * Gets the current list of ramp gradients.
  11933. * You must use addRampGradient and removeRampGradient to udpate this list
  11934. * @returns the list of ramp gradients
  11935. */
  11936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11937. /** Force the system to rebuild all gradients that need to be resync */
  11938. forceRefreshGradients(): void;
  11939. private _syncRampGradientTexture;
  11940. /**
  11941. * Adds a new ramp gradient used to remap particle colors
  11942. * @param gradient defines the gradient to use (between 0 and 1)
  11943. * @param color defines the color to affect to the specified gradient
  11944. * @returns the current particle system
  11945. */
  11946. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11947. /**
  11948. * Remove a specific ramp gradient
  11949. * @param gradient defines the gradient to remove
  11950. * @returns the current particle system
  11951. */
  11952. removeRampGradient(gradient: number): ParticleSystem;
  11953. /**
  11954. * Adds a new color gradient
  11955. * @param gradient defines the gradient to use (between 0 and 1)
  11956. * @param color1 defines the color to affect to the specified gradient
  11957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11958. * @returns this particle system
  11959. */
  11960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11961. /**
  11962. * Remove a specific color gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns this particle system
  11965. */
  11966. removeColorGradient(gradient: number): IParticleSystem;
  11967. private _fetchR;
  11968. protected _reset(): void;
  11969. private _resetEffect;
  11970. private _createVertexBuffers;
  11971. private _createIndexBuffer;
  11972. /**
  11973. * Gets the maximum number of particles active at the same time.
  11974. * @returns The max number of active particles.
  11975. */
  11976. getCapacity(): number;
  11977. /**
  11978. * Gets whether there are still active particles in the system.
  11979. * @returns True if it is alive, otherwise false.
  11980. */
  11981. isAlive(): boolean;
  11982. /**
  11983. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11984. * @returns True if it has been started, otherwise false.
  11985. */
  11986. isStarted(): boolean;
  11987. private _prepareSubEmitterInternalArray;
  11988. /**
  11989. * Starts the particle system and begins to emit
  11990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11991. */
  11992. start(delay?: number): void;
  11993. /**
  11994. * Stops the particle system.
  11995. * @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.
  11996. */
  11997. stop(stopSubEmitters?: boolean): void;
  11998. /**
  11999. * Remove all active particles
  12000. */
  12001. reset(): void;
  12002. /**
  12003. * @hidden (for internal use only)
  12004. */
  12005. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12006. /**
  12007. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12008. * Its lifetime will start back at 0.
  12009. */
  12010. recycleParticle: (particle: Particle) => void;
  12011. private _stopSubEmitters;
  12012. private _createParticle;
  12013. private _removeFromRoot;
  12014. private _emitFromParticle;
  12015. private _update;
  12016. /** @hidden */
  12017. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12018. /** @hidden */
  12019. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12020. /** @hidden */
  12021. private _getEffect;
  12022. /**
  12023. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12024. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12025. */
  12026. animate(preWarmOnly?: boolean): void;
  12027. private _appendParticleVertices;
  12028. /**
  12029. * Rebuilds the particle system.
  12030. */
  12031. rebuild(): void;
  12032. /**
  12033. * Is this system ready to be used/rendered
  12034. * @return true if the system is ready
  12035. */
  12036. isReady(): boolean;
  12037. private _render;
  12038. /**
  12039. * Renders the particle system in its current state.
  12040. * @returns the current number of particles
  12041. */
  12042. render(): number;
  12043. /**
  12044. * Disposes the particle system and free the associated resources
  12045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12046. */
  12047. dispose(disposeTexture?: boolean): void;
  12048. /**
  12049. * Clones the particle system.
  12050. * @param name The name of the cloned object
  12051. * @param newEmitter The new emitter to use
  12052. * @returns the cloned particle system
  12053. */
  12054. clone(name: string, newEmitter: any): ParticleSystem;
  12055. /**
  12056. * Serializes the particle system to a JSON object
  12057. * @param serializeTexture defines if the texture must be serialized as well
  12058. * @returns the JSON object
  12059. */
  12060. serialize(serializeTexture?: boolean): any;
  12061. /** @hidden */
  12062. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12063. /** @hidden */
  12064. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12065. /**
  12066. * Parses a JSON object to create a particle system.
  12067. * @param parsedParticleSystem The JSON object to parse
  12068. * @param scene The scene to create the particle system in
  12069. * @param rootUrl The root url to use to load external dependencies like texture
  12070. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12071. * @returns the Parsed particle system
  12072. */
  12073. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12074. }
  12075. }
  12076. declare module BABYLON {
  12077. /**
  12078. * A particle represents one of the element emitted by a particle system.
  12079. * This is mainly define by its coordinates, direction, velocity and age.
  12080. */
  12081. export class Particle {
  12082. /**
  12083. * The particle system the particle belongs to.
  12084. */
  12085. particleSystem: ParticleSystem;
  12086. private static _Count;
  12087. /**
  12088. * Unique ID of the particle
  12089. */
  12090. id: number;
  12091. /**
  12092. * The world position of the particle in the scene.
  12093. */
  12094. position: Vector3;
  12095. /**
  12096. * The world direction of the particle in the scene.
  12097. */
  12098. direction: Vector3;
  12099. /**
  12100. * The color of the particle.
  12101. */
  12102. color: Color4;
  12103. /**
  12104. * The color change of the particle per step.
  12105. */
  12106. colorStep: Color4;
  12107. /**
  12108. * Defines how long will the life of the particle be.
  12109. */
  12110. lifeTime: number;
  12111. /**
  12112. * The current age of the particle.
  12113. */
  12114. age: number;
  12115. /**
  12116. * The current size of the particle.
  12117. */
  12118. size: number;
  12119. /**
  12120. * The current scale of the particle.
  12121. */
  12122. scale: Vector2;
  12123. /**
  12124. * The current angle of the particle.
  12125. */
  12126. angle: number;
  12127. /**
  12128. * Defines how fast is the angle changing.
  12129. */
  12130. angularSpeed: number;
  12131. /**
  12132. * Defines the cell index used by the particle to be rendered from a sprite.
  12133. */
  12134. cellIndex: number;
  12135. /**
  12136. * The information required to support color remapping
  12137. */
  12138. remapData: Vector4;
  12139. /** @hidden */
  12140. _randomCellOffset?: number;
  12141. /** @hidden */
  12142. _initialDirection: Nullable<Vector3>;
  12143. /** @hidden */
  12144. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12145. /** @hidden */
  12146. _initialStartSpriteCellID: number;
  12147. /** @hidden */
  12148. _initialEndSpriteCellID: number;
  12149. /** @hidden */
  12150. _currentColorGradient: Nullable<ColorGradient>;
  12151. /** @hidden */
  12152. _currentColor1: Color4;
  12153. /** @hidden */
  12154. _currentColor2: Color4;
  12155. /** @hidden */
  12156. _currentSizeGradient: Nullable<FactorGradient>;
  12157. /** @hidden */
  12158. _currentSize1: number;
  12159. /** @hidden */
  12160. _currentSize2: number;
  12161. /** @hidden */
  12162. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12163. /** @hidden */
  12164. _currentAngularSpeed1: number;
  12165. /** @hidden */
  12166. _currentAngularSpeed2: number;
  12167. /** @hidden */
  12168. _currentVelocityGradient: Nullable<FactorGradient>;
  12169. /** @hidden */
  12170. _currentVelocity1: number;
  12171. /** @hidden */
  12172. _currentVelocity2: number;
  12173. /** @hidden */
  12174. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12175. /** @hidden */
  12176. _currentLimitVelocity1: number;
  12177. /** @hidden */
  12178. _currentLimitVelocity2: number;
  12179. /** @hidden */
  12180. _currentDragGradient: Nullable<FactorGradient>;
  12181. /** @hidden */
  12182. _currentDrag1: number;
  12183. /** @hidden */
  12184. _currentDrag2: number;
  12185. /** @hidden */
  12186. _randomNoiseCoordinates1: Vector3;
  12187. /** @hidden */
  12188. _randomNoiseCoordinates2: Vector3;
  12189. /** @hidden */
  12190. _localPosition?: Vector3;
  12191. /**
  12192. * Creates a new instance Particle
  12193. * @param particleSystem the particle system the particle belongs to
  12194. */
  12195. constructor(
  12196. /**
  12197. * The particle system the particle belongs to.
  12198. */
  12199. particleSystem: ParticleSystem);
  12200. private updateCellInfoFromSystem;
  12201. /**
  12202. * Defines how the sprite cell index is updated for the particle
  12203. */
  12204. updateCellIndex(): void;
  12205. /** @hidden */
  12206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12207. /** @hidden */
  12208. _inheritParticleInfoToSubEmitters(): void;
  12209. /** @hidden */
  12210. _reset(): void;
  12211. /**
  12212. * Copy the properties of particle to another one.
  12213. * @param other the particle to copy the information to.
  12214. */
  12215. copyTo(other: Particle): void;
  12216. }
  12217. }
  12218. declare module BABYLON {
  12219. /**
  12220. * Particle emitter represents a volume emitting particles.
  12221. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12222. */
  12223. export interface IParticleEmitterType {
  12224. /**
  12225. * Called by the particle System when the direction is computed for the created particle.
  12226. * @param worldMatrix is the world matrix of the particle system
  12227. * @param directionToUpdate is the direction vector to update with the result
  12228. * @param particle is the particle we are computed the direction for
  12229. * @param isLocal defines if the direction should be set in local space
  12230. */
  12231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12232. /**
  12233. * Called by the particle System when the position is computed for the created particle.
  12234. * @param worldMatrix is the world matrix of the particle system
  12235. * @param positionToUpdate is the position vector to update with the result
  12236. * @param particle is the particle we are computed the position for
  12237. * @param isLocal defines if the position should be set in local space
  12238. */
  12239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12240. /**
  12241. * Clones the current emitter and returns a copy of it
  12242. * @returns the new emitter
  12243. */
  12244. clone(): IParticleEmitterType;
  12245. /**
  12246. * Called by the GPUParticleSystem to setup the update shader
  12247. * @param effect defines the update shader
  12248. */
  12249. applyToShader(effect: Effect): void;
  12250. /**
  12251. * Returns a string to use to update the GPU particles update shader
  12252. * @returns the effect defines string
  12253. */
  12254. getEffectDefines(): string;
  12255. /**
  12256. * Returns a string representing the class name
  12257. * @returns a string containing the class name
  12258. */
  12259. getClassName(): string;
  12260. /**
  12261. * Serializes the particle system to a JSON object.
  12262. * @returns the JSON object
  12263. */
  12264. serialize(): any;
  12265. /**
  12266. * Parse properties from a JSON object
  12267. * @param serializationObject defines the JSON object
  12268. * @param scene defines the hosting scene
  12269. */
  12270. parse(serializationObject: any, scene: Scene): void;
  12271. }
  12272. }
  12273. declare module BABYLON {
  12274. /**
  12275. * Particle emitter emitting particles from the inside of a box.
  12276. * It emits the particles randomly between 2 given directions.
  12277. */
  12278. export class BoxParticleEmitter implements IParticleEmitterType {
  12279. /**
  12280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12281. */
  12282. direction1: Vector3;
  12283. /**
  12284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12285. */
  12286. direction2: Vector3;
  12287. /**
  12288. * 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.
  12289. */
  12290. minEmitBox: Vector3;
  12291. /**
  12292. * 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.
  12293. */
  12294. maxEmitBox: Vector3;
  12295. /**
  12296. * Creates a new instance BoxParticleEmitter
  12297. */
  12298. constructor();
  12299. /**
  12300. * Called by the particle System when the direction is computed for the created particle.
  12301. * @param worldMatrix is the world matrix of the particle system
  12302. * @param directionToUpdate is the direction vector to update with the result
  12303. * @param particle is the particle we are computed the direction for
  12304. * @param isLocal defines if the direction should be set in local space
  12305. */
  12306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12307. /**
  12308. * Called by the particle System when the position is computed for the created particle.
  12309. * @param worldMatrix is the world matrix of the particle system
  12310. * @param positionToUpdate is the position vector to update with the result
  12311. * @param particle is the particle we are computed the position for
  12312. * @param isLocal defines if the position should be set in local space
  12313. */
  12314. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12315. /**
  12316. * Clones the current emitter and returns a copy of it
  12317. * @returns the new emitter
  12318. */
  12319. clone(): BoxParticleEmitter;
  12320. /**
  12321. * Called by the GPUParticleSystem to setup the update shader
  12322. * @param effect defines the update shader
  12323. */
  12324. applyToShader(effect: Effect): void;
  12325. /**
  12326. * Returns a string to use to update the GPU particles update shader
  12327. * @returns a string containng the defines string
  12328. */
  12329. getEffectDefines(): string;
  12330. /**
  12331. * Returns the string "BoxParticleEmitter"
  12332. * @returns a string containing the class name
  12333. */
  12334. getClassName(): string;
  12335. /**
  12336. * Serializes the particle system to a JSON object.
  12337. * @returns the JSON object
  12338. */
  12339. serialize(): any;
  12340. /**
  12341. * Parse properties from a JSON object
  12342. * @param serializationObject defines the JSON object
  12343. */
  12344. parse(serializationObject: any): void;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Particle emitter emitting particles from the inside of a cone.
  12350. * It emits the particles alongside the cone volume from the base to the particle.
  12351. * The emission direction might be randomized.
  12352. */
  12353. export class ConeParticleEmitter implements IParticleEmitterType {
  12354. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12355. directionRandomizer: number;
  12356. private _radius;
  12357. private _angle;
  12358. private _height;
  12359. /**
  12360. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12361. */
  12362. radiusRange: number;
  12363. /**
  12364. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12365. */
  12366. heightRange: number;
  12367. /**
  12368. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12369. */
  12370. emitFromSpawnPointOnly: boolean;
  12371. /**
  12372. * Gets or sets the radius of the emission cone
  12373. */
  12374. get radius(): number;
  12375. set radius(value: number);
  12376. /**
  12377. * Gets or sets the angle of the emission cone
  12378. */
  12379. get angle(): number;
  12380. set angle(value: number);
  12381. private _buildHeight;
  12382. /**
  12383. * Creates a new instance ConeParticleEmitter
  12384. * @param radius the radius of the emission cone (1 by default)
  12385. * @param angle the cone base angle (PI by default)
  12386. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12387. */
  12388. constructor(radius?: number, angle?: number,
  12389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12390. directionRandomizer?: number);
  12391. /**
  12392. * Called by the particle System when the direction is computed for the created particle.
  12393. * @param worldMatrix is the world matrix of the particle system
  12394. * @param directionToUpdate is the direction vector to update with the result
  12395. * @param particle is the particle we are computed the direction for
  12396. * @param isLocal defines if the direction should be set in local space
  12397. */
  12398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12399. /**
  12400. * Called by the particle System when the position is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param positionToUpdate is the position vector to update with the result
  12403. * @param particle is the particle we are computed the position for
  12404. * @param isLocal defines if the position should be set in local space
  12405. */
  12406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12407. /**
  12408. * Clones the current emitter and returns a copy of it
  12409. * @returns the new emitter
  12410. */
  12411. clone(): ConeParticleEmitter;
  12412. /**
  12413. * Called by the GPUParticleSystem to setup the update shader
  12414. * @param effect defines the update shader
  12415. */
  12416. applyToShader(effect: Effect): void;
  12417. /**
  12418. * Returns a string to use to update the GPU particles update shader
  12419. * @returns a string containng the defines string
  12420. */
  12421. getEffectDefines(): string;
  12422. /**
  12423. * Returns the string "ConeParticleEmitter"
  12424. * @returns a string containing the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Serializes the particle system to a JSON object.
  12429. * @returns the JSON object
  12430. */
  12431. serialize(): any;
  12432. /**
  12433. * Parse properties from a JSON object
  12434. * @param serializationObject defines the JSON object
  12435. */
  12436. parse(serializationObject: any): void;
  12437. }
  12438. }
  12439. declare module BABYLON {
  12440. /**
  12441. * Particle emitter emitting particles from the inside of a cylinder.
  12442. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12443. */
  12444. export class CylinderParticleEmitter implements IParticleEmitterType {
  12445. /**
  12446. * The radius of the emission cylinder.
  12447. */
  12448. radius: number;
  12449. /**
  12450. * The height of the emission cylinder.
  12451. */
  12452. height: number;
  12453. /**
  12454. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12455. */
  12456. radiusRange: number;
  12457. /**
  12458. * How much to randomize the particle direction [0-1].
  12459. */
  12460. directionRandomizer: number;
  12461. /**
  12462. * Creates a new instance CylinderParticleEmitter
  12463. * @param radius the radius of the emission cylinder (1 by default)
  12464. * @param height the height of the emission cylinder (1 by default)
  12465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12467. */
  12468. constructor(
  12469. /**
  12470. * The radius of the emission cylinder.
  12471. */
  12472. radius?: number,
  12473. /**
  12474. * The height of the emission cylinder.
  12475. */
  12476. height?: number,
  12477. /**
  12478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12479. */
  12480. radiusRange?: number,
  12481. /**
  12482. * How much to randomize the particle direction [0-1].
  12483. */
  12484. directionRandomizer?: number);
  12485. /**
  12486. * Called by the particle System when the direction is computed for the created particle.
  12487. * @param worldMatrix is the world matrix of the particle system
  12488. * @param directionToUpdate is the direction vector to update with the result
  12489. * @param particle is the particle we are computed the direction for
  12490. * @param isLocal defines if the direction should be set in local space
  12491. */
  12492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12493. /**
  12494. * Called by the particle System when the position is computed for the created particle.
  12495. * @param worldMatrix is the world matrix of the particle system
  12496. * @param positionToUpdate is the position vector to update with the result
  12497. * @param particle is the particle we are computed the position for
  12498. * @param isLocal defines if the position should be set in local space
  12499. */
  12500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12501. /**
  12502. * Clones the current emitter and returns a copy of it
  12503. * @returns the new emitter
  12504. */
  12505. clone(): CylinderParticleEmitter;
  12506. /**
  12507. * Called by the GPUParticleSystem to setup the update shader
  12508. * @param effect defines the update shader
  12509. */
  12510. applyToShader(effect: Effect): void;
  12511. /**
  12512. * Returns a string to use to update the GPU particles update shader
  12513. * @returns a string containng the defines string
  12514. */
  12515. getEffectDefines(): string;
  12516. /**
  12517. * Returns the string "CylinderParticleEmitter"
  12518. * @returns a string containing the class name
  12519. */
  12520. getClassName(): string;
  12521. /**
  12522. * Serializes the particle system to a JSON object.
  12523. * @returns the JSON object
  12524. */
  12525. serialize(): any;
  12526. /**
  12527. * Parse properties from a JSON object
  12528. * @param serializationObject defines the JSON object
  12529. */
  12530. parse(serializationObject: any): void;
  12531. }
  12532. /**
  12533. * Particle emitter emitting particles from the inside of a cylinder.
  12534. * It emits the particles randomly between two vectors.
  12535. */
  12536. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12537. /**
  12538. * The min limit of the emission direction.
  12539. */
  12540. direction1: Vector3;
  12541. /**
  12542. * The max limit of the emission direction.
  12543. */
  12544. direction2: Vector3;
  12545. /**
  12546. * Creates a new instance CylinderDirectedParticleEmitter
  12547. * @param radius the radius of the emission cylinder (1 by default)
  12548. * @param height the height of the emission cylinder (1 by default)
  12549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12550. * @param direction1 the min limit of the emission direction (up vector by default)
  12551. * @param direction2 the max limit of the emission direction (up vector by default)
  12552. */
  12553. constructor(radius?: number, height?: number, radiusRange?: number,
  12554. /**
  12555. * The min limit of the emission direction.
  12556. */
  12557. direction1?: Vector3,
  12558. /**
  12559. * The max limit of the emission direction.
  12560. */
  12561. direction2?: Vector3);
  12562. /**
  12563. * Called by the particle System when the direction is computed for the created particle.
  12564. * @param worldMatrix is the world matrix of the particle system
  12565. * @param directionToUpdate is the direction vector to update with the result
  12566. * @param particle is the particle we are computed the direction for
  12567. */
  12568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12569. /**
  12570. * Clones the current emitter and returns a copy of it
  12571. * @returns the new emitter
  12572. */
  12573. clone(): CylinderDirectedParticleEmitter;
  12574. /**
  12575. * Called by the GPUParticleSystem to setup the update shader
  12576. * @param effect defines the update shader
  12577. */
  12578. applyToShader(effect: Effect): void;
  12579. /**
  12580. * Returns a string to use to update the GPU particles update shader
  12581. * @returns a string containng the defines string
  12582. */
  12583. getEffectDefines(): string;
  12584. /**
  12585. * Returns the string "CylinderDirectedParticleEmitter"
  12586. * @returns a string containing the class name
  12587. */
  12588. getClassName(): string;
  12589. /**
  12590. * Serializes the particle system to a JSON object.
  12591. * @returns the JSON object
  12592. */
  12593. serialize(): any;
  12594. /**
  12595. * Parse properties from a JSON object
  12596. * @param serializationObject defines the JSON object
  12597. */
  12598. parse(serializationObject: any): void;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * Particle emitter emitting particles from the inside of a hemisphere.
  12604. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12605. */
  12606. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12607. /**
  12608. * The radius of the emission hemisphere.
  12609. */
  12610. radius: number;
  12611. /**
  12612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12613. */
  12614. radiusRange: number;
  12615. /**
  12616. * How much to randomize the particle direction [0-1].
  12617. */
  12618. directionRandomizer: number;
  12619. /**
  12620. * Creates a new instance HemisphericParticleEmitter
  12621. * @param radius the radius of the emission hemisphere (1 by default)
  12622. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12623. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12624. */
  12625. constructor(
  12626. /**
  12627. * The radius of the emission hemisphere.
  12628. */
  12629. radius?: number,
  12630. /**
  12631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12632. */
  12633. radiusRange?: number,
  12634. /**
  12635. * How much to randomize the particle direction [0-1].
  12636. */
  12637. directionRandomizer?: number);
  12638. /**
  12639. * Called by the particle System when the direction is computed for the created particle.
  12640. * @param worldMatrix is the world matrix of the particle system
  12641. * @param directionToUpdate is the direction vector to update with the result
  12642. * @param particle is the particle we are computed the direction for
  12643. * @param isLocal defines if the direction should be set in local space
  12644. */
  12645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12646. /**
  12647. * Called by the particle System when the position is computed for the created particle.
  12648. * @param worldMatrix is the world matrix of the particle system
  12649. * @param positionToUpdate is the position vector to update with the result
  12650. * @param particle is the particle we are computed the position for
  12651. * @param isLocal defines if the position should be set in local space
  12652. */
  12653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12654. /**
  12655. * Clones the current emitter and returns a copy of it
  12656. * @returns the new emitter
  12657. */
  12658. clone(): HemisphericParticleEmitter;
  12659. /**
  12660. * Called by the GPUParticleSystem to setup the update shader
  12661. * @param effect defines the update shader
  12662. */
  12663. applyToShader(effect: Effect): void;
  12664. /**
  12665. * Returns a string to use to update the GPU particles update shader
  12666. * @returns a string containng the defines string
  12667. */
  12668. getEffectDefines(): string;
  12669. /**
  12670. * Returns the string "HemisphericParticleEmitter"
  12671. * @returns a string containing the class name
  12672. */
  12673. getClassName(): string;
  12674. /**
  12675. * Serializes the particle system to a JSON object.
  12676. * @returns the JSON object
  12677. */
  12678. serialize(): any;
  12679. /**
  12680. * Parse properties from a JSON object
  12681. * @param serializationObject defines the JSON object
  12682. */
  12683. parse(serializationObject: any): void;
  12684. }
  12685. }
  12686. declare module BABYLON {
  12687. /**
  12688. * Particle emitter emitting particles from a point.
  12689. * It emits the particles randomly between 2 given directions.
  12690. */
  12691. export class PointParticleEmitter implements IParticleEmitterType {
  12692. /**
  12693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12694. */
  12695. direction1: Vector3;
  12696. /**
  12697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12698. */
  12699. direction2: Vector3;
  12700. /**
  12701. * Creates a new instance PointParticleEmitter
  12702. */
  12703. constructor();
  12704. /**
  12705. * Called by the particle System when the direction is computed for the created particle.
  12706. * @param worldMatrix is the world matrix of the particle system
  12707. * @param directionToUpdate is the direction vector to update with the result
  12708. * @param particle is the particle we are computed the direction for
  12709. * @param isLocal defines if the direction should be set in local space
  12710. */
  12711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12712. /**
  12713. * Called by the particle System when the position is computed for the created particle.
  12714. * @param worldMatrix is the world matrix of the particle system
  12715. * @param positionToUpdate is the position vector to update with the result
  12716. * @param particle is the particle we are computed the position for
  12717. * @param isLocal defines if the position should be set in local space
  12718. */
  12719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12720. /**
  12721. * Clones the current emitter and returns a copy of it
  12722. * @returns the new emitter
  12723. */
  12724. clone(): PointParticleEmitter;
  12725. /**
  12726. * Called by the GPUParticleSystem to setup the update shader
  12727. * @param effect defines the update shader
  12728. */
  12729. applyToShader(effect: Effect): void;
  12730. /**
  12731. * Returns a string to use to update the GPU particles update shader
  12732. * @returns a string containng the defines string
  12733. */
  12734. getEffectDefines(): string;
  12735. /**
  12736. * Returns the string "PointParticleEmitter"
  12737. * @returns a string containing the class name
  12738. */
  12739. getClassName(): string;
  12740. /**
  12741. * Serializes the particle system to a JSON object.
  12742. * @returns the JSON object
  12743. */
  12744. serialize(): any;
  12745. /**
  12746. * Parse properties from a JSON object
  12747. * @param serializationObject defines the JSON object
  12748. */
  12749. parse(serializationObject: any): void;
  12750. }
  12751. }
  12752. declare module BABYLON {
  12753. /**
  12754. * Particle emitter emitting particles from the inside of a sphere.
  12755. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12756. */
  12757. export class SphereParticleEmitter implements IParticleEmitterType {
  12758. /**
  12759. * The radius of the emission sphere.
  12760. */
  12761. radius: number;
  12762. /**
  12763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12764. */
  12765. radiusRange: number;
  12766. /**
  12767. * How much to randomize the particle direction [0-1].
  12768. */
  12769. directionRandomizer: number;
  12770. /**
  12771. * Creates a new instance SphereParticleEmitter
  12772. * @param radius the radius of the emission sphere (1 by default)
  12773. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12774. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12775. */
  12776. constructor(
  12777. /**
  12778. * The radius of the emission sphere.
  12779. */
  12780. radius?: number,
  12781. /**
  12782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12783. */
  12784. radiusRange?: number,
  12785. /**
  12786. * How much to randomize the particle direction [0-1].
  12787. */
  12788. directionRandomizer?: number);
  12789. /**
  12790. * Called by the particle System when the direction is computed for the created particle.
  12791. * @param worldMatrix is the world matrix of the particle system
  12792. * @param directionToUpdate is the direction vector to update with the result
  12793. * @param particle is the particle we are computed the direction for
  12794. * @param isLocal defines if the direction should be set in local space
  12795. */
  12796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12797. /**
  12798. * Called by the particle System when the position is computed for the created particle.
  12799. * @param worldMatrix is the world matrix of the particle system
  12800. * @param positionToUpdate is the position vector to update with the result
  12801. * @param particle is the particle we are computed the position for
  12802. * @param isLocal defines if the position should be set in local space
  12803. */
  12804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12805. /**
  12806. * Clones the current emitter and returns a copy of it
  12807. * @returns the new emitter
  12808. */
  12809. clone(): SphereParticleEmitter;
  12810. /**
  12811. * Called by the GPUParticleSystem to setup the update shader
  12812. * @param effect defines the update shader
  12813. */
  12814. applyToShader(effect: Effect): void;
  12815. /**
  12816. * Returns a string to use to update the GPU particles update shader
  12817. * @returns a string containng the defines string
  12818. */
  12819. getEffectDefines(): string;
  12820. /**
  12821. * Returns the string "SphereParticleEmitter"
  12822. * @returns a string containing the class name
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Serializes the particle system to a JSON object.
  12827. * @returns the JSON object
  12828. */
  12829. serialize(): any;
  12830. /**
  12831. * Parse properties from a JSON object
  12832. * @param serializationObject defines the JSON object
  12833. */
  12834. parse(serializationObject: any): void;
  12835. }
  12836. /**
  12837. * Particle emitter emitting particles from the inside of a sphere.
  12838. * It emits the particles randomly between two vectors.
  12839. */
  12840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12841. /**
  12842. * The min limit of the emission direction.
  12843. */
  12844. direction1: Vector3;
  12845. /**
  12846. * The max limit of the emission direction.
  12847. */
  12848. direction2: Vector3;
  12849. /**
  12850. * Creates a new instance SphereDirectedParticleEmitter
  12851. * @param radius the radius of the emission sphere (1 by default)
  12852. * @param direction1 the min limit of the emission direction (up vector by default)
  12853. * @param direction2 the max limit of the emission direction (up vector by default)
  12854. */
  12855. constructor(radius?: number,
  12856. /**
  12857. * The min limit of the emission direction.
  12858. */
  12859. direction1?: Vector3,
  12860. /**
  12861. * The max limit of the emission direction.
  12862. */
  12863. direction2?: Vector3);
  12864. /**
  12865. * Called by the particle System when the direction is computed for the created particle.
  12866. * @param worldMatrix is the world matrix of the particle system
  12867. * @param directionToUpdate is the direction vector to update with the result
  12868. * @param particle is the particle we are computed the direction for
  12869. */
  12870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12871. /**
  12872. * Clones the current emitter and returns a copy of it
  12873. * @returns the new emitter
  12874. */
  12875. clone(): SphereDirectedParticleEmitter;
  12876. /**
  12877. * Called by the GPUParticleSystem to setup the update shader
  12878. * @param effect defines the update shader
  12879. */
  12880. applyToShader(effect: Effect): void;
  12881. /**
  12882. * Returns a string to use to update the GPU particles update shader
  12883. * @returns a string containng the defines string
  12884. */
  12885. getEffectDefines(): string;
  12886. /**
  12887. * Returns the string "SphereDirectedParticleEmitter"
  12888. * @returns a string containing the class name
  12889. */
  12890. getClassName(): string;
  12891. /**
  12892. * Serializes the particle system to a JSON object.
  12893. * @returns the JSON object
  12894. */
  12895. serialize(): any;
  12896. /**
  12897. * Parse properties from a JSON object
  12898. * @param serializationObject defines the JSON object
  12899. */
  12900. parse(serializationObject: any): void;
  12901. }
  12902. }
  12903. declare module BABYLON {
  12904. /**
  12905. * Particle emitter emitting particles from a custom list of positions.
  12906. */
  12907. export class CustomParticleEmitter implements IParticleEmitterType {
  12908. /**
  12909. * Gets or sets the position generator that will create the inital position of each particle.
  12910. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12911. */
  12912. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12913. /**
  12914. * Gets or sets the destination generator that will create the final destination of each particle.
  12915. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12916. */
  12917. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12918. /**
  12919. * Creates a new instance CustomParticleEmitter
  12920. */
  12921. constructor();
  12922. /**
  12923. * Called by the particle System when the direction is computed for the created particle.
  12924. * @param worldMatrix is the world matrix of the particle system
  12925. * @param directionToUpdate is the direction vector to update with the result
  12926. * @param particle is the particle we are computed the direction for
  12927. * @param isLocal defines if the direction should be set in local space
  12928. */
  12929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12930. /**
  12931. * Called by the particle System when the position is computed for the created particle.
  12932. * @param worldMatrix is the world matrix of the particle system
  12933. * @param positionToUpdate is the position vector to update with the result
  12934. * @param particle is the particle we are computed the position for
  12935. * @param isLocal defines if the position should be set in local space
  12936. */
  12937. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12938. /**
  12939. * Clones the current emitter and returns a copy of it
  12940. * @returns the new emitter
  12941. */
  12942. clone(): CustomParticleEmitter;
  12943. /**
  12944. * Called by the GPUParticleSystem to setup the update shader
  12945. * @param effect defines the update shader
  12946. */
  12947. applyToShader(effect: Effect): void;
  12948. /**
  12949. * Returns a string to use to update the GPU particles update shader
  12950. * @returns a string containng the defines string
  12951. */
  12952. getEffectDefines(): string;
  12953. /**
  12954. * Returns the string "PointParticleEmitter"
  12955. * @returns a string containing the class name
  12956. */
  12957. getClassName(): string;
  12958. /**
  12959. * Serializes the particle system to a JSON object.
  12960. * @returns the JSON object
  12961. */
  12962. serialize(): any;
  12963. /**
  12964. * Parse properties from a JSON object
  12965. * @param serializationObject defines the JSON object
  12966. */
  12967. parse(serializationObject: any): void;
  12968. }
  12969. }
  12970. declare module BABYLON {
  12971. /**
  12972. * Particle emitter emitting particles from the inside of a box.
  12973. * It emits the particles randomly between 2 given directions.
  12974. */
  12975. export class MeshParticleEmitter implements IParticleEmitterType {
  12976. private _indices;
  12977. private _positions;
  12978. private _normals;
  12979. private _storedNormal;
  12980. private _mesh;
  12981. /**
  12982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12983. */
  12984. direction1: Vector3;
  12985. /**
  12986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12987. */
  12988. direction2: Vector3;
  12989. /**
  12990. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12991. */
  12992. useMeshNormalsForDirection: boolean;
  12993. /** Defines the mesh to use as source */
  12994. get mesh(): Nullable<AbstractMesh>;
  12995. set mesh(value: Nullable<AbstractMesh>);
  12996. /**
  12997. * Creates a new instance MeshParticleEmitter
  12998. * @param mesh defines the mesh to use as source
  12999. */
  13000. constructor(mesh?: Nullable<AbstractMesh>);
  13001. /**
  13002. * Called by the particle System when the direction is computed for the created particle.
  13003. * @param worldMatrix is the world matrix of the particle system
  13004. * @param directionToUpdate is the direction vector to update with the result
  13005. * @param particle is the particle we are computed the direction for
  13006. * @param isLocal defines if the direction should be set in local space
  13007. */
  13008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13009. /**
  13010. * Called by the particle System when the position is computed for the created particle.
  13011. * @param worldMatrix is the world matrix of the particle system
  13012. * @param positionToUpdate is the position vector to update with the result
  13013. * @param particle is the particle we are computed the position for
  13014. * @param isLocal defines if the position should be set in local space
  13015. */
  13016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13017. /**
  13018. * Clones the current emitter and returns a copy of it
  13019. * @returns the new emitter
  13020. */
  13021. clone(): MeshParticleEmitter;
  13022. /**
  13023. * Called by the GPUParticleSystem to setup the update shader
  13024. * @param effect defines the update shader
  13025. */
  13026. applyToShader(effect: Effect): void;
  13027. /**
  13028. * Returns a string to use to update the GPU particles update shader
  13029. * @returns a string containng the defines string
  13030. */
  13031. getEffectDefines(): string;
  13032. /**
  13033. * Returns the string "BoxParticleEmitter"
  13034. * @returns a string containing the class name
  13035. */
  13036. getClassName(): string;
  13037. /**
  13038. * Serializes the particle system to a JSON object.
  13039. * @returns the JSON object
  13040. */
  13041. serialize(): any;
  13042. /**
  13043. * Parse properties from a JSON object
  13044. * @param serializationObject defines the JSON object
  13045. * @param scene defines the hosting scene
  13046. */
  13047. parse(serializationObject: any, scene: Scene): void;
  13048. }
  13049. }
  13050. declare module BABYLON {
  13051. /**
  13052. * Interface representing a particle system in Babylon.js.
  13053. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13054. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13055. */
  13056. export interface IParticleSystem {
  13057. /**
  13058. * List of animations used by the particle system.
  13059. */
  13060. animations: Animation[];
  13061. /**
  13062. * The id of the Particle system.
  13063. */
  13064. id: string;
  13065. /**
  13066. * The name of the Particle system.
  13067. */
  13068. name: string;
  13069. /**
  13070. * The emitter represents the Mesh or position we are attaching the particle system to.
  13071. */
  13072. emitter: Nullable<AbstractMesh | Vector3>;
  13073. /**
  13074. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13075. */
  13076. isBillboardBased: boolean;
  13077. /**
  13078. * The rendering group used by the Particle system to chose when to render.
  13079. */
  13080. renderingGroupId: number;
  13081. /**
  13082. * The layer mask we are rendering the particles through.
  13083. */
  13084. layerMask: number;
  13085. /**
  13086. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13087. */
  13088. updateSpeed: number;
  13089. /**
  13090. * The amount of time the particle system is running (depends of the overall update speed).
  13091. */
  13092. targetStopDuration: number;
  13093. /**
  13094. * The texture used to render each particle. (this can be a spritesheet)
  13095. */
  13096. particleTexture: Nullable<Texture>;
  13097. /**
  13098. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13099. */
  13100. blendMode: number;
  13101. /**
  13102. * Minimum life time of emitting particles.
  13103. */
  13104. minLifeTime: number;
  13105. /**
  13106. * Maximum life time of emitting particles.
  13107. */
  13108. maxLifeTime: number;
  13109. /**
  13110. * Minimum Size of emitting particles.
  13111. */
  13112. minSize: number;
  13113. /**
  13114. * Maximum Size of emitting particles.
  13115. */
  13116. maxSize: number;
  13117. /**
  13118. * Minimum scale of emitting particles on X axis.
  13119. */
  13120. minScaleX: number;
  13121. /**
  13122. * Maximum scale of emitting particles on X axis.
  13123. */
  13124. maxScaleX: number;
  13125. /**
  13126. * Minimum scale of emitting particles on Y axis.
  13127. */
  13128. minScaleY: number;
  13129. /**
  13130. * Maximum scale of emitting particles on Y axis.
  13131. */
  13132. maxScaleY: number;
  13133. /**
  13134. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13135. */
  13136. color1: Color4;
  13137. /**
  13138. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13139. */
  13140. color2: Color4;
  13141. /**
  13142. * Color the particle will have at the end of its lifetime.
  13143. */
  13144. colorDead: Color4;
  13145. /**
  13146. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13147. */
  13148. emitRate: number;
  13149. /**
  13150. * You can use gravity if you want to give an orientation to your particles.
  13151. */
  13152. gravity: Vector3;
  13153. /**
  13154. * Minimum power of emitting particles.
  13155. */
  13156. minEmitPower: number;
  13157. /**
  13158. * Maximum power of emitting particles.
  13159. */
  13160. maxEmitPower: number;
  13161. /**
  13162. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13163. */
  13164. minAngularSpeed: number;
  13165. /**
  13166. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13167. */
  13168. maxAngularSpeed: number;
  13169. /**
  13170. * Gets or sets the minimal initial rotation in radians.
  13171. */
  13172. minInitialRotation: number;
  13173. /**
  13174. * Gets or sets the maximal initial rotation in radians.
  13175. */
  13176. maxInitialRotation: number;
  13177. /**
  13178. * The particle emitter type defines the emitter used by the particle system.
  13179. * It can be for example box, sphere, or cone...
  13180. */
  13181. particleEmitterType: Nullable<IParticleEmitterType>;
  13182. /**
  13183. * Defines the delay in milliseconds before starting the system (0 by default)
  13184. */
  13185. startDelay: number;
  13186. /**
  13187. * 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
  13188. */
  13189. preWarmCycles: number;
  13190. /**
  13191. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13192. */
  13193. preWarmStepOffset: number;
  13194. /**
  13195. * 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)
  13196. */
  13197. spriteCellChangeSpeed: number;
  13198. /**
  13199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13200. */
  13201. startSpriteCellID: number;
  13202. /**
  13203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13204. */
  13205. endSpriteCellID: number;
  13206. /**
  13207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13208. */
  13209. spriteCellWidth: number;
  13210. /**
  13211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13212. */
  13213. spriteCellHeight: number;
  13214. /**
  13215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13216. */
  13217. spriteRandomStartCell: boolean;
  13218. /**
  13219. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13220. */
  13221. isAnimationSheetEnabled: boolean;
  13222. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13223. translationPivot: Vector2;
  13224. /**
  13225. * Gets or sets a texture used to add random noise to particle positions
  13226. */
  13227. noiseTexture: Nullable<BaseTexture>;
  13228. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13229. noiseStrength: Vector3;
  13230. /**
  13231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13233. */
  13234. billboardMode: number;
  13235. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13236. limitVelocityDamping: number;
  13237. /**
  13238. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13239. */
  13240. beginAnimationOnStart: boolean;
  13241. /**
  13242. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13243. */
  13244. beginAnimationFrom: number;
  13245. /**
  13246. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13247. */
  13248. beginAnimationTo: number;
  13249. /**
  13250. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13251. */
  13252. beginAnimationLoop: boolean;
  13253. /**
  13254. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13255. */
  13256. disposeOnStop: boolean;
  13257. /**
  13258. * Specifies if the particles are updated in emitter local space or world space
  13259. */
  13260. isLocal: boolean;
  13261. /** Snippet ID if the particle system was created from the snippet server */
  13262. snippetId: string;
  13263. /**
  13264. * Gets the maximum number of particles active at the same time.
  13265. * @returns The max number of active particles.
  13266. */
  13267. getCapacity(): number;
  13268. /**
  13269. * Gets the number of particles active at the same time.
  13270. * @returns The number of active particles.
  13271. */
  13272. getActiveCount(): number;
  13273. /**
  13274. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13275. * @returns True if it has been started, otherwise false.
  13276. */
  13277. isStarted(): boolean;
  13278. /**
  13279. * Animates the particle system for this frame.
  13280. */
  13281. animate(): void;
  13282. /**
  13283. * Renders the particle system in its current state.
  13284. * @returns the current number of particles
  13285. */
  13286. render(): number;
  13287. /**
  13288. * Dispose the particle system and frees its associated resources.
  13289. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13290. */
  13291. dispose(disposeTexture?: boolean): void;
  13292. /**
  13293. * Clones the particle system.
  13294. * @param name The name of the cloned object
  13295. * @param newEmitter The new emitter to use
  13296. * @returns the cloned particle system
  13297. */
  13298. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13299. /**
  13300. * Serializes the particle system to a JSON object
  13301. * @param serializeTexture defines if the texture must be serialized as well
  13302. * @returns the JSON object
  13303. */
  13304. serialize(serializeTexture: boolean): any;
  13305. /**
  13306. * Rebuild the particle system
  13307. */
  13308. rebuild(): void;
  13309. /** Force the system to rebuild all gradients that need to be resync */
  13310. forceRefreshGradients(): void;
  13311. /**
  13312. * Starts the particle system and begins to emit
  13313. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13314. */
  13315. start(delay?: number): void;
  13316. /**
  13317. * Stops the particle system.
  13318. */
  13319. stop(): void;
  13320. /**
  13321. * Remove all active particles
  13322. */
  13323. reset(): void;
  13324. /**
  13325. * Gets a boolean indicating that the system is stopping
  13326. * @returns true if the system is currently stopping
  13327. */
  13328. isStopping(): boolean;
  13329. /**
  13330. * Is this system ready to be used/rendered
  13331. * @return true if the system is ready
  13332. */
  13333. isReady(): boolean;
  13334. /**
  13335. * Returns the string "ParticleSystem"
  13336. * @returns a string containing the class name
  13337. */
  13338. getClassName(): string;
  13339. /**
  13340. * Adds a new color gradient
  13341. * @param gradient defines the gradient to use (between 0 and 1)
  13342. * @param color1 defines the color to affect to the specified gradient
  13343. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13344. * @returns the current particle system
  13345. */
  13346. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13347. /**
  13348. * Remove a specific color gradient
  13349. * @param gradient defines the gradient to remove
  13350. * @returns the current particle system
  13351. */
  13352. removeColorGradient(gradient: number): IParticleSystem;
  13353. /**
  13354. * Adds a new size gradient
  13355. * @param gradient defines the gradient to use (between 0 and 1)
  13356. * @param factor defines the size factor to affect to the specified gradient
  13357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13358. * @returns the current particle system
  13359. */
  13360. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13361. /**
  13362. * Remove a specific size gradient
  13363. * @param gradient defines the gradient to remove
  13364. * @returns the current particle system
  13365. */
  13366. removeSizeGradient(gradient: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of color gradients.
  13369. * You must use addColorGradient and removeColorGradient to udpate this list
  13370. * @returns the list of color gradients
  13371. */
  13372. getColorGradients(): Nullable<Array<ColorGradient>>;
  13373. /**
  13374. * Gets the current list of size gradients.
  13375. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13376. * @returns the list of size gradients
  13377. */
  13378. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13379. /**
  13380. * Gets the current list of angular speed gradients.
  13381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13382. * @returns the list of angular speed gradients
  13383. */
  13384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13385. /**
  13386. * Adds a new angular speed gradient
  13387. * @param gradient defines the gradient to use (between 0 and 1)
  13388. * @param factor defines the angular speed to affect to the specified gradient
  13389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13390. * @returns the current particle system
  13391. */
  13392. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13393. /**
  13394. * Remove a specific angular speed gradient
  13395. * @param gradient defines the gradient to remove
  13396. * @returns the current particle system
  13397. */
  13398. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13399. /**
  13400. * Gets the current list of velocity gradients.
  13401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13402. * @returns the list of velocity gradients
  13403. */
  13404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13405. /**
  13406. * Adds a new velocity gradient
  13407. * @param gradient defines the gradient to use (between 0 and 1)
  13408. * @param factor defines the velocity to affect to the specified gradient
  13409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13410. * @returns the current particle system
  13411. */
  13412. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13413. /**
  13414. * Remove a specific velocity gradient
  13415. * @param gradient defines the gradient to remove
  13416. * @returns the current particle system
  13417. */
  13418. removeVelocityGradient(gradient: number): IParticleSystem;
  13419. /**
  13420. * Gets the current list of limit velocity gradients.
  13421. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13422. * @returns the list of limit velocity gradients
  13423. */
  13424. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13425. /**
  13426. * Adds a new limit velocity gradient
  13427. * @param gradient defines the gradient to use (between 0 and 1)
  13428. * @param factor defines the limit velocity to affect to the specified gradient
  13429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13430. * @returns the current particle system
  13431. */
  13432. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13433. /**
  13434. * Remove a specific limit velocity gradient
  13435. * @param gradient defines the gradient to remove
  13436. * @returns the current particle system
  13437. */
  13438. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13439. /**
  13440. * Adds a new drag gradient
  13441. * @param gradient defines the gradient to use (between 0 and 1)
  13442. * @param factor defines the drag to affect to the specified gradient
  13443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13444. * @returns the current particle system
  13445. */
  13446. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13447. /**
  13448. * Remove a specific drag gradient
  13449. * @param gradient defines the gradient to remove
  13450. * @returns the current particle system
  13451. */
  13452. removeDragGradient(gradient: number): IParticleSystem;
  13453. /**
  13454. * Gets the current list of drag gradients.
  13455. * You must use addDragGradient and removeDragGradient to udpate this list
  13456. * @returns the list of drag gradients
  13457. */
  13458. getDragGradients(): Nullable<Array<FactorGradient>>;
  13459. /**
  13460. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13461. * @param gradient defines the gradient to use (between 0 and 1)
  13462. * @param factor defines the emit rate to affect to the specified gradient
  13463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13464. * @returns the current particle system
  13465. */
  13466. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13467. /**
  13468. * Remove a specific emit rate gradient
  13469. * @param gradient defines the gradient to remove
  13470. * @returns the current particle system
  13471. */
  13472. removeEmitRateGradient(gradient: number): IParticleSystem;
  13473. /**
  13474. * Gets the current list of emit rate gradients.
  13475. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13476. * @returns the list of emit rate gradients
  13477. */
  13478. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13479. /**
  13480. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13481. * @param gradient defines the gradient to use (between 0 and 1)
  13482. * @param factor defines the start size to affect to the specified gradient
  13483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13484. * @returns the current particle system
  13485. */
  13486. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13487. /**
  13488. * Remove a specific start size gradient
  13489. * @param gradient defines the gradient to remove
  13490. * @returns the current particle system
  13491. */
  13492. removeStartSizeGradient(gradient: number): IParticleSystem;
  13493. /**
  13494. * Gets the current list of start size gradients.
  13495. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13496. * @returns the list of start size gradients
  13497. */
  13498. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13499. /**
  13500. * Adds a new life time gradient
  13501. * @param gradient defines the gradient to use (between 0 and 1)
  13502. * @param factor defines the life time factor to affect to the specified gradient
  13503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13504. * @returns the current particle system
  13505. */
  13506. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13507. /**
  13508. * Remove a specific life time gradient
  13509. * @param gradient defines the gradient to remove
  13510. * @returns the current particle system
  13511. */
  13512. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13513. /**
  13514. * Gets the current list of life time gradients.
  13515. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13516. * @returns the list of life time gradients
  13517. */
  13518. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13519. /**
  13520. * Gets the current list of color gradients.
  13521. * You must use addColorGradient and removeColorGradient to udpate this list
  13522. * @returns the list of color gradients
  13523. */
  13524. getColorGradients(): Nullable<Array<ColorGradient>>;
  13525. /**
  13526. * Adds a new ramp gradient used to remap particle colors
  13527. * @param gradient defines the gradient to use (between 0 and 1)
  13528. * @param color defines the color to affect to the specified gradient
  13529. * @returns the current particle system
  13530. */
  13531. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13532. /**
  13533. * Gets the current list of ramp gradients.
  13534. * You must use addRampGradient and removeRampGradient to udpate this list
  13535. * @returns the list of ramp gradients
  13536. */
  13537. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13538. /** Gets or sets a boolean indicating that ramp gradients must be used
  13539. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13540. */
  13541. useRampGradients: boolean;
  13542. /**
  13543. * Adds a new color remap gradient
  13544. * @param gradient defines the gradient to use (between 0 and 1)
  13545. * @param min defines the color remap minimal range
  13546. * @param max defines the color remap maximal range
  13547. * @returns the current particle system
  13548. */
  13549. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13550. /**
  13551. * Gets the current list of color remap gradients.
  13552. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13553. * @returns the list of color remap gradients
  13554. */
  13555. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13556. /**
  13557. * Adds a new alpha remap gradient
  13558. * @param gradient defines the gradient to use (between 0 and 1)
  13559. * @param min defines the alpha remap minimal range
  13560. * @param max defines the alpha remap maximal range
  13561. * @returns the current particle system
  13562. */
  13563. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13564. /**
  13565. * Gets the current list of alpha remap gradients.
  13566. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13567. * @returns the list of alpha remap gradients
  13568. */
  13569. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13570. /**
  13571. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13574. * @returns the emitter
  13575. */
  13576. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13577. /**
  13578. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13579. * @param radius The radius of the hemisphere to emit from
  13580. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13581. * @returns the emitter
  13582. */
  13583. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13584. /**
  13585. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13586. * @param radius The radius of the sphere to emit from
  13587. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13588. * @returns the emitter
  13589. */
  13590. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13591. /**
  13592. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13593. * @param radius The radius of the sphere to emit from
  13594. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13595. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13596. * @returns the emitter
  13597. */
  13598. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13599. /**
  13600. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13601. * @param radius The radius of the emission cylinder
  13602. * @param height The height of the emission cylinder
  13603. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13604. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13605. * @returns the emitter
  13606. */
  13607. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13608. /**
  13609. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13610. * @param radius The radius of the cylinder to emit from
  13611. * @param height The height of the emission cylinder
  13612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13615. * @returns the emitter
  13616. */
  13617. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13618. /**
  13619. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13620. * @param radius The radius of the cone to emit from
  13621. * @param angle The base angle of the cone
  13622. * @returns the emitter
  13623. */
  13624. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13625. /**
  13626. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13629. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13630. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13631. * @returns the emitter
  13632. */
  13633. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13634. /**
  13635. * Get hosting scene
  13636. * @returns the scene
  13637. */
  13638. getScene(): Scene;
  13639. }
  13640. }
  13641. declare module BABYLON {
  13642. /**
  13643. * 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.
  13644. * @see https://doc.babylonjs.com/how_to/transformnode
  13645. */
  13646. export class TransformNode extends Node {
  13647. /**
  13648. * Object will not rotate to face the camera
  13649. */
  13650. static BILLBOARDMODE_NONE: number;
  13651. /**
  13652. * Object will rotate to face the camera but only on the x axis
  13653. */
  13654. static BILLBOARDMODE_X: number;
  13655. /**
  13656. * Object will rotate to face the camera but only on the y axis
  13657. */
  13658. static BILLBOARDMODE_Y: number;
  13659. /**
  13660. * Object will rotate to face the camera but only on the z axis
  13661. */
  13662. static BILLBOARDMODE_Z: number;
  13663. /**
  13664. * Object will rotate to face the camera
  13665. */
  13666. static BILLBOARDMODE_ALL: number;
  13667. /**
  13668. * Object will rotate to face the camera's position instead of orientation
  13669. */
  13670. static BILLBOARDMODE_USE_POSITION: number;
  13671. private _forward;
  13672. private _forwardInverted;
  13673. private _up;
  13674. private _right;
  13675. private _rightInverted;
  13676. private _position;
  13677. private _rotation;
  13678. private _rotationQuaternion;
  13679. protected _scaling: Vector3;
  13680. protected _isDirty: boolean;
  13681. private _transformToBoneReferal;
  13682. private _isAbsoluteSynced;
  13683. private _billboardMode;
  13684. /**
  13685. * Gets or sets the billboard mode. Default is 0.
  13686. *
  13687. * | Value | Type | Description |
  13688. * | --- | --- | --- |
  13689. * | 0 | BILLBOARDMODE_NONE | |
  13690. * | 1 | BILLBOARDMODE_X | |
  13691. * | 2 | BILLBOARDMODE_Y | |
  13692. * | 4 | BILLBOARDMODE_Z | |
  13693. * | 7 | BILLBOARDMODE_ALL | |
  13694. *
  13695. */
  13696. get billboardMode(): number;
  13697. set billboardMode(value: number);
  13698. private _preserveParentRotationForBillboard;
  13699. /**
  13700. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13701. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13702. */
  13703. get preserveParentRotationForBillboard(): boolean;
  13704. set preserveParentRotationForBillboard(value: boolean);
  13705. /**
  13706. * 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
  13707. */
  13708. scalingDeterminant: number;
  13709. private _infiniteDistance;
  13710. /**
  13711. * Gets or sets the distance of the object to max, often used by skybox
  13712. */
  13713. get infiniteDistance(): boolean;
  13714. set infiniteDistance(value: boolean);
  13715. /**
  13716. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13717. * By default the system will update normals to compensate
  13718. */
  13719. ignoreNonUniformScaling: boolean;
  13720. /**
  13721. * 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
  13722. */
  13723. reIntegrateRotationIntoRotationQuaternion: boolean;
  13724. /** @hidden */
  13725. _poseMatrix: Nullable<Matrix>;
  13726. /** @hidden */
  13727. _localMatrix: Matrix;
  13728. private _usePivotMatrix;
  13729. private _absolutePosition;
  13730. private _absoluteScaling;
  13731. private _absoluteRotationQuaternion;
  13732. private _pivotMatrix;
  13733. private _pivotMatrixInverse;
  13734. protected _postMultiplyPivotMatrix: boolean;
  13735. protected _isWorldMatrixFrozen: boolean;
  13736. /** @hidden */
  13737. _indexInSceneTransformNodesArray: number;
  13738. /**
  13739. * An event triggered after the world matrix is updated
  13740. */
  13741. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13742. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13743. /**
  13744. * Gets a string identifying the name of the class
  13745. * @returns "TransformNode" string
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13750. */
  13751. get position(): Vector3;
  13752. set position(newPosition: Vector3);
  13753. /**
  13754. * 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)).
  13755. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13756. */
  13757. get rotation(): Vector3;
  13758. set rotation(newRotation: Vector3);
  13759. /**
  13760. * 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)).
  13761. */
  13762. get scaling(): Vector3;
  13763. set scaling(newScaling: Vector3);
  13764. /**
  13765. * 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).
  13766. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13767. */
  13768. get rotationQuaternion(): Nullable<Quaternion>;
  13769. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13770. /**
  13771. * The forward direction of that transform in world space.
  13772. */
  13773. get forward(): Vector3;
  13774. /**
  13775. * The up direction of that transform in world space.
  13776. */
  13777. get up(): Vector3;
  13778. /**
  13779. * The right direction of that transform in world space.
  13780. */
  13781. get right(): Vector3;
  13782. /**
  13783. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13784. * @param matrix the matrix to copy the pose from
  13785. * @returns this TransformNode.
  13786. */
  13787. updatePoseMatrix(matrix: Matrix): TransformNode;
  13788. /**
  13789. * Returns the mesh Pose matrix.
  13790. * @returns the pose matrix
  13791. */
  13792. getPoseMatrix(): Matrix;
  13793. /** @hidden */
  13794. _isSynchronized(): boolean;
  13795. /** @hidden */
  13796. _initCache(): void;
  13797. /**
  13798. * Flag the transform node as dirty (Forcing it to update everything)
  13799. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13800. * @returns this transform node
  13801. */
  13802. markAsDirty(property: string): TransformNode;
  13803. /**
  13804. * Returns the current mesh absolute position.
  13805. * Returns a Vector3.
  13806. */
  13807. get absolutePosition(): Vector3;
  13808. /**
  13809. * Returns the current mesh absolute scaling.
  13810. * Returns a Vector3.
  13811. */
  13812. get absoluteScaling(): Vector3;
  13813. /**
  13814. * Returns the current mesh absolute rotation.
  13815. * Returns a Quaternion.
  13816. */
  13817. get absoluteRotationQuaternion(): Quaternion;
  13818. /**
  13819. * Sets a new matrix to apply before all other transformation
  13820. * @param matrix defines the transform matrix
  13821. * @returns the current TransformNode
  13822. */
  13823. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13824. /**
  13825. * Sets a new pivot matrix to the current node
  13826. * @param matrix defines the new pivot matrix to use
  13827. * @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
  13828. * @returns the current TransformNode
  13829. */
  13830. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13831. /**
  13832. * Returns the mesh pivot matrix.
  13833. * Default : Identity.
  13834. * @returns the matrix
  13835. */
  13836. getPivotMatrix(): Matrix;
  13837. /**
  13838. * Instantiate (when possible) or clone that node with its hierarchy
  13839. * @param newParent defines the new parent to use for the instance (or clone)
  13840. * @param options defines options to configure how copy is done
  13841. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13842. * @returns an instance (or a clone) of the current node with its hiearchy
  13843. */
  13844. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13845. doNotInstantiate: boolean;
  13846. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13847. /**
  13848. * Prevents the World matrix to be computed any longer
  13849. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13850. * @returns the TransformNode.
  13851. */
  13852. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13853. /**
  13854. * Allows back the World matrix computation.
  13855. * @returns the TransformNode.
  13856. */
  13857. unfreezeWorldMatrix(): this;
  13858. /**
  13859. * True if the World matrix has been frozen.
  13860. */
  13861. get isWorldMatrixFrozen(): boolean;
  13862. /**
  13863. * Retuns the mesh absolute position in the World.
  13864. * @returns a Vector3.
  13865. */
  13866. getAbsolutePosition(): Vector3;
  13867. /**
  13868. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13869. * @param absolutePosition the absolute position to set
  13870. * @returns the TransformNode.
  13871. */
  13872. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13873. /**
  13874. * Sets the mesh position in its local space.
  13875. * @param vector3 the position to set in localspace
  13876. * @returns the TransformNode.
  13877. */
  13878. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13879. /**
  13880. * Returns the mesh position in the local space from the current World matrix values.
  13881. * @returns a new Vector3.
  13882. */
  13883. getPositionExpressedInLocalSpace(): Vector3;
  13884. /**
  13885. * Translates the mesh along the passed Vector3 in its local space.
  13886. * @param vector3 the distance to translate in localspace
  13887. * @returns the TransformNode.
  13888. */
  13889. locallyTranslate(vector3: Vector3): TransformNode;
  13890. private static _lookAtVectorCache;
  13891. /**
  13892. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13893. * @param targetPoint the position (must be in same space as current mesh) to look at
  13894. * @param yawCor optional yaw (y-axis) correction in radians
  13895. * @param pitchCor optional pitch (x-axis) correction in radians
  13896. * @param rollCor optional roll (z-axis) correction in radians
  13897. * @param space the choosen space of the target
  13898. * @returns the TransformNode.
  13899. */
  13900. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13901. /**
  13902. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13903. * This Vector3 is expressed in the World space.
  13904. * @param localAxis axis to rotate
  13905. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13906. */
  13907. getDirection(localAxis: Vector3): Vector3;
  13908. /**
  13909. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13910. * localAxis is expressed in the mesh local space.
  13911. * result is computed in the Wordl space from the mesh World matrix.
  13912. * @param localAxis axis to rotate
  13913. * @param result the resulting transformnode
  13914. * @returns this TransformNode.
  13915. */
  13916. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13917. /**
  13918. * Sets this transform node rotation to the given local axis.
  13919. * @param localAxis the axis in local space
  13920. * @param yawCor optional yaw (y-axis) correction in radians
  13921. * @param pitchCor optional pitch (x-axis) correction in radians
  13922. * @param rollCor optional roll (z-axis) correction in radians
  13923. * @returns this TransformNode
  13924. */
  13925. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13926. /**
  13927. * Sets a new pivot point to the current node
  13928. * @param point defines the new pivot point to use
  13929. * @param space defines if the point is in world or local space (local by default)
  13930. * @returns the current TransformNode
  13931. */
  13932. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13933. /**
  13934. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13935. * @returns the pivot point
  13936. */
  13937. getPivotPoint(): Vector3;
  13938. /**
  13939. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13940. * @param result the vector3 to store the result
  13941. * @returns this TransformNode.
  13942. */
  13943. getPivotPointToRef(result: Vector3): TransformNode;
  13944. /**
  13945. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13946. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13947. */
  13948. getAbsolutePivotPoint(): Vector3;
  13949. /**
  13950. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13951. * @param result vector3 to store the result
  13952. * @returns this TransformNode.
  13953. */
  13954. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13955. /**
  13956. * Defines the passed node as the parent of the current node.
  13957. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13958. * @see https://doc.babylonjs.com/how_to/parenting
  13959. * @param node the node ot set as the parent
  13960. * @returns this TransformNode.
  13961. */
  13962. setParent(node: Nullable<Node>): TransformNode;
  13963. private _nonUniformScaling;
  13964. /**
  13965. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13966. */
  13967. get nonUniformScaling(): boolean;
  13968. /** @hidden */
  13969. _updateNonUniformScalingState(value: boolean): boolean;
  13970. /**
  13971. * Attach the current TransformNode to another TransformNode associated with a bone
  13972. * @param bone Bone affecting the TransformNode
  13973. * @param affectedTransformNode TransformNode associated with the bone
  13974. * @returns this object
  13975. */
  13976. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13977. /**
  13978. * Detach the transform node if its associated with a bone
  13979. * @returns this object
  13980. */
  13981. detachFromBone(): TransformNode;
  13982. private static _rotationAxisCache;
  13983. /**
  13984. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13985. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13986. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13987. * The passed axis is also normalized.
  13988. * @param axis the axis to rotate around
  13989. * @param amount the amount to rotate in radians
  13990. * @param space Space to rotate in (Default: local)
  13991. * @returns the TransformNode.
  13992. */
  13993. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13994. /**
  13995. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13996. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13997. * The passed axis is also normalized. .
  13998. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13999. * @param point the point to rotate around
  14000. * @param axis the axis to rotate around
  14001. * @param amount the amount to rotate in radians
  14002. * @returns the TransformNode
  14003. */
  14004. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14005. /**
  14006. * Translates the mesh along the axis vector for the passed distance in the given space.
  14007. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14008. * @param axis the axis to translate in
  14009. * @param distance the distance to translate
  14010. * @param space Space to rotate in (Default: local)
  14011. * @returns the TransformNode.
  14012. */
  14013. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14014. /**
  14015. * Adds a rotation step to the mesh current rotation.
  14016. * x, y, z are Euler angles expressed in radians.
  14017. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14018. * This means this rotation is made in the mesh local space only.
  14019. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14020. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14021. * ```javascript
  14022. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14023. * ```
  14024. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14025. * 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.
  14026. * @param x Rotation to add
  14027. * @param y Rotation to add
  14028. * @param z Rotation to add
  14029. * @returns the TransformNode.
  14030. */
  14031. addRotation(x: number, y: number, z: number): TransformNode;
  14032. /**
  14033. * @hidden
  14034. */
  14035. protected _getEffectiveParent(): Nullable<Node>;
  14036. /**
  14037. * Computes the world matrix of the node
  14038. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14039. * @returns the world matrix
  14040. */
  14041. computeWorldMatrix(force?: boolean): Matrix;
  14042. /**
  14043. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14044. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14045. */
  14046. resetLocalMatrix(independentOfChildren?: boolean): void;
  14047. protected _afterComputeWorldMatrix(): void;
  14048. /**
  14049. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14050. * @param func callback function to add
  14051. *
  14052. * @returns the TransformNode.
  14053. */
  14054. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14055. /**
  14056. * Removes a registered callback function.
  14057. * @param func callback function to remove
  14058. * @returns the TransformNode.
  14059. */
  14060. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14061. /**
  14062. * Gets the position of the current mesh in camera space
  14063. * @param camera defines the camera to use
  14064. * @returns a position
  14065. */
  14066. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14067. /**
  14068. * Returns the distance from the mesh to the active camera
  14069. * @param camera defines the camera to use
  14070. * @returns the distance
  14071. */
  14072. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14073. /**
  14074. * Clone the current transform node
  14075. * @param name Name of the new clone
  14076. * @param newParent New parent for the clone
  14077. * @param doNotCloneChildren Do not clone children hierarchy
  14078. * @returns the new transform node
  14079. */
  14080. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14081. /**
  14082. * Serializes the objects information.
  14083. * @param currentSerializationObject defines the object to serialize in
  14084. * @returns the serialized object
  14085. */
  14086. serialize(currentSerializationObject?: any): any;
  14087. /**
  14088. * Returns a new TransformNode object parsed from the source provided.
  14089. * @param parsedTransformNode is the source.
  14090. * @param scene the scne the object belongs to
  14091. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14092. * @returns a new TransformNode object parsed from the source provided.
  14093. */
  14094. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14095. /**
  14096. * Get all child-transformNodes of this node
  14097. * @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
  14098. * @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
  14099. * @returns an array of TransformNode
  14100. */
  14101. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14102. /**
  14103. * Releases resources associated with this transform node.
  14104. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14105. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14106. */
  14107. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14108. /**
  14109. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14110. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14111. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14112. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14113. * @returns the current mesh
  14114. */
  14115. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14116. private _syncAbsoluteScalingAndRotation;
  14117. }
  14118. }
  14119. declare module BABYLON {
  14120. /**
  14121. * Class used to override all child animations of a given target
  14122. */
  14123. export class AnimationPropertiesOverride {
  14124. /**
  14125. * Gets or sets a value indicating if animation blending must be used
  14126. */
  14127. enableBlending: boolean;
  14128. /**
  14129. * Gets or sets the blending speed to use when enableBlending is true
  14130. */
  14131. blendingSpeed: number;
  14132. /**
  14133. * Gets or sets the default loop mode to use
  14134. */
  14135. loopMode: number;
  14136. }
  14137. }
  14138. declare module BABYLON {
  14139. /**
  14140. * Class used to store bone information
  14141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14142. */
  14143. export class Bone extends Node {
  14144. /**
  14145. * defines the bone name
  14146. */
  14147. name: string;
  14148. private static _tmpVecs;
  14149. private static _tmpQuat;
  14150. private static _tmpMats;
  14151. /**
  14152. * Gets the list of child bones
  14153. */
  14154. children: Bone[];
  14155. /** Gets the animations associated with this bone */
  14156. animations: Animation[];
  14157. /**
  14158. * Gets or sets bone length
  14159. */
  14160. length: number;
  14161. /**
  14162. * @hidden Internal only
  14163. * Set this value to map this bone to a different index in the transform matrices
  14164. * Set this value to -1 to exclude the bone from the transform matrices
  14165. */
  14166. _index: Nullable<number>;
  14167. private _skeleton;
  14168. private _localMatrix;
  14169. private _restPose;
  14170. private _baseMatrix;
  14171. private _absoluteTransform;
  14172. private _invertedAbsoluteTransform;
  14173. private _parent;
  14174. private _scalingDeterminant;
  14175. private _worldTransform;
  14176. private _localScaling;
  14177. private _localRotation;
  14178. private _localPosition;
  14179. private _needToDecompose;
  14180. private _needToCompose;
  14181. /** @hidden */
  14182. _linkedTransformNode: Nullable<TransformNode>;
  14183. /** @hidden */
  14184. _waitingTransformNodeId: Nullable<string>;
  14185. /** @hidden */
  14186. get _matrix(): Matrix;
  14187. /** @hidden */
  14188. set _matrix(value: Matrix);
  14189. /**
  14190. * Create a new bone
  14191. * @param name defines the bone name
  14192. * @param skeleton defines the parent skeleton
  14193. * @param parentBone defines the parent (can be null if the bone is the root)
  14194. * @param localMatrix defines the local matrix
  14195. * @param restPose defines the rest pose matrix
  14196. * @param baseMatrix defines the base matrix
  14197. * @param index defines index of the bone in the hiearchy
  14198. */
  14199. constructor(
  14200. /**
  14201. * defines the bone name
  14202. */
  14203. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14204. /**
  14205. * Gets the current object class name.
  14206. * @return the class name
  14207. */
  14208. getClassName(): string;
  14209. /**
  14210. * Gets the parent skeleton
  14211. * @returns a skeleton
  14212. */
  14213. getSkeleton(): Skeleton;
  14214. /**
  14215. * Gets parent bone
  14216. * @returns a bone or null if the bone is the root of the bone hierarchy
  14217. */
  14218. getParent(): Nullable<Bone>;
  14219. /**
  14220. * Returns an array containing the root bones
  14221. * @returns an array containing the root bones
  14222. */
  14223. getChildren(): Array<Bone>;
  14224. /**
  14225. * Gets the node index in matrix array generated for rendering
  14226. * @returns the node index
  14227. */
  14228. getIndex(): number;
  14229. /**
  14230. * Sets the parent bone
  14231. * @param parent defines the parent (can be null if the bone is the root)
  14232. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14233. */
  14234. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14235. /**
  14236. * Gets the local matrix
  14237. * @returns a matrix
  14238. */
  14239. getLocalMatrix(): Matrix;
  14240. /**
  14241. * Gets the base matrix (initial matrix which remains unchanged)
  14242. * @returns a matrix
  14243. */
  14244. getBaseMatrix(): Matrix;
  14245. /**
  14246. * Gets the rest pose matrix
  14247. * @returns a matrix
  14248. */
  14249. getRestPose(): Matrix;
  14250. /**
  14251. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14252. */
  14253. getWorldMatrix(): Matrix;
  14254. /**
  14255. * Sets the local matrix to rest pose matrix
  14256. */
  14257. returnToRest(): void;
  14258. /**
  14259. * Gets the inverse of the absolute transform matrix.
  14260. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14261. * @returns a matrix
  14262. */
  14263. getInvertedAbsoluteTransform(): Matrix;
  14264. /**
  14265. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14266. * @returns a matrix
  14267. */
  14268. getAbsoluteTransform(): Matrix;
  14269. /**
  14270. * Links with the given transform node.
  14271. * The local matrix of this bone is copied from the transform node every frame.
  14272. * @param transformNode defines the transform node to link to
  14273. */
  14274. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14275. /**
  14276. * Gets the node used to drive the bone's transformation
  14277. * @returns a transform node or null
  14278. */
  14279. getTransformNode(): Nullable<TransformNode>;
  14280. /** Gets or sets current position (in local space) */
  14281. get position(): Vector3;
  14282. set position(newPosition: Vector3);
  14283. /** Gets or sets current rotation (in local space) */
  14284. get rotation(): Vector3;
  14285. set rotation(newRotation: Vector3);
  14286. /** Gets or sets current rotation quaternion (in local space) */
  14287. get rotationQuaternion(): Quaternion;
  14288. set rotationQuaternion(newRotation: Quaternion);
  14289. /** Gets or sets current scaling (in local space) */
  14290. get scaling(): Vector3;
  14291. set scaling(newScaling: Vector3);
  14292. /**
  14293. * Gets the animation properties override
  14294. */
  14295. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14296. private _decompose;
  14297. private _compose;
  14298. /**
  14299. * Update the base and local matrices
  14300. * @param matrix defines the new base or local matrix
  14301. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14302. * @param updateLocalMatrix defines if the local matrix should be updated
  14303. */
  14304. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14305. /** @hidden */
  14306. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14307. /**
  14308. * Flag the bone as dirty (Forcing it to update everything)
  14309. */
  14310. markAsDirty(): void;
  14311. /** @hidden */
  14312. _markAsDirtyAndCompose(): void;
  14313. private _markAsDirtyAndDecompose;
  14314. /**
  14315. * Translate the bone in local or world space
  14316. * @param vec The amount to translate the bone
  14317. * @param space The space that the translation is in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. */
  14320. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14321. /**
  14322. * Set the postion of the bone in local or world space
  14323. * @param position The position to set the bone
  14324. * @param space The space that the position is in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. */
  14327. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14328. /**
  14329. * Set the absolute position of the bone (world space)
  14330. * @param position The position to set the bone
  14331. * @param mesh The mesh that this bone is attached to
  14332. */
  14333. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14334. /**
  14335. * Scale the bone on the x, y and z axes (in local space)
  14336. * @param x The amount to scale the bone on the x axis
  14337. * @param y The amount to scale the bone on the y axis
  14338. * @param z The amount to scale the bone on the z axis
  14339. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14340. */
  14341. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14342. /**
  14343. * Set the bone scaling in local space
  14344. * @param scale defines the scaling vector
  14345. */
  14346. setScale(scale: Vector3): void;
  14347. /**
  14348. * Gets the current scaling in local space
  14349. * @returns the current scaling vector
  14350. */
  14351. getScale(): Vector3;
  14352. /**
  14353. * Gets the current scaling in local space and stores it in a target vector
  14354. * @param result defines the target vector
  14355. */
  14356. getScaleToRef(result: Vector3): void;
  14357. /**
  14358. * Set the yaw, pitch, and roll of the bone in local or world space
  14359. * @param yaw The rotation of the bone on the y axis
  14360. * @param pitch The rotation of the bone on the x axis
  14361. * @param roll The rotation of the bone on the z axis
  14362. * @param space The space that the axes of rotation are in
  14363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14364. */
  14365. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14366. /**
  14367. * Add a rotation to the bone on an axis in local or world space
  14368. * @param axis The axis to rotate the bone on
  14369. * @param amount The amount to rotate the bone
  14370. * @param space The space that the axis is in
  14371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14372. */
  14373. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14374. /**
  14375. * Set the rotation of the bone to a particular axis angle in local or world space
  14376. * @param axis The axis to rotate the bone on
  14377. * @param angle The angle that the bone should be rotated to
  14378. * @param space The space that the axis is in
  14379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14380. */
  14381. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14382. /**
  14383. * Set the euler rotation of the bone in local of world space
  14384. * @param rotation The euler rotation that the bone should be set to
  14385. * @param space The space that the rotation is in
  14386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14387. */
  14388. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14389. /**
  14390. * Set the quaternion rotation of the bone in local of world space
  14391. * @param quat The quaternion rotation that the bone should be set to
  14392. * @param space The space that the rotation is in
  14393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14394. */
  14395. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14396. /**
  14397. * Set the rotation matrix of the bone in local of world space
  14398. * @param rotMat The rotation matrix that the bone should be set to
  14399. * @param space The space that the rotation is in
  14400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14401. */
  14402. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14403. private _rotateWithMatrix;
  14404. private _getNegativeRotationToRef;
  14405. /**
  14406. * Get the position of the bone in local or world space
  14407. * @param space The space that the returned position is in
  14408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14409. * @returns The position of the bone
  14410. */
  14411. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14412. /**
  14413. * Copy the position of the bone to a vector3 in local or world space
  14414. * @param space The space that the returned position is in
  14415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14416. * @param result The vector3 to copy the position to
  14417. */
  14418. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14419. /**
  14420. * Get the absolute position of the bone (world space)
  14421. * @param mesh The mesh that this bone is attached to
  14422. * @returns The absolute position of the bone
  14423. */
  14424. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14425. /**
  14426. * Copy the absolute position of the bone (world space) to the result param
  14427. * @param mesh The mesh that this bone is attached to
  14428. * @param result The vector3 to copy the absolute position to
  14429. */
  14430. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14431. /**
  14432. * Compute the absolute transforms of this bone and its children
  14433. */
  14434. computeAbsoluteTransforms(): void;
  14435. /**
  14436. * Get the world direction from an axis that is in the local space of the bone
  14437. * @param localAxis The local direction that is used to compute the world direction
  14438. * @param mesh The mesh that this bone is attached to
  14439. * @returns The world direction
  14440. */
  14441. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14442. /**
  14443. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14444. * @param localAxis The local direction that is used to compute the world direction
  14445. * @param mesh The mesh that this bone is attached to
  14446. * @param result The vector3 that the world direction will be copied to
  14447. */
  14448. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14449. /**
  14450. * Get the euler rotation of the bone in local or world space
  14451. * @param space The space that the rotation should be in
  14452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14453. * @returns The euler rotation
  14454. */
  14455. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14456. /**
  14457. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14458. * @param space The space that the rotation should be in
  14459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14460. * @param result The vector3 that the rotation should be copied to
  14461. */
  14462. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14463. /**
  14464. * Get the quaternion rotation of the bone in either local or world space
  14465. * @param space The space that the rotation should be in
  14466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14467. * @returns The quaternion rotation
  14468. */
  14469. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14470. /**
  14471. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14472. * @param space The space that the rotation should be in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. * @param result The quaternion that the rotation should be copied to
  14475. */
  14476. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14477. /**
  14478. * Get the rotation matrix of the bone in local or world space
  14479. * @param space The space that the rotation should be in
  14480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14481. * @returns The rotation matrix
  14482. */
  14483. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14484. /**
  14485. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14486. * @param space The space that the rotation should be in
  14487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14488. * @param result The quaternion that the rotation should be copied to
  14489. */
  14490. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14491. /**
  14492. * Get the world position of a point that is in the local space of the bone
  14493. * @param position The local position
  14494. * @param mesh The mesh that this bone is attached to
  14495. * @returns The world position
  14496. */
  14497. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14498. /**
  14499. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14500. * @param position The local position
  14501. * @param mesh The mesh that this bone is attached to
  14502. * @param result The vector3 that the world position should be copied to
  14503. */
  14504. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14505. /**
  14506. * Get the local position of a point that is in world space
  14507. * @param position The world position
  14508. * @param mesh The mesh that this bone is attached to
  14509. * @returns The local position
  14510. */
  14511. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14512. /**
  14513. * Get the local position of a point that is in world space and copy it to the result param
  14514. * @param position The world position
  14515. * @param mesh The mesh that this bone is attached to
  14516. * @param result The vector3 that the local position should be copied to
  14517. */
  14518. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14519. }
  14520. }
  14521. declare module BABYLON {
  14522. /**
  14523. * Defines a runtime animation
  14524. */
  14525. export class RuntimeAnimation {
  14526. private _events;
  14527. /**
  14528. * The current frame of the runtime animation
  14529. */
  14530. private _currentFrame;
  14531. /**
  14532. * The animation used by the runtime animation
  14533. */
  14534. private _animation;
  14535. /**
  14536. * The target of the runtime animation
  14537. */
  14538. private _target;
  14539. /**
  14540. * The initiating animatable
  14541. */
  14542. private _host;
  14543. /**
  14544. * The original value of the runtime animation
  14545. */
  14546. private _originalValue;
  14547. /**
  14548. * The original blend value of the runtime animation
  14549. */
  14550. private _originalBlendValue;
  14551. /**
  14552. * The offsets cache of the runtime animation
  14553. */
  14554. private _offsetsCache;
  14555. /**
  14556. * The high limits cache of the runtime animation
  14557. */
  14558. private _highLimitsCache;
  14559. /**
  14560. * Specifies if the runtime animation has been stopped
  14561. */
  14562. private _stopped;
  14563. /**
  14564. * The blending factor of the runtime animation
  14565. */
  14566. private _blendingFactor;
  14567. /**
  14568. * The BabylonJS scene
  14569. */
  14570. private _scene;
  14571. /**
  14572. * The current value of the runtime animation
  14573. */
  14574. private _currentValue;
  14575. /** @hidden */
  14576. _animationState: _IAnimationState;
  14577. /**
  14578. * The active target of the runtime animation
  14579. */
  14580. private _activeTargets;
  14581. private _currentActiveTarget;
  14582. private _directTarget;
  14583. /**
  14584. * The target path of the runtime animation
  14585. */
  14586. private _targetPath;
  14587. /**
  14588. * The weight of the runtime animation
  14589. */
  14590. private _weight;
  14591. /**
  14592. * The ratio offset of the runtime animation
  14593. */
  14594. private _ratioOffset;
  14595. /**
  14596. * The previous delay of the runtime animation
  14597. */
  14598. private _previousDelay;
  14599. /**
  14600. * The previous ratio of the runtime animation
  14601. */
  14602. private _previousRatio;
  14603. private _enableBlending;
  14604. private _keys;
  14605. private _minFrame;
  14606. private _maxFrame;
  14607. private _minValue;
  14608. private _maxValue;
  14609. private _targetIsArray;
  14610. /**
  14611. * Gets the current frame of the runtime animation
  14612. */
  14613. get currentFrame(): number;
  14614. /**
  14615. * Gets the weight of the runtime animation
  14616. */
  14617. get weight(): number;
  14618. /**
  14619. * Gets the current value of the runtime animation
  14620. */
  14621. get currentValue(): any;
  14622. /**
  14623. * Gets the target path of the runtime animation
  14624. */
  14625. get targetPath(): string;
  14626. /**
  14627. * Gets the actual target of the runtime animation
  14628. */
  14629. get target(): any;
  14630. /**
  14631. * Gets the additive state of the runtime animation
  14632. */
  14633. get isAdditive(): boolean;
  14634. /** @hidden */
  14635. _onLoop: () => void;
  14636. /**
  14637. * Create a new RuntimeAnimation object
  14638. * @param target defines the target of the animation
  14639. * @param animation defines the source animation object
  14640. * @param scene defines the hosting scene
  14641. * @param host defines the initiating Animatable
  14642. */
  14643. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14644. private _preparePath;
  14645. /**
  14646. * Gets the animation from the runtime animation
  14647. */
  14648. get animation(): Animation;
  14649. /**
  14650. * Resets the runtime animation to the beginning
  14651. * @param restoreOriginal defines whether to restore the target property to the original value
  14652. */
  14653. reset(restoreOriginal?: boolean): void;
  14654. /**
  14655. * Specifies if the runtime animation is stopped
  14656. * @returns Boolean specifying if the runtime animation is stopped
  14657. */
  14658. isStopped(): boolean;
  14659. /**
  14660. * Disposes of the runtime animation
  14661. */
  14662. dispose(): void;
  14663. /**
  14664. * Apply the interpolated value to the target
  14665. * @param currentValue defines the value computed by the animation
  14666. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14667. */
  14668. setValue(currentValue: any, weight: number): void;
  14669. private _getOriginalValues;
  14670. private _setValue;
  14671. /**
  14672. * Gets the loop pmode of the runtime animation
  14673. * @returns Loop Mode
  14674. */
  14675. private _getCorrectLoopMode;
  14676. /**
  14677. * Move the current animation to a given frame
  14678. * @param frame defines the frame to move to
  14679. */
  14680. goToFrame(frame: number): void;
  14681. /**
  14682. * @hidden Internal use only
  14683. */
  14684. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14685. /**
  14686. * Execute the current animation
  14687. * @param delay defines the delay to add to the current frame
  14688. * @param from defines the lower bound of the animation range
  14689. * @param to defines the upper bound of the animation range
  14690. * @param loop defines if the current animation must loop
  14691. * @param speedRatio defines the current speed ratio
  14692. * @param weight defines the weight of the animation (default is -1 so no weight)
  14693. * @param onLoop optional callback called when animation loops
  14694. * @returns a boolean indicating if the animation is running
  14695. */
  14696. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14697. }
  14698. }
  14699. declare module BABYLON {
  14700. /**
  14701. * Class used to store an actual running animation
  14702. */
  14703. export class Animatable {
  14704. /** defines the target object */
  14705. target: any;
  14706. /** defines the starting frame number (default is 0) */
  14707. fromFrame: number;
  14708. /** defines the ending frame number (default is 100) */
  14709. toFrame: number;
  14710. /** defines if the animation must loop (default is false) */
  14711. loopAnimation: boolean;
  14712. /** defines a callback to call when animation ends if it is not looping */
  14713. onAnimationEnd?: (() => void) | null | undefined;
  14714. /** defines a callback to call when animation loops */
  14715. onAnimationLoop?: (() => void) | null | undefined;
  14716. /** defines whether the animation should be evaluated additively */
  14717. isAdditive: boolean;
  14718. private _localDelayOffset;
  14719. private _pausedDelay;
  14720. private _runtimeAnimations;
  14721. private _paused;
  14722. private _scene;
  14723. private _speedRatio;
  14724. private _weight;
  14725. private _syncRoot;
  14726. /**
  14727. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14728. * This will only apply for non looping animation (default is true)
  14729. */
  14730. disposeOnEnd: boolean;
  14731. /**
  14732. * Gets a boolean indicating if the animation has started
  14733. */
  14734. animationStarted: boolean;
  14735. /**
  14736. * Observer raised when the animation ends
  14737. */
  14738. onAnimationEndObservable: Observable<Animatable>;
  14739. /**
  14740. * Observer raised when the animation loops
  14741. */
  14742. onAnimationLoopObservable: Observable<Animatable>;
  14743. /**
  14744. * Gets the root Animatable used to synchronize and normalize animations
  14745. */
  14746. get syncRoot(): Nullable<Animatable>;
  14747. /**
  14748. * Gets the current frame of the first RuntimeAnimation
  14749. * Used to synchronize Animatables
  14750. */
  14751. get masterFrame(): number;
  14752. /**
  14753. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14754. */
  14755. get weight(): number;
  14756. set weight(value: number);
  14757. /**
  14758. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14759. */
  14760. get speedRatio(): number;
  14761. set speedRatio(value: number);
  14762. /**
  14763. * Creates a new Animatable
  14764. * @param scene defines the hosting scene
  14765. * @param target defines the target object
  14766. * @param fromFrame defines the starting frame number (default is 0)
  14767. * @param toFrame defines the ending frame number (default is 100)
  14768. * @param loopAnimation defines if the animation must loop (default is false)
  14769. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14770. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14771. * @param animations defines a group of animation to add to the new Animatable
  14772. * @param onAnimationLoop defines a callback to call when animation loops
  14773. * @param isAdditive defines whether the animation should be evaluated additively
  14774. */
  14775. constructor(scene: Scene,
  14776. /** defines the target object */
  14777. target: any,
  14778. /** defines the starting frame number (default is 0) */
  14779. fromFrame?: number,
  14780. /** defines the ending frame number (default is 100) */
  14781. toFrame?: number,
  14782. /** defines if the animation must loop (default is false) */
  14783. loopAnimation?: boolean, speedRatio?: number,
  14784. /** defines a callback to call when animation ends if it is not looping */
  14785. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14786. /** defines a callback to call when animation loops */
  14787. onAnimationLoop?: (() => void) | null | undefined,
  14788. /** defines whether the animation should be evaluated additively */
  14789. isAdditive?: boolean);
  14790. /**
  14791. * Synchronize and normalize current Animatable with a source Animatable
  14792. * This is useful when using animation weights and when animations are not of the same length
  14793. * @param root defines the root Animatable to synchronize with
  14794. * @returns the current Animatable
  14795. */
  14796. syncWith(root: Animatable): Animatable;
  14797. /**
  14798. * Gets the list of runtime animations
  14799. * @returns an array of RuntimeAnimation
  14800. */
  14801. getAnimations(): RuntimeAnimation[];
  14802. /**
  14803. * Adds more animations to the current animatable
  14804. * @param target defines the target of the animations
  14805. * @param animations defines the new animations to add
  14806. */
  14807. appendAnimations(target: any, animations: Animation[]): void;
  14808. /**
  14809. * Gets the source animation for a specific property
  14810. * @param property defines the propertyu to look for
  14811. * @returns null or the source animation for the given property
  14812. */
  14813. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14814. /**
  14815. * Gets the runtime animation for a specific property
  14816. * @param property defines the propertyu to look for
  14817. * @returns null or the runtime animation for the given property
  14818. */
  14819. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14820. /**
  14821. * Resets the animatable to its original state
  14822. */
  14823. reset(): void;
  14824. /**
  14825. * Allows the animatable to blend with current running animations
  14826. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14827. * @param blendingSpeed defines the blending speed to use
  14828. */
  14829. enableBlending(blendingSpeed: number): void;
  14830. /**
  14831. * Disable animation blending
  14832. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14833. */
  14834. disableBlending(): void;
  14835. /**
  14836. * Jump directly to a given frame
  14837. * @param frame defines the frame to jump to
  14838. */
  14839. goToFrame(frame: number): void;
  14840. /**
  14841. * Pause the animation
  14842. */
  14843. pause(): void;
  14844. /**
  14845. * Restart the animation
  14846. */
  14847. restart(): void;
  14848. private _raiseOnAnimationEnd;
  14849. /**
  14850. * Stop and delete the current animation
  14851. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14852. * @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)
  14853. */
  14854. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14855. /**
  14856. * Wait asynchronously for the animation to end
  14857. * @returns a promise which will be fullfilled when the animation ends
  14858. */
  14859. waitAsync(): Promise<Animatable>;
  14860. /** @hidden */
  14861. _animate(delay: number): boolean;
  14862. }
  14863. interface Scene {
  14864. /** @hidden */
  14865. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14866. /** @hidden */
  14867. _processLateAnimationBindingsForMatrices(holder: {
  14868. totalWeight: number;
  14869. totalAdditiveWeight: number;
  14870. animations: RuntimeAnimation[];
  14871. additiveAnimations: RuntimeAnimation[];
  14872. originalValue: Matrix;
  14873. }): any;
  14874. /** @hidden */
  14875. _processLateAnimationBindingsForQuaternions(holder: {
  14876. totalWeight: number;
  14877. totalAdditiveWeight: number;
  14878. animations: RuntimeAnimation[];
  14879. additiveAnimations: RuntimeAnimation[];
  14880. originalValue: Quaternion;
  14881. }, refQuaternion: Quaternion): Quaternion;
  14882. /** @hidden */
  14883. _processLateAnimationBindings(): void;
  14884. /**
  14885. * Will start the animation sequence of a given target
  14886. * @param target defines the target
  14887. * @param from defines from which frame should animation start
  14888. * @param to defines until which frame should animation run.
  14889. * @param weight defines the weight to apply to the animation (1.0 by default)
  14890. * @param loop defines if the animation loops
  14891. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14892. * @param onAnimationEnd defines the function to be executed when the animation ends
  14893. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14894. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14895. * @param onAnimationLoop defines the callback to call when an animation loops
  14896. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14897. * @returns the animatable object created for this animation
  14898. */
  14899. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14900. /**
  14901. * Will start the animation sequence of a given target
  14902. * @param target defines the target
  14903. * @param from defines from which frame should animation start
  14904. * @param to defines until which frame should animation run.
  14905. * @param loop defines if the animation loops
  14906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14907. * @param onAnimationEnd defines the function to be executed when the animation ends
  14908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14909. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14910. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14911. * @param onAnimationLoop defines the callback to call when an animation loops
  14912. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14913. * @returns the animatable object created for this animation
  14914. */
  14915. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14916. /**
  14917. * Will start the animation sequence of a given target and its hierarchy
  14918. * @param target defines the target
  14919. * @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.
  14920. * @param from defines from which frame should animation start
  14921. * @param to defines until which frame should animation run.
  14922. * @param loop defines if the animation loops
  14923. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14924. * @param onAnimationEnd defines the function to be executed when the animation ends
  14925. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14926. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14927. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14928. * @param onAnimationLoop defines the callback to call when an animation loops
  14929. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14930. * @returns the list of created animatables
  14931. */
  14932. 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, isAdditive?: boolean): Animatable[];
  14933. /**
  14934. * Begin a new animation on a given node
  14935. * @param target defines the target where the animation will take place
  14936. * @param animations defines the list of animations to start
  14937. * @param from defines the initial value
  14938. * @param to defines the final value
  14939. * @param loop defines if you want animation to loop (off by default)
  14940. * @param speedRatio defines the speed ratio to apply to all animations
  14941. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14942. * @param onAnimationLoop defines the callback to call when an animation loops
  14943. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14944. * @returns the list of created animatables
  14945. */
  14946. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14947. /**
  14948. * Begin a new animation on a given node and its hierarchy
  14949. * @param target defines the root node where the animation will take place
  14950. * @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.
  14951. * @param animations defines the list of animations to start
  14952. * @param from defines the initial value
  14953. * @param to defines the final value
  14954. * @param loop defines if you want animation to loop (off by default)
  14955. * @param speedRatio defines the speed ratio to apply to all animations
  14956. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14957. * @param onAnimationLoop defines the callback to call when an animation loops
  14958. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14959. * @returns the list of animatables created for all nodes
  14960. */
  14961. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14962. /**
  14963. * Gets the animatable associated with a specific target
  14964. * @param target defines the target of the animatable
  14965. * @returns the required animatable if found
  14966. */
  14967. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14968. /**
  14969. * Gets all animatables associated with a given target
  14970. * @param target defines the target to look animatables for
  14971. * @returns an array of Animatables
  14972. */
  14973. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14974. /**
  14975. * Stops and removes all animations that have been applied to the scene
  14976. */
  14977. stopAllAnimations(): void;
  14978. /**
  14979. * Gets the current delta time used by animation engine
  14980. */
  14981. deltaTime: number;
  14982. }
  14983. interface Bone {
  14984. /**
  14985. * Copy an animation range from another bone
  14986. * @param source defines the source bone
  14987. * @param rangeName defines the range name to copy
  14988. * @param frameOffset defines the frame offset
  14989. * @param rescaleAsRequired defines if rescaling must be applied if required
  14990. * @param skelDimensionsRatio defines the scaling ratio
  14991. * @returns true if operation was successful
  14992. */
  14993. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14994. }
  14995. }
  14996. declare module BABYLON {
  14997. /**
  14998. * Class used to handle skinning animations
  14999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15000. */
  15001. export class Skeleton implements IAnimatable {
  15002. /** defines the skeleton name */
  15003. name: string;
  15004. /** defines the skeleton Id */
  15005. id: string;
  15006. /**
  15007. * Defines the list of child bones
  15008. */
  15009. bones: Bone[];
  15010. /**
  15011. * Defines an estimate of the dimension of the skeleton at rest
  15012. */
  15013. dimensionsAtRest: Vector3;
  15014. /**
  15015. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15016. */
  15017. needInitialSkinMatrix: boolean;
  15018. /**
  15019. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15020. */
  15021. overrideMesh: Nullable<AbstractMesh>;
  15022. /**
  15023. * Gets the list of animations attached to this skeleton
  15024. */
  15025. animations: Array<Animation>;
  15026. private _scene;
  15027. private _isDirty;
  15028. private _transformMatrices;
  15029. private _transformMatrixTexture;
  15030. private _meshesWithPoseMatrix;
  15031. private _animatables;
  15032. private _identity;
  15033. private _synchronizedWithMesh;
  15034. private _ranges;
  15035. private _lastAbsoluteTransformsUpdateId;
  15036. private _canUseTextureForBones;
  15037. private _uniqueId;
  15038. /** @hidden */
  15039. _numBonesWithLinkedTransformNode: number;
  15040. /** @hidden */
  15041. _hasWaitingData: Nullable<boolean>;
  15042. /**
  15043. * Specifies if the skeleton should be serialized
  15044. */
  15045. doNotSerialize: boolean;
  15046. private _useTextureToStoreBoneMatrices;
  15047. /**
  15048. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15049. * Please note that this option is not available if the hardware does not support it
  15050. */
  15051. get useTextureToStoreBoneMatrices(): boolean;
  15052. set useTextureToStoreBoneMatrices(value: boolean);
  15053. private _animationPropertiesOverride;
  15054. /**
  15055. * Gets or sets the animation properties override
  15056. */
  15057. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15058. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15059. /**
  15060. * List of inspectable custom properties (used by the Inspector)
  15061. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15062. */
  15063. inspectableCustomProperties: IInspectable[];
  15064. /**
  15065. * An observable triggered before computing the skeleton's matrices
  15066. */
  15067. onBeforeComputeObservable: Observable<Skeleton>;
  15068. /**
  15069. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15070. */
  15071. get isUsingTextureForMatrices(): boolean;
  15072. /**
  15073. * Gets the unique ID of this skeleton
  15074. */
  15075. get uniqueId(): number;
  15076. /**
  15077. * Creates a new skeleton
  15078. * @param name defines the skeleton name
  15079. * @param id defines the skeleton Id
  15080. * @param scene defines the hosting scene
  15081. */
  15082. constructor(
  15083. /** defines the skeleton name */
  15084. name: string,
  15085. /** defines the skeleton Id */
  15086. id: string, scene: Scene);
  15087. /**
  15088. * Gets the current object class name.
  15089. * @return the class name
  15090. */
  15091. getClassName(): string;
  15092. /**
  15093. * Returns an array containing the root bones
  15094. * @returns an array containing the root bones
  15095. */
  15096. getChildren(): Array<Bone>;
  15097. /**
  15098. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15099. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15100. * @returns a Float32Array containing matrices data
  15101. */
  15102. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15103. /**
  15104. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15105. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15106. * @returns a raw texture containing the data
  15107. */
  15108. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15109. /**
  15110. * Gets the current hosting scene
  15111. * @returns a scene object
  15112. */
  15113. getScene(): Scene;
  15114. /**
  15115. * Gets a string representing the current skeleton data
  15116. * @param fullDetails defines a boolean indicating if we want a verbose version
  15117. * @returns a string representing the current skeleton data
  15118. */
  15119. toString(fullDetails?: boolean): string;
  15120. /**
  15121. * Get bone's index searching by name
  15122. * @param name defines bone's name to search for
  15123. * @return the indice of the bone. Returns -1 if not found
  15124. */
  15125. getBoneIndexByName(name: string): number;
  15126. /**
  15127. * Creater a new animation range
  15128. * @param name defines the name of the range
  15129. * @param from defines the start key
  15130. * @param to defines the end key
  15131. */
  15132. createAnimationRange(name: string, from: number, to: number): void;
  15133. /**
  15134. * Delete a specific animation range
  15135. * @param name defines the name of the range
  15136. * @param deleteFrames defines if frames must be removed as well
  15137. */
  15138. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15139. /**
  15140. * Gets a specific animation range
  15141. * @param name defines the name of the range to look for
  15142. * @returns the requested animation range or null if not found
  15143. */
  15144. getAnimationRange(name: string): Nullable<AnimationRange>;
  15145. /**
  15146. * Gets the list of all animation ranges defined on this skeleton
  15147. * @returns an array
  15148. */
  15149. getAnimationRanges(): Nullable<AnimationRange>[];
  15150. /**
  15151. * Copy animation range from a source skeleton.
  15152. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15153. * @param source defines the source skeleton
  15154. * @param name defines the name of the range to copy
  15155. * @param rescaleAsRequired defines if rescaling must be applied if required
  15156. * @returns true if operation was successful
  15157. */
  15158. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15159. /**
  15160. * Forces the skeleton to go to rest pose
  15161. */
  15162. returnToRest(): void;
  15163. private _getHighestAnimationFrame;
  15164. /**
  15165. * Begin a specific animation range
  15166. * @param name defines the name of the range to start
  15167. * @param loop defines if looping must be turned on (false by default)
  15168. * @param speedRatio defines the speed ratio to apply (1 by default)
  15169. * @param onAnimationEnd defines a callback which will be called when animation will end
  15170. * @returns a new animatable
  15171. */
  15172. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15173. /**
  15174. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15175. * @param skeleton defines the Skeleton containing the animation range to convert
  15176. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15177. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15178. * @returns the original skeleton
  15179. */
  15180. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15181. /** @hidden */
  15182. _markAsDirty(): void;
  15183. /** @hidden */
  15184. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15185. /** @hidden */
  15186. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15187. private _computeTransformMatrices;
  15188. /**
  15189. * Build all resources required to render a skeleton
  15190. */
  15191. prepare(): void;
  15192. /**
  15193. * Gets the list of animatables currently running for this skeleton
  15194. * @returns an array of animatables
  15195. */
  15196. getAnimatables(): IAnimatable[];
  15197. /**
  15198. * Clone the current skeleton
  15199. * @param name defines the name of the new skeleton
  15200. * @param id defines the id of the new skeleton
  15201. * @returns the new skeleton
  15202. */
  15203. clone(name: string, id?: string): Skeleton;
  15204. /**
  15205. * Enable animation blending for this skeleton
  15206. * @param blendingSpeed defines the blending speed to apply
  15207. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15208. */
  15209. enableBlending(blendingSpeed?: number): void;
  15210. /**
  15211. * Releases all resources associated with the current skeleton
  15212. */
  15213. dispose(): void;
  15214. /**
  15215. * Serialize the skeleton in a JSON object
  15216. * @returns a JSON object
  15217. */
  15218. serialize(): any;
  15219. /**
  15220. * Creates a new skeleton from serialized data
  15221. * @param parsedSkeleton defines the serialized data
  15222. * @param scene defines the hosting scene
  15223. * @returns a new skeleton
  15224. */
  15225. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15226. /**
  15227. * Compute all node absolute transforms
  15228. * @param forceUpdate defines if computation must be done even if cache is up to date
  15229. */
  15230. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15231. /**
  15232. * Gets the root pose matrix
  15233. * @returns a matrix
  15234. */
  15235. getPoseMatrix(): Nullable<Matrix>;
  15236. /**
  15237. * Sorts bones per internal index
  15238. */
  15239. sortBones(): void;
  15240. private _sortBones;
  15241. }
  15242. }
  15243. declare module BABYLON {
  15244. /**
  15245. * Creates an instance based on a source mesh.
  15246. */
  15247. export class InstancedMesh extends AbstractMesh {
  15248. private _sourceMesh;
  15249. private _currentLOD;
  15250. /** @hidden */
  15251. _indexInSourceMeshInstanceArray: number;
  15252. constructor(name: string, source: Mesh);
  15253. /**
  15254. * Returns the string "InstancedMesh".
  15255. */
  15256. getClassName(): string;
  15257. /** Gets the list of lights affecting that mesh */
  15258. get lightSources(): Light[];
  15259. _resyncLightSources(): void;
  15260. _resyncLightSource(light: Light): void;
  15261. _removeLightSource(light: Light, dispose: boolean): void;
  15262. /**
  15263. * If the source mesh receives shadows
  15264. */
  15265. get receiveShadows(): boolean;
  15266. /**
  15267. * The material of the source mesh
  15268. */
  15269. get material(): Nullable<Material>;
  15270. /**
  15271. * Visibility of the source mesh
  15272. */
  15273. get visibility(): number;
  15274. /**
  15275. * Skeleton of the source mesh
  15276. */
  15277. get skeleton(): Nullable<Skeleton>;
  15278. /**
  15279. * Rendering ground id of the source mesh
  15280. */
  15281. get renderingGroupId(): number;
  15282. set renderingGroupId(value: number);
  15283. /**
  15284. * Returns the total number of vertices (integer).
  15285. */
  15286. getTotalVertices(): number;
  15287. /**
  15288. * Returns a positive integer : the total number of indices in this mesh geometry.
  15289. * @returns the numner of indices or zero if the mesh has no geometry.
  15290. */
  15291. getTotalIndices(): number;
  15292. /**
  15293. * The source mesh of the instance
  15294. */
  15295. get sourceMesh(): Mesh;
  15296. /**
  15297. * Is this node ready to be used/rendered
  15298. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15299. * @return {boolean} is it ready
  15300. */
  15301. isReady(completeCheck?: boolean): boolean;
  15302. /**
  15303. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15304. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15305. * @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.
  15306. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15307. */
  15308. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15309. /**
  15310. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15311. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15312. * The `data` are either a numeric array either a Float32Array.
  15313. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15314. * 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).
  15315. * Note that a new underlying VertexBuffer object is created each call.
  15316. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15317. *
  15318. * Possible `kind` values :
  15319. * - VertexBuffer.PositionKind
  15320. * - VertexBuffer.UVKind
  15321. * - VertexBuffer.UV2Kind
  15322. * - VertexBuffer.UV3Kind
  15323. * - VertexBuffer.UV4Kind
  15324. * - VertexBuffer.UV5Kind
  15325. * - VertexBuffer.UV6Kind
  15326. * - VertexBuffer.ColorKind
  15327. * - VertexBuffer.MatricesIndicesKind
  15328. * - VertexBuffer.MatricesIndicesExtraKind
  15329. * - VertexBuffer.MatricesWeightsKind
  15330. * - VertexBuffer.MatricesWeightsExtraKind
  15331. *
  15332. * Returns the Mesh.
  15333. */
  15334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15335. /**
  15336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15337. * If the mesh has no geometry, it is simply returned as it is.
  15338. * The `data` are either a numeric array either a Float32Array.
  15339. * No new underlying VertexBuffer object is created.
  15340. * 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.
  15341. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15342. *
  15343. * Possible `kind` values :
  15344. * - VertexBuffer.PositionKind
  15345. * - VertexBuffer.UVKind
  15346. * - VertexBuffer.UV2Kind
  15347. * - VertexBuffer.UV3Kind
  15348. * - VertexBuffer.UV4Kind
  15349. * - VertexBuffer.UV5Kind
  15350. * - VertexBuffer.UV6Kind
  15351. * - VertexBuffer.ColorKind
  15352. * - VertexBuffer.MatricesIndicesKind
  15353. * - VertexBuffer.MatricesIndicesExtraKind
  15354. * - VertexBuffer.MatricesWeightsKind
  15355. * - VertexBuffer.MatricesWeightsExtraKind
  15356. *
  15357. * Returns the Mesh.
  15358. */
  15359. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15360. /**
  15361. * Sets the mesh indices.
  15362. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15363. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15364. * This method creates a new index buffer each call.
  15365. * Returns the Mesh.
  15366. */
  15367. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15368. /**
  15369. * Boolean : True if the mesh owns the requested kind of data.
  15370. */
  15371. isVerticesDataPresent(kind: string): boolean;
  15372. /**
  15373. * Returns an array of indices (IndicesArray).
  15374. */
  15375. getIndices(): Nullable<IndicesArray>;
  15376. get _positions(): Nullable<Vector3[]>;
  15377. /**
  15378. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15379. * This means the mesh underlying bounding box and sphere are recomputed.
  15380. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15381. * @returns the current mesh
  15382. */
  15383. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15384. /** @hidden */
  15385. _preActivate(): InstancedMesh;
  15386. /** @hidden */
  15387. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15388. /** @hidden */
  15389. _postActivate(): void;
  15390. getWorldMatrix(): Matrix;
  15391. get isAnInstance(): boolean;
  15392. /**
  15393. * Returns the current associated LOD AbstractMesh.
  15394. */
  15395. getLOD(camera: Camera): AbstractMesh;
  15396. /** @hidden */
  15397. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15398. /** @hidden */
  15399. _syncSubMeshes(): InstancedMesh;
  15400. /** @hidden */
  15401. _generatePointsArray(): boolean;
  15402. /**
  15403. * Creates a new InstancedMesh from the current mesh.
  15404. * - name (string) : the cloned mesh name
  15405. * - newParent (optional Node) : the optional Node to parent the clone to.
  15406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15407. *
  15408. * Returns the clone.
  15409. */
  15410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15411. /**
  15412. * Disposes the InstancedMesh.
  15413. * Returns nothing.
  15414. */
  15415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15416. }
  15417. interface Mesh {
  15418. /**
  15419. * Register a custom buffer that will be instanced
  15420. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15421. * @param kind defines the buffer kind
  15422. * @param stride defines the stride in floats
  15423. */
  15424. registerInstancedBuffer(kind: string, stride: number): void;
  15425. /** @hidden */
  15426. _userInstancedBuffersStorage: {
  15427. data: {
  15428. [key: string]: Float32Array;
  15429. };
  15430. sizes: {
  15431. [key: string]: number;
  15432. };
  15433. vertexBuffers: {
  15434. [key: string]: Nullable<VertexBuffer>;
  15435. };
  15436. strides: {
  15437. [key: string]: number;
  15438. };
  15439. };
  15440. }
  15441. interface AbstractMesh {
  15442. /**
  15443. * Object used to store instanced buffers defined by user
  15444. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15445. */
  15446. instancedBuffers: {
  15447. [key: string]: any;
  15448. };
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * Defines the options associated with the creation of a shader material.
  15454. */
  15455. export interface IShaderMaterialOptions {
  15456. /**
  15457. * Does the material work in alpha blend mode
  15458. */
  15459. needAlphaBlending: boolean;
  15460. /**
  15461. * Does the material work in alpha test mode
  15462. */
  15463. needAlphaTesting: boolean;
  15464. /**
  15465. * The list of attribute names used in the shader
  15466. */
  15467. attributes: string[];
  15468. /**
  15469. * The list of unifrom names used in the shader
  15470. */
  15471. uniforms: string[];
  15472. /**
  15473. * The list of UBO names used in the shader
  15474. */
  15475. uniformBuffers: string[];
  15476. /**
  15477. * The list of sampler names used in the shader
  15478. */
  15479. samplers: string[];
  15480. /**
  15481. * The list of defines used in the shader
  15482. */
  15483. defines: string[];
  15484. }
  15485. /**
  15486. * 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.
  15487. *
  15488. * This returned material effects how the mesh will look based on the code in the shaders.
  15489. *
  15490. * @see http://doc.babylonjs.com/how_to/shader_material
  15491. */
  15492. export class ShaderMaterial extends Material {
  15493. private _shaderPath;
  15494. private _options;
  15495. private _textures;
  15496. private _textureArrays;
  15497. private _floats;
  15498. private _ints;
  15499. private _floatsArrays;
  15500. private _colors3;
  15501. private _colors3Arrays;
  15502. private _colors4;
  15503. private _colors4Arrays;
  15504. private _vectors2;
  15505. private _vectors3;
  15506. private _vectors4;
  15507. private _matrices;
  15508. private _matrixArrays;
  15509. private _matrices3x3;
  15510. private _matrices2x2;
  15511. private _vectors2Arrays;
  15512. private _vectors3Arrays;
  15513. private _vectors4Arrays;
  15514. private _cachedWorldViewMatrix;
  15515. private _cachedWorldViewProjectionMatrix;
  15516. private _renderId;
  15517. private _multiview;
  15518. private _cachedDefines;
  15519. /**
  15520. * Instantiate a new shader material.
  15521. * 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.
  15522. * This returned material effects how the mesh will look based on the code in the shaders.
  15523. * @see http://doc.babylonjs.com/how_to/shader_material
  15524. * @param name Define the name of the material in the scene
  15525. * @param scene Define the scene the material belongs to
  15526. * @param shaderPath Defines the route to the shader code in one of three ways:
  15527. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15528. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15529. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15530. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15531. * @param options Define the options used to create the shader
  15532. */
  15533. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15534. /**
  15535. * Gets the shader path used to define the shader code
  15536. * It can be modified to trigger a new compilation
  15537. */
  15538. get shaderPath(): any;
  15539. /**
  15540. * Sets the shader path used to define the shader code
  15541. * It can be modified to trigger a new compilation
  15542. */
  15543. set shaderPath(shaderPath: any);
  15544. /**
  15545. * Gets the options used to compile the shader.
  15546. * They can be modified to trigger a new compilation
  15547. */
  15548. get options(): IShaderMaterialOptions;
  15549. /**
  15550. * Gets the current class name of the material e.g. "ShaderMaterial"
  15551. * Mainly use in serialization.
  15552. * @returns the class name
  15553. */
  15554. getClassName(): string;
  15555. /**
  15556. * Specifies if the material will require alpha blending
  15557. * @returns a boolean specifying if alpha blending is needed
  15558. */
  15559. needAlphaBlending(): boolean;
  15560. /**
  15561. * Specifies if this material should be rendered in alpha test mode
  15562. * @returns a boolean specifying if an alpha test is needed.
  15563. */
  15564. needAlphaTesting(): boolean;
  15565. private _checkUniform;
  15566. /**
  15567. * Set a texture in the shader.
  15568. * @param name Define the name of the uniform samplers as defined in the shader
  15569. * @param texture Define the texture to bind to this sampler
  15570. * @return the material itself allowing "fluent" like uniform updates
  15571. */
  15572. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15573. /**
  15574. * Set a texture array in the shader.
  15575. * @param name Define the name of the uniform sampler array as defined in the shader
  15576. * @param textures Define the list of textures to bind to this sampler
  15577. * @return the material itself allowing "fluent" like uniform updates
  15578. */
  15579. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15580. /**
  15581. * Set a float in the shader.
  15582. * @param name Define the name of the uniform as defined in the shader
  15583. * @param value Define the value to give to the uniform
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setFloat(name: string, value: number): ShaderMaterial;
  15587. /**
  15588. * Set a int in the shader.
  15589. * @param name Define the name of the uniform as defined in the shader
  15590. * @param value Define the value to give to the uniform
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setInt(name: string, value: number): ShaderMaterial;
  15594. /**
  15595. * Set an array of floats in the shader.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setFloats(name: string, value: number[]): ShaderMaterial;
  15601. /**
  15602. * Set a vec3 in the shader from a Color3.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setColor3(name: string, value: Color3): ShaderMaterial;
  15608. /**
  15609. * Set a vec3 array in the shader from a Color3 array.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15615. /**
  15616. * Set a vec4 in the shader from a Color4.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setColor4(name: string, value: Color4): ShaderMaterial;
  15622. /**
  15623. * Set a vec4 array in the shader from a Color4 array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15629. /**
  15630. * Set a vec2 in the shader from a Vector2.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setVector2(name: string, value: Vector2): ShaderMaterial;
  15636. /**
  15637. * Set a vec3 in the shader from a Vector3.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setVector3(name: string, value: Vector3): ShaderMaterial;
  15643. /**
  15644. * Set a vec4 in the shader from a Vector4.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setVector4(name: string, value: Vector4): ShaderMaterial;
  15650. /**
  15651. * Set a mat4 in the shader from a Matrix.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15657. /**
  15658. * Set a float32Array in the shader from a matrix array.
  15659. * @param name Define the name of the uniform as defined in the shader
  15660. * @param value Define the value to give to the uniform
  15661. * @return the material itself allowing "fluent" like uniform updates
  15662. */
  15663. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15664. /**
  15665. * Set a mat3 in the shader from a Float32Array.
  15666. * @param name Define the name of the uniform as defined in the shader
  15667. * @param value Define the value to give to the uniform
  15668. * @return the material itself allowing "fluent" like uniform updates
  15669. */
  15670. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15671. /**
  15672. * Set a mat2 in the shader from a Float32Array.
  15673. * @param name Define the name of the uniform as defined in the shader
  15674. * @param value Define the value to give to the uniform
  15675. * @return the material itself allowing "fluent" like uniform updates
  15676. */
  15677. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15678. /**
  15679. * Set a vec2 array in the shader from a number array.
  15680. * @param name Define the name of the uniform as defined in the shader
  15681. * @param value Define the value to give to the uniform
  15682. * @return the material itself allowing "fluent" like uniform updates
  15683. */
  15684. setArray2(name: string, value: number[]): ShaderMaterial;
  15685. /**
  15686. * Set a vec3 array in the shader from a number array.
  15687. * @param name Define the name of the uniform as defined in the shader
  15688. * @param value Define the value to give to the uniform
  15689. * @return the material itself allowing "fluent" like uniform updates
  15690. */
  15691. setArray3(name: string, value: number[]): ShaderMaterial;
  15692. /**
  15693. * Set a vec4 array in the shader from a number array.
  15694. * @param name Define the name of the uniform as defined in the shader
  15695. * @param value Define the value to give to the uniform
  15696. * @return the material itself allowing "fluent" like uniform updates
  15697. */
  15698. setArray4(name: string, value: number[]): ShaderMaterial;
  15699. private _checkCache;
  15700. /**
  15701. * Specifies that the submesh is ready to be used
  15702. * @param mesh defines the mesh to check
  15703. * @param subMesh defines which submesh to check
  15704. * @param useInstances specifies that instances should be used
  15705. * @returns a boolean indicating that the submesh is ready or not
  15706. */
  15707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15708. /**
  15709. * Checks if the material is ready to render the requested mesh
  15710. * @param mesh Define the mesh to render
  15711. * @param useInstances Define whether or not the material is used with instances
  15712. * @returns true if ready, otherwise false
  15713. */
  15714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15715. /**
  15716. * Binds the world matrix to the material
  15717. * @param world defines the world transformation matrix
  15718. * @param effectOverride - If provided, use this effect instead of internal effect
  15719. */
  15720. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15721. /**
  15722. * Binds the submesh to this material by preparing the effect and shader to draw
  15723. * @param world defines the world transformation matrix
  15724. * @param mesh defines the mesh containing the submesh
  15725. * @param subMesh defines the submesh to bind the material to
  15726. */
  15727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15728. /**
  15729. * Binds the material to the mesh
  15730. * @param world defines the world transformation matrix
  15731. * @param mesh defines the mesh to bind the material to
  15732. * @param effectOverride - If provided, use this effect instead of internal effect
  15733. */
  15734. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15735. protected _afterBind(mesh?: Mesh): void;
  15736. /**
  15737. * Gets the active textures from the material
  15738. * @returns an array of textures
  15739. */
  15740. getActiveTextures(): BaseTexture[];
  15741. /**
  15742. * Specifies if the material uses a texture
  15743. * @param texture defines the texture to check against the material
  15744. * @returns a boolean specifying if the material uses the texture
  15745. */
  15746. hasTexture(texture: BaseTexture): boolean;
  15747. /**
  15748. * Makes a duplicate of the material, and gives it a new name
  15749. * @param name defines the new name for the duplicated material
  15750. * @returns the cloned material
  15751. */
  15752. clone(name: string): ShaderMaterial;
  15753. /**
  15754. * Disposes the material
  15755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15757. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15758. */
  15759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15760. /**
  15761. * Serializes this material in a JSON representation
  15762. * @returns the serialized material object
  15763. */
  15764. serialize(): any;
  15765. /**
  15766. * Creates a shader material from parsed shader material data
  15767. * @param source defines the JSON represnetation of the material
  15768. * @param scene defines the hosting scene
  15769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15770. * @returns a new material
  15771. */
  15772. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15773. }
  15774. }
  15775. declare module BABYLON {
  15776. /** @hidden */
  15777. export var colorPixelShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module BABYLON {
  15783. /** @hidden */
  15784. export var colorVertexShader: {
  15785. name: string;
  15786. shader: string;
  15787. };
  15788. }
  15789. declare module BABYLON {
  15790. /**
  15791. * Line mesh
  15792. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15793. */
  15794. export class LinesMesh extends Mesh {
  15795. /**
  15796. * If vertex color should be applied to the mesh
  15797. */
  15798. readonly useVertexColor?: boolean | undefined;
  15799. /**
  15800. * If vertex alpha should be applied to the mesh
  15801. */
  15802. readonly useVertexAlpha?: boolean | undefined;
  15803. /**
  15804. * Color of the line (Default: White)
  15805. */
  15806. color: Color3;
  15807. /**
  15808. * Alpha of the line (Default: 1)
  15809. */
  15810. alpha: number;
  15811. /**
  15812. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15813. * This margin is expressed in world space coordinates, so its value may vary.
  15814. * Default value is 0.1
  15815. */
  15816. intersectionThreshold: number;
  15817. private _colorShader;
  15818. private color4;
  15819. /**
  15820. * Creates a new LinesMesh
  15821. * @param name defines the name
  15822. * @param scene defines the hosting scene
  15823. * @param parent defines the parent mesh if any
  15824. * @param source defines the optional source LinesMesh used to clone data from
  15825. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15826. * When false, achieved by calling a clone(), also passing False.
  15827. * This will make creation of children, recursive.
  15828. * @param useVertexColor defines if this LinesMesh supports vertex color
  15829. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15830. */
  15831. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15832. /**
  15833. * If vertex color should be applied to the mesh
  15834. */
  15835. useVertexColor?: boolean | undefined,
  15836. /**
  15837. * If vertex alpha should be applied to the mesh
  15838. */
  15839. useVertexAlpha?: boolean | undefined);
  15840. private _addClipPlaneDefine;
  15841. private _removeClipPlaneDefine;
  15842. isReady(): boolean;
  15843. /**
  15844. * Returns the string "LineMesh"
  15845. */
  15846. getClassName(): string;
  15847. /**
  15848. * @hidden
  15849. */
  15850. get material(): Material;
  15851. /**
  15852. * @hidden
  15853. */
  15854. set material(value: Material);
  15855. /**
  15856. * @hidden
  15857. */
  15858. get checkCollisions(): boolean;
  15859. /** @hidden */
  15860. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15861. /** @hidden */
  15862. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15863. /**
  15864. * Disposes of the line mesh
  15865. * @param doNotRecurse If children should be disposed
  15866. */
  15867. dispose(doNotRecurse?: boolean): void;
  15868. /**
  15869. * Returns a new LineMesh object cloned from the current one.
  15870. */
  15871. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15872. /**
  15873. * Creates a new InstancedLinesMesh object from the mesh model.
  15874. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15875. * @param name defines the name of the new instance
  15876. * @returns a new InstancedLinesMesh
  15877. */
  15878. createInstance(name: string): InstancedLinesMesh;
  15879. }
  15880. /**
  15881. * Creates an instance based on a source LinesMesh
  15882. */
  15883. export class InstancedLinesMesh extends InstancedMesh {
  15884. /**
  15885. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15886. * This margin is expressed in world space coordinates, so its value may vary.
  15887. * Initilized with the intersectionThreshold value of the source LinesMesh
  15888. */
  15889. intersectionThreshold: number;
  15890. constructor(name: string, source: LinesMesh);
  15891. /**
  15892. * Returns the string "InstancedLinesMesh".
  15893. */
  15894. getClassName(): string;
  15895. }
  15896. }
  15897. declare module BABYLON {
  15898. /** @hidden */
  15899. export var linePixelShader: {
  15900. name: string;
  15901. shader: string;
  15902. };
  15903. }
  15904. declare module BABYLON {
  15905. /** @hidden */
  15906. export var lineVertexShader: {
  15907. name: string;
  15908. shader: string;
  15909. };
  15910. }
  15911. declare module BABYLON {
  15912. interface AbstractMesh {
  15913. /**
  15914. * Gets the edgesRenderer associated with the mesh
  15915. */
  15916. edgesRenderer: Nullable<EdgesRenderer>;
  15917. }
  15918. interface LinesMesh {
  15919. /**
  15920. * Enables the edge rendering mode on the mesh.
  15921. * This mode makes the mesh edges visible
  15922. * @param epsilon defines the maximal distance between two angles to detect a face
  15923. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15924. * @returns the currentAbstractMesh
  15925. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15926. */
  15927. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15928. }
  15929. interface InstancedLinesMesh {
  15930. /**
  15931. * Enables the edge rendering mode on the mesh.
  15932. * This mode makes the mesh edges visible
  15933. * @param epsilon defines the maximal distance between two angles to detect a face
  15934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15935. * @returns the current InstancedLinesMesh
  15936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15937. */
  15938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15939. }
  15940. /**
  15941. * Defines the minimum contract an Edges renderer should follow.
  15942. */
  15943. export interface IEdgesRenderer extends IDisposable {
  15944. /**
  15945. * Gets or sets a boolean indicating if the edgesRenderer is active
  15946. */
  15947. isEnabled: boolean;
  15948. /**
  15949. * Renders the edges of the attached mesh,
  15950. */
  15951. render(): void;
  15952. /**
  15953. * Checks wether or not the edges renderer is ready to render.
  15954. * @return true if ready, otherwise false.
  15955. */
  15956. isReady(): boolean;
  15957. }
  15958. /**
  15959. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15960. */
  15961. export class EdgesRenderer implements IEdgesRenderer {
  15962. /**
  15963. * Define the size of the edges with an orthographic camera
  15964. */
  15965. edgesWidthScalerForOrthographic: number;
  15966. /**
  15967. * Define the size of the edges with a perspective camera
  15968. */
  15969. edgesWidthScalerForPerspective: number;
  15970. protected _source: AbstractMesh;
  15971. protected _linesPositions: number[];
  15972. protected _linesNormals: number[];
  15973. protected _linesIndices: number[];
  15974. protected _epsilon: number;
  15975. protected _indicesCount: number;
  15976. protected _lineShader: ShaderMaterial;
  15977. protected _ib: DataBuffer;
  15978. protected _buffers: {
  15979. [key: string]: Nullable<VertexBuffer>;
  15980. };
  15981. protected _checkVerticesInsteadOfIndices: boolean;
  15982. private _meshRebuildObserver;
  15983. private _meshDisposeObserver;
  15984. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15985. isEnabled: boolean;
  15986. /**
  15987. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15988. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15989. * @param source Mesh used to create edges
  15990. * @param epsilon sum of angles in adjacency to check for edge
  15991. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15992. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15993. */
  15994. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15995. protected _prepareRessources(): void;
  15996. /** @hidden */
  15997. _rebuild(): void;
  15998. /**
  15999. * Releases the required resources for the edges renderer
  16000. */
  16001. dispose(): void;
  16002. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16003. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16004. /**
  16005. * Checks if the pair of p0 and p1 is en edge
  16006. * @param faceIndex
  16007. * @param edge
  16008. * @param faceNormals
  16009. * @param p0
  16010. * @param p1
  16011. * @private
  16012. */
  16013. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16014. /**
  16015. * push line into the position, normal and index buffer
  16016. * @protected
  16017. */
  16018. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16019. /**
  16020. * Generates lines edges from adjacencjes
  16021. * @private
  16022. */
  16023. _generateEdgesLines(): void;
  16024. /**
  16025. * Checks wether or not the edges renderer is ready to render.
  16026. * @return true if ready, otherwise false.
  16027. */
  16028. isReady(): boolean;
  16029. /**
  16030. * Renders the edges of the attached mesh,
  16031. */
  16032. render(): void;
  16033. }
  16034. /**
  16035. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16036. */
  16037. export class LineEdgesRenderer extends EdgesRenderer {
  16038. /**
  16039. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16040. * @param source LineMesh used to generate edges
  16041. * @param epsilon not important (specified angle for edge detection)
  16042. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16043. */
  16044. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16045. /**
  16046. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16047. */
  16048. _generateEdgesLines(): void;
  16049. }
  16050. }
  16051. declare module BABYLON {
  16052. /**
  16053. * This represents the object necessary to create a rendering group.
  16054. * This is exclusively used and created by the rendering manager.
  16055. * To modify the behavior, you use the available helpers in your scene or meshes.
  16056. * @hidden
  16057. */
  16058. export class RenderingGroup {
  16059. index: number;
  16060. private static _zeroVector;
  16061. private _scene;
  16062. private _opaqueSubMeshes;
  16063. private _transparentSubMeshes;
  16064. private _alphaTestSubMeshes;
  16065. private _depthOnlySubMeshes;
  16066. private _particleSystems;
  16067. private _spriteManagers;
  16068. private _opaqueSortCompareFn;
  16069. private _alphaTestSortCompareFn;
  16070. private _transparentSortCompareFn;
  16071. private _renderOpaque;
  16072. private _renderAlphaTest;
  16073. private _renderTransparent;
  16074. /** @hidden */
  16075. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16076. onBeforeTransparentRendering: () => void;
  16077. /**
  16078. * Set the opaque sort comparison function.
  16079. * If null the sub meshes will be render in the order they were created
  16080. */
  16081. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16082. /**
  16083. * Set the alpha test sort comparison function.
  16084. * If null the sub meshes will be render in the order they were created
  16085. */
  16086. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16087. /**
  16088. * Set the transparent sort comparison function.
  16089. * If null the sub meshes will be render in the order they were created
  16090. */
  16091. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16092. /**
  16093. * Creates a new rendering group.
  16094. * @param index The rendering group index
  16095. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16096. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16097. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16098. */
  16099. 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>);
  16100. /**
  16101. * Render all the sub meshes contained in the group.
  16102. * @param customRenderFunction Used to override the default render behaviour of the group.
  16103. * @returns true if rendered some submeshes.
  16104. */
  16105. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16106. /**
  16107. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16108. * @param subMeshes The submeshes to render
  16109. */
  16110. private renderOpaqueSorted;
  16111. /**
  16112. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16113. * @param subMeshes The submeshes to render
  16114. */
  16115. private renderAlphaTestSorted;
  16116. /**
  16117. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16118. * @param subMeshes The submeshes to render
  16119. */
  16120. private renderTransparentSorted;
  16121. /**
  16122. * Renders the submeshes in a specified order.
  16123. * @param subMeshes The submeshes to sort before render
  16124. * @param sortCompareFn The comparison function use to sort
  16125. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16126. * @param transparent Specifies to activate blending if true
  16127. */
  16128. private static renderSorted;
  16129. /**
  16130. * Renders the submeshes in the order they were dispatched (no sort applied).
  16131. * @param subMeshes The submeshes to render
  16132. */
  16133. private static renderUnsorted;
  16134. /**
  16135. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16136. * are rendered back to front if in the same alpha index.
  16137. *
  16138. * @param a The first submesh
  16139. * @param b The second submesh
  16140. * @returns The result of the comparison
  16141. */
  16142. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16143. /**
  16144. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16145. * are rendered back to front.
  16146. *
  16147. * @param a The first submesh
  16148. * @param b The second submesh
  16149. * @returns The result of the comparison
  16150. */
  16151. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16152. /**
  16153. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16154. * are rendered front to back (prevent overdraw).
  16155. *
  16156. * @param a The first submesh
  16157. * @param b The second submesh
  16158. * @returns The result of the comparison
  16159. */
  16160. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16161. /**
  16162. * Resets the different lists of submeshes to prepare a new frame.
  16163. */
  16164. prepare(): void;
  16165. dispose(): void;
  16166. /**
  16167. * Inserts the submesh in its correct queue depending on its material.
  16168. * @param subMesh The submesh to dispatch
  16169. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16170. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16171. */
  16172. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16173. dispatchSprites(spriteManager: ISpriteManager): void;
  16174. dispatchParticles(particleSystem: IParticleSystem): void;
  16175. private _renderParticles;
  16176. private _renderSprites;
  16177. }
  16178. }
  16179. declare module BABYLON {
  16180. /**
  16181. * Interface describing the different options available in the rendering manager
  16182. * regarding Auto Clear between groups.
  16183. */
  16184. export interface IRenderingManagerAutoClearSetup {
  16185. /**
  16186. * Defines whether or not autoclear is enable.
  16187. */
  16188. autoClear: boolean;
  16189. /**
  16190. * Defines whether or not to autoclear the depth buffer.
  16191. */
  16192. depth: boolean;
  16193. /**
  16194. * Defines whether or not to autoclear the stencil buffer.
  16195. */
  16196. stencil: boolean;
  16197. }
  16198. /**
  16199. * This class is used by the onRenderingGroupObservable
  16200. */
  16201. export class RenderingGroupInfo {
  16202. /**
  16203. * The Scene that being rendered
  16204. */
  16205. scene: Scene;
  16206. /**
  16207. * The camera currently used for the rendering pass
  16208. */
  16209. camera: Nullable<Camera>;
  16210. /**
  16211. * The ID of the renderingGroup being processed
  16212. */
  16213. renderingGroupId: number;
  16214. }
  16215. /**
  16216. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16217. * It is enable to manage the different groups as well as the different necessary sort functions.
  16218. * This should not be used directly aside of the few static configurations
  16219. */
  16220. export class RenderingManager {
  16221. /**
  16222. * The max id used for rendering groups (not included)
  16223. */
  16224. static MAX_RENDERINGGROUPS: number;
  16225. /**
  16226. * The min id used for rendering groups (included)
  16227. */
  16228. static MIN_RENDERINGGROUPS: number;
  16229. /**
  16230. * Used to globally prevent autoclearing scenes.
  16231. */
  16232. static AUTOCLEAR: boolean;
  16233. /**
  16234. * @hidden
  16235. */
  16236. _useSceneAutoClearSetup: boolean;
  16237. private _scene;
  16238. private _renderingGroups;
  16239. private _depthStencilBufferAlreadyCleaned;
  16240. private _autoClearDepthStencil;
  16241. private _customOpaqueSortCompareFn;
  16242. private _customAlphaTestSortCompareFn;
  16243. private _customTransparentSortCompareFn;
  16244. private _renderingGroupInfo;
  16245. /**
  16246. * Instantiates a new rendering group for a particular scene
  16247. * @param scene Defines the scene the groups belongs to
  16248. */
  16249. constructor(scene: Scene);
  16250. private _clearDepthStencilBuffer;
  16251. /**
  16252. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16253. * @hidden
  16254. */
  16255. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16256. /**
  16257. * Resets the different information of the group to prepare a new frame
  16258. * @hidden
  16259. */
  16260. reset(): void;
  16261. /**
  16262. * Dispose and release the group and its associated resources.
  16263. * @hidden
  16264. */
  16265. dispose(): void;
  16266. /**
  16267. * Clear the info related to rendering groups preventing retention points during dispose.
  16268. */
  16269. freeRenderingGroups(): void;
  16270. private _prepareRenderingGroup;
  16271. /**
  16272. * Add a sprite manager to the rendering manager in order to render it this frame.
  16273. * @param spriteManager Define the sprite manager to render
  16274. */
  16275. dispatchSprites(spriteManager: ISpriteManager): void;
  16276. /**
  16277. * Add a particle system to the rendering manager in order to render it this frame.
  16278. * @param particleSystem Define the particle system to render
  16279. */
  16280. dispatchParticles(particleSystem: IParticleSystem): void;
  16281. /**
  16282. * Add a submesh to the manager in order to render it this frame
  16283. * @param subMesh The submesh to dispatch
  16284. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16285. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16286. */
  16287. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16288. /**
  16289. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16290. * This allowed control for front to back rendering or reversly depending of the special needs.
  16291. *
  16292. * @param renderingGroupId The rendering group id corresponding to its index
  16293. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16294. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16295. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16296. */
  16297. 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;
  16298. /**
  16299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16300. *
  16301. * @param renderingGroupId The rendering group id corresponding to its index
  16302. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16303. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16304. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16305. */
  16306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16307. /**
  16308. * Gets the current auto clear configuration for one rendering group of the rendering
  16309. * manager.
  16310. * @param index the rendering group index to get the information for
  16311. * @returns The auto clear setup for the requested rendering group
  16312. */
  16313. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16314. }
  16315. }
  16316. declare module BABYLON {
  16317. /**
  16318. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16319. */
  16320. export interface ICustomShaderOptions {
  16321. /**
  16322. * Gets or sets the custom shader name to use
  16323. */
  16324. shaderName: string;
  16325. /**
  16326. * The list of attribute names used in the shader
  16327. */
  16328. attributes?: string[];
  16329. /**
  16330. * The list of unifrom names used in the shader
  16331. */
  16332. uniforms?: string[];
  16333. /**
  16334. * The list of sampler names used in the shader
  16335. */
  16336. samplers?: string[];
  16337. /**
  16338. * The list of defines used in the shader
  16339. */
  16340. defines?: string[];
  16341. }
  16342. /**
  16343. * Interface to implement to create a shadow generator compatible with BJS.
  16344. */
  16345. export interface IShadowGenerator {
  16346. /**
  16347. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16348. * @returns The render target texture if present otherwise, null
  16349. */
  16350. getShadowMap(): Nullable<RenderTargetTexture>;
  16351. /**
  16352. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16353. * @param subMesh The submesh we want to render in the shadow map
  16354. * @param useInstances Defines wether will draw in the map using instances
  16355. * @returns true if ready otherwise, false
  16356. */
  16357. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16358. /**
  16359. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16360. * @param defines Defines of the material we want to update
  16361. * @param lightIndex Index of the light in the enabled light list of the material
  16362. */
  16363. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16364. /**
  16365. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16366. * defined in the generator but impacting the effect).
  16367. * It implies the unifroms available on the materials are the standard BJS ones.
  16368. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16369. * @param effect The effect we are binfing the information for
  16370. */
  16371. bindShadowLight(lightIndex: string, effect: Effect): void;
  16372. /**
  16373. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16374. * (eq to shadow prjection matrix * light transform matrix)
  16375. * @returns The transform matrix used to create the shadow map
  16376. */
  16377. getTransformMatrix(): Matrix;
  16378. /**
  16379. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16380. * Cube and 2D textures for instance.
  16381. */
  16382. recreateShadowMap(): void;
  16383. /**
  16384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16385. * @param onCompiled Callback triggered at the and of the effects compilation
  16386. * @param options Sets of optional options forcing the compilation with different modes
  16387. */
  16388. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16389. useInstances: boolean;
  16390. }>): void;
  16391. /**
  16392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16393. * @param options Sets of optional options forcing the compilation with different modes
  16394. * @returns A promise that resolves when the compilation completes
  16395. */
  16396. forceCompilationAsync(options?: Partial<{
  16397. useInstances: boolean;
  16398. }>): Promise<void>;
  16399. /**
  16400. * Serializes the shadow generator setup to a json object.
  16401. * @returns The serialized JSON object
  16402. */
  16403. serialize(): any;
  16404. /**
  16405. * Disposes the Shadow map and related Textures and effects.
  16406. */
  16407. dispose(): void;
  16408. }
  16409. /**
  16410. * Default implementation IShadowGenerator.
  16411. * This is the main object responsible of generating shadows in the framework.
  16412. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16413. */
  16414. export class ShadowGenerator implements IShadowGenerator {
  16415. /**
  16416. * Name of the shadow generator class
  16417. */
  16418. static CLASSNAME: string;
  16419. /**
  16420. * Shadow generator mode None: no filtering applied.
  16421. */
  16422. static readonly FILTER_NONE: number;
  16423. /**
  16424. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16426. */
  16427. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16428. /**
  16429. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16430. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16431. */
  16432. static readonly FILTER_POISSONSAMPLING: number;
  16433. /**
  16434. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16436. */
  16437. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16438. /**
  16439. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16440. * edge artifacts on steep falloff.
  16441. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16442. */
  16443. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16444. /**
  16445. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16446. * edge artifacts on steep falloff.
  16447. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16448. */
  16449. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16450. /**
  16451. * Shadow generator mode PCF: Percentage Closer Filtering
  16452. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16453. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16454. */
  16455. static readonly FILTER_PCF: number;
  16456. /**
  16457. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16458. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16459. * Contact Hardening
  16460. */
  16461. static readonly FILTER_PCSS: number;
  16462. /**
  16463. * Reserved for PCF and PCSS
  16464. * Highest Quality.
  16465. *
  16466. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16467. *
  16468. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16469. */
  16470. static readonly QUALITY_HIGH: number;
  16471. /**
  16472. * Reserved for PCF and PCSS
  16473. * Good tradeoff for quality/perf cross devices
  16474. *
  16475. * Execute PCF on a 3*3 kernel.
  16476. *
  16477. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16478. */
  16479. static readonly QUALITY_MEDIUM: number;
  16480. /**
  16481. * Reserved for PCF and PCSS
  16482. * The lowest quality but the fastest.
  16483. *
  16484. * Execute PCF on a 1*1 kernel.
  16485. *
  16486. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16487. */
  16488. static readonly QUALITY_LOW: number;
  16489. /** Gets or sets the custom shader name to use */
  16490. customShaderOptions: ICustomShaderOptions;
  16491. /**
  16492. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16493. */
  16494. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16495. /**
  16496. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16497. */
  16498. onAfterShadowMapRenderObservable: Observable<Effect>;
  16499. /**
  16500. * Observable triggered before a mesh is rendered in the shadow map.
  16501. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16502. */
  16503. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16504. /**
  16505. * Observable triggered after a mesh is rendered in the shadow map.
  16506. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16507. */
  16508. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16509. protected _bias: number;
  16510. /**
  16511. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16512. */
  16513. get bias(): number;
  16514. /**
  16515. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16516. */
  16517. set bias(bias: number);
  16518. protected _normalBias: number;
  16519. /**
  16520. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16521. */
  16522. get normalBias(): number;
  16523. /**
  16524. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16525. */
  16526. set normalBias(normalBias: number);
  16527. protected _blurBoxOffset: number;
  16528. /**
  16529. * Gets the blur box offset: offset applied during the blur pass.
  16530. * Only useful if useKernelBlur = false
  16531. */
  16532. get blurBoxOffset(): number;
  16533. /**
  16534. * Sets the blur box offset: offset applied during the blur pass.
  16535. * Only useful if useKernelBlur = false
  16536. */
  16537. set blurBoxOffset(value: number);
  16538. protected _blurScale: number;
  16539. /**
  16540. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16541. * 2 means half of the size.
  16542. */
  16543. get blurScale(): number;
  16544. /**
  16545. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16546. * 2 means half of the size.
  16547. */
  16548. set blurScale(value: number);
  16549. protected _blurKernel: number;
  16550. /**
  16551. * Gets the blur kernel: kernel size of the blur pass.
  16552. * Only useful if useKernelBlur = true
  16553. */
  16554. get blurKernel(): number;
  16555. /**
  16556. * Sets the blur kernel: kernel size of the blur pass.
  16557. * Only useful if useKernelBlur = true
  16558. */
  16559. set blurKernel(value: number);
  16560. protected _useKernelBlur: boolean;
  16561. /**
  16562. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16563. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16564. */
  16565. get useKernelBlur(): boolean;
  16566. /**
  16567. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16568. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16569. */
  16570. set useKernelBlur(value: boolean);
  16571. protected _depthScale: number;
  16572. /**
  16573. * Gets the depth scale used in ESM mode.
  16574. */
  16575. get depthScale(): number;
  16576. /**
  16577. * Sets the depth scale used in ESM mode.
  16578. * This can override the scale stored on the light.
  16579. */
  16580. set depthScale(value: number);
  16581. protected _validateFilter(filter: number): number;
  16582. protected _filter: number;
  16583. /**
  16584. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16585. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16586. */
  16587. get filter(): number;
  16588. /**
  16589. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16591. */
  16592. set filter(value: number);
  16593. /**
  16594. * Gets if the current filter is set to Poisson Sampling.
  16595. */
  16596. get usePoissonSampling(): boolean;
  16597. /**
  16598. * Sets the current filter to Poisson Sampling.
  16599. */
  16600. set usePoissonSampling(value: boolean);
  16601. /**
  16602. * Gets if the current filter is set to ESM.
  16603. */
  16604. get useExponentialShadowMap(): boolean;
  16605. /**
  16606. * Sets the current filter is to ESM.
  16607. */
  16608. set useExponentialShadowMap(value: boolean);
  16609. /**
  16610. * Gets if the current filter is set to filtered ESM.
  16611. */
  16612. get useBlurExponentialShadowMap(): boolean;
  16613. /**
  16614. * Gets if the current filter is set to filtered ESM.
  16615. */
  16616. set useBlurExponentialShadowMap(value: boolean);
  16617. /**
  16618. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16619. * exponential to prevent steep falloff artifacts).
  16620. */
  16621. get useCloseExponentialShadowMap(): boolean;
  16622. /**
  16623. * Sets the current filter to "close ESM" (using the inverse of the
  16624. * exponential to prevent steep falloff artifacts).
  16625. */
  16626. set useCloseExponentialShadowMap(value: boolean);
  16627. /**
  16628. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16629. * exponential to prevent steep falloff artifacts).
  16630. */
  16631. get useBlurCloseExponentialShadowMap(): boolean;
  16632. /**
  16633. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16634. * exponential to prevent steep falloff artifacts).
  16635. */
  16636. set useBlurCloseExponentialShadowMap(value: boolean);
  16637. /**
  16638. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16639. */
  16640. get usePercentageCloserFiltering(): boolean;
  16641. /**
  16642. * Sets the current filter to "PCF" (percentage closer filtering).
  16643. */
  16644. set usePercentageCloserFiltering(value: boolean);
  16645. protected _filteringQuality: number;
  16646. /**
  16647. * Gets the PCF or PCSS Quality.
  16648. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16649. */
  16650. get filteringQuality(): number;
  16651. /**
  16652. * Sets the PCF or PCSS Quality.
  16653. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16654. */
  16655. set filteringQuality(filteringQuality: number);
  16656. /**
  16657. * Gets if the current filter is set to "PCSS" (contact hardening).
  16658. */
  16659. get useContactHardeningShadow(): boolean;
  16660. /**
  16661. * Sets the current filter to "PCSS" (contact hardening).
  16662. */
  16663. set useContactHardeningShadow(value: boolean);
  16664. protected _contactHardeningLightSizeUVRatio: number;
  16665. /**
  16666. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16667. * Using a ratio helps keeping shape stability independently of the map size.
  16668. *
  16669. * It does not account for the light projection as it was having too much
  16670. * instability during the light setup or during light position changes.
  16671. *
  16672. * Only valid if useContactHardeningShadow is true.
  16673. */
  16674. get contactHardeningLightSizeUVRatio(): number;
  16675. /**
  16676. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16677. * Using a ratio helps keeping shape stability independently of the map size.
  16678. *
  16679. * It does not account for the light projection as it was having too much
  16680. * instability during the light setup or during light position changes.
  16681. *
  16682. * Only valid if useContactHardeningShadow is true.
  16683. */
  16684. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16685. protected _darkness: number;
  16686. /** Gets or sets the actual darkness of a shadow */
  16687. get darkness(): number;
  16688. set darkness(value: number);
  16689. /**
  16690. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16691. * 0 means strongest and 1 would means no shadow.
  16692. * @returns the darkness.
  16693. */
  16694. getDarkness(): number;
  16695. /**
  16696. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16697. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16698. * @returns the shadow generator allowing fluent coding.
  16699. */
  16700. setDarkness(darkness: number): ShadowGenerator;
  16701. protected _transparencyShadow: boolean;
  16702. /** Gets or sets the ability to have transparent shadow */
  16703. get transparencyShadow(): boolean;
  16704. set transparencyShadow(value: boolean);
  16705. /**
  16706. * Sets the ability to have transparent shadow (boolean).
  16707. * @param transparent True if transparent else False
  16708. * @returns the shadow generator allowing fluent coding
  16709. */
  16710. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16711. protected _shadowMap: Nullable<RenderTargetTexture>;
  16712. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16713. /**
  16714. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16715. * @returns The render target texture if present otherwise, null
  16716. */
  16717. getShadowMap(): Nullable<RenderTargetTexture>;
  16718. /**
  16719. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16720. * @returns The render target texture if the shadow map is present otherwise, null
  16721. */
  16722. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16723. /**
  16724. * Gets the class name of that object
  16725. * @returns "ShadowGenerator"
  16726. */
  16727. getClassName(): string;
  16728. /**
  16729. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16730. * @param mesh Mesh to add
  16731. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16732. * @returns the Shadow Generator itself
  16733. */
  16734. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16735. /**
  16736. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16737. * @param mesh Mesh to remove
  16738. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16739. * @returns the Shadow Generator itself
  16740. */
  16741. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16742. /**
  16743. * Controls the extent to which the shadows fade out at the edge of the frustum
  16744. */
  16745. frustumEdgeFalloff: number;
  16746. protected _light: IShadowLight;
  16747. /**
  16748. * Returns the associated light object.
  16749. * @returns the light generating the shadow
  16750. */
  16751. getLight(): IShadowLight;
  16752. /**
  16753. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16754. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16755. * It might on the other hand introduce peter panning.
  16756. */
  16757. forceBackFacesOnly: boolean;
  16758. protected _scene: Scene;
  16759. protected _lightDirection: Vector3;
  16760. protected _effect: Effect;
  16761. protected _viewMatrix: Matrix;
  16762. protected _projectionMatrix: Matrix;
  16763. protected _transformMatrix: Matrix;
  16764. protected _cachedPosition: Vector3;
  16765. protected _cachedDirection: Vector3;
  16766. protected _cachedDefines: string;
  16767. protected _currentRenderID: number;
  16768. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16769. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16770. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16771. protected _blurPostProcesses: PostProcess[];
  16772. protected _mapSize: number;
  16773. protected _currentFaceIndex: number;
  16774. protected _currentFaceIndexCache: number;
  16775. protected _textureType: number;
  16776. protected _defaultTextureMatrix: Matrix;
  16777. protected _storedUniqueId: Nullable<number>;
  16778. /** @hidden */
  16779. static _SceneComponentInitialization: (scene: Scene) => void;
  16780. /**
  16781. * Creates a ShadowGenerator object.
  16782. * A ShadowGenerator is the required tool to use the shadows.
  16783. * Each light casting shadows needs to use its own ShadowGenerator.
  16784. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16785. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16786. * @param light The light object generating the shadows.
  16787. * @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.
  16788. */
  16789. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16790. protected _initializeGenerator(): void;
  16791. protected _createTargetRenderTexture(): void;
  16792. protected _initializeShadowMap(): void;
  16793. protected _initializeBlurRTTAndPostProcesses(): void;
  16794. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16795. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16796. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16797. protected _applyFilterValues(): void;
  16798. /**
  16799. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16800. * @param onCompiled Callback triggered at the and of the effects compilation
  16801. * @param options Sets of optional options forcing the compilation with different modes
  16802. */
  16803. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16804. useInstances: boolean;
  16805. }>): void;
  16806. /**
  16807. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16808. * @param options Sets of optional options forcing the compilation with different modes
  16809. * @returns A promise that resolves when the compilation completes
  16810. */
  16811. forceCompilationAsync(options?: Partial<{
  16812. useInstances: boolean;
  16813. }>): Promise<void>;
  16814. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16815. private _prepareShadowDefines;
  16816. /**
  16817. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16818. * @param subMesh The submesh we want to render in the shadow map
  16819. * @param useInstances Defines wether will draw in the map using instances
  16820. * @returns true if ready otherwise, false
  16821. */
  16822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16823. /**
  16824. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16825. * @param defines Defines of the material we want to update
  16826. * @param lightIndex Index of the light in the enabled light list of the material
  16827. */
  16828. prepareDefines(defines: any, lightIndex: number): void;
  16829. /**
  16830. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16831. * defined in the generator but impacting the effect).
  16832. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16833. * @param effect The effect we are binfing the information for
  16834. */
  16835. bindShadowLight(lightIndex: string, effect: Effect): void;
  16836. /**
  16837. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16838. * (eq to shadow prjection matrix * light transform matrix)
  16839. * @returns The transform matrix used to create the shadow map
  16840. */
  16841. getTransformMatrix(): Matrix;
  16842. /**
  16843. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16844. * Cube and 2D textures for instance.
  16845. */
  16846. recreateShadowMap(): void;
  16847. protected _disposeBlurPostProcesses(): void;
  16848. protected _disposeRTTandPostProcesses(): void;
  16849. /**
  16850. * Disposes the ShadowGenerator.
  16851. * Returns nothing.
  16852. */
  16853. dispose(): void;
  16854. /**
  16855. * Serializes the shadow generator setup to a json object.
  16856. * @returns The serialized JSON object
  16857. */
  16858. serialize(): any;
  16859. /**
  16860. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16861. * @param parsedShadowGenerator The JSON object to parse
  16862. * @param scene The scene to create the shadow map for
  16863. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16864. * @returns The parsed shadow generator
  16865. */
  16866. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16867. }
  16868. }
  16869. declare module BABYLON {
  16870. /**
  16871. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16872. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16873. * 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.
  16874. */
  16875. export abstract class Light extends Node {
  16876. /**
  16877. * Falloff Default: light is falling off following the material specification:
  16878. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16879. */
  16880. static readonly FALLOFF_DEFAULT: number;
  16881. /**
  16882. * Falloff Physical: light is falling off following the inverse squared distance law.
  16883. */
  16884. static readonly FALLOFF_PHYSICAL: number;
  16885. /**
  16886. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16887. * to enhance interoperability with other engines.
  16888. */
  16889. static readonly FALLOFF_GLTF: number;
  16890. /**
  16891. * Falloff Standard: light is falling off like in the standard material
  16892. * to enhance interoperability with other materials.
  16893. */
  16894. static readonly FALLOFF_STANDARD: number;
  16895. /**
  16896. * If every light affecting the material is in this lightmapMode,
  16897. * material.lightmapTexture adds or multiplies
  16898. * (depends on material.useLightmapAsShadowmap)
  16899. * after every other light calculations.
  16900. */
  16901. static readonly LIGHTMAP_DEFAULT: number;
  16902. /**
  16903. * material.lightmapTexture as only diffuse lighting from this light
  16904. * adds only specular lighting from this light
  16905. * adds dynamic shadows
  16906. */
  16907. static readonly LIGHTMAP_SPECULAR: number;
  16908. /**
  16909. * material.lightmapTexture as only lighting
  16910. * no light calculation from this light
  16911. * only adds dynamic shadows from this light
  16912. */
  16913. static readonly LIGHTMAP_SHADOWSONLY: number;
  16914. /**
  16915. * Each light type uses the default quantity according to its type:
  16916. * point/spot lights use luminous intensity
  16917. * directional lights use illuminance
  16918. */
  16919. static readonly INTENSITYMODE_AUTOMATIC: number;
  16920. /**
  16921. * lumen (lm)
  16922. */
  16923. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16924. /**
  16925. * candela (lm/sr)
  16926. */
  16927. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16928. /**
  16929. * lux (lm/m^2)
  16930. */
  16931. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16932. /**
  16933. * nit (cd/m^2)
  16934. */
  16935. static readonly INTENSITYMODE_LUMINANCE: number;
  16936. /**
  16937. * Light type const id of the point light.
  16938. */
  16939. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16940. /**
  16941. * Light type const id of the directional light.
  16942. */
  16943. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16944. /**
  16945. * Light type const id of the spot light.
  16946. */
  16947. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16948. /**
  16949. * Light type const id of the hemispheric light.
  16950. */
  16951. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16952. /**
  16953. * Diffuse gives the basic color to an object.
  16954. */
  16955. diffuse: Color3;
  16956. /**
  16957. * Specular produces a highlight color on an object.
  16958. * Note: This is note affecting PBR materials.
  16959. */
  16960. specular: Color3;
  16961. /**
  16962. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16963. * falling off base on range or angle.
  16964. * This can be set to any values in Light.FALLOFF_x.
  16965. *
  16966. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16967. * other types of materials.
  16968. */
  16969. falloffType: number;
  16970. /**
  16971. * Strength of the light.
  16972. * Note: By default it is define in the framework own unit.
  16973. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16974. */
  16975. intensity: number;
  16976. private _range;
  16977. protected _inverseSquaredRange: number;
  16978. /**
  16979. * Defines how far from the source the light is impacting in scene units.
  16980. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16981. */
  16982. get range(): number;
  16983. /**
  16984. * Defines how far from the source the light is impacting in scene units.
  16985. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16986. */
  16987. set range(value: number);
  16988. /**
  16989. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16990. * of light.
  16991. */
  16992. private _photometricScale;
  16993. private _intensityMode;
  16994. /**
  16995. * Gets the photometric scale used to interpret the intensity.
  16996. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16997. */
  16998. get intensityMode(): number;
  16999. /**
  17000. * Sets the photometric scale used to interpret the intensity.
  17001. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17002. */
  17003. set intensityMode(value: number);
  17004. private _radius;
  17005. /**
  17006. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17007. */
  17008. get radius(): number;
  17009. /**
  17010. * sets the light radius used by PBR Materials to simulate soft area lights.
  17011. */
  17012. set radius(value: number);
  17013. private _renderPriority;
  17014. /**
  17015. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17016. * exceeding the number allowed of the materials.
  17017. */
  17018. renderPriority: number;
  17019. private _shadowEnabled;
  17020. /**
  17021. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17022. * the current shadow generator.
  17023. */
  17024. get shadowEnabled(): boolean;
  17025. /**
  17026. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17027. * the current shadow generator.
  17028. */
  17029. set shadowEnabled(value: boolean);
  17030. private _includedOnlyMeshes;
  17031. /**
  17032. * Gets the only meshes impacted by this light.
  17033. */
  17034. get includedOnlyMeshes(): AbstractMesh[];
  17035. /**
  17036. * Sets the only meshes impacted by this light.
  17037. */
  17038. set includedOnlyMeshes(value: AbstractMesh[]);
  17039. private _excludedMeshes;
  17040. /**
  17041. * Gets the meshes not impacted by this light.
  17042. */
  17043. get excludedMeshes(): AbstractMesh[];
  17044. /**
  17045. * Sets the meshes not impacted by this light.
  17046. */
  17047. set excludedMeshes(value: AbstractMesh[]);
  17048. private _excludeWithLayerMask;
  17049. /**
  17050. * Gets the layer id use to find what meshes are not impacted by the light.
  17051. * Inactive if 0
  17052. */
  17053. get excludeWithLayerMask(): number;
  17054. /**
  17055. * Sets the layer id use to find what meshes are not impacted by the light.
  17056. * Inactive if 0
  17057. */
  17058. set excludeWithLayerMask(value: number);
  17059. private _includeOnlyWithLayerMask;
  17060. /**
  17061. * Gets the layer id use to find what meshes are impacted by the light.
  17062. * Inactive if 0
  17063. */
  17064. get includeOnlyWithLayerMask(): number;
  17065. /**
  17066. * Sets the layer id use to find what meshes are impacted by the light.
  17067. * Inactive if 0
  17068. */
  17069. set includeOnlyWithLayerMask(value: number);
  17070. private _lightmapMode;
  17071. /**
  17072. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17073. */
  17074. get lightmapMode(): number;
  17075. /**
  17076. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17077. */
  17078. set lightmapMode(value: number);
  17079. /**
  17080. * Shadow generator associted to the light.
  17081. * @hidden Internal use only.
  17082. */
  17083. _shadowGenerator: Nullable<IShadowGenerator>;
  17084. /**
  17085. * @hidden Internal use only.
  17086. */
  17087. _excludedMeshesIds: string[];
  17088. /**
  17089. * @hidden Internal use only.
  17090. */
  17091. _includedOnlyMeshesIds: string[];
  17092. /**
  17093. * The current light unifom buffer.
  17094. * @hidden Internal use only.
  17095. */
  17096. _uniformBuffer: UniformBuffer;
  17097. /** @hidden */
  17098. _renderId: number;
  17099. /**
  17100. * Creates a Light object in the scene.
  17101. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17102. * @param name The firendly name of the light
  17103. * @param scene The scene the light belongs too
  17104. */
  17105. constructor(name: string, scene: Scene);
  17106. protected abstract _buildUniformLayout(): void;
  17107. /**
  17108. * Sets the passed Effect "effect" with the Light information.
  17109. * @param effect The effect to update
  17110. * @param lightIndex The index of the light in the effect to update
  17111. * @returns The light
  17112. */
  17113. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17114. /**
  17115. * Sets the passed Effect "effect" with the Light textures.
  17116. * @param effect The effect to update
  17117. * @param lightIndex The index of the light in the effect to update
  17118. * @returns The light
  17119. */
  17120. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17121. /**
  17122. * Binds the lights information from the scene to the effect for the given mesh.
  17123. * @param lightIndex Light index
  17124. * @param scene The scene where the light belongs to
  17125. * @param effect The effect we are binding the data to
  17126. * @param useSpecular Defines if specular is supported
  17127. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17128. */
  17129. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17130. /**
  17131. * Sets the passed Effect "effect" with the Light information.
  17132. * @param effect The effect to update
  17133. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17134. * @returns The light
  17135. */
  17136. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17137. /**
  17138. * Returns the string "Light".
  17139. * @returns the class name
  17140. */
  17141. getClassName(): string;
  17142. /** @hidden */
  17143. readonly _isLight: boolean;
  17144. /**
  17145. * Converts the light information to a readable string for debug purpose.
  17146. * @param fullDetails Supports for multiple levels of logging within scene loading
  17147. * @returns the human readable light info
  17148. */
  17149. toString(fullDetails?: boolean): string;
  17150. /** @hidden */
  17151. protected _syncParentEnabledState(): void;
  17152. /**
  17153. * Set the enabled state of this node.
  17154. * @param value - the new enabled state
  17155. */
  17156. setEnabled(value: boolean): void;
  17157. /**
  17158. * Returns the Light associated shadow generator if any.
  17159. * @return the associated shadow generator.
  17160. */
  17161. getShadowGenerator(): Nullable<IShadowGenerator>;
  17162. /**
  17163. * Returns a Vector3, the absolute light position in the World.
  17164. * @returns the world space position of the light
  17165. */
  17166. getAbsolutePosition(): Vector3;
  17167. /**
  17168. * Specifies if the light will affect the passed mesh.
  17169. * @param mesh The mesh to test against the light
  17170. * @return true the mesh is affected otherwise, false.
  17171. */
  17172. canAffectMesh(mesh: AbstractMesh): boolean;
  17173. /**
  17174. * Sort function to order lights for rendering.
  17175. * @param a First Light object to compare to second.
  17176. * @param b Second Light object to compare first.
  17177. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17178. */
  17179. static CompareLightsPriority(a: Light, b: Light): number;
  17180. /**
  17181. * Releases resources associated with this node.
  17182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17184. */
  17185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17186. /**
  17187. * Returns the light type ID (integer).
  17188. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17189. */
  17190. getTypeID(): number;
  17191. /**
  17192. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17193. * @returns the scaled intensity in intensity mode unit
  17194. */
  17195. getScaledIntensity(): number;
  17196. /**
  17197. * Returns a new Light object, named "name", from the current one.
  17198. * @param name The name of the cloned light
  17199. * @returns the new created light
  17200. */
  17201. clone(name: string): Nullable<Light>;
  17202. /**
  17203. * Serializes the current light into a Serialization object.
  17204. * @returns the serialized object.
  17205. */
  17206. serialize(): any;
  17207. /**
  17208. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17209. * This new light is named "name" and added to the passed scene.
  17210. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17211. * @param name The friendly name of the light
  17212. * @param scene The scene the new light will belong to
  17213. * @returns the constructor function
  17214. */
  17215. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17216. /**
  17217. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17218. * @param parsedLight The JSON representation of the light
  17219. * @param scene The scene to create the parsed light in
  17220. * @returns the created light after parsing
  17221. */
  17222. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17223. private _hookArrayForExcluded;
  17224. private _hookArrayForIncludedOnly;
  17225. private _resyncMeshes;
  17226. /**
  17227. * Forces the meshes to update their light related information in their rendering used effects
  17228. * @hidden Internal Use Only
  17229. */
  17230. _markMeshesAsLightDirty(): void;
  17231. /**
  17232. * Recomputes the cached photometric scale if needed.
  17233. */
  17234. private _computePhotometricScale;
  17235. /**
  17236. * Returns the Photometric Scale according to the light type and intensity mode.
  17237. */
  17238. private _getPhotometricScale;
  17239. /**
  17240. * Reorder the light in the scene according to their defined priority.
  17241. * @hidden Internal Use Only
  17242. */
  17243. _reorderLightsInScene(): void;
  17244. /**
  17245. * Prepares the list of defines specific to the light type.
  17246. * @param defines the list of defines
  17247. * @param lightIndex defines the index of the light for the effect
  17248. */
  17249. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17250. }
  17251. }
  17252. declare module BABYLON {
  17253. /**
  17254. * Interface used to define Action
  17255. */
  17256. export interface IAction {
  17257. /**
  17258. * Trigger for the action
  17259. */
  17260. trigger: number;
  17261. /** Options of the trigger */
  17262. triggerOptions: any;
  17263. /**
  17264. * Gets the trigger parameters
  17265. * @returns the trigger parameters
  17266. */
  17267. getTriggerParameter(): any;
  17268. /**
  17269. * Internal only - executes current action event
  17270. * @hidden
  17271. */
  17272. _executeCurrent(evt?: ActionEvent): void;
  17273. /**
  17274. * Serialize placeholder for child classes
  17275. * @param parent of child
  17276. * @returns the serialized object
  17277. */
  17278. serialize(parent: any): any;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. _prepare(): void;
  17284. /**
  17285. * Internal only - manager for action
  17286. * @hidden
  17287. */
  17288. _actionManager: AbstractActionManager;
  17289. /**
  17290. * Adds action to chain of actions, may be a DoNothingAction
  17291. * @param action defines the next action to execute
  17292. * @returns The action passed in
  17293. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17294. */
  17295. then(action: IAction): IAction;
  17296. }
  17297. /**
  17298. * The action to be carried out following a trigger
  17299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17300. */
  17301. export class Action implements IAction {
  17302. /** the trigger, with or without parameters, for the action */
  17303. triggerOptions: any;
  17304. /**
  17305. * Trigger for the action
  17306. */
  17307. trigger: number;
  17308. /**
  17309. * Internal only - manager for action
  17310. * @hidden
  17311. */
  17312. _actionManager: ActionManager;
  17313. private _nextActiveAction;
  17314. private _child;
  17315. private _condition?;
  17316. private _triggerParameter;
  17317. /**
  17318. * An event triggered prior to action being executed.
  17319. */
  17320. onBeforeExecuteObservable: Observable<Action>;
  17321. /**
  17322. * Creates a new Action
  17323. * @param triggerOptions the trigger, with or without parameters, for the action
  17324. * @param condition an optional determinant of action
  17325. */
  17326. constructor(
  17327. /** the trigger, with or without parameters, for the action */
  17328. triggerOptions: any, condition?: Condition);
  17329. /**
  17330. * Internal only
  17331. * @hidden
  17332. */
  17333. _prepare(): void;
  17334. /**
  17335. * Gets the trigger parameters
  17336. * @returns the trigger parameters
  17337. */
  17338. getTriggerParameter(): any;
  17339. /**
  17340. * Internal only - executes current action event
  17341. * @hidden
  17342. */
  17343. _executeCurrent(evt?: ActionEvent): void;
  17344. /**
  17345. * Execute placeholder for child classes
  17346. * @param evt optional action event
  17347. */
  17348. execute(evt?: ActionEvent): void;
  17349. /**
  17350. * Skips to next active action
  17351. */
  17352. skipToNextActiveAction(): void;
  17353. /**
  17354. * Adds action to chain of actions, may be a DoNothingAction
  17355. * @param action defines the next action to execute
  17356. * @returns The action passed in
  17357. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17358. */
  17359. then(action: Action): Action;
  17360. /**
  17361. * Internal only
  17362. * @hidden
  17363. */
  17364. _getProperty(propertyPath: string): string;
  17365. /**
  17366. * Internal only
  17367. * @hidden
  17368. */
  17369. _getEffectiveTarget(target: any, propertyPath: string): any;
  17370. /**
  17371. * Serialize placeholder for child classes
  17372. * @param parent of child
  17373. * @returns the serialized object
  17374. */
  17375. serialize(parent: any): any;
  17376. /**
  17377. * Internal only called by serialize
  17378. * @hidden
  17379. */
  17380. protected _serialize(serializedAction: any, parent?: any): any;
  17381. /**
  17382. * Internal only
  17383. * @hidden
  17384. */
  17385. static _SerializeValueAsString: (value: any) => string;
  17386. /**
  17387. * Internal only
  17388. * @hidden
  17389. */
  17390. static _GetTargetProperty: (target: Node | Scene) => {
  17391. name: string;
  17392. targetType: string;
  17393. value: string;
  17394. };
  17395. }
  17396. }
  17397. declare module BABYLON {
  17398. /**
  17399. * A Condition applied to an Action
  17400. */
  17401. export class Condition {
  17402. /**
  17403. * Internal only - manager for action
  17404. * @hidden
  17405. */
  17406. _actionManager: ActionManager;
  17407. /**
  17408. * Internal only
  17409. * @hidden
  17410. */
  17411. _evaluationId: number;
  17412. /**
  17413. * Internal only
  17414. * @hidden
  17415. */
  17416. _currentResult: boolean;
  17417. /**
  17418. * Creates a new Condition
  17419. * @param actionManager the manager of the action the condition is applied to
  17420. */
  17421. constructor(actionManager: ActionManager);
  17422. /**
  17423. * Check if the current condition is valid
  17424. * @returns a boolean
  17425. */
  17426. isValid(): boolean;
  17427. /**
  17428. * Internal only
  17429. * @hidden
  17430. */
  17431. _getProperty(propertyPath: string): string;
  17432. /**
  17433. * Internal only
  17434. * @hidden
  17435. */
  17436. _getEffectiveTarget(target: any, propertyPath: string): any;
  17437. /**
  17438. * Serialize placeholder for child classes
  17439. * @returns the serialized object
  17440. */
  17441. serialize(): any;
  17442. /**
  17443. * Internal only
  17444. * @hidden
  17445. */
  17446. protected _serialize(serializedCondition: any): any;
  17447. }
  17448. /**
  17449. * Defines specific conditional operators as extensions of Condition
  17450. */
  17451. export class ValueCondition extends Condition {
  17452. /** path to specify the property of the target the conditional operator uses */
  17453. propertyPath: string;
  17454. /** the value compared by the conditional operator against the current value of the property */
  17455. value: any;
  17456. /** the conditional operator, default ValueCondition.IsEqual */
  17457. operator: number;
  17458. /**
  17459. * Internal only
  17460. * @hidden
  17461. */
  17462. private static _IsEqual;
  17463. /**
  17464. * Internal only
  17465. * @hidden
  17466. */
  17467. private static _IsDifferent;
  17468. /**
  17469. * Internal only
  17470. * @hidden
  17471. */
  17472. private static _IsGreater;
  17473. /**
  17474. * Internal only
  17475. * @hidden
  17476. */
  17477. private static _IsLesser;
  17478. /**
  17479. * returns the number for IsEqual
  17480. */
  17481. static get IsEqual(): number;
  17482. /**
  17483. * Returns the number for IsDifferent
  17484. */
  17485. static get IsDifferent(): number;
  17486. /**
  17487. * Returns the number for IsGreater
  17488. */
  17489. static get IsGreater(): number;
  17490. /**
  17491. * Returns the number for IsLesser
  17492. */
  17493. static get IsLesser(): number;
  17494. /**
  17495. * Internal only The action manager for the condition
  17496. * @hidden
  17497. */
  17498. _actionManager: ActionManager;
  17499. /**
  17500. * Internal only
  17501. * @hidden
  17502. */
  17503. private _target;
  17504. /**
  17505. * Internal only
  17506. * @hidden
  17507. */
  17508. private _effectiveTarget;
  17509. /**
  17510. * Internal only
  17511. * @hidden
  17512. */
  17513. private _property;
  17514. /**
  17515. * Creates a new ValueCondition
  17516. * @param actionManager manager for the action the condition applies to
  17517. * @param target for the action
  17518. * @param propertyPath path to specify the property of the target the conditional operator uses
  17519. * @param value the value compared by the conditional operator against the current value of the property
  17520. * @param operator the conditional operator, default ValueCondition.IsEqual
  17521. */
  17522. constructor(actionManager: ActionManager, target: any,
  17523. /** path to specify the property of the target the conditional operator uses */
  17524. propertyPath: string,
  17525. /** the value compared by the conditional operator against the current value of the property */
  17526. value: any,
  17527. /** the conditional operator, default ValueCondition.IsEqual */
  17528. operator?: number);
  17529. /**
  17530. * Compares the given value with the property value for the specified conditional operator
  17531. * @returns the result of the comparison
  17532. */
  17533. isValid(): boolean;
  17534. /**
  17535. * Serialize the ValueCondition into a JSON compatible object
  17536. * @returns serialization object
  17537. */
  17538. serialize(): any;
  17539. /**
  17540. * Gets the name of the conditional operator for the ValueCondition
  17541. * @param operator the conditional operator
  17542. * @returns the name
  17543. */
  17544. static GetOperatorName(operator: number): string;
  17545. }
  17546. /**
  17547. * Defines a predicate condition as an extension of Condition
  17548. */
  17549. export class PredicateCondition extends Condition {
  17550. /** defines the predicate function used to validate the condition */
  17551. predicate: () => boolean;
  17552. /**
  17553. * Internal only - manager for action
  17554. * @hidden
  17555. */
  17556. _actionManager: ActionManager;
  17557. /**
  17558. * Creates a new PredicateCondition
  17559. * @param actionManager manager for the action the condition applies to
  17560. * @param predicate defines the predicate function used to validate the condition
  17561. */
  17562. constructor(actionManager: ActionManager,
  17563. /** defines the predicate function used to validate the condition */
  17564. predicate: () => boolean);
  17565. /**
  17566. * @returns the validity of the predicate condition
  17567. */
  17568. isValid(): boolean;
  17569. }
  17570. /**
  17571. * Defines a state condition as an extension of Condition
  17572. */
  17573. export class StateCondition extends Condition {
  17574. /** Value to compare with target state */
  17575. value: string;
  17576. /**
  17577. * Internal only - manager for action
  17578. * @hidden
  17579. */
  17580. _actionManager: ActionManager;
  17581. /**
  17582. * Internal only
  17583. * @hidden
  17584. */
  17585. private _target;
  17586. /**
  17587. * Creates a new StateCondition
  17588. * @param actionManager manager for the action the condition applies to
  17589. * @param target of the condition
  17590. * @param value to compare with target state
  17591. */
  17592. constructor(actionManager: ActionManager, target: any,
  17593. /** Value to compare with target state */
  17594. value: string);
  17595. /**
  17596. * Gets a boolean indicating if the current condition is met
  17597. * @returns the validity of the state
  17598. */
  17599. isValid(): boolean;
  17600. /**
  17601. * Serialize the StateCondition into a JSON compatible object
  17602. * @returns serialization object
  17603. */
  17604. serialize(): any;
  17605. }
  17606. }
  17607. declare module BABYLON {
  17608. /**
  17609. * This defines an action responsible to toggle a boolean once triggered.
  17610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17611. */
  17612. export class SwitchBooleanAction extends Action {
  17613. /**
  17614. * The path to the boolean property in the target object
  17615. */
  17616. propertyPath: string;
  17617. private _target;
  17618. private _effectiveTarget;
  17619. private _property;
  17620. /**
  17621. * Instantiate the action
  17622. * @param triggerOptions defines the trigger options
  17623. * @param target defines the object containing the boolean
  17624. * @param propertyPath defines the path to the boolean property in the target object
  17625. * @param condition defines the trigger related conditions
  17626. */
  17627. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17628. /** @hidden */
  17629. _prepare(): void;
  17630. /**
  17631. * Execute the action toggle the boolean value.
  17632. */
  17633. execute(): void;
  17634. /**
  17635. * Serializes the actions and its related information.
  17636. * @param parent defines the object to serialize in
  17637. * @returns the serialized object
  17638. */
  17639. serialize(parent: any): any;
  17640. }
  17641. /**
  17642. * This defines an action responsible to set a the state field of the target
  17643. * to a desired value once triggered.
  17644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17645. */
  17646. export class SetStateAction extends Action {
  17647. /**
  17648. * The value to store in the state field.
  17649. */
  17650. value: string;
  17651. private _target;
  17652. /**
  17653. * Instantiate the action
  17654. * @param triggerOptions defines the trigger options
  17655. * @param target defines the object containing the state property
  17656. * @param value defines the value to store in the state field
  17657. * @param condition defines the trigger related conditions
  17658. */
  17659. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17660. /**
  17661. * Execute the action and store the value on the target state property.
  17662. */
  17663. execute(): void;
  17664. /**
  17665. * Serializes the actions and its related information.
  17666. * @param parent defines the object to serialize in
  17667. * @returns the serialized object
  17668. */
  17669. serialize(parent: any): any;
  17670. }
  17671. /**
  17672. * This defines an action responsible to set a property of the target
  17673. * to a desired value once triggered.
  17674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17675. */
  17676. export class SetValueAction extends Action {
  17677. /**
  17678. * The path of the property to set in the target.
  17679. */
  17680. propertyPath: string;
  17681. /**
  17682. * The value to set in the property
  17683. */
  17684. value: any;
  17685. private _target;
  17686. private _effectiveTarget;
  17687. private _property;
  17688. /**
  17689. * Instantiate the action
  17690. * @param triggerOptions defines the trigger options
  17691. * @param target defines the object containing the property
  17692. * @param propertyPath defines the path of the property to set in the target
  17693. * @param value defines the value to set in the property
  17694. * @param condition defines the trigger related conditions
  17695. */
  17696. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17697. /** @hidden */
  17698. _prepare(): void;
  17699. /**
  17700. * Execute the action and set the targetted property to the desired value.
  17701. */
  17702. execute(): void;
  17703. /**
  17704. * Serializes the actions and its related information.
  17705. * @param parent defines the object to serialize in
  17706. * @returns the serialized object
  17707. */
  17708. serialize(parent: any): any;
  17709. }
  17710. /**
  17711. * This defines an action responsible to increment the target value
  17712. * to a desired value once triggered.
  17713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17714. */
  17715. export class IncrementValueAction extends Action {
  17716. /**
  17717. * The path of the property to increment in the target.
  17718. */
  17719. propertyPath: string;
  17720. /**
  17721. * The value we should increment the property by.
  17722. */
  17723. value: any;
  17724. private _target;
  17725. private _effectiveTarget;
  17726. private _property;
  17727. /**
  17728. * Instantiate the action
  17729. * @param triggerOptions defines the trigger options
  17730. * @param target defines the object containing the property
  17731. * @param propertyPath defines the path of the property to increment in the target
  17732. * @param value defines the value value we should increment the property by
  17733. * @param condition defines the trigger related conditions
  17734. */
  17735. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17736. /** @hidden */
  17737. _prepare(): void;
  17738. /**
  17739. * Execute the action and increment the target of the value amount.
  17740. */
  17741. execute(): void;
  17742. /**
  17743. * Serializes the actions and its related information.
  17744. * @param parent defines the object to serialize in
  17745. * @returns the serialized object
  17746. */
  17747. serialize(parent: any): any;
  17748. }
  17749. /**
  17750. * This defines an action responsible to start an animation once triggered.
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17752. */
  17753. export class PlayAnimationAction extends Action {
  17754. /**
  17755. * Where the animation should start (animation frame)
  17756. */
  17757. from: number;
  17758. /**
  17759. * Where the animation should stop (animation frame)
  17760. */
  17761. to: number;
  17762. /**
  17763. * Define if the animation should loop or stop after the first play.
  17764. */
  17765. loop?: boolean;
  17766. private _target;
  17767. /**
  17768. * Instantiate the action
  17769. * @param triggerOptions defines the trigger options
  17770. * @param target defines the target animation or animation name
  17771. * @param from defines from where the animation should start (animation frame)
  17772. * @param end defines where the animation should stop (animation frame)
  17773. * @param loop defines if the animation should loop or stop after the first play
  17774. * @param condition defines the trigger related conditions
  17775. */
  17776. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17777. /** @hidden */
  17778. _prepare(): void;
  17779. /**
  17780. * Execute the action and play the animation.
  17781. */
  17782. execute(): void;
  17783. /**
  17784. * Serializes the actions and its related information.
  17785. * @param parent defines the object to serialize in
  17786. * @returns the serialized object
  17787. */
  17788. serialize(parent: any): any;
  17789. }
  17790. /**
  17791. * This defines an action responsible to stop an animation once triggered.
  17792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17793. */
  17794. export class StopAnimationAction extends Action {
  17795. private _target;
  17796. /**
  17797. * Instantiate the action
  17798. * @param triggerOptions defines the trigger options
  17799. * @param target defines the target animation or animation name
  17800. * @param condition defines the trigger related conditions
  17801. */
  17802. constructor(triggerOptions: any, target: any, condition?: Condition);
  17803. /** @hidden */
  17804. _prepare(): void;
  17805. /**
  17806. * Execute the action and stop the animation.
  17807. */
  17808. execute(): void;
  17809. /**
  17810. * Serializes the actions and its related information.
  17811. * @param parent defines the object to serialize in
  17812. * @returns the serialized object
  17813. */
  17814. serialize(parent: any): any;
  17815. }
  17816. /**
  17817. * This defines an action responsible that does nothing once triggered.
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17819. */
  17820. export class DoNothingAction extends Action {
  17821. /**
  17822. * Instantiate the action
  17823. * @param triggerOptions defines the trigger options
  17824. * @param condition defines the trigger related conditions
  17825. */
  17826. constructor(triggerOptions?: any, condition?: Condition);
  17827. /**
  17828. * Execute the action and do nothing.
  17829. */
  17830. execute(): void;
  17831. /**
  17832. * Serializes the actions and its related information.
  17833. * @param parent defines the object to serialize in
  17834. * @returns the serialized object
  17835. */
  17836. serialize(parent: any): any;
  17837. }
  17838. /**
  17839. * This defines an action responsible to trigger several actions once triggered.
  17840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17841. */
  17842. export class CombineAction extends Action {
  17843. /**
  17844. * The list of aggregated animations to run.
  17845. */
  17846. children: Action[];
  17847. /**
  17848. * Instantiate the action
  17849. * @param triggerOptions defines the trigger options
  17850. * @param children defines the list of aggregated animations to run
  17851. * @param condition defines the trigger related conditions
  17852. */
  17853. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17854. /** @hidden */
  17855. _prepare(): void;
  17856. /**
  17857. * Execute the action and executes all the aggregated actions.
  17858. */
  17859. execute(evt: ActionEvent): void;
  17860. /**
  17861. * Serializes the actions and its related information.
  17862. * @param parent defines the object to serialize in
  17863. * @returns the serialized object
  17864. */
  17865. serialize(parent: any): any;
  17866. }
  17867. /**
  17868. * This defines an action responsible to run code (external event) once triggered.
  17869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17870. */
  17871. export class ExecuteCodeAction extends Action {
  17872. /**
  17873. * The callback function to run.
  17874. */
  17875. func: (evt: ActionEvent) => void;
  17876. /**
  17877. * Instantiate the action
  17878. * @param triggerOptions defines the trigger options
  17879. * @param func defines the callback function to run
  17880. * @param condition defines the trigger related conditions
  17881. */
  17882. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17883. /**
  17884. * Execute the action and run the attached code.
  17885. */
  17886. execute(evt: ActionEvent): void;
  17887. }
  17888. /**
  17889. * This defines an action responsible to set the parent property of the target once triggered.
  17890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17891. */
  17892. export class SetParentAction extends Action {
  17893. private _parent;
  17894. private _target;
  17895. /**
  17896. * Instantiate the action
  17897. * @param triggerOptions defines the trigger options
  17898. * @param target defines the target containing the parent property
  17899. * @param parent defines from where the animation should start (animation frame)
  17900. * @param condition defines the trigger related conditions
  17901. */
  17902. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17903. /** @hidden */
  17904. _prepare(): void;
  17905. /**
  17906. * Execute the action and set the parent property.
  17907. */
  17908. execute(): void;
  17909. /**
  17910. * Serializes the actions and its related information.
  17911. * @param parent defines the object to serialize in
  17912. * @returns the serialized object
  17913. */
  17914. serialize(parent: any): any;
  17915. }
  17916. }
  17917. declare module BABYLON {
  17918. /**
  17919. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17920. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17922. */
  17923. export class ActionManager extends AbstractActionManager {
  17924. /**
  17925. * Nothing
  17926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17927. */
  17928. static readonly NothingTrigger: number;
  17929. /**
  17930. * On pick
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17932. */
  17933. static readonly OnPickTrigger: number;
  17934. /**
  17935. * On left pick
  17936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17937. */
  17938. static readonly OnLeftPickTrigger: number;
  17939. /**
  17940. * On right pick
  17941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17942. */
  17943. static readonly OnRightPickTrigger: number;
  17944. /**
  17945. * On center pick
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17947. */
  17948. static readonly OnCenterPickTrigger: number;
  17949. /**
  17950. * On pick down
  17951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17952. */
  17953. static readonly OnPickDownTrigger: number;
  17954. /**
  17955. * On double pick
  17956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17957. */
  17958. static readonly OnDoublePickTrigger: number;
  17959. /**
  17960. * On pick up
  17961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17962. */
  17963. static readonly OnPickUpTrigger: number;
  17964. /**
  17965. * On pick out.
  17966. * This trigger will only be raised if you also declared a OnPickDown
  17967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17968. */
  17969. static readonly OnPickOutTrigger: number;
  17970. /**
  17971. * On long press
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17973. */
  17974. static readonly OnLongPressTrigger: number;
  17975. /**
  17976. * On pointer over
  17977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17978. */
  17979. static readonly OnPointerOverTrigger: number;
  17980. /**
  17981. * On pointer out
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17983. */
  17984. static readonly OnPointerOutTrigger: number;
  17985. /**
  17986. * On every frame
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17988. */
  17989. static readonly OnEveryFrameTrigger: number;
  17990. /**
  17991. * On intersection enter
  17992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17993. */
  17994. static readonly OnIntersectionEnterTrigger: number;
  17995. /**
  17996. * On intersection exit
  17997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17998. */
  17999. static readonly OnIntersectionExitTrigger: number;
  18000. /**
  18001. * On key down
  18002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18003. */
  18004. static readonly OnKeyDownTrigger: number;
  18005. /**
  18006. * On key up
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18008. */
  18009. static readonly OnKeyUpTrigger: number;
  18010. private _scene;
  18011. /**
  18012. * Creates a new action manager
  18013. * @param scene defines the hosting scene
  18014. */
  18015. constructor(scene: Scene);
  18016. /**
  18017. * Releases all associated resources
  18018. */
  18019. dispose(): void;
  18020. /**
  18021. * Gets hosting scene
  18022. * @returns the hosting scene
  18023. */
  18024. getScene(): Scene;
  18025. /**
  18026. * Does this action manager handles actions of any of the given triggers
  18027. * @param triggers defines the triggers to be tested
  18028. * @return a boolean indicating whether one (or more) of the triggers is handled
  18029. */
  18030. hasSpecificTriggers(triggers: number[]): boolean;
  18031. /**
  18032. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18033. * speed.
  18034. * @param triggerA defines the trigger to be tested
  18035. * @param triggerB defines the trigger to be tested
  18036. * @return a boolean indicating whether one (or more) of the triggers is handled
  18037. */
  18038. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18039. /**
  18040. * Does this action manager handles actions of a given trigger
  18041. * @param trigger defines the trigger to be tested
  18042. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18043. * @return whether the trigger is handled
  18044. */
  18045. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18046. /**
  18047. * Does this action manager has pointer triggers
  18048. */
  18049. get hasPointerTriggers(): boolean;
  18050. /**
  18051. * Does this action manager has pick triggers
  18052. */
  18053. get hasPickTriggers(): boolean;
  18054. /**
  18055. * Registers an action to this action manager
  18056. * @param action defines the action to be registered
  18057. * @return the action amended (prepared) after registration
  18058. */
  18059. registerAction(action: IAction): Nullable<IAction>;
  18060. /**
  18061. * Unregisters an action to this action manager
  18062. * @param action defines the action to be unregistered
  18063. * @return a boolean indicating whether the action has been unregistered
  18064. */
  18065. unregisterAction(action: IAction): Boolean;
  18066. /**
  18067. * Process a specific trigger
  18068. * @param trigger defines the trigger to process
  18069. * @param evt defines the event details to be processed
  18070. */
  18071. processTrigger(trigger: number, evt?: IActionEvent): void;
  18072. /** @hidden */
  18073. _getEffectiveTarget(target: any, propertyPath: string): any;
  18074. /** @hidden */
  18075. _getProperty(propertyPath: string): string;
  18076. /**
  18077. * Serialize this manager to a JSON object
  18078. * @param name defines the property name to store this manager
  18079. * @returns a JSON representation of this manager
  18080. */
  18081. serialize(name: string): any;
  18082. /**
  18083. * Creates a new ActionManager from a JSON data
  18084. * @param parsedActions defines the JSON data to read from
  18085. * @param object defines the hosting mesh
  18086. * @param scene defines the hosting scene
  18087. */
  18088. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18089. /**
  18090. * Get a trigger name by index
  18091. * @param trigger defines the trigger index
  18092. * @returns a trigger name
  18093. */
  18094. static GetTriggerName(trigger: number): string;
  18095. }
  18096. }
  18097. declare module BABYLON {
  18098. /**
  18099. * Class used to represent a sprite
  18100. * @see http://doc.babylonjs.com/babylon101/sprites
  18101. */
  18102. export class Sprite {
  18103. /** defines the name */
  18104. name: string;
  18105. /** Gets or sets the current world position */
  18106. position: Vector3;
  18107. /** Gets or sets the main color */
  18108. color: Color4;
  18109. /** Gets or sets the width */
  18110. width: number;
  18111. /** Gets or sets the height */
  18112. height: number;
  18113. /** Gets or sets rotation angle */
  18114. angle: number;
  18115. /** Gets or sets the cell index in the sprite sheet */
  18116. cellIndex: number;
  18117. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18118. cellRef: string;
  18119. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18120. invertU: number;
  18121. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18122. invertV: number;
  18123. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18124. disposeWhenFinishedAnimating: boolean;
  18125. /** Gets the list of attached animations */
  18126. animations: Animation[];
  18127. /** Gets or sets a boolean indicating if the sprite can be picked */
  18128. isPickable: boolean;
  18129. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18130. useAlphaForPicking: boolean;
  18131. /** @hidden */
  18132. _xOffset: number;
  18133. /** @hidden */
  18134. _yOffset: number;
  18135. /** @hidden */
  18136. _xSize: number;
  18137. /** @hidden */
  18138. _ySize: number;
  18139. /**
  18140. * Gets or sets the associated action manager
  18141. */
  18142. actionManager: Nullable<ActionManager>;
  18143. private _animationStarted;
  18144. private _loopAnimation;
  18145. private _fromIndex;
  18146. private _toIndex;
  18147. private _delay;
  18148. private _direction;
  18149. private _manager;
  18150. private _time;
  18151. private _onAnimationEnd;
  18152. /**
  18153. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18154. */
  18155. isVisible: boolean;
  18156. /**
  18157. * Gets or sets the sprite size
  18158. */
  18159. get size(): number;
  18160. set size(value: number);
  18161. /**
  18162. * Creates a new Sprite
  18163. * @param name defines the name
  18164. * @param manager defines the manager
  18165. */
  18166. constructor(
  18167. /** defines the name */
  18168. name: string, manager: ISpriteManager);
  18169. /**
  18170. * Starts an animation
  18171. * @param from defines the initial key
  18172. * @param to defines the end key
  18173. * @param loop defines if the animation must loop
  18174. * @param delay defines the start delay (in ms)
  18175. * @param onAnimationEnd defines a callback to call when animation ends
  18176. */
  18177. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18178. /** Stops current animation (if any) */
  18179. stopAnimation(): void;
  18180. /** @hidden */
  18181. _animate(deltaTime: number): void;
  18182. /** Release associated resources */
  18183. dispose(): void;
  18184. }
  18185. }
  18186. declare module BABYLON {
  18187. /**
  18188. * Information about the result of picking within a scene
  18189. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18190. */
  18191. export class PickingInfo {
  18192. /** @hidden */
  18193. _pickingUnavailable: boolean;
  18194. /**
  18195. * If the pick collided with an object
  18196. */
  18197. hit: boolean;
  18198. /**
  18199. * Distance away where the pick collided
  18200. */
  18201. distance: number;
  18202. /**
  18203. * The location of pick collision
  18204. */
  18205. pickedPoint: Nullable<Vector3>;
  18206. /**
  18207. * The mesh corresponding the the pick collision
  18208. */
  18209. pickedMesh: Nullable<AbstractMesh>;
  18210. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18211. bu: number;
  18212. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18213. bv: number;
  18214. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18215. faceId: number;
  18216. /** Id of the the submesh that was picked */
  18217. subMeshId: number;
  18218. /** If a sprite was picked, this will be the sprite the pick collided with */
  18219. pickedSprite: Nullable<Sprite>;
  18220. /**
  18221. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18222. */
  18223. originMesh: Nullable<AbstractMesh>;
  18224. /**
  18225. * The ray that was used to perform the picking.
  18226. */
  18227. ray: Nullable<Ray>;
  18228. /**
  18229. * Gets the normal correspodning to the face the pick collided with
  18230. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18231. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18232. * @returns The normal correspodning to the face the pick collided with
  18233. */
  18234. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18235. /**
  18236. * Gets the texture coordinates of where the pick occured
  18237. * @returns the vector containing the coordnates of the texture
  18238. */
  18239. getTextureCoordinates(): Nullable<Vector2>;
  18240. }
  18241. }
  18242. declare module BABYLON {
  18243. /**
  18244. * Gather the list of pointer event types as constants.
  18245. */
  18246. export class PointerEventTypes {
  18247. /**
  18248. * 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.
  18249. */
  18250. static readonly POINTERDOWN: number;
  18251. /**
  18252. * The pointerup event is fired when a pointer is no longer active.
  18253. */
  18254. static readonly POINTERUP: number;
  18255. /**
  18256. * The pointermove event is fired when a pointer changes coordinates.
  18257. */
  18258. static readonly POINTERMOVE: number;
  18259. /**
  18260. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18261. */
  18262. static readonly POINTERWHEEL: number;
  18263. /**
  18264. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18265. */
  18266. static readonly POINTERPICK: number;
  18267. /**
  18268. * The pointertap event is fired when a the object has been touched and released without drag.
  18269. */
  18270. static readonly POINTERTAP: number;
  18271. /**
  18272. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18273. */
  18274. static readonly POINTERDOUBLETAP: number;
  18275. }
  18276. /**
  18277. * Base class of pointer info types.
  18278. */
  18279. export class PointerInfoBase {
  18280. /**
  18281. * Defines the type of event (PointerEventTypes)
  18282. */
  18283. type: number;
  18284. /**
  18285. * Defines the related dom event
  18286. */
  18287. event: PointerEvent | MouseWheelEvent;
  18288. /**
  18289. * Instantiates the base class of pointers info.
  18290. * @param type Defines the type of event (PointerEventTypes)
  18291. * @param event Defines the related dom event
  18292. */
  18293. constructor(
  18294. /**
  18295. * Defines the type of event (PointerEventTypes)
  18296. */
  18297. type: number,
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: PointerEvent | MouseWheelEvent);
  18302. }
  18303. /**
  18304. * This class is used to store pointer related info for the onPrePointerObservable event.
  18305. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18306. */
  18307. export class PointerInfoPre extends PointerInfoBase {
  18308. /**
  18309. * Ray from a pointer if availible (eg. 6dof controller)
  18310. */
  18311. ray: Nullable<Ray>;
  18312. /**
  18313. * Defines the local position of the pointer on the canvas.
  18314. */
  18315. localPosition: Vector2;
  18316. /**
  18317. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18318. */
  18319. skipOnPointerObservable: boolean;
  18320. /**
  18321. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18322. * @param type Defines the type of event (PointerEventTypes)
  18323. * @param event Defines the related dom event
  18324. * @param localX Defines the local x coordinates of the pointer when the event occured
  18325. * @param localY Defines the local y coordinates of the pointer when the event occured
  18326. */
  18327. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18328. }
  18329. /**
  18330. * This type contains all the data related to a pointer event in Babylon.js.
  18331. * 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.
  18332. */
  18333. export class PointerInfo extends PointerInfoBase {
  18334. /**
  18335. * Defines the picking info associated to the info (if any)\
  18336. */
  18337. pickInfo: Nullable<PickingInfo>;
  18338. /**
  18339. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18340. * @param type Defines the type of event (PointerEventTypes)
  18341. * @param event Defines the related dom event
  18342. * @param pickInfo Defines the picking info associated to the info (if any)\
  18343. */
  18344. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18345. /**
  18346. * Defines the picking info associated to the info (if any)\
  18347. */
  18348. pickInfo: Nullable<PickingInfo>);
  18349. }
  18350. /**
  18351. * Data relating to a touch event on the screen.
  18352. */
  18353. export interface PointerTouch {
  18354. /**
  18355. * X coordinate of touch.
  18356. */
  18357. x: number;
  18358. /**
  18359. * Y coordinate of touch.
  18360. */
  18361. y: number;
  18362. /**
  18363. * Id of touch. Unique for each finger.
  18364. */
  18365. pointerId: number;
  18366. /**
  18367. * Event type passed from DOM.
  18368. */
  18369. type: any;
  18370. }
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * Manage the mouse inputs to control the movement of a free camera.
  18375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18376. */
  18377. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18378. /**
  18379. * Define if touch is enabled in the mouse input
  18380. */
  18381. touchEnabled: boolean;
  18382. /**
  18383. * Defines the camera the input is attached to.
  18384. */
  18385. camera: FreeCamera;
  18386. /**
  18387. * Defines the buttons associated with the input to handle camera move.
  18388. */
  18389. buttons: number[];
  18390. /**
  18391. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18392. */
  18393. angularSensibility: number;
  18394. private _pointerInput;
  18395. private _onMouseMove;
  18396. private _observer;
  18397. private previousPosition;
  18398. /**
  18399. * Observable for when a pointer move event occurs containing the move offset
  18400. */
  18401. onPointerMovedObservable: Observable<{
  18402. offsetX: number;
  18403. offsetY: number;
  18404. }>;
  18405. /**
  18406. * @hidden
  18407. * If the camera should be rotated automatically based on pointer movement
  18408. */
  18409. _allowCameraRotation: boolean;
  18410. /**
  18411. * Manage the mouse inputs to control the movement of a free camera.
  18412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18413. * @param touchEnabled Defines if touch is enabled or not
  18414. */
  18415. constructor(
  18416. /**
  18417. * Define if touch is enabled in the mouse input
  18418. */
  18419. touchEnabled?: boolean);
  18420. /**
  18421. * Attach the input controls to a specific dom element to get the input from.
  18422. * @param element Defines the element the controls should be listened from
  18423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18424. */
  18425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18426. /**
  18427. * Called on JS contextmenu event.
  18428. * Override this method to provide functionality.
  18429. */
  18430. protected onContextMenu(evt: PointerEvent): void;
  18431. /**
  18432. * Detach the current controls from the specified dom element.
  18433. * @param element Defines the element to stop listening the inputs from
  18434. */
  18435. detachControl(element: Nullable<HTMLElement>): void;
  18436. /**
  18437. * Gets the class name of the current intput.
  18438. * @returns the class name
  18439. */
  18440. getClassName(): string;
  18441. /**
  18442. * Get the friendly name associated with the input class.
  18443. * @returns the input friendly name
  18444. */
  18445. getSimpleName(): string;
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. /**
  18450. * Manage the touch inputs to control the movement of a free camera.
  18451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18452. */
  18453. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18454. /**
  18455. * Defines the camera the input is attached to.
  18456. */
  18457. camera: FreeCamera;
  18458. /**
  18459. * Defines the touch sensibility for rotation.
  18460. * The higher the faster.
  18461. */
  18462. touchAngularSensibility: number;
  18463. /**
  18464. * Defines the touch sensibility for move.
  18465. * The higher the faster.
  18466. */
  18467. touchMoveSensibility: number;
  18468. private _offsetX;
  18469. private _offsetY;
  18470. private _pointerPressed;
  18471. private _pointerInput;
  18472. private _observer;
  18473. private _onLostFocus;
  18474. /**
  18475. * Attach the input controls to a specific dom element to get the input from.
  18476. * @param element Defines the element the controls should be listened from
  18477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18478. */
  18479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18480. /**
  18481. * Detach the current controls from the specified dom element.
  18482. * @param element Defines the element to stop listening the inputs from
  18483. */
  18484. detachControl(element: Nullable<HTMLElement>): void;
  18485. /**
  18486. * Update the current camera state depending on the inputs that have been used this frame.
  18487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18488. */
  18489. checkInputs(): void;
  18490. /**
  18491. * Gets the class name of the current intput.
  18492. * @returns the class name
  18493. */
  18494. getClassName(): string;
  18495. /**
  18496. * Get the friendly name associated with the input class.
  18497. * @returns the input friendly name
  18498. */
  18499. getSimpleName(): string;
  18500. }
  18501. }
  18502. declare module BABYLON {
  18503. /**
  18504. * Default Inputs manager for the FreeCamera.
  18505. * It groups all the default supported inputs for ease of use.
  18506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18507. */
  18508. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18509. /**
  18510. * @hidden
  18511. */
  18512. _mouseInput: Nullable<FreeCameraMouseInput>;
  18513. /**
  18514. * Instantiates a new FreeCameraInputsManager.
  18515. * @param camera Defines the camera the inputs belong to
  18516. */
  18517. constructor(camera: FreeCamera);
  18518. /**
  18519. * Add keyboard input support to the input manager.
  18520. * @returns the current input manager
  18521. */
  18522. addKeyboard(): FreeCameraInputsManager;
  18523. /**
  18524. * Add mouse input support to the input manager.
  18525. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18526. * @returns the current input manager
  18527. */
  18528. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18529. /**
  18530. * Removes the mouse input support from the manager
  18531. * @returns the current input manager
  18532. */
  18533. removeMouse(): FreeCameraInputsManager;
  18534. /**
  18535. * Add touch input support to the input manager.
  18536. * @returns the current input manager
  18537. */
  18538. addTouch(): FreeCameraInputsManager;
  18539. /**
  18540. * Remove all attached input methods from a camera
  18541. */
  18542. clear(): void;
  18543. }
  18544. }
  18545. declare module BABYLON {
  18546. /**
  18547. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18548. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18549. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18550. */
  18551. export class FreeCamera extends TargetCamera {
  18552. /**
  18553. * Define the collision ellipsoid of the camera.
  18554. * This is helpful to simulate a camera body like the player body around the camera
  18555. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18556. */
  18557. ellipsoid: Vector3;
  18558. /**
  18559. * Define an offset for the position of the ellipsoid around the camera.
  18560. * This can be helpful to determine the center of the body near the gravity center of the body
  18561. * instead of its head.
  18562. */
  18563. ellipsoidOffset: Vector3;
  18564. /**
  18565. * Enable or disable collisions of the camera with the rest of the scene objects.
  18566. */
  18567. checkCollisions: boolean;
  18568. /**
  18569. * Enable or disable gravity on the camera.
  18570. */
  18571. applyGravity: boolean;
  18572. /**
  18573. * Define the input manager associated to the camera.
  18574. */
  18575. inputs: FreeCameraInputsManager;
  18576. /**
  18577. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18578. * Higher values reduce sensitivity.
  18579. */
  18580. get angularSensibility(): number;
  18581. /**
  18582. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18583. * Higher values reduce sensitivity.
  18584. */
  18585. set angularSensibility(value: number);
  18586. /**
  18587. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18588. */
  18589. get keysUp(): number[];
  18590. set keysUp(value: number[]);
  18591. /**
  18592. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18593. */
  18594. get keysUpward(): number[];
  18595. set keysUpward(value: number[]);
  18596. /**
  18597. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18598. */
  18599. get keysDown(): number[];
  18600. set keysDown(value: number[]);
  18601. /**
  18602. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18603. */
  18604. get keysDownward(): number[];
  18605. set keysDownward(value: number[]);
  18606. /**
  18607. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18608. */
  18609. get keysLeft(): number[];
  18610. set keysLeft(value: number[]);
  18611. /**
  18612. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18613. */
  18614. get keysRight(): number[];
  18615. set keysRight(value: number[]);
  18616. /**
  18617. * Event raised when the camera collide with a mesh in the scene.
  18618. */
  18619. onCollide: (collidedMesh: AbstractMesh) => void;
  18620. private _collider;
  18621. private _needMoveForGravity;
  18622. private _oldPosition;
  18623. private _diffPosition;
  18624. private _newPosition;
  18625. /** @hidden */
  18626. _localDirection: Vector3;
  18627. /** @hidden */
  18628. _transformedDirection: Vector3;
  18629. /**
  18630. * Instantiates a Free Camera.
  18631. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18632. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18634. * @param name Define the name of the camera in the scene
  18635. * @param position Define the start position of the camera in the scene
  18636. * @param scene Define the scene the camera belongs to
  18637. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18638. */
  18639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18640. /**
  18641. * Attached controls to the current camera.
  18642. * @param element Defines the element the controls should be listened from
  18643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18644. */
  18645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18646. /**
  18647. * Detach the current controls from the camera.
  18648. * The camera will stop reacting to inputs.
  18649. * @param element Defines the element to stop listening the inputs from
  18650. */
  18651. detachControl(element: HTMLElement): void;
  18652. private _collisionMask;
  18653. /**
  18654. * Define a collision mask to limit the list of object the camera can collide with
  18655. */
  18656. get collisionMask(): number;
  18657. set collisionMask(mask: number);
  18658. /** @hidden */
  18659. _collideWithWorld(displacement: Vector3): void;
  18660. private _onCollisionPositionChange;
  18661. /** @hidden */
  18662. _checkInputs(): void;
  18663. /** @hidden */
  18664. _decideIfNeedsToMove(): boolean;
  18665. /** @hidden */
  18666. _updatePosition(): void;
  18667. /**
  18668. * Destroy the camera and release the current resources hold by it.
  18669. */
  18670. dispose(): void;
  18671. /**
  18672. * Gets the current object class name.
  18673. * @return the class name
  18674. */
  18675. getClassName(): string;
  18676. }
  18677. }
  18678. declare module BABYLON {
  18679. /**
  18680. * Represents a gamepad control stick position
  18681. */
  18682. export class StickValues {
  18683. /**
  18684. * The x component of the control stick
  18685. */
  18686. x: number;
  18687. /**
  18688. * The y component of the control stick
  18689. */
  18690. y: number;
  18691. /**
  18692. * Initializes the gamepad x and y control stick values
  18693. * @param x The x component of the gamepad control stick value
  18694. * @param y The y component of the gamepad control stick value
  18695. */
  18696. constructor(
  18697. /**
  18698. * The x component of the control stick
  18699. */
  18700. x: number,
  18701. /**
  18702. * The y component of the control stick
  18703. */
  18704. y: number);
  18705. }
  18706. /**
  18707. * An interface which manages callbacks for gamepad button changes
  18708. */
  18709. export interface GamepadButtonChanges {
  18710. /**
  18711. * Called when a gamepad has been changed
  18712. */
  18713. changed: boolean;
  18714. /**
  18715. * Called when a gamepad press event has been triggered
  18716. */
  18717. pressChanged: boolean;
  18718. /**
  18719. * Called when a touch event has been triggered
  18720. */
  18721. touchChanged: boolean;
  18722. /**
  18723. * Called when a value has changed
  18724. */
  18725. valueChanged: boolean;
  18726. }
  18727. /**
  18728. * Represents a gamepad
  18729. */
  18730. export class Gamepad {
  18731. /**
  18732. * The id of the gamepad
  18733. */
  18734. id: string;
  18735. /**
  18736. * The index of the gamepad
  18737. */
  18738. index: number;
  18739. /**
  18740. * The browser gamepad
  18741. */
  18742. browserGamepad: any;
  18743. /**
  18744. * Specifies what type of gamepad this represents
  18745. */
  18746. type: number;
  18747. private _leftStick;
  18748. private _rightStick;
  18749. /** @hidden */
  18750. _isConnected: boolean;
  18751. private _leftStickAxisX;
  18752. private _leftStickAxisY;
  18753. private _rightStickAxisX;
  18754. private _rightStickAxisY;
  18755. /**
  18756. * Triggered when the left control stick has been changed
  18757. */
  18758. private _onleftstickchanged;
  18759. /**
  18760. * Triggered when the right control stick has been changed
  18761. */
  18762. private _onrightstickchanged;
  18763. /**
  18764. * Represents a gamepad controller
  18765. */
  18766. static GAMEPAD: number;
  18767. /**
  18768. * Represents a generic controller
  18769. */
  18770. static GENERIC: number;
  18771. /**
  18772. * Represents an XBox controller
  18773. */
  18774. static XBOX: number;
  18775. /**
  18776. * Represents a pose-enabled controller
  18777. */
  18778. static POSE_ENABLED: number;
  18779. /**
  18780. * Represents an Dual Shock controller
  18781. */
  18782. static DUALSHOCK: number;
  18783. /**
  18784. * Specifies whether the left control stick should be Y-inverted
  18785. */
  18786. protected _invertLeftStickY: boolean;
  18787. /**
  18788. * Specifies if the gamepad has been connected
  18789. */
  18790. get isConnected(): boolean;
  18791. /**
  18792. * Initializes the gamepad
  18793. * @param id The id of the gamepad
  18794. * @param index The index of the gamepad
  18795. * @param browserGamepad The browser gamepad
  18796. * @param leftStickX The x component of the left joystick
  18797. * @param leftStickY The y component of the left joystick
  18798. * @param rightStickX The x component of the right joystick
  18799. * @param rightStickY The y component of the right joystick
  18800. */
  18801. constructor(
  18802. /**
  18803. * The id of the gamepad
  18804. */
  18805. id: string,
  18806. /**
  18807. * The index of the gamepad
  18808. */
  18809. index: number,
  18810. /**
  18811. * The browser gamepad
  18812. */
  18813. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18814. /**
  18815. * Callback triggered when the left joystick has changed
  18816. * @param callback
  18817. */
  18818. onleftstickchanged(callback: (values: StickValues) => void): void;
  18819. /**
  18820. * Callback triggered when the right joystick has changed
  18821. * @param callback
  18822. */
  18823. onrightstickchanged(callback: (values: StickValues) => void): void;
  18824. /**
  18825. * Gets the left joystick
  18826. */
  18827. get leftStick(): StickValues;
  18828. /**
  18829. * Sets the left joystick values
  18830. */
  18831. set leftStick(newValues: StickValues);
  18832. /**
  18833. * Gets the right joystick
  18834. */
  18835. get rightStick(): StickValues;
  18836. /**
  18837. * Sets the right joystick value
  18838. */
  18839. set rightStick(newValues: StickValues);
  18840. /**
  18841. * Updates the gamepad joystick positions
  18842. */
  18843. update(): void;
  18844. /**
  18845. * Disposes the gamepad
  18846. */
  18847. dispose(): void;
  18848. }
  18849. /**
  18850. * Represents a generic gamepad
  18851. */
  18852. export class GenericPad extends Gamepad {
  18853. private _buttons;
  18854. private _onbuttondown;
  18855. private _onbuttonup;
  18856. /**
  18857. * Observable triggered when a button has been pressed
  18858. */
  18859. onButtonDownObservable: Observable<number>;
  18860. /**
  18861. * Observable triggered when a button has been released
  18862. */
  18863. onButtonUpObservable: Observable<number>;
  18864. /**
  18865. * Callback triggered when a button has been pressed
  18866. * @param callback Called when a button has been pressed
  18867. */
  18868. onbuttondown(callback: (buttonPressed: number) => void): void;
  18869. /**
  18870. * Callback triggered when a button has been released
  18871. * @param callback Called when a button has been released
  18872. */
  18873. onbuttonup(callback: (buttonReleased: number) => void): void;
  18874. /**
  18875. * Initializes the generic gamepad
  18876. * @param id The id of the generic gamepad
  18877. * @param index The index of the generic gamepad
  18878. * @param browserGamepad The browser gamepad
  18879. */
  18880. constructor(id: string, index: number, browserGamepad: any);
  18881. private _setButtonValue;
  18882. /**
  18883. * Updates the generic gamepad
  18884. */
  18885. update(): void;
  18886. /**
  18887. * Disposes the generic gamepad
  18888. */
  18889. dispose(): void;
  18890. }
  18891. }
  18892. declare module BABYLON {
  18893. /**
  18894. * Defines the types of pose enabled controllers that are supported
  18895. */
  18896. export enum PoseEnabledControllerType {
  18897. /**
  18898. * HTC Vive
  18899. */
  18900. VIVE = 0,
  18901. /**
  18902. * Oculus Rift
  18903. */
  18904. OCULUS = 1,
  18905. /**
  18906. * Windows mixed reality
  18907. */
  18908. WINDOWS = 2,
  18909. /**
  18910. * Samsung gear VR
  18911. */
  18912. GEAR_VR = 3,
  18913. /**
  18914. * Google Daydream
  18915. */
  18916. DAYDREAM = 4,
  18917. /**
  18918. * Generic
  18919. */
  18920. GENERIC = 5
  18921. }
  18922. /**
  18923. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18924. */
  18925. export interface MutableGamepadButton {
  18926. /**
  18927. * Value of the button/trigger
  18928. */
  18929. value: number;
  18930. /**
  18931. * If the button/trigger is currently touched
  18932. */
  18933. touched: boolean;
  18934. /**
  18935. * If the button/trigger is currently pressed
  18936. */
  18937. pressed: boolean;
  18938. }
  18939. /**
  18940. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18941. * @hidden
  18942. */
  18943. export interface ExtendedGamepadButton extends GamepadButton {
  18944. /**
  18945. * If the button/trigger is currently pressed
  18946. */
  18947. readonly pressed: boolean;
  18948. /**
  18949. * If the button/trigger is currently touched
  18950. */
  18951. readonly touched: boolean;
  18952. /**
  18953. * Value of the button/trigger
  18954. */
  18955. readonly value: number;
  18956. }
  18957. /** @hidden */
  18958. export interface _GamePadFactory {
  18959. /**
  18960. * Returns whether or not the current gamepad can be created for this type of controller.
  18961. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18962. * @returns true if it can be created, otherwise false
  18963. */
  18964. canCreate(gamepadInfo: any): boolean;
  18965. /**
  18966. * Creates a new instance of the Gamepad.
  18967. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18968. * @returns the new gamepad instance
  18969. */
  18970. create(gamepadInfo: any): Gamepad;
  18971. }
  18972. /**
  18973. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18974. */
  18975. export class PoseEnabledControllerHelper {
  18976. /** @hidden */
  18977. static _ControllerFactories: _GamePadFactory[];
  18978. /** @hidden */
  18979. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18980. /**
  18981. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18982. * @param vrGamepad the gamepad to initialized
  18983. * @returns a vr controller of the type the gamepad identified as
  18984. */
  18985. static InitiateController(vrGamepad: any): Gamepad;
  18986. }
  18987. /**
  18988. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18989. */
  18990. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18991. /**
  18992. * If the controller is used in a webXR session
  18993. */
  18994. isXR: boolean;
  18995. private _deviceRoomPosition;
  18996. private _deviceRoomRotationQuaternion;
  18997. /**
  18998. * The device position in babylon space
  18999. */
  19000. devicePosition: Vector3;
  19001. /**
  19002. * The device rotation in babylon space
  19003. */
  19004. deviceRotationQuaternion: Quaternion;
  19005. /**
  19006. * The scale factor of the device in babylon space
  19007. */
  19008. deviceScaleFactor: number;
  19009. /**
  19010. * (Likely devicePosition should be used instead) The device position in its room space
  19011. */
  19012. position: Vector3;
  19013. /**
  19014. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19015. */
  19016. rotationQuaternion: Quaternion;
  19017. /**
  19018. * The type of controller (Eg. Windows mixed reality)
  19019. */
  19020. controllerType: PoseEnabledControllerType;
  19021. protected _calculatedPosition: Vector3;
  19022. private _calculatedRotation;
  19023. /**
  19024. * The raw pose from the device
  19025. */
  19026. rawPose: DevicePose;
  19027. private _trackPosition;
  19028. private _maxRotationDistFromHeadset;
  19029. private _draggedRoomRotation;
  19030. /**
  19031. * @hidden
  19032. */
  19033. _disableTrackPosition(fixedPosition: Vector3): void;
  19034. /**
  19035. * Internal, the mesh attached to the controller
  19036. * @hidden
  19037. */
  19038. _mesh: Nullable<AbstractMesh>;
  19039. private _poseControlledCamera;
  19040. private _leftHandSystemQuaternion;
  19041. /**
  19042. * Internal, matrix used to convert room space to babylon space
  19043. * @hidden
  19044. */
  19045. _deviceToWorld: Matrix;
  19046. /**
  19047. * Node to be used when casting a ray from the controller
  19048. * @hidden
  19049. */
  19050. _pointingPoseNode: Nullable<TransformNode>;
  19051. /**
  19052. * Name of the child mesh that can be used to cast a ray from the controller
  19053. */
  19054. static readonly POINTING_POSE: string;
  19055. /**
  19056. * Creates a new PoseEnabledController from a gamepad
  19057. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19058. */
  19059. constructor(browserGamepad: any);
  19060. private _workingMatrix;
  19061. /**
  19062. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19063. */
  19064. update(): void;
  19065. /**
  19066. * Updates only the pose device and mesh without doing any button event checking
  19067. */
  19068. protected _updatePoseAndMesh(): void;
  19069. /**
  19070. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19071. * @param poseData raw pose fromthe device
  19072. */
  19073. updateFromDevice(poseData: DevicePose): void;
  19074. /**
  19075. * @hidden
  19076. */
  19077. _meshAttachedObservable: Observable<AbstractMesh>;
  19078. /**
  19079. * Attaches a mesh to the controller
  19080. * @param mesh the mesh to be attached
  19081. */
  19082. attachToMesh(mesh: AbstractMesh): void;
  19083. /**
  19084. * Attaches the controllers mesh to a camera
  19085. * @param camera the camera the mesh should be attached to
  19086. */
  19087. attachToPoseControlledCamera(camera: TargetCamera): void;
  19088. /**
  19089. * Disposes of the controller
  19090. */
  19091. dispose(): void;
  19092. /**
  19093. * The mesh that is attached to the controller
  19094. */
  19095. get mesh(): Nullable<AbstractMesh>;
  19096. /**
  19097. * Gets the ray of the controller in the direction the controller is pointing
  19098. * @param length the length the resulting ray should be
  19099. * @returns a ray in the direction the controller is pointing
  19100. */
  19101. getForwardRay(length?: number): Ray;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. /**
  19106. * Defines the WebVRController object that represents controllers tracked in 3D space
  19107. */
  19108. export abstract class WebVRController extends PoseEnabledController {
  19109. /**
  19110. * Internal, the default controller model for the controller
  19111. */
  19112. protected _defaultModel: Nullable<AbstractMesh>;
  19113. /**
  19114. * Fired when the trigger state has changed
  19115. */
  19116. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19117. /**
  19118. * Fired when the main button state has changed
  19119. */
  19120. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19121. /**
  19122. * Fired when the secondary button state has changed
  19123. */
  19124. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19125. /**
  19126. * Fired when the pad state has changed
  19127. */
  19128. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19129. /**
  19130. * Fired when controllers stick values have changed
  19131. */
  19132. onPadValuesChangedObservable: Observable<StickValues>;
  19133. /**
  19134. * Array of button availible on the controller
  19135. */
  19136. protected _buttons: Array<MutableGamepadButton>;
  19137. private _onButtonStateChange;
  19138. /**
  19139. * Fired when a controller button's state has changed
  19140. * @param callback the callback containing the button that was modified
  19141. */
  19142. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19143. /**
  19144. * X and Y axis corresponding to the controllers joystick
  19145. */
  19146. pad: StickValues;
  19147. /**
  19148. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19149. */
  19150. hand: string;
  19151. /**
  19152. * The default controller model for the controller
  19153. */
  19154. get defaultModel(): Nullable<AbstractMesh>;
  19155. /**
  19156. * Creates a new WebVRController from a gamepad
  19157. * @param vrGamepad the gamepad that the WebVRController should be created from
  19158. */
  19159. constructor(vrGamepad: any);
  19160. /**
  19161. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19162. */
  19163. update(): void;
  19164. /**
  19165. * Function to be called when a button is modified
  19166. */
  19167. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19168. /**
  19169. * Loads a mesh and attaches it to the controller
  19170. * @param scene the scene the mesh should be added to
  19171. * @param meshLoaded callback for when the mesh has been loaded
  19172. */
  19173. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19174. private _setButtonValue;
  19175. private _changes;
  19176. private _checkChanges;
  19177. /**
  19178. * Disposes of th webVRCOntroller
  19179. */
  19180. dispose(): void;
  19181. }
  19182. }
  19183. declare module BABYLON {
  19184. /**
  19185. * The HemisphericLight simulates the ambient environment light,
  19186. * so the passed direction is the light reflection direction, not the incoming direction.
  19187. */
  19188. export class HemisphericLight extends Light {
  19189. /**
  19190. * The groundColor is the light in the opposite direction to the one specified during creation.
  19191. * 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.
  19192. */
  19193. groundColor: Color3;
  19194. /**
  19195. * The light reflection direction, not the incoming direction.
  19196. */
  19197. direction: Vector3;
  19198. /**
  19199. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19200. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19201. * The HemisphericLight can't cast shadows.
  19202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19203. * @param name The friendly name of the light
  19204. * @param direction The direction of the light reflection
  19205. * @param scene The scene the light belongs to
  19206. */
  19207. constructor(name: string, direction: Vector3, scene: Scene);
  19208. protected _buildUniformLayout(): void;
  19209. /**
  19210. * Returns the string "HemisphericLight".
  19211. * @return The class name
  19212. */
  19213. getClassName(): string;
  19214. /**
  19215. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19216. * Returns the updated direction.
  19217. * @param target The target the direction should point to
  19218. * @return The computed direction
  19219. */
  19220. setDirectionToTarget(target: Vector3): Vector3;
  19221. /**
  19222. * Returns the shadow generator associated to the light.
  19223. * @returns Always null for hemispheric lights because it does not support shadows.
  19224. */
  19225. getShadowGenerator(): Nullable<IShadowGenerator>;
  19226. /**
  19227. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19228. * @param effect The effect to update
  19229. * @param lightIndex The index of the light in the effect to update
  19230. * @returns The hemispheric light
  19231. */
  19232. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19233. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19234. /**
  19235. * Computes the world matrix of the node
  19236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19237. * @param useWasUpdatedFlag defines a reserved property
  19238. * @returns the world matrix
  19239. */
  19240. computeWorldMatrix(): Matrix;
  19241. /**
  19242. * Returns the integer 3.
  19243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19244. */
  19245. getTypeID(): number;
  19246. /**
  19247. * Prepares the list of defines specific to the light type.
  19248. * @param defines the list of defines
  19249. * @param lightIndex defines the index of the light for the effect
  19250. */
  19251. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19252. }
  19253. }
  19254. declare module BABYLON {
  19255. /** @hidden */
  19256. export var vrMultiviewToSingleviewPixelShader: {
  19257. name: string;
  19258. shader: string;
  19259. };
  19260. }
  19261. declare module BABYLON {
  19262. /**
  19263. * Renders to multiple views with a single draw call
  19264. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19265. */
  19266. export class MultiviewRenderTarget extends RenderTargetTexture {
  19267. /**
  19268. * Creates a multiview render target
  19269. * @param scene scene used with the render target
  19270. * @param size the size of the render target (used for each view)
  19271. */
  19272. constructor(scene: Scene, size?: number | {
  19273. width: number;
  19274. height: number;
  19275. } | {
  19276. ratio: number;
  19277. });
  19278. /**
  19279. * @hidden
  19280. * @param faceIndex the face index, if its a cube texture
  19281. */
  19282. _bindFrameBuffer(faceIndex?: number): void;
  19283. /**
  19284. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19285. * @returns the view count
  19286. */
  19287. getViewCount(): number;
  19288. }
  19289. }
  19290. declare module BABYLON {
  19291. /**
  19292. * Represents a camera frustum
  19293. */
  19294. export class Frustum {
  19295. /**
  19296. * Gets the planes representing the frustum
  19297. * @param transform matrix to be applied to the returned planes
  19298. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19299. */
  19300. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19301. /**
  19302. * Gets the near frustum plane transformed by the transform matrix
  19303. * @param transform transformation matrix to be applied to the resulting frustum plane
  19304. * @param frustumPlane the resuling frustum plane
  19305. */
  19306. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19307. /**
  19308. * Gets the far frustum plane transformed by the transform matrix
  19309. * @param transform transformation matrix to be applied to the resulting frustum plane
  19310. * @param frustumPlane the resuling frustum plane
  19311. */
  19312. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19313. /**
  19314. * Gets the left frustum plane transformed by the transform matrix
  19315. * @param transform transformation matrix to be applied to the resulting frustum plane
  19316. * @param frustumPlane the resuling frustum plane
  19317. */
  19318. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19319. /**
  19320. * Gets the right frustum plane transformed by the transform matrix
  19321. * @param transform transformation matrix to be applied to the resulting frustum plane
  19322. * @param frustumPlane the resuling frustum plane
  19323. */
  19324. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19325. /**
  19326. * Gets the top frustum plane transformed by the transform matrix
  19327. * @param transform transformation matrix to be applied to the resulting frustum plane
  19328. * @param frustumPlane the resuling frustum plane
  19329. */
  19330. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19331. /**
  19332. * Gets the bottom frustum plane transformed by the transform matrix
  19333. * @param transform transformation matrix to be applied to the resulting frustum plane
  19334. * @param frustumPlane the resuling frustum plane
  19335. */
  19336. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19337. /**
  19338. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19339. * @param transform transformation matrix to be applied to the resulting frustum planes
  19340. * @param frustumPlanes the resuling frustum planes
  19341. */
  19342. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19343. }
  19344. }
  19345. declare module BABYLON {
  19346. interface Engine {
  19347. /**
  19348. * Creates a new multiview render target
  19349. * @param width defines the width of the texture
  19350. * @param height defines the height of the texture
  19351. * @returns the created multiview texture
  19352. */
  19353. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19354. /**
  19355. * Binds a multiview framebuffer to be drawn to
  19356. * @param multiviewTexture texture to bind
  19357. */
  19358. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19359. }
  19360. interface Camera {
  19361. /**
  19362. * @hidden
  19363. * 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)
  19364. */
  19365. _useMultiviewToSingleView: boolean;
  19366. /**
  19367. * @hidden
  19368. * 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)
  19369. */
  19370. _multiviewTexture: Nullable<RenderTargetTexture>;
  19371. /**
  19372. * @hidden
  19373. * ensures the multiview texture of the camera exists and has the specified width/height
  19374. * @param width height to set on the multiview texture
  19375. * @param height width to set on the multiview texture
  19376. */
  19377. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19378. }
  19379. interface Scene {
  19380. /** @hidden */
  19381. _transformMatrixR: Matrix;
  19382. /** @hidden */
  19383. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19384. /** @hidden */
  19385. _createMultiviewUbo(): void;
  19386. /** @hidden */
  19387. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19388. /** @hidden */
  19389. _renderMultiviewToSingleView(camera: Camera): void;
  19390. }
  19391. }
  19392. declare module BABYLON {
  19393. /**
  19394. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19395. * This will not be used for webXR as it supports displaying texture arrays directly
  19396. */
  19397. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19398. /**
  19399. * Initializes a VRMultiviewToSingleview
  19400. * @param name name of the post process
  19401. * @param camera camera to be applied to
  19402. * @param scaleFactor scaling factor to the size of the output texture
  19403. */
  19404. constructor(name: string, camera: Camera, scaleFactor: number);
  19405. }
  19406. }
  19407. declare module BABYLON {
  19408. /**
  19409. * Interface used to define additional presentation attributes
  19410. */
  19411. export interface IVRPresentationAttributes {
  19412. /**
  19413. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19414. */
  19415. highRefreshRate: boolean;
  19416. /**
  19417. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19418. */
  19419. foveationLevel: number;
  19420. }
  19421. interface Engine {
  19422. /** @hidden */
  19423. _vrDisplay: any;
  19424. /** @hidden */
  19425. _vrSupported: boolean;
  19426. /** @hidden */
  19427. _oldSize: Size;
  19428. /** @hidden */
  19429. _oldHardwareScaleFactor: number;
  19430. /** @hidden */
  19431. _vrExclusivePointerMode: boolean;
  19432. /** @hidden */
  19433. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19434. /** @hidden */
  19435. _onVRDisplayPointerRestricted: () => void;
  19436. /** @hidden */
  19437. _onVRDisplayPointerUnrestricted: () => void;
  19438. /** @hidden */
  19439. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19440. /** @hidden */
  19441. _onVrDisplayDisconnect: Nullable<() => void>;
  19442. /** @hidden */
  19443. _onVrDisplayPresentChange: Nullable<() => void>;
  19444. /**
  19445. * Observable signaled when VR display mode changes
  19446. */
  19447. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19448. /**
  19449. * Observable signaled when VR request present is complete
  19450. */
  19451. onVRRequestPresentComplete: Observable<boolean>;
  19452. /**
  19453. * Observable signaled when VR request present starts
  19454. */
  19455. onVRRequestPresentStart: Observable<Engine>;
  19456. /**
  19457. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19458. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19459. */
  19460. isInVRExclusivePointerMode: boolean;
  19461. /**
  19462. * Gets a boolean indicating if a webVR device was detected
  19463. * @returns true if a webVR device was detected
  19464. */
  19465. isVRDevicePresent(): boolean;
  19466. /**
  19467. * Gets the current webVR device
  19468. * @returns the current webVR device (or null)
  19469. */
  19470. getVRDevice(): any;
  19471. /**
  19472. * Initializes a webVR display and starts listening to display change events
  19473. * The onVRDisplayChangedObservable will be notified upon these changes
  19474. * @returns A promise containing a VRDisplay and if vr is supported
  19475. */
  19476. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19477. /** @hidden */
  19478. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19479. /**
  19480. * Gets or sets the presentation attributes used to configure VR rendering
  19481. */
  19482. vrPresentationAttributes?: IVRPresentationAttributes;
  19483. /**
  19484. * Call this function to switch to webVR mode
  19485. * Will do nothing if webVR is not supported or if there is no webVR device
  19486. * @param options the webvr options provided to the camera. mainly used for multiview
  19487. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19488. */
  19489. enableVR(options: WebVROptions): void;
  19490. /** @hidden */
  19491. _onVRFullScreenTriggered(): void;
  19492. }
  19493. }
  19494. declare module BABYLON {
  19495. /**
  19496. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19497. * IMPORTANT!! The data is right-hand data.
  19498. * @export
  19499. * @interface DevicePose
  19500. */
  19501. export interface DevicePose {
  19502. /**
  19503. * The position of the device, values in array are [x,y,z].
  19504. */
  19505. readonly position: Nullable<Float32Array>;
  19506. /**
  19507. * The linearVelocity of the device, values in array are [x,y,z].
  19508. */
  19509. readonly linearVelocity: Nullable<Float32Array>;
  19510. /**
  19511. * The linearAcceleration of the device, values in array are [x,y,z].
  19512. */
  19513. readonly linearAcceleration: Nullable<Float32Array>;
  19514. /**
  19515. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19516. */
  19517. readonly orientation: Nullable<Float32Array>;
  19518. /**
  19519. * The angularVelocity of the device, values in array are [x,y,z].
  19520. */
  19521. readonly angularVelocity: Nullable<Float32Array>;
  19522. /**
  19523. * The angularAcceleration of the device, values in array are [x,y,z].
  19524. */
  19525. readonly angularAcceleration: Nullable<Float32Array>;
  19526. }
  19527. /**
  19528. * Interface representing a pose controlled object in Babylon.
  19529. * A pose controlled object has both regular pose values as well as pose values
  19530. * from an external device such as a VR head mounted display
  19531. */
  19532. export interface PoseControlled {
  19533. /**
  19534. * The position of the object in babylon space.
  19535. */
  19536. position: Vector3;
  19537. /**
  19538. * The rotation quaternion of the object in babylon space.
  19539. */
  19540. rotationQuaternion: Quaternion;
  19541. /**
  19542. * The position of the device in babylon space.
  19543. */
  19544. devicePosition?: Vector3;
  19545. /**
  19546. * The rotation quaternion of the device in babylon space.
  19547. */
  19548. deviceRotationQuaternion: Quaternion;
  19549. /**
  19550. * The raw pose coming from the device.
  19551. */
  19552. rawPose: Nullable<DevicePose>;
  19553. /**
  19554. * The scale of the device to be used when translating from device space to babylon space.
  19555. */
  19556. deviceScaleFactor: number;
  19557. /**
  19558. * Updates the poseControlled values based on the input device pose.
  19559. * @param poseData the pose data to update the object with
  19560. */
  19561. updateFromDevice(poseData: DevicePose): void;
  19562. }
  19563. /**
  19564. * Set of options to customize the webVRCamera
  19565. */
  19566. export interface WebVROptions {
  19567. /**
  19568. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19569. */
  19570. trackPosition?: boolean;
  19571. /**
  19572. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19573. */
  19574. positionScale?: number;
  19575. /**
  19576. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19577. */
  19578. displayName?: string;
  19579. /**
  19580. * Should the native controller meshes be initialized. (default: true)
  19581. */
  19582. controllerMeshes?: boolean;
  19583. /**
  19584. * Creating a default HemiLight only on controllers. (default: true)
  19585. */
  19586. defaultLightingOnControllers?: boolean;
  19587. /**
  19588. * If you don't want to use the default VR button of the helper. (default: false)
  19589. */
  19590. useCustomVRButton?: boolean;
  19591. /**
  19592. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19593. */
  19594. customVRButton?: HTMLButtonElement;
  19595. /**
  19596. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19597. */
  19598. rayLength?: number;
  19599. /**
  19600. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19601. */
  19602. defaultHeight?: number;
  19603. /**
  19604. * If multiview should be used if availible (default: false)
  19605. */
  19606. useMultiview?: boolean;
  19607. }
  19608. /**
  19609. * This represents a WebVR camera.
  19610. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19611. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19612. */
  19613. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19614. private webVROptions;
  19615. /**
  19616. * @hidden
  19617. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19618. */
  19619. _vrDevice: any;
  19620. /**
  19621. * The rawPose of the vrDevice.
  19622. */
  19623. rawPose: Nullable<DevicePose>;
  19624. private _onVREnabled;
  19625. private _specsVersion;
  19626. private _attached;
  19627. private _frameData;
  19628. protected _descendants: Array<Node>;
  19629. private _deviceRoomPosition;
  19630. /** @hidden */
  19631. _deviceRoomRotationQuaternion: Quaternion;
  19632. private _standingMatrix;
  19633. /**
  19634. * Represents device position in babylon space.
  19635. */
  19636. devicePosition: Vector3;
  19637. /**
  19638. * Represents device rotation in babylon space.
  19639. */
  19640. deviceRotationQuaternion: Quaternion;
  19641. /**
  19642. * The scale of the device to be used when translating from device space to babylon space.
  19643. */
  19644. deviceScaleFactor: number;
  19645. private _deviceToWorld;
  19646. private _worldToDevice;
  19647. /**
  19648. * References to the webVR controllers for the vrDevice.
  19649. */
  19650. controllers: Array<WebVRController>;
  19651. /**
  19652. * Emits an event when a controller is attached.
  19653. */
  19654. onControllersAttachedObservable: Observable<WebVRController[]>;
  19655. /**
  19656. * Emits an event when a controller's mesh has been loaded;
  19657. */
  19658. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19659. /**
  19660. * Emits an event when the HMD's pose has been updated.
  19661. */
  19662. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19663. private _poseSet;
  19664. /**
  19665. * If the rig cameras be used as parent instead of this camera.
  19666. */
  19667. rigParenting: boolean;
  19668. private _lightOnControllers;
  19669. private _defaultHeight?;
  19670. /**
  19671. * Instantiates a WebVRFreeCamera.
  19672. * @param name The name of the WebVRFreeCamera
  19673. * @param position The starting anchor position for the camera
  19674. * @param scene The scene the camera belongs to
  19675. * @param webVROptions a set of customizable options for the webVRCamera
  19676. */
  19677. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19678. /**
  19679. * Gets the device distance from the ground in meters.
  19680. * @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.
  19681. */
  19682. deviceDistanceToRoomGround(): number;
  19683. /**
  19684. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19685. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19686. */
  19687. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19688. /**
  19689. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19690. * @returns A promise with a boolean set to if the standing matrix is supported.
  19691. */
  19692. useStandingMatrixAsync(): Promise<boolean>;
  19693. /**
  19694. * Disposes the camera
  19695. */
  19696. dispose(): void;
  19697. /**
  19698. * Gets a vrController by name.
  19699. * @param name The name of the controller to retreive
  19700. * @returns the controller matching the name specified or null if not found
  19701. */
  19702. getControllerByName(name: string): Nullable<WebVRController>;
  19703. private _leftController;
  19704. /**
  19705. * The controller corresponding to the users left hand.
  19706. */
  19707. get leftController(): Nullable<WebVRController>;
  19708. private _rightController;
  19709. /**
  19710. * The controller corresponding to the users right hand.
  19711. */
  19712. get rightController(): Nullable<WebVRController>;
  19713. /**
  19714. * Casts a ray forward from the vrCamera's gaze.
  19715. * @param length Length of the ray (default: 100)
  19716. * @returns the ray corresponding to the gaze
  19717. */
  19718. getForwardRay(length?: number): Ray;
  19719. /**
  19720. * @hidden
  19721. * Updates the camera based on device's frame data
  19722. */
  19723. _checkInputs(): void;
  19724. /**
  19725. * Updates the poseControlled values based on the input device pose.
  19726. * @param poseData Pose coming from the device
  19727. */
  19728. updateFromDevice(poseData: DevicePose): void;
  19729. private _htmlElementAttached;
  19730. private _detachIfAttached;
  19731. /**
  19732. * WebVR's attach control will start broadcasting frames to the device.
  19733. * Note that in certain browsers (chrome for example) this function must be called
  19734. * within a user-interaction callback. Example:
  19735. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19736. *
  19737. * @param element html element to attach the vrDevice to
  19738. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19739. */
  19740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19741. /**
  19742. * Detaches the camera from the html element and disables VR
  19743. *
  19744. * @param element html element to detach from
  19745. */
  19746. detachControl(element: HTMLElement): void;
  19747. /**
  19748. * @returns the name of this class
  19749. */
  19750. getClassName(): string;
  19751. /**
  19752. * Calls resetPose on the vrDisplay
  19753. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19754. */
  19755. resetToCurrentRotation(): void;
  19756. /**
  19757. * @hidden
  19758. * Updates the rig cameras (left and right eye)
  19759. */
  19760. _updateRigCameras(): void;
  19761. private _workingVector;
  19762. private _oneVector;
  19763. private _workingMatrix;
  19764. private updateCacheCalled;
  19765. private _correctPositionIfNotTrackPosition;
  19766. /**
  19767. * @hidden
  19768. * Updates the cached values of the camera
  19769. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19770. */
  19771. _updateCache(ignoreParentClass?: boolean): void;
  19772. /**
  19773. * @hidden
  19774. * Get current device position in babylon world
  19775. */
  19776. _computeDevicePosition(): void;
  19777. /**
  19778. * Updates the current device position and rotation in the babylon world
  19779. */
  19780. update(): void;
  19781. /**
  19782. * @hidden
  19783. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19784. * @returns an identity matrix
  19785. */
  19786. _getViewMatrix(): Matrix;
  19787. private _tmpMatrix;
  19788. /**
  19789. * This function is called by the two RIG cameras.
  19790. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19791. * @hidden
  19792. */
  19793. _getWebVRViewMatrix(): Matrix;
  19794. /** @hidden */
  19795. _getWebVRProjectionMatrix(): Matrix;
  19796. private _onGamepadConnectedObserver;
  19797. private _onGamepadDisconnectedObserver;
  19798. private _updateCacheWhenTrackingDisabledObserver;
  19799. /**
  19800. * Initializes the controllers and their meshes
  19801. */
  19802. initControllers(): void;
  19803. }
  19804. }
  19805. declare module BABYLON {
  19806. /**
  19807. * Size options for a post process
  19808. */
  19809. export type PostProcessOptions = {
  19810. width: number;
  19811. height: number;
  19812. };
  19813. /**
  19814. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19815. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19816. */
  19817. export class PostProcess {
  19818. /** Name of the PostProcess. */
  19819. name: string;
  19820. /**
  19821. * Gets or sets the unique id of the post process
  19822. */
  19823. uniqueId: number;
  19824. /**
  19825. * Width of the texture to apply the post process on
  19826. */
  19827. width: number;
  19828. /**
  19829. * Height of the texture to apply the post process on
  19830. */
  19831. height: number;
  19832. /**
  19833. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19834. * @hidden
  19835. */
  19836. _outputTexture: Nullable<InternalTexture>;
  19837. /**
  19838. * Sampling mode used by the shader
  19839. * See https://doc.babylonjs.com/classes/3.1/texture
  19840. */
  19841. renderTargetSamplingMode: number;
  19842. /**
  19843. * Clear color to use when screen clearing
  19844. */
  19845. clearColor: Color4;
  19846. /**
  19847. * If the buffer needs to be cleared before applying the post process. (default: true)
  19848. * Should be set to false if shader will overwrite all previous pixels.
  19849. */
  19850. autoClear: boolean;
  19851. /**
  19852. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19853. */
  19854. alphaMode: number;
  19855. /**
  19856. * Sets the setAlphaBlendConstants of the babylon engine
  19857. */
  19858. alphaConstants: Color4;
  19859. /**
  19860. * Animations to be used for the post processing
  19861. */
  19862. animations: Animation[];
  19863. /**
  19864. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19865. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19866. */
  19867. enablePixelPerfectMode: boolean;
  19868. /**
  19869. * Force the postprocess to be applied without taking in account viewport
  19870. */
  19871. forceFullscreenViewport: boolean;
  19872. /**
  19873. * List of inspectable custom properties (used by the Inspector)
  19874. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19875. */
  19876. inspectableCustomProperties: IInspectable[];
  19877. /**
  19878. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19879. *
  19880. * | Value | Type | Description |
  19881. * | ----- | ----------------------------------- | ----------- |
  19882. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19883. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19884. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19885. *
  19886. */
  19887. scaleMode: number;
  19888. /**
  19889. * Force textures to be a power of two (default: false)
  19890. */
  19891. alwaysForcePOT: boolean;
  19892. private _samples;
  19893. /**
  19894. * Number of sample textures (default: 1)
  19895. */
  19896. get samples(): number;
  19897. set samples(n: number);
  19898. /**
  19899. * Modify the scale of the post process to be the same as the viewport (default: false)
  19900. */
  19901. adaptScaleToCurrentViewport: boolean;
  19902. private _camera;
  19903. private _scene;
  19904. private _engine;
  19905. private _options;
  19906. private _reusable;
  19907. private _textureType;
  19908. private _textureFormat;
  19909. /**
  19910. * Smart array of input and output textures for the post process.
  19911. * @hidden
  19912. */
  19913. _textures: SmartArray<InternalTexture>;
  19914. /**
  19915. * The index in _textures that corresponds to the output texture.
  19916. * @hidden
  19917. */
  19918. _currentRenderTextureInd: number;
  19919. private _effect;
  19920. private _samplers;
  19921. private _fragmentUrl;
  19922. private _vertexUrl;
  19923. private _parameters;
  19924. private _scaleRatio;
  19925. protected _indexParameters: any;
  19926. private _shareOutputWithPostProcess;
  19927. private _texelSize;
  19928. private _forcedOutputTexture;
  19929. /**
  19930. * Returns the fragment url or shader name used in the post process.
  19931. * @returns the fragment url or name in the shader store.
  19932. */
  19933. getEffectName(): string;
  19934. /**
  19935. * An event triggered when the postprocess is activated.
  19936. */
  19937. onActivateObservable: Observable<Camera>;
  19938. private _onActivateObserver;
  19939. /**
  19940. * A function that is added to the onActivateObservable
  19941. */
  19942. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19943. /**
  19944. * An event triggered when the postprocess changes its size.
  19945. */
  19946. onSizeChangedObservable: Observable<PostProcess>;
  19947. private _onSizeChangedObserver;
  19948. /**
  19949. * A function that is added to the onSizeChangedObservable
  19950. */
  19951. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19952. /**
  19953. * An event triggered when the postprocess applies its effect.
  19954. */
  19955. onApplyObservable: Observable<Effect>;
  19956. private _onApplyObserver;
  19957. /**
  19958. * A function that is added to the onApplyObservable
  19959. */
  19960. set onApply(callback: (effect: Effect) => void);
  19961. /**
  19962. * An event triggered before rendering the postprocess
  19963. */
  19964. onBeforeRenderObservable: Observable<Effect>;
  19965. private _onBeforeRenderObserver;
  19966. /**
  19967. * A function that is added to the onBeforeRenderObservable
  19968. */
  19969. set onBeforeRender(callback: (effect: Effect) => void);
  19970. /**
  19971. * An event triggered after rendering the postprocess
  19972. */
  19973. onAfterRenderObservable: Observable<Effect>;
  19974. private _onAfterRenderObserver;
  19975. /**
  19976. * A function that is added to the onAfterRenderObservable
  19977. */
  19978. set onAfterRender(callback: (efect: Effect) => void);
  19979. /**
  19980. * 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
  19981. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19982. */
  19983. get inputTexture(): InternalTexture;
  19984. set inputTexture(value: InternalTexture);
  19985. /**
  19986. * Gets the camera which post process is applied to.
  19987. * @returns The camera the post process is applied to.
  19988. */
  19989. getCamera(): Camera;
  19990. /**
  19991. * Gets the texel size of the postprocess.
  19992. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19993. */
  19994. get texelSize(): Vector2;
  19995. /**
  19996. * Creates a new instance PostProcess
  19997. * @param name The name of the PostProcess.
  19998. * @param fragmentUrl The url of the fragment shader to be used.
  19999. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20000. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20001. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20002. * @param camera The camera to apply the render pass to.
  20003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20004. * @param engine The engine which the post process will be applied. (default: current engine)
  20005. * @param reusable If the post process can be reused on the same frame. (default: false)
  20006. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20007. * @param textureType Type of textures used when performing the post process. (default: 0)
  20008. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20009. * @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
  20010. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20011. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20012. */
  20013. constructor(
  20014. /** Name of the PostProcess. */
  20015. 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, textureFormat?: number);
  20016. /**
  20017. * Gets a string idenfifying the name of the class
  20018. * @returns "PostProcess" string
  20019. */
  20020. getClassName(): string;
  20021. /**
  20022. * Gets the engine which this post process belongs to.
  20023. * @returns The engine the post process was enabled with.
  20024. */
  20025. getEngine(): Engine;
  20026. /**
  20027. * The effect that is created when initializing the post process.
  20028. * @returns The created effect corresponding the the postprocess.
  20029. */
  20030. getEffect(): Effect;
  20031. /**
  20032. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20033. * @param postProcess The post process to share the output with.
  20034. * @returns This post process.
  20035. */
  20036. shareOutputWith(postProcess: PostProcess): PostProcess;
  20037. /**
  20038. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20039. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20040. */
  20041. useOwnOutput(): void;
  20042. /**
  20043. * Updates the effect with the current post process compile time values and recompiles the shader.
  20044. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20045. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20046. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20047. * @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
  20048. * @param onCompiled Called when the shader has been compiled.
  20049. * @param onError Called if there is an error when compiling a shader.
  20050. */
  20051. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20052. /**
  20053. * The post process is reusable if it can be used multiple times within one frame.
  20054. * @returns If the post process is reusable
  20055. */
  20056. isReusable(): boolean;
  20057. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20058. markTextureDirty(): void;
  20059. /**
  20060. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20061. * 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.
  20062. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20063. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20064. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20065. * @returns The target texture that was bound to be written to.
  20066. */
  20067. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20068. /**
  20069. * If the post process is supported.
  20070. */
  20071. get isSupported(): boolean;
  20072. /**
  20073. * The aspect ratio of the output texture.
  20074. */
  20075. get aspectRatio(): number;
  20076. /**
  20077. * Get a value indicating if the post-process is ready to be used
  20078. * @returns true if the post-process is ready (shader is compiled)
  20079. */
  20080. isReady(): boolean;
  20081. /**
  20082. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20083. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20084. */
  20085. apply(): Nullable<Effect>;
  20086. private _disposeTextures;
  20087. /**
  20088. * Disposes the post process.
  20089. * @param camera The camera to dispose the post process on.
  20090. */
  20091. dispose(camera?: Camera): void;
  20092. }
  20093. }
  20094. declare module BABYLON {
  20095. /** @hidden */
  20096. export var kernelBlurVaryingDeclaration: {
  20097. name: string;
  20098. shader: string;
  20099. };
  20100. }
  20101. declare module BABYLON {
  20102. /** @hidden */
  20103. export var kernelBlurFragment: {
  20104. name: string;
  20105. shader: string;
  20106. };
  20107. }
  20108. declare module BABYLON {
  20109. /** @hidden */
  20110. export var kernelBlurFragment2: {
  20111. name: string;
  20112. shader: string;
  20113. };
  20114. }
  20115. declare module BABYLON {
  20116. /** @hidden */
  20117. export var kernelBlurPixelShader: {
  20118. name: string;
  20119. shader: string;
  20120. };
  20121. }
  20122. declare module BABYLON {
  20123. /** @hidden */
  20124. export var kernelBlurVertex: {
  20125. name: string;
  20126. shader: string;
  20127. };
  20128. }
  20129. declare module BABYLON {
  20130. /** @hidden */
  20131. export var kernelBlurVertexShader: {
  20132. name: string;
  20133. shader: string;
  20134. };
  20135. }
  20136. declare module BABYLON {
  20137. /**
  20138. * The Blur Post Process which blurs an image based on a kernel and direction.
  20139. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20140. */
  20141. export class BlurPostProcess extends PostProcess {
  20142. /** The direction in which to blur the image. */
  20143. direction: Vector2;
  20144. private blockCompilation;
  20145. protected _kernel: number;
  20146. protected _idealKernel: number;
  20147. protected _packedFloat: boolean;
  20148. private _staticDefines;
  20149. /**
  20150. * Sets the length in pixels of the blur sample region
  20151. */
  20152. set kernel(v: number);
  20153. /**
  20154. * Gets the length in pixels of the blur sample region
  20155. */
  20156. get kernel(): number;
  20157. /**
  20158. * Sets wether or not the blur needs to unpack/repack floats
  20159. */
  20160. set packedFloat(v: boolean);
  20161. /**
  20162. * Gets wether or not the blur is unpacking/repacking floats
  20163. */
  20164. get packedFloat(): boolean;
  20165. /**
  20166. * Creates a new instance BlurPostProcess
  20167. * @param name The name of the effect.
  20168. * @param direction The direction in which to blur the image.
  20169. * @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.
  20170. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20171. * @param camera The camera to apply the render pass to.
  20172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20173. * @param engine The engine which the post process will be applied. (default: current engine)
  20174. * @param reusable If the post process can be reused on the same frame. (default: false)
  20175. * @param textureType Type of textures used when performing the post process. (default: 0)
  20176. * @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)
  20177. */
  20178. constructor(name: string,
  20179. /** The direction in which to blur the image. */
  20180. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20181. /**
  20182. * Updates the effect with the current post process compile time values and recompiles the shader.
  20183. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20184. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20185. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20186. * @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
  20187. * @param onCompiled Called when the shader has been compiled.
  20188. * @param onError Called if there is an error when compiling a shader.
  20189. */
  20190. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20191. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20192. /**
  20193. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20194. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20195. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20196. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20197. * The gaps between physical kernels are compensated for in the weighting of the samples
  20198. * @param idealKernel Ideal blur kernel.
  20199. * @return Nearest best kernel.
  20200. */
  20201. protected _nearestBestKernel(idealKernel: number): number;
  20202. /**
  20203. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20204. * @param x The point on the Gaussian distribution to sample.
  20205. * @return the value of the Gaussian function at x.
  20206. */
  20207. protected _gaussianWeight(x: number): number;
  20208. /**
  20209. * Generates a string that can be used as a floating point number in GLSL.
  20210. * @param x Value to print.
  20211. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20212. * @return GLSL float string.
  20213. */
  20214. protected _glslFloat(x: number, decimalFigures?: number): string;
  20215. }
  20216. }
  20217. declare module BABYLON {
  20218. /**
  20219. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20220. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20221. * You can then easily use it as a reflectionTexture on a flat surface.
  20222. * In case the surface is not a plane, please consider relying on reflection probes.
  20223. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20224. */
  20225. export class MirrorTexture extends RenderTargetTexture {
  20226. private scene;
  20227. /**
  20228. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20229. * 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.
  20230. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20231. */
  20232. mirrorPlane: Plane;
  20233. /**
  20234. * Define the blur ratio used to blur the reflection if needed.
  20235. */
  20236. set blurRatio(value: number);
  20237. get blurRatio(): number;
  20238. /**
  20239. * Define the adaptive blur kernel used to blur the reflection if needed.
  20240. * This will autocompute the closest best match for the `blurKernel`
  20241. */
  20242. set adaptiveBlurKernel(value: number);
  20243. /**
  20244. * Define the blur kernel used to blur the reflection if needed.
  20245. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20246. */
  20247. set blurKernel(value: number);
  20248. /**
  20249. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20250. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20251. */
  20252. set blurKernelX(value: number);
  20253. get blurKernelX(): number;
  20254. /**
  20255. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20256. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20257. */
  20258. set blurKernelY(value: number);
  20259. get blurKernelY(): number;
  20260. private _autoComputeBlurKernel;
  20261. protected _onRatioRescale(): void;
  20262. private _updateGammaSpace;
  20263. private _imageProcessingConfigChangeObserver;
  20264. private _transformMatrix;
  20265. private _mirrorMatrix;
  20266. private _savedViewMatrix;
  20267. private _blurX;
  20268. private _blurY;
  20269. private _adaptiveBlurKernel;
  20270. private _blurKernelX;
  20271. private _blurKernelY;
  20272. private _blurRatio;
  20273. /**
  20274. * Instantiates a Mirror Texture.
  20275. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20276. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20277. * You can then easily use it as a reflectionTexture on a flat surface.
  20278. * In case the surface is not a plane, please consider relying on reflection probes.
  20279. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20280. * @param name
  20281. * @param size
  20282. * @param scene
  20283. * @param generateMipMaps
  20284. * @param type
  20285. * @param samplingMode
  20286. * @param generateDepthBuffer
  20287. */
  20288. constructor(name: string, size: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20294. private _preparePostProcesses;
  20295. /**
  20296. * Clone the mirror texture.
  20297. * @returns the cloned texture
  20298. */
  20299. clone(): MirrorTexture;
  20300. /**
  20301. * Serialize the texture to a JSON representation you could use in Parse later on
  20302. * @returns the serialized JSON representation
  20303. */
  20304. serialize(): any;
  20305. /**
  20306. * Dispose the texture and release its associated resources.
  20307. */
  20308. dispose(): void;
  20309. }
  20310. }
  20311. declare module BABYLON {
  20312. /**
  20313. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20314. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20315. */
  20316. export class Texture extends BaseTexture {
  20317. /**
  20318. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20319. */
  20320. static SerializeBuffers: boolean;
  20321. /** @hidden */
  20322. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20323. /** @hidden */
  20324. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20325. /** @hidden */
  20326. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20327. /** nearest is mag = nearest and min = nearest and mip = linear */
  20328. static readonly NEAREST_SAMPLINGMODE: number;
  20329. /** nearest is mag = nearest and min = nearest and mip = linear */
  20330. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20332. static readonly BILINEAR_SAMPLINGMODE: number;
  20333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20334. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20335. /** Trilinear is mag = linear and min = linear and mip = linear */
  20336. static readonly TRILINEAR_SAMPLINGMODE: number;
  20337. /** Trilinear is mag = linear and min = linear and mip = linear */
  20338. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20339. /** mag = nearest and min = nearest and mip = nearest */
  20340. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20341. /** mag = nearest and min = linear and mip = nearest */
  20342. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20343. /** mag = nearest and min = linear and mip = linear */
  20344. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20345. /** mag = nearest and min = linear and mip = none */
  20346. static readonly NEAREST_LINEAR: number;
  20347. /** mag = nearest and min = nearest and mip = none */
  20348. static readonly NEAREST_NEAREST: number;
  20349. /** mag = linear and min = nearest and mip = nearest */
  20350. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20351. /** mag = linear and min = nearest and mip = linear */
  20352. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20353. /** mag = linear and min = linear and mip = none */
  20354. static readonly LINEAR_LINEAR: number;
  20355. /** mag = linear and min = nearest and mip = none */
  20356. static readonly LINEAR_NEAREST: number;
  20357. /** Explicit coordinates mode */
  20358. static readonly EXPLICIT_MODE: number;
  20359. /** Spherical coordinates mode */
  20360. static readonly SPHERICAL_MODE: number;
  20361. /** Planar coordinates mode */
  20362. static readonly PLANAR_MODE: number;
  20363. /** Cubic coordinates mode */
  20364. static readonly CUBIC_MODE: number;
  20365. /** Projection coordinates mode */
  20366. static readonly PROJECTION_MODE: number;
  20367. /** Inverse Cubic coordinates mode */
  20368. static readonly SKYBOX_MODE: number;
  20369. /** Inverse Cubic coordinates mode */
  20370. static readonly INVCUBIC_MODE: number;
  20371. /** Equirectangular coordinates mode */
  20372. static readonly EQUIRECTANGULAR_MODE: number;
  20373. /** Equirectangular Fixed coordinates mode */
  20374. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20375. /** Equirectangular Fixed Mirrored coordinates mode */
  20376. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20377. /** Texture is not repeating outside of 0..1 UVs */
  20378. static readonly CLAMP_ADDRESSMODE: number;
  20379. /** Texture is repeating outside of 0..1 UVs */
  20380. static readonly WRAP_ADDRESSMODE: number;
  20381. /** Texture is repeating and mirrored */
  20382. static readonly MIRROR_ADDRESSMODE: number;
  20383. /**
  20384. * 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
  20385. */
  20386. static UseSerializedUrlIfAny: boolean;
  20387. /**
  20388. * Define the url of the texture.
  20389. */
  20390. url: Nullable<string>;
  20391. /**
  20392. * Define an offset on the texture to offset the u coordinates of the UVs
  20393. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20394. */
  20395. uOffset: number;
  20396. /**
  20397. * Define an offset on the texture to offset the v coordinates of the UVs
  20398. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20399. */
  20400. vOffset: number;
  20401. /**
  20402. * Define an offset on the texture to scale the u coordinates of the UVs
  20403. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20404. */
  20405. uScale: number;
  20406. /**
  20407. * Define an offset on the texture to scale the v coordinates of the UVs
  20408. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20409. */
  20410. vScale: number;
  20411. /**
  20412. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20413. * @see http://doc.babylonjs.com/how_to/more_materials
  20414. */
  20415. uAng: number;
  20416. /**
  20417. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20418. * @see http://doc.babylonjs.com/how_to/more_materials
  20419. */
  20420. vAng: number;
  20421. /**
  20422. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20423. * @see http://doc.babylonjs.com/how_to/more_materials
  20424. */
  20425. wAng: number;
  20426. /**
  20427. * Defines the center of rotation (U)
  20428. */
  20429. uRotationCenter: number;
  20430. /**
  20431. * Defines the center of rotation (V)
  20432. */
  20433. vRotationCenter: number;
  20434. /**
  20435. * Defines the center of rotation (W)
  20436. */
  20437. wRotationCenter: number;
  20438. /**
  20439. * Are mip maps generated for this texture or not.
  20440. */
  20441. get noMipmap(): boolean;
  20442. /**
  20443. * List of inspectable custom properties (used by the Inspector)
  20444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20445. */
  20446. inspectableCustomProperties: Nullable<IInspectable[]>;
  20447. private _noMipmap;
  20448. /** @hidden */
  20449. _invertY: boolean;
  20450. private _rowGenerationMatrix;
  20451. private _cachedTextureMatrix;
  20452. private _projectionModeMatrix;
  20453. private _t0;
  20454. private _t1;
  20455. private _t2;
  20456. private _cachedUOffset;
  20457. private _cachedVOffset;
  20458. private _cachedUScale;
  20459. private _cachedVScale;
  20460. private _cachedUAng;
  20461. private _cachedVAng;
  20462. private _cachedWAng;
  20463. private _cachedProjectionMatrixId;
  20464. private _cachedCoordinatesMode;
  20465. /** @hidden */
  20466. protected _initialSamplingMode: number;
  20467. /** @hidden */
  20468. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20469. private _deleteBuffer;
  20470. protected _format: Nullable<number>;
  20471. private _delayedOnLoad;
  20472. private _delayedOnError;
  20473. private _mimeType?;
  20474. /**
  20475. * Observable triggered once the texture has been loaded.
  20476. */
  20477. onLoadObservable: Observable<Texture>;
  20478. protected _isBlocking: boolean;
  20479. /**
  20480. * Is the texture preventing material to render while loading.
  20481. * If false, a default texture will be used instead of the loading one during the preparation step.
  20482. */
  20483. set isBlocking(value: boolean);
  20484. get isBlocking(): boolean;
  20485. /**
  20486. * Get the current sampling mode associated with the texture.
  20487. */
  20488. get samplingMode(): number;
  20489. /**
  20490. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20491. */
  20492. get invertY(): boolean;
  20493. /**
  20494. * Instantiates a new texture.
  20495. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20496. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20497. * @param url defines the url of the picture to load as a texture
  20498. * @param scene defines the scene or engine the texture will belong to
  20499. * @param noMipmap defines if the texture will require mip maps or not
  20500. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20501. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20502. * @param onLoad defines a callback triggered when the texture has been loaded
  20503. * @param onError defines a callback triggered when an error occurred during the loading session
  20504. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20505. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20506. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20507. * @param mimeType defines an optional mime type information
  20508. */
  20509. 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);
  20510. /**
  20511. * Update the url (and optional buffer) of this texture if url was null during construction.
  20512. * @param url the url of the texture
  20513. * @param buffer the buffer of the texture (defaults to null)
  20514. * @param onLoad callback called when the texture is loaded (defaults to null)
  20515. */
  20516. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20517. /**
  20518. * Finish the loading sequence of a texture flagged as delayed load.
  20519. * @hidden
  20520. */
  20521. delayLoad(): void;
  20522. private _prepareRowForTextureGeneration;
  20523. /**
  20524. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20525. * @returns the transform matrix of the texture.
  20526. */
  20527. getTextureMatrix(uBase?: number): Matrix;
  20528. /**
  20529. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20530. * @returns The reflection texture transform
  20531. */
  20532. getReflectionTextureMatrix(): Matrix;
  20533. /**
  20534. * Clones the texture.
  20535. * @returns the cloned texture
  20536. */
  20537. clone(): Texture;
  20538. /**
  20539. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20540. * @returns The JSON representation of the texture
  20541. */
  20542. serialize(): any;
  20543. /**
  20544. * Get the current class name of the texture useful for serialization or dynamic coding.
  20545. * @returns "Texture"
  20546. */
  20547. getClassName(): string;
  20548. /**
  20549. * Dispose the texture and release its associated resources.
  20550. */
  20551. dispose(): void;
  20552. /**
  20553. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20554. * @param parsedTexture Define the JSON representation of the texture
  20555. * @param scene Define the scene the parsed texture should be instantiated in
  20556. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20557. * @returns The parsed texture if successful
  20558. */
  20559. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20560. /**
  20561. * Creates a texture from its base 64 representation.
  20562. * @param data Define the base64 payload without the data: prefix
  20563. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20564. * @param scene Define the scene the texture should belong to
  20565. * @param noMipmap Forces the texture to not create mip map information if true
  20566. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20567. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20568. * @param onLoad define a callback triggered when the texture has been loaded
  20569. * @param onError define a callback triggered when an error occurred during the loading session
  20570. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20571. * @returns the created texture
  20572. */
  20573. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20574. /**
  20575. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20576. * @param data Define the base64 payload without the data: prefix
  20577. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20578. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20579. * @param scene Define the scene the texture should belong to
  20580. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20581. * @param noMipmap Forces the texture to not create mip map information if true
  20582. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20583. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20584. * @param onLoad define a callback triggered when the texture has been loaded
  20585. * @param onError define a callback triggered when an error occurred during the loading session
  20586. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20587. * @returns the created texture
  20588. */
  20589. 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;
  20590. }
  20591. }
  20592. declare module BABYLON {
  20593. /**
  20594. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20595. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20596. */
  20597. export class PostProcessManager {
  20598. private _scene;
  20599. private _indexBuffer;
  20600. private _vertexBuffers;
  20601. /**
  20602. * Creates a new instance PostProcess
  20603. * @param scene The scene that the post process is associated with.
  20604. */
  20605. constructor(scene: Scene);
  20606. private _prepareBuffers;
  20607. private _buildIndexBuffer;
  20608. /**
  20609. * Rebuilds the vertex buffers of the manager.
  20610. * @hidden
  20611. */
  20612. _rebuild(): void;
  20613. /**
  20614. * Prepares a frame to be run through a post process.
  20615. * @param sourceTexture The input texture to the post procesess. (default: null)
  20616. * @param postProcesses An array of post processes to be run. (default: null)
  20617. * @returns True if the post processes were able to be run.
  20618. * @hidden
  20619. */
  20620. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20621. /**
  20622. * Manually render a set of post processes to a texture.
  20623. * @param postProcesses An array of post processes to be run.
  20624. * @param targetTexture The target texture to render to.
  20625. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20626. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20627. * @param lodLevel defines which lod of the texture to render to
  20628. */
  20629. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20630. /**
  20631. * Finalize the result of the output of the postprocesses.
  20632. * @param doNotPresent If true the result will not be displayed to the screen.
  20633. * @param targetTexture The target texture to render to.
  20634. * @param faceIndex The index of the face to bind the target texture to.
  20635. * @param postProcesses The array of post processes to render.
  20636. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20637. * @hidden
  20638. */
  20639. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20640. /**
  20641. * Disposes of the post process manager.
  20642. */
  20643. dispose(): void;
  20644. }
  20645. }
  20646. declare module BABYLON {
  20647. /**
  20648. * This Helps creating a texture that will be created from a camera in your scene.
  20649. * It is basically a dynamic texture that could be used to create special effects for instance.
  20650. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20651. */
  20652. export class RenderTargetTexture extends Texture {
  20653. isCube: boolean;
  20654. /**
  20655. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20656. */
  20657. static readonly REFRESHRATE_RENDER_ONCE: number;
  20658. /**
  20659. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20660. */
  20661. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20662. /**
  20663. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20664. * the central point of your effect and can save a lot of performances.
  20665. */
  20666. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20667. /**
  20668. * Use this predicate to dynamically define the list of mesh you want to render.
  20669. * If set, the renderList property will be overwritten.
  20670. */
  20671. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20672. private _renderList;
  20673. /**
  20674. * Use this list to define the list of mesh you want to render.
  20675. */
  20676. get renderList(): Nullable<Array<AbstractMesh>>;
  20677. set renderList(value: Nullable<Array<AbstractMesh>>);
  20678. /**
  20679. * Use this function to overload the renderList array at rendering time.
  20680. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20681. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20682. * the cube (if the RTT is a cube, else layerOrFace=0).
  20683. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20684. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20685. * hold dummy elements!
  20686. */
  20687. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20688. private _hookArray;
  20689. /**
  20690. * Define if particles should be rendered in your texture.
  20691. */
  20692. renderParticles: boolean;
  20693. /**
  20694. * Define if sprites should be rendered in your texture.
  20695. */
  20696. renderSprites: boolean;
  20697. /**
  20698. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20699. */
  20700. coordinatesMode: number;
  20701. /**
  20702. * Define the camera used to render the texture.
  20703. */
  20704. activeCamera: Nullable<Camera>;
  20705. /**
  20706. * Override the mesh isReady function with your own one.
  20707. */
  20708. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20709. /**
  20710. * Override the render function of the texture with your own one.
  20711. */
  20712. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20713. /**
  20714. * Define if camera post processes should be use while rendering the texture.
  20715. */
  20716. useCameraPostProcesses: boolean;
  20717. /**
  20718. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20719. */
  20720. ignoreCameraViewport: boolean;
  20721. private _postProcessManager;
  20722. private _postProcesses;
  20723. private _resizeObserver;
  20724. /**
  20725. * An event triggered when the texture is unbind.
  20726. */
  20727. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20728. /**
  20729. * An event triggered when the texture is unbind.
  20730. */
  20731. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20732. private _onAfterUnbindObserver;
  20733. /**
  20734. * Set a after unbind callback in the texture.
  20735. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20736. */
  20737. set onAfterUnbind(callback: () => void);
  20738. /**
  20739. * An event triggered before rendering the texture
  20740. */
  20741. onBeforeRenderObservable: Observable<number>;
  20742. private _onBeforeRenderObserver;
  20743. /**
  20744. * Set a before render callback in the texture.
  20745. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20746. */
  20747. set onBeforeRender(callback: (faceIndex: number) => void);
  20748. /**
  20749. * An event triggered after rendering the texture
  20750. */
  20751. onAfterRenderObservable: Observable<number>;
  20752. private _onAfterRenderObserver;
  20753. /**
  20754. * Set a after render callback in the texture.
  20755. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20756. */
  20757. set onAfterRender(callback: (faceIndex: number) => void);
  20758. /**
  20759. * An event triggered after the texture clear
  20760. */
  20761. onClearObservable: Observable<Engine>;
  20762. private _onClearObserver;
  20763. /**
  20764. * Set a clear callback in the texture.
  20765. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20766. */
  20767. set onClear(callback: (Engine: Engine) => void);
  20768. /**
  20769. * An event triggered when the texture is resized.
  20770. */
  20771. onResizeObservable: Observable<RenderTargetTexture>;
  20772. /**
  20773. * Define the clear color of the Render Target if it should be different from the scene.
  20774. */
  20775. clearColor: Color4;
  20776. protected _size: number | {
  20777. width: number;
  20778. height: number;
  20779. layers?: number;
  20780. };
  20781. protected _initialSizeParameter: number | {
  20782. width: number;
  20783. height: number;
  20784. } | {
  20785. ratio: number;
  20786. };
  20787. protected _sizeRatio: Nullable<number>;
  20788. /** @hidden */
  20789. _generateMipMaps: boolean;
  20790. protected _renderingManager: RenderingManager;
  20791. /** @hidden */
  20792. _waitingRenderList: string[];
  20793. protected _doNotChangeAspectRatio: boolean;
  20794. protected _currentRefreshId: number;
  20795. protected _refreshRate: number;
  20796. protected _textureMatrix: Matrix;
  20797. protected _samples: number;
  20798. protected _renderTargetOptions: RenderTargetCreationOptions;
  20799. /**
  20800. * Gets render target creation options that were used.
  20801. */
  20802. get renderTargetOptions(): RenderTargetCreationOptions;
  20803. protected _engine: Engine;
  20804. protected _onRatioRescale(): void;
  20805. /**
  20806. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20807. * It must define where the camera used to render the texture is set
  20808. */
  20809. boundingBoxPosition: Vector3;
  20810. private _boundingBoxSize;
  20811. /**
  20812. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20813. * When defined, the cubemap will switch to local mode
  20814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20815. * @example https://www.babylonjs-playground.com/#RNASML
  20816. */
  20817. set boundingBoxSize(value: Vector3);
  20818. get boundingBoxSize(): Vector3;
  20819. /**
  20820. * In case the RTT has been created with a depth texture, get the associated
  20821. * depth texture.
  20822. * Otherwise, return null.
  20823. */
  20824. get depthStencilTexture(): Nullable<InternalTexture>;
  20825. /**
  20826. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20827. * or used a shadow, depth texture...
  20828. * @param name The friendly name of the texture
  20829. * @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)
  20830. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20831. * @param generateMipMaps True if mip maps need to be generated after render.
  20832. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20833. * @param type The type of the buffer in the RTT (int, half float, float...)
  20834. * @param isCube True if a cube texture needs to be created
  20835. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20836. * @param generateDepthBuffer True to generate a depth buffer
  20837. * @param generateStencilBuffer True to generate a stencil buffer
  20838. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20839. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20840. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20841. */
  20842. constructor(name: string, size: number | {
  20843. width: number;
  20844. height: number;
  20845. layers?: number;
  20846. } | {
  20847. ratio: number;
  20848. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20849. /**
  20850. * Creates a depth stencil texture.
  20851. * This is only available in WebGL 2 or with the depth texture extension available.
  20852. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20853. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20854. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20855. */
  20856. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20857. private _processSizeParameter;
  20858. /**
  20859. * Define the number of samples to use in case of MSAA.
  20860. * It defaults to one meaning no MSAA has been enabled.
  20861. */
  20862. get samples(): number;
  20863. set samples(value: number);
  20864. /**
  20865. * Resets the refresh counter of the texture and start bak from scratch.
  20866. * Could be useful to regenerate the texture if it is setup to render only once.
  20867. */
  20868. resetRefreshCounter(): void;
  20869. /**
  20870. * Define the refresh rate of the texture or the rendering frequency.
  20871. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20872. */
  20873. get refreshRate(): number;
  20874. set refreshRate(value: number);
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Gets the actual number of layers of the texture.
  20909. * @returns the number of layers
  20910. */
  20911. getRenderLayers(): number;
  20912. /**
  20913. * Get if the texture can be rescaled or not.
  20914. */
  20915. get canRescale(): boolean;
  20916. /**
  20917. * Resize the texture using a ratio.
  20918. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20919. */
  20920. scale(ratio: number): void;
  20921. /**
  20922. * Get the texture reflection matrix used to rotate/transform the reflection.
  20923. * @returns the reflection matrix
  20924. */
  20925. getReflectionTextureMatrix(): Matrix;
  20926. /**
  20927. * Resize the texture to a new desired size.
  20928. * Be carrefull as it will recreate all the data in the new texture.
  20929. * @param size Define the new size. It can be:
  20930. * - a number for squared texture,
  20931. * - an object containing { width: number, height: number }
  20932. * - or an object containing a ratio { ratio: number }
  20933. */
  20934. resize(size: number | {
  20935. width: number;
  20936. height: number;
  20937. } | {
  20938. ratio: number;
  20939. }): void;
  20940. private _defaultRenderListPrepared;
  20941. /**
  20942. * Renders all the objects from the render list into the texture.
  20943. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20944. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20945. */
  20946. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20947. private _bestReflectionRenderTargetDimension;
  20948. private _prepareRenderingManager;
  20949. /**
  20950. * @hidden
  20951. * @param faceIndex face index to bind to if this is a cubetexture
  20952. * @param layer defines the index of the texture to bind in the array
  20953. */
  20954. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20955. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20956. private renderToTarget;
  20957. /**
  20958. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20959. * This allowed control for front to back rendering or reversly depending of the special needs.
  20960. *
  20961. * @param renderingGroupId The rendering group id corresponding to its index
  20962. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20963. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20964. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20965. */
  20966. 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;
  20967. /**
  20968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20969. *
  20970. * @param renderingGroupId The rendering group id corresponding to its index
  20971. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20972. */
  20973. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20974. /**
  20975. * Clones the texture.
  20976. * @returns the cloned texture
  20977. */
  20978. clone(): RenderTargetTexture;
  20979. /**
  20980. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20981. * @returns The JSON representation of the texture
  20982. */
  20983. serialize(): any;
  20984. /**
  20985. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20986. */
  20987. disposeFramebufferObjects(): void;
  20988. /**
  20989. * Dispose the texture and release its associated resources.
  20990. */
  20991. dispose(): void;
  20992. /** @hidden */
  20993. _rebuild(): void;
  20994. /**
  20995. * Clear the info related to rendering groups preventing retention point in material dispose.
  20996. */
  20997. freeRenderingGroups(): void;
  20998. /**
  20999. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21000. * @returns the view count
  21001. */
  21002. getViewCount(): number;
  21003. }
  21004. }
  21005. declare module BABYLON {
  21006. /**
  21007. * Class used to manipulate GUIDs
  21008. */
  21009. export class GUID {
  21010. /**
  21011. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21012. * Be aware Math.random() could cause collisions, but:
  21013. * "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"
  21014. * @returns a pseudo random id
  21015. */
  21016. static RandomId(): string;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /**
  21021. * Options to be used when creating a shadow depth material
  21022. */
  21023. export interface IIOptionShadowDepthMaterial {
  21024. /** Variables in the vertex shader code that need to have their names remapped.
  21025. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21026. * "var_name" should be either: worldPos or vNormalW
  21027. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21028. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21029. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21030. */
  21031. remappedVariables?: string[];
  21032. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21033. standalone?: boolean;
  21034. }
  21035. /**
  21036. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21037. */
  21038. export class ShadowDepthWrapper {
  21039. private _scene;
  21040. private _options?;
  21041. private _baseMaterial;
  21042. private _onEffectCreatedObserver;
  21043. private _subMeshToEffect;
  21044. private _subMeshToDepthEffect;
  21045. private _meshes;
  21046. /** @hidden */
  21047. _matriceNames: any;
  21048. /** Gets the standalone status of the wrapper */
  21049. get standalone(): boolean;
  21050. /** Gets the base material the wrapper is built upon */
  21051. get baseMaterial(): Material;
  21052. /**
  21053. * Instantiate a new shadow depth wrapper.
  21054. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21055. * generate the shadow depth map. For more information, please refer to the documentation:
  21056. * https://doc.babylonjs.com/babylon101/shadows
  21057. * @param baseMaterial Material to wrap
  21058. * @param scene Define the scene the material belongs to
  21059. * @param options Options used to create the wrapper
  21060. */
  21061. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21062. /**
  21063. * Gets the effect to use to generate the depth map
  21064. * @param subMesh subMesh to get the effect for
  21065. * @param shadowGenerator shadow generator to get the effect for
  21066. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21067. */
  21068. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21069. /**
  21070. * Specifies that the submesh is ready to be used for depth rendering
  21071. * @param subMesh submesh to check
  21072. * @param defines the list of defines to take into account when checking the effect
  21073. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21074. * @param useInstances specifies that instances should be used
  21075. * @returns a boolean indicating that the submesh is ready or not
  21076. */
  21077. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21078. /**
  21079. * Disposes the resources
  21080. */
  21081. dispose(): void;
  21082. private _makeEffect;
  21083. }
  21084. }
  21085. declare module BABYLON {
  21086. /**
  21087. * Options for compiling materials.
  21088. */
  21089. export interface IMaterialCompilationOptions {
  21090. /**
  21091. * Defines whether clip planes are enabled.
  21092. */
  21093. clipPlane: boolean;
  21094. /**
  21095. * Defines whether instances are enabled.
  21096. */
  21097. useInstances: boolean;
  21098. }
  21099. /**
  21100. * Base class for the main features of a material in Babylon.js
  21101. */
  21102. export class Material implements IAnimatable {
  21103. /**
  21104. * Returns the triangle fill mode
  21105. */
  21106. static readonly TriangleFillMode: number;
  21107. /**
  21108. * Returns the wireframe mode
  21109. */
  21110. static readonly WireFrameFillMode: number;
  21111. /**
  21112. * Returns the point fill mode
  21113. */
  21114. static readonly PointFillMode: number;
  21115. /**
  21116. * Returns the point list draw mode
  21117. */
  21118. static readonly PointListDrawMode: number;
  21119. /**
  21120. * Returns the line list draw mode
  21121. */
  21122. static readonly LineListDrawMode: number;
  21123. /**
  21124. * Returns the line loop draw mode
  21125. */
  21126. static readonly LineLoopDrawMode: number;
  21127. /**
  21128. * Returns the line strip draw mode
  21129. */
  21130. static readonly LineStripDrawMode: number;
  21131. /**
  21132. * Returns the triangle strip draw mode
  21133. */
  21134. static readonly TriangleStripDrawMode: number;
  21135. /**
  21136. * Returns the triangle fan draw mode
  21137. */
  21138. static readonly TriangleFanDrawMode: number;
  21139. /**
  21140. * Stores the clock-wise side orientation
  21141. */
  21142. static readonly ClockWiseSideOrientation: number;
  21143. /**
  21144. * Stores the counter clock-wise side orientation
  21145. */
  21146. static readonly CounterClockWiseSideOrientation: number;
  21147. /**
  21148. * The dirty texture flag value
  21149. */
  21150. static readonly TextureDirtyFlag: number;
  21151. /**
  21152. * The dirty light flag value
  21153. */
  21154. static readonly LightDirtyFlag: number;
  21155. /**
  21156. * The dirty fresnel flag value
  21157. */
  21158. static readonly FresnelDirtyFlag: number;
  21159. /**
  21160. * The dirty attribute flag value
  21161. */
  21162. static readonly AttributesDirtyFlag: number;
  21163. /**
  21164. * The dirty misc flag value
  21165. */
  21166. static readonly MiscDirtyFlag: number;
  21167. /**
  21168. * The all dirty flag value
  21169. */
  21170. static readonly AllDirtyFlag: number;
  21171. /**
  21172. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21173. */
  21174. static readonly MATERIAL_OPAQUE: number;
  21175. /**
  21176. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21177. */
  21178. static readonly MATERIAL_ALPHATEST: number;
  21179. /**
  21180. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21181. */
  21182. static readonly MATERIAL_ALPHABLEND: number;
  21183. /**
  21184. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21185. * They are also discarded below the alpha cutoff threshold to improve performances.
  21186. */
  21187. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21188. /**
  21189. * Custom callback helping to override the default shader used in the material.
  21190. */
  21191. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21192. /**
  21193. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21194. */
  21195. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21196. /**
  21197. * The ID of the material
  21198. */
  21199. id: string;
  21200. /**
  21201. * Gets or sets the unique id of the material
  21202. */
  21203. uniqueId: number;
  21204. /**
  21205. * The name of the material
  21206. */
  21207. name: string;
  21208. /**
  21209. * Gets or sets user defined metadata
  21210. */
  21211. metadata: any;
  21212. /**
  21213. * For internal use only. Please do not use.
  21214. */
  21215. reservedDataStore: any;
  21216. /**
  21217. * Specifies if the ready state should be checked on each call
  21218. */
  21219. checkReadyOnEveryCall: boolean;
  21220. /**
  21221. * Specifies if the ready state should be checked once
  21222. */
  21223. checkReadyOnlyOnce: boolean;
  21224. /**
  21225. * The state of the material
  21226. */
  21227. state: string;
  21228. /**
  21229. * The alpha value of the material
  21230. */
  21231. protected _alpha: number;
  21232. /**
  21233. * List of inspectable custom properties (used by the Inspector)
  21234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21235. */
  21236. inspectableCustomProperties: IInspectable[];
  21237. /**
  21238. * Sets the alpha value of the material
  21239. */
  21240. set alpha(value: number);
  21241. /**
  21242. * Gets the alpha value of the material
  21243. */
  21244. get alpha(): number;
  21245. /**
  21246. * Specifies if back face culling is enabled
  21247. */
  21248. protected _backFaceCulling: boolean;
  21249. /**
  21250. * Sets the back-face culling state
  21251. */
  21252. set backFaceCulling(value: boolean);
  21253. /**
  21254. * Gets the back-face culling state
  21255. */
  21256. get backFaceCulling(): boolean;
  21257. /**
  21258. * Stores the value for side orientation
  21259. */
  21260. sideOrientation: number;
  21261. /**
  21262. * Callback triggered when the material is compiled
  21263. */
  21264. onCompiled: Nullable<(effect: Effect) => void>;
  21265. /**
  21266. * Callback triggered when an error occurs
  21267. */
  21268. onError: Nullable<(effect: Effect, errors: string) => void>;
  21269. /**
  21270. * Callback triggered to get the render target textures
  21271. */
  21272. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21273. /**
  21274. * Gets a boolean indicating that current material needs to register RTT
  21275. */
  21276. get hasRenderTargetTextures(): boolean;
  21277. /**
  21278. * Specifies if the material should be serialized
  21279. */
  21280. doNotSerialize: boolean;
  21281. /**
  21282. * @hidden
  21283. */
  21284. _storeEffectOnSubMeshes: boolean;
  21285. /**
  21286. * Stores the animations for the material
  21287. */
  21288. animations: Nullable<Array<Animation>>;
  21289. /**
  21290. * An event triggered when the material is disposed
  21291. */
  21292. onDisposeObservable: Observable<Material>;
  21293. /**
  21294. * An observer which watches for dispose events
  21295. */
  21296. private _onDisposeObserver;
  21297. private _onUnBindObservable;
  21298. /**
  21299. * Called during a dispose event
  21300. */
  21301. set onDispose(callback: () => void);
  21302. private _onBindObservable;
  21303. /**
  21304. * An event triggered when the material is bound
  21305. */
  21306. get onBindObservable(): Observable<AbstractMesh>;
  21307. /**
  21308. * An observer which watches for bind events
  21309. */
  21310. private _onBindObserver;
  21311. /**
  21312. * Called during a bind event
  21313. */
  21314. set onBind(callback: (Mesh: AbstractMesh) => void);
  21315. /**
  21316. * An event triggered when the material is unbound
  21317. */
  21318. get onUnBindObservable(): Observable<Material>;
  21319. protected _onEffectCreatedObservable: Nullable<Observable<{
  21320. effect: Effect;
  21321. subMesh: Nullable<SubMesh>;
  21322. }>>;
  21323. /**
  21324. * An event triggered when the effect is (re)created
  21325. */
  21326. get onEffectCreatedObservable(): Observable<{
  21327. effect: Effect;
  21328. subMesh: Nullable<SubMesh>;
  21329. }>;
  21330. /**
  21331. * Stores the value of the alpha mode
  21332. */
  21333. private _alphaMode;
  21334. /**
  21335. * Sets the value of the alpha mode.
  21336. *
  21337. * | Value | Type | Description |
  21338. * | --- | --- | --- |
  21339. * | 0 | ALPHA_DISABLE | |
  21340. * | 1 | ALPHA_ADD | |
  21341. * | 2 | ALPHA_COMBINE | |
  21342. * | 3 | ALPHA_SUBTRACT | |
  21343. * | 4 | ALPHA_MULTIPLY | |
  21344. * | 5 | ALPHA_MAXIMIZED | |
  21345. * | 6 | ALPHA_ONEONE | |
  21346. * | 7 | ALPHA_PREMULTIPLIED | |
  21347. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21348. * | 9 | ALPHA_INTERPOLATE | |
  21349. * | 10 | ALPHA_SCREENMODE | |
  21350. *
  21351. */
  21352. set alphaMode(value: number);
  21353. /**
  21354. * Gets the value of the alpha mode
  21355. */
  21356. get alphaMode(): number;
  21357. /**
  21358. * Stores the state of the need depth pre-pass value
  21359. */
  21360. private _needDepthPrePass;
  21361. /**
  21362. * Sets the need depth pre-pass value
  21363. */
  21364. set needDepthPrePass(value: boolean);
  21365. /**
  21366. * Gets the depth pre-pass value
  21367. */
  21368. get needDepthPrePass(): boolean;
  21369. /**
  21370. * Specifies if depth writing should be disabled
  21371. */
  21372. disableDepthWrite: boolean;
  21373. /**
  21374. * Specifies if color writing should be disabled
  21375. */
  21376. disableColorWrite: boolean;
  21377. /**
  21378. * Specifies if depth writing should be forced
  21379. */
  21380. forceDepthWrite: boolean;
  21381. /**
  21382. * Specifies the depth function that should be used. 0 means the default engine function
  21383. */
  21384. depthFunction: number;
  21385. /**
  21386. * Specifies if there should be a separate pass for culling
  21387. */
  21388. separateCullingPass: boolean;
  21389. /**
  21390. * Stores the state specifing if fog should be enabled
  21391. */
  21392. private _fogEnabled;
  21393. /**
  21394. * Sets the state for enabling fog
  21395. */
  21396. set fogEnabled(value: boolean);
  21397. /**
  21398. * Gets the value of the fog enabled state
  21399. */
  21400. get fogEnabled(): boolean;
  21401. /**
  21402. * Stores the size of points
  21403. */
  21404. pointSize: number;
  21405. /**
  21406. * Stores the z offset value
  21407. */
  21408. zOffset: number;
  21409. /**
  21410. * Gets a value specifying if wireframe mode is enabled
  21411. */
  21412. get wireframe(): boolean;
  21413. /**
  21414. * Sets the state of wireframe mode
  21415. */
  21416. set wireframe(value: boolean);
  21417. /**
  21418. * Gets the value specifying if point clouds are enabled
  21419. */
  21420. get pointsCloud(): boolean;
  21421. /**
  21422. * Sets the state of point cloud mode
  21423. */
  21424. set pointsCloud(value: boolean);
  21425. /**
  21426. * Gets the material fill mode
  21427. */
  21428. get fillMode(): number;
  21429. /**
  21430. * Sets the material fill mode
  21431. */
  21432. set fillMode(value: number);
  21433. /**
  21434. * @hidden
  21435. * Stores the effects for the material
  21436. */
  21437. _effect: Nullable<Effect>;
  21438. /**
  21439. * Specifies if uniform buffers should be used
  21440. */
  21441. private _useUBO;
  21442. /**
  21443. * Stores a reference to the scene
  21444. */
  21445. private _scene;
  21446. /**
  21447. * Stores the fill mode state
  21448. */
  21449. private _fillMode;
  21450. /**
  21451. * Specifies if the depth write state should be cached
  21452. */
  21453. private _cachedDepthWriteState;
  21454. /**
  21455. * Specifies if the color write state should be cached
  21456. */
  21457. private _cachedColorWriteState;
  21458. /**
  21459. * Specifies if the depth function state should be cached
  21460. */
  21461. private _cachedDepthFunctionState;
  21462. /**
  21463. * Stores the uniform buffer
  21464. */
  21465. protected _uniformBuffer: UniformBuffer;
  21466. /** @hidden */
  21467. _indexInSceneMaterialArray: number;
  21468. /** @hidden */
  21469. meshMap: Nullable<{
  21470. [id: string]: AbstractMesh | undefined;
  21471. }>;
  21472. /**
  21473. * Creates a material instance
  21474. * @param name defines the name of the material
  21475. * @param scene defines the scene to reference
  21476. * @param doNotAdd specifies if the material should be added to the scene
  21477. */
  21478. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21479. /**
  21480. * Returns a string representation of the current material
  21481. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21482. * @returns a string with material information
  21483. */
  21484. toString(fullDetails?: boolean): string;
  21485. /**
  21486. * Gets the class name of the material
  21487. * @returns a string with the class name of the material
  21488. */
  21489. getClassName(): string;
  21490. /**
  21491. * Specifies if updates for the material been locked
  21492. */
  21493. get isFrozen(): boolean;
  21494. /**
  21495. * Locks updates for the material
  21496. */
  21497. freeze(): void;
  21498. /**
  21499. * Unlocks updates for the material
  21500. */
  21501. unfreeze(): void;
  21502. /**
  21503. * Specifies if the material is ready to be used
  21504. * @param mesh defines the mesh to check
  21505. * @param useInstances specifies if instances should be used
  21506. * @returns a boolean indicating if the material is ready to be used
  21507. */
  21508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21509. /**
  21510. * Specifies that the submesh is ready to be used
  21511. * @param mesh defines the mesh to check
  21512. * @param subMesh defines which submesh to check
  21513. * @param useInstances specifies that instances should be used
  21514. * @returns a boolean indicating that the submesh is ready or not
  21515. */
  21516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21517. /**
  21518. * Returns the material effect
  21519. * @returns the effect associated with the material
  21520. */
  21521. getEffect(): Nullable<Effect>;
  21522. /**
  21523. * Returns the current scene
  21524. * @returns a Scene
  21525. */
  21526. getScene(): Scene;
  21527. /**
  21528. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21529. */
  21530. protected _forceAlphaTest: boolean;
  21531. /**
  21532. * The transparency mode of the material.
  21533. */
  21534. protected _transparencyMode: Nullable<number>;
  21535. /**
  21536. * Gets the current transparency mode.
  21537. */
  21538. get transparencyMode(): Nullable<number>;
  21539. /**
  21540. * Sets the transparency mode of the material.
  21541. *
  21542. * | Value | Type | Description |
  21543. * | ----- | ----------------------------------- | ----------- |
  21544. * | 0 | OPAQUE | |
  21545. * | 1 | ALPHATEST | |
  21546. * | 2 | ALPHABLEND | |
  21547. * | 3 | ALPHATESTANDBLEND | |
  21548. *
  21549. */
  21550. set transparencyMode(value: Nullable<number>);
  21551. /**
  21552. * Returns true if alpha blending should be disabled.
  21553. */
  21554. protected get _disableAlphaBlending(): boolean;
  21555. /**
  21556. * Specifies whether or not this material should be rendered in alpha blend mode.
  21557. * @returns a boolean specifying if alpha blending is needed
  21558. */
  21559. needAlphaBlending(): boolean;
  21560. /**
  21561. * Specifies if the mesh will require alpha blending
  21562. * @param mesh defines the mesh to check
  21563. * @returns a boolean specifying if alpha blending is needed for the mesh
  21564. */
  21565. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21566. /**
  21567. * Specifies whether or not this material should be rendered in alpha test mode.
  21568. * @returns a boolean specifying if an alpha test is needed.
  21569. */
  21570. needAlphaTesting(): boolean;
  21571. /**
  21572. * Specifies if material alpha testing should be turned on for the mesh
  21573. * @param mesh defines the mesh to check
  21574. */
  21575. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21576. /**
  21577. * Gets the texture used for the alpha test
  21578. * @returns the texture to use for alpha testing
  21579. */
  21580. getAlphaTestTexture(): Nullable<BaseTexture>;
  21581. /**
  21582. * Marks the material to indicate that it needs to be re-calculated
  21583. */
  21584. markDirty(): void;
  21585. /** @hidden */
  21586. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21587. /**
  21588. * Binds the material to the mesh
  21589. * @param world defines the world transformation matrix
  21590. * @param mesh defines the mesh to bind the material to
  21591. */
  21592. bind(world: Matrix, mesh?: Mesh): void;
  21593. /**
  21594. * Binds the submesh to the material
  21595. * @param world defines the world transformation matrix
  21596. * @param mesh defines the mesh containing the submesh
  21597. * @param subMesh defines the submesh to bind the material to
  21598. */
  21599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21600. /**
  21601. * Binds the world matrix to the material
  21602. * @param world defines the world transformation matrix
  21603. */
  21604. bindOnlyWorldMatrix(world: Matrix): void;
  21605. /**
  21606. * Binds the scene's uniform buffer to the effect.
  21607. * @param effect defines the effect to bind to the scene uniform buffer
  21608. * @param sceneUbo defines the uniform buffer storing scene data
  21609. */
  21610. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21611. /**
  21612. * Binds the view matrix to the effect
  21613. * @param effect defines the effect to bind the view matrix to
  21614. */
  21615. bindView(effect: Effect): void;
  21616. /**
  21617. * Binds the view projection matrix to the effect
  21618. * @param effect defines the effect to bind the view projection matrix to
  21619. */
  21620. bindViewProjection(effect: Effect): void;
  21621. /**
  21622. * Processes to execute after binding the material to a mesh
  21623. * @param mesh defines the rendered mesh
  21624. */
  21625. protected _afterBind(mesh?: Mesh): void;
  21626. /**
  21627. * Unbinds the material from the mesh
  21628. */
  21629. unbind(): void;
  21630. /**
  21631. * Gets the active textures from the material
  21632. * @returns an array of textures
  21633. */
  21634. getActiveTextures(): BaseTexture[];
  21635. /**
  21636. * Specifies if the material uses a texture
  21637. * @param texture defines the texture to check against the material
  21638. * @returns a boolean specifying if the material uses the texture
  21639. */
  21640. hasTexture(texture: BaseTexture): boolean;
  21641. /**
  21642. * Makes a duplicate of the material, and gives it a new name
  21643. * @param name defines the new name for the duplicated material
  21644. * @returns the cloned material
  21645. */
  21646. clone(name: string): Nullable<Material>;
  21647. /**
  21648. * Gets the meshes bound to the material
  21649. * @returns an array of meshes bound to the material
  21650. */
  21651. getBindedMeshes(): AbstractMesh[];
  21652. /**
  21653. * Force shader compilation
  21654. * @param mesh defines the mesh associated with this material
  21655. * @param onCompiled defines a function to execute once the material is compiled
  21656. * @param options defines the options to configure the compilation
  21657. * @param onError defines a function to execute if the material fails compiling
  21658. */
  21659. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21660. /**
  21661. * Force shader compilation
  21662. * @param mesh defines the mesh that will use this material
  21663. * @param options defines additional options for compiling the shaders
  21664. * @returns a promise that resolves when the compilation completes
  21665. */
  21666. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21667. private static readonly _AllDirtyCallBack;
  21668. private static readonly _ImageProcessingDirtyCallBack;
  21669. private static readonly _TextureDirtyCallBack;
  21670. private static readonly _FresnelDirtyCallBack;
  21671. private static readonly _MiscDirtyCallBack;
  21672. private static readonly _LightsDirtyCallBack;
  21673. private static readonly _AttributeDirtyCallBack;
  21674. private static _FresnelAndMiscDirtyCallBack;
  21675. private static _TextureAndMiscDirtyCallBack;
  21676. private static readonly _DirtyCallbackArray;
  21677. private static readonly _RunDirtyCallBacks;
  21678. /**
  21679. * Marks a define in the material to indicate that it needs to be re-computed
  21680. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21681. */
  21682. markAsDirty(flag: number): void;
  21683. /**
  21684. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21685. * @param func defines a function which checks material defines against the submeshes
  21686. */
  21687. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21688. /**
  21689. * Indicates that we need to re-calculated for all submeshes
  21690. */
  21691. protected _markAllSubMeshesAsAllDirty(): void;
  21692. /**
  21693. * Indicates that image processing needs to be re-calculated for all submeshes
  21694. */
  21695. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21696. /**
  21697. * Indicates that textures need to be re-calculated for all submeshes
  21698. */
  21699. protected _markAllSubMeshesAsTexturesDirty(): void;
  21700. /**
  21701. * Indicates that fresnel needs to be re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsFresnelDirty(): void;
  21704. /**
  21705. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21708. /**
  21709. * Indicates that lights need to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsLightsDirty(): void;
  21712. /**
  21713. * Indicates that attributes need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsAttributesDirty(): void;
  21716. /**
  21717. * Indicates that misc needs to be re-calculated for all submeshes
  21718. */
  21719. protected _markAllSubMeshesAsMiscDirty(): void;
  21720. /**
  21721. * Indicates that textures and misc need to be re-calculated for all submeshes
  21722. */
  21723. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21724. /**
  21725. * Disposes the material
  21726. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21727. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21728. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21729. */
  21730. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21731. /** @hidden */
  21732. private releaseVertexArrayObject;
  21733. /**
  21734. * Serializes this material
  21735. * @returns the serialized material object
  21736. */
  21737. serialize(): any;
  21738. /**
  21739. * Creates a material from parsed material data
  21740. * @param parsedMaterial defines parsed material data
  21741. * @param scene defines the hosting scene
  21742. * @param rootUrl defines the root URL to use to load textures
  21743. * @returns a new material
  21744. */
  21745. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21746. }
  21747. }
  21748. declare module BABYLON {
  21749. /**
  21750. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21751. * separate meshes. This can be use to improve performances.
  21752. * @see http://doc.babylonjs.com/how_to/multi_materials
  21753. */
  21754. export class MultiMaterial extends Material {
  21755. private _subMaterials;
  21756. /**
  21757. * Gets or Sets the list of Materials used within the multi material.
  21758. * They need to be ordered according to the submeshes order in the associated mesh
  21759. */
  21760. get subMaterials(): Nullable<Material>[];
  21761. set subMaterials(value: Nullable<Material>[]);
  21762. /**
  21763. * Function used to align with Node.getChildren()
  21764. * @returns the list of Materials used within the multi material
  21765. */
  21766. getChildren(): Nullable<Material>[];
  21767. /**
  21768. * Instantiates a new Multi Material
  21769. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21770. * separate meshes. This can be use to improve performances.
  21771. * @see http://doc.babylonjs.com/how_to/multi_materials
  21772. * @param name Define the name in the scene
  21773. * @param scene Define the scene the material belongs to
  21774. */
  21775. constructor(name: string, scene: Scene);
  21776. private _hookArray;
  21777. /**
  21778. * Get one of the submaterial by its index in the submaterials array
  21779. * @param index The index to look the sub material at
  21780. * @returns The Material if the index has been defined
  21781. */
  21782. getSubMaterial(index: number): Nullable<Material>;
  21783. /**
  21784. * Get the list of active textures for the whole sub materials list.
  21785. * @returns All the textures that will be used during the rendering
  21786. */
  21787. getActiveTextures(): BaseTexture[];
  21788. /**
  21789. * Gets the current class name of the material e.g. "MultiMaterial"
  21790. * Mainly use in serialization.
  21791. * @returns the class name
  21792. */
  21793. getClassName(): string;
  21794. /**
  21795. * Checks if the material is ready to render the requested sub mesh
  21796. * @param mesh Define the mesh the submesh belongs to
  21797. * @param subMesh Define the sub mesh to look readyness for
  21798. * @param useInstances Define whether or not the material is used with instances
  21799. * @returns true if ready, otherwise false
  21800. */
  21801. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21802. /**
  21803. * Clones the current material and its related sub materials
  21804. * @param name Define the name of the newly cloned material
  21805. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21806. * @returns the cloned material
  21807. */
  21808. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21809. /**
  21810. * Serializes the materials into a JSON representation.
  21811. * @returns the JSON representation
  21812. */
  21813. serialize(): any;
  21814. /**
  21815. * Dispose the material and release its associated resources
  21816. * @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)
  21817. * @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)
  21818. * @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)
  21819. */
  21820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21821. /**
  21822. * Creates a MultiMaterial from parsed MultiMaterial data.
  21823. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21824. * @param scene defines the hosting scene
  21825. * @returns a new MultiMaterial
  21826. */
  21827. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21828. }
  21829. }
  21830. declare module BABYLON {
  21831. /**
  21832. * Base class for submeshes
  21833. */
  21834. export class BaseSubMesh {
  21835. /** @hidden */
  21836. _materialDefines: Nullable<MaterialDefines>;
  21837. /** @hidden */
  21838. _materialEffect: Nullable<Effect>;
  21839. /** @hidden */
  21840. _effectOverride: Nullable<Effect>;
  21841. /**
  21842. * Gets material defines used by the effect associated to the sub mesh
  21843. */
  21844. get materialDefines(): Nullable<MaterialDefines>;
  21845. /**
  21846. * Sets material defines used by the effect associated to the sub mesh
  21847. */
  21848. set materialDefines(defines: Nullable<MaterialDefines>);
  21849. /**
  21850. * Gets associated effect
  21851. */
  21852. get effect(): Nullable<Effect>;
  21853. /**
  21854. * Sets associated effect (effect used to render this submesh)
  21855. * @param effect defines the effect to associate with
  21856. * @param defines defines the set of defines used to compile this effect
  21857. */
  21858. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21859. }
  21860. /**
  21861. * Defines a subdivision inside a mesh
  21862. */
  21863. export class SubMesh extends BaseSubMesh implements ICullable {
  21864. /** the material index to use */
  21865. materialIndex: number;
  21866. /** vertex index start */
  21867. verticesStart: number;
  21868. /** vertices count */
  21869. verticesCount: number;
  21870. /** index start */
  21871. indexStart: number;
  21872. /** indices count */
  21873. indexCount: number;
  21874. /** @hidden */
  21875. _linesIndexCount: number;
  21876. private _mesh;
  21877. private _renderingMesh;
  21878. private _boundingInfo;
  21879. private _linesIndexBuffer;
  21880. /** @hidden */
  21881. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21882. /** @hidden */
  21883. _trianglePlanes: Plane[];
  21884. /** @hidden */
  21885. _lastColliderTransformMatrix: Nullable<Matrix>;
  21886. /** @hidden */
  21887. _renderId: number;
  21888. /** @hidden */
  21889. _alphaIndex: number;
  21890. /** @hidden */
  21891. _distanceToCamera: number;
  21892. /** @hidden */
  21893. _id: number;
  21894. private _currentMaterial;
  21895. /**
  21896. * Add a new submesh to a mesh
  21897. * @param materialIndex defines the material index to use
  21898. * @param verticesStart defines vertex index start
  21899. * @param verticesCount defines vertices count
  21900. * @param indexStart defines index start
  21901. * @param indexCount defines indices count
  21902. * @param mesh defines the parent mesh
  21903. * @param renderingMesh defines an optional rendering mesh
  21904. * @param createBoundingBox defines if bounding box should be created for this submesh
  21905. * @returns the new submesh
  21906. */
  21907. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21908. /**
  21909. * Creates a new submesh
  21910. * @param materialIndex defines the material index to use
  21911. * @param verticesStart defines vertex index start
  21912. * @param verticesCount defines vertices count
  21913. * @param indexStart defines index start
  21914. * @param indexCount defines indices count
  21915. * @param mesh defines the parent mesh
  21916. * @param renderingMesh defines an optional rendering mesh
  21917. * @param createBoundingBox defines if bounding box should be created for this submesh
  21918. */
  21919. constructor(
  21920. /** the material index to use */
  21921. materialIndex: number,
  21922. /** vertex index start */
  21923. verticesStart: number,
  21924. /** vertices count */
  21925. verticesCount: number,
  21926. /** index start */
  21927. indexStart: number,
  21928. /** indices count */
  21929. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21930. /**
  21931. * Returns true if this submesh covers the entire parent mesh
  21932. * @ignorenaming
  21933. */
  21934. get IsGlobal(): boolean;
  21935. /**
  21936. * Returns the submesh BoudingInfo object
  21937. * @returns current bounding info (or mesh's one if the submesh is global)
  21938. */
  21939. getBoundingInfo(): BoundingInfo;
  21940. /**
  21941. * Sets the submesh BoundingInfo
  21942. * @param boundingInfo defines the new bounding info to use
  21943. * @returns the SubMesh
  21944. */
  21945. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21946. /**
  21947. * Returns the mesh of the current submesh
  21948. * @return the parent mesh
  21949. */
  21950. getMesh(): AbstractMesh;
  21951. /**
  21952. * Returns the rendering mesh of the submesh
  21953. * @returns the rendering mesh (could be different from parent mesh)
  21954. */
  21955. getRenderingMesh(): Mesh;
  21956. /**
  21957. * Returns the submesh material
  21958. * @returns null or the current material
  21959. */
  21960. getMaterial(): Nullable<Material>;
  21961. /**
  21962. * Sets a new updated BoundingInfo object to the submesh
  21963. * @param data defines an optional position array to use to determine the bounding info
  21964. * @returns the SubMesh
  21965. */
  21966. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21967. /** @hidden */
  21968. _checkCollision(collider: Collider): boolean;
  21969. /**
  21970. * Updates the submesh BoundingInfo
  21971. * @param world defines the world matrix to use to update the bounding info
  21972. * @returns the submesh
  21973. */
  21974. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21975. /**
  21976. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21977. * @param frustumPlanes defines the frustum planes
  21978. * @returns true if the submesh is intersecting with the frustum
  21979. */
  21980. isInFrustum(frustumPlanes: Plane[]): boolean;
  21981. /**
  21982. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21983. * @param frustumPlanes defines the frustum planes
  21984. * @returns true if the submesh is inside the frustum
  21985. */
  21986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21987. /**
  21988. * Renders the submesh
  21989. * @param enableAlphaMode defines if alpha needs to be used
  21990. * @returns the submesh
  21991. */
  21992. render(enableAlphaMode: boolean): SubMesh;
  21993. /**
  21994. * @hidden
  21995. */
  21996. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21997. /**
  21998. * Checks if the submesh intersects with a ray
  21999. * @param ray defines the ray to test
  22000. * @returns true is the passed ray intersects the submesh bounding box
  22001. */
  22002. canIntersects(ray: Ray): boolean;
  22003. /**
  22004. * Intersects current submesh with a ray
  22005. * @param ray defines the ray to test
  22006. * @param positions defines mesh's positions array
  22007. * @param indices defines mesh's indices array
  22008. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22009. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22010. * @returns intersection info or null if no intersection
  22011. */
  22012. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22013. /** @hidden */
  22014. private _intersectLines;
  22015. /** @hidden */
  22016. private _intersectUnIndexedLines;
  22017. /** @hidden */
  22018. private _intersectTriangles;
  22019. /** @hidden */
  22020. private _intersectUnIndexedTriangles;
  22021. /** @hidden */
  22022. _rebuild(): void;
  22023. /**
  22024. * Creates a new submesh from the passed mesh
  22025. * @param newMesh defines the new hosting mesh
  22026. * @param newRenderingMesh defines an optional rendering mesh
  22027. * @returns the new submesh
  22028. */
  22029. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22030. /**
  22031. * Release associated resources
  22032. */
  22033. dispose(): void;
  22034. /**
  22035. * Gets the class name
  22036. * @returns the string "SubMesh".
  22037. */
  22038. getClassName(): string;
  22039. /**
  22040. * Creates a new submesh from indices data
  22041. * @param materialIndex the index of the main mesh material
  22042. * @param startIndex the index where to start the copy in the mesh indices array
  22043. * @param indexCount the number of indices to copy then from the startIndex
  22044. * @param mesh the main mesh to create the submesh from
  22045. * @param renderingMesh the optional rendering mesh
  22046. * @returns a new submesh
  22047. */
  22048. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22049. }
  22050. }
  22051. declare module BABYLON {
  22052. /**
  22053. * Class used to represent data loading progression
  22054. */
  22055. export class SceneLoaderFlags {
  22056. private static _ForceFullSceneLoadingForIncremental;
  22057. private static _ShowLoadingScreen;
  22058. private static _CleanBoneMatrixWeights;
  22059. private static _loggingLevel;
  22060. /**
  22061. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22062. */
  22063. static get ForceFullSceneLoadingForIncremental(): boolean;
  22064. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22065. /**
  22066. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22067. */
  22068. static get ShowLoadingScreen(): boolean;
  22069. static set ShowLoadingScreen(value: boolean);
  22070. /**
  22071. * Defines the current logging level (while loading the scene)
  22072. * @ignorenaming
  22073. */
  22074. static get loggingLevel(): number;
  22075. static set loggingLevel(value: number);
  22076. /**
  22077. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22078. */
  22079. static get CleanBoneMatrixWeights(): boolean;
  22080. static set CleanBoneMatrixWeights(value: boolean);
  22081. }
  22082. }
  22083. declare module BABYLON {
  22084. /**
  22085. * Class used to store geometry data (vertex buffers + index buffer)
  22086. */
  22087. export class Geometry implements IGetSetVerticesData {
  22088. /**
  22089. * Gets or sets the ID of the geometry
  22090. */
  22091. id: string;
  22092. /**
  22093. * Gets or sets the unique ID of the geometry
  22094. */
  22095. uniqueId: number;
  22096. /**
  22097. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22098. */
  22099. delayLoadState: number;
  22100. /**
  22101. * Gets the file containing the data to load when running in delay load state
  22102. */
  22103. delayLoadingFile: Nullable<string>;
  22104. /**
  22105. * Callback called when the geometry is updated
  22106. */
  22107. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22108. private _scene;
  22109. private _engine;
  22110. private _meshes;
  22111. private _totalVertices;
  22112. /** @hidden */
  22113. _indices: IndicesArray;
  22114. /** @hidden */
  22115. _vertexBuffers: {
  22116. [key: string]: VertexBuffer;
  22117. };
  22118. private _isDisposed;
  22119. private _extend;
  22120. private _boundingBias;
  22121. /** @hidden */
  22122. _delayInfo: Array<string>;
  22123. private _indexBuffer;
  22124. private _indexBufferIsUpdatable;
  22125. /** @hidden */
  22126. _boundingInfo: Nullable<BoundingInfo>;
  22127. /** @hidden */
  22128. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22129. /** @hidden */
  22130. _softwareSkinningFrameId: number;
  22131. private _vertexArrayObjects;
  22132. private _updatable;
  22133. /** @hidden */
  22134. _positions: Nullable<Vector3[]>;
  22135. /**
  22136. * 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
  22137. */
  22138. get boundingBias(): Vector2;
  22139. /**
  22140. * 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
  22141. */
  22142. set boundingBias(value: Vector2);
  22143. /**
  22144. * Static function used to attach a new empty geometry to a mesh
  22145. * @param mesh defines the mesh to attach the geometry to
  22146. * @returns the new Geometry
  22147. */
  22148. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22149. /** Get the list of meshes using this geometry */
  22150. get meshes(): Mesh[];
  22151. /**
  22152. * Creates a new geometry
  22153. * @param id defines the unique ID
  22154. * @param scene defines the hosting scene
  22155. * @param vertexData defines the VertexData used to get geometry data
  22156. * @param updatable defines if geometry must be updatable (false by default)
  22157. * @param mesh defines the mesh that will be associated with the geometry
  22158. */
  22159. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22160. /**
  22161. * Gets the current extend of the geometry
  22162. */
  22163. get extend(): {
  22164. minimum: Vector3;
  22165. maximum: Vector3;
  22166. };
  22167. /**
  22168. * Gets the hosting scene
  22169. * @returns the hosting Scene
  22170. */
  22171. getScene(): Scene;
  22172. /**
  22173. * Gets the hosting engine
  22174. * @returns the hosting Engine
  22175. */
  22176. getEngine(): Engine;
  22177. /**
  22178. * Defines if the geometry is ready to use
  22179. * @returns true if the geometry is ready to be used
  22180. */
  22181. isReady(): boolean;
  22182. /**
  22183. * Gets a value indicating that the geometry should not be serialized
  22184. */
  22185. get doNotSerialize(): boolean;
  22186. /** @hidden */
  22187. _rebuild(): void;
  22188. /**
  22189. * Affects all geometry data in one call
  22190. * @param vertexData defines the geometry data
  22191. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22192. */
  22193. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22194. /**
  22195. * Set specific vertex data
  22196. * @param kind defines the data kind (Position, normal, etc...)
  22197. * @param data defines the vertex data to use
  22198. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22199. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22200. */
  22201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22202. /**
  22203. * Removes a specific vertex data
  22204. * @param kind defines the data kind (Position, normal, etc...)
  22205. */
  22206. removeVerticesData(kind: string): void;
  22207. /**
  22208. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22209. * @param buffer defines the vertex buffer to use
  22210. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22211. */
  22212. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22213. /**
  22214. * Update a specific vertex buffer
  22215. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22216. * It will do nothing if the buffer is not updatable
  22217. * @param kind defines the data kind (Position, normal, etc...)
  22218. * @param data defines the data to use
  22219. * @param offset defines the offset in the target buffer where to store the data
  22220. * @param useBytes set to true if the offset is in bytes
  22221. */
  22222. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22223. /**
  22224. * Update a specific vertex buffer
  22225. * This function will create a new buffer if the current one is not updatable
  22226. * @param kind defines the data kind (Position, normal, etc...)
  22227. * @param data defines the data to use
  22228. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22229. */
  22230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22231. private _updateBoundingInfo;
  22232. /** @hidden */
  22233. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22234. /**
  22235. * Gets total number of vertices
  22236. * @returns the total number of vertices
  22237. */
  22238. getTotalVertices(): number;
  22239. /**
  22240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22241. * @param kind defines the data kind (Position, normal, etc...)
  22242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22244. * @returns a float array containing vertex data
  22245. */
  22246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22247. /**
  22248. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22249. * @param kind defines the data kind (Position, normal, etc...)
  22250. * @returns true if the vertex buffer with the specified kind is updatable
  22251. */
  22252. isVertexBufferUpdatable(kind: string): boolean;
  22253. /**
  22254. * Gets a specific vertex buffer
  22255. * @param kind defines the data kind (Position, normal, etc...)
  22256. * @returns a VertexBuffer
  22257. */
  22258. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22259. /**
  22260. * Returns all vertex buffers
  22261. * @return an object holding all vertex buffers indexed by kind
  22262. */
  22263. getVertexBuffers(): Nullable<{
  22264. [key: string]: VertexBuffer;
  22265. }>;
  22266. /**
  22267. * Gets a boolean indicating if specific vertex buffer is present
  22268. * @param kind defines the data kind (Position, normal, etc...)
  22269. * @returns true if data is present
  22270. */
  22271. isVerticesDataPresent(kind: string): boolean;
  22272. /**
  22273. * Gets a list of all attached data kinds (Position, normal, etc...)
  22274. * @returns a list of string containing all kinds
  22275. */
  22276. getVerticesDataKinds(): string[];
  22277. /**
  22278. * Update index buffer
  22279. * @param indices defines the indices to store in the index buffer
  22280. * @param offset defines the offset in the target buffer where to store the data
  22281. * @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)
  22282. */
  22283. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22284. /**
  22285. * Creates a new index buffer
  22286. * @param indices defines the indices to store in the index buffer
  22287. * @param totalVertices defines the total number of vertices (could be null)
  22288. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22289. */
  22290. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22291. /**
  22292. * Return the total number of indices
  22293. * @returns the total number of indices
  22294. */
  22295. getTotalIndices(): number;
  22296. /**
  22297. * Gets the index buffer array
  22298. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22300. * @returns the index buffer array
  22301. */
  22302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22303. /**
  22304. * Gets the index buffer
  22305. * @return the index buffer
  22306. */
  22307. getIndexBuffer(): Nullable<DataBuffer>;
  22308. /** @hidden */
  22309. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22310. /**
  22311. * Release the associated resources for a specific mesh
  22312. * @param mesh defines the source mesh
  22313. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22314. */
  22315. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22316. /**
  22317. * Apply current geometry to a given mesh
  22318. * @param mesh defines the mesh to apply geometry to
  22319. */
  22320. applyToMesh(mesh: Mesh): void;
  22321. private _updateExtend;
  22322. private _applyToMesh;
  22323. private notifyUpdate;
  22324. /**
  22325. * Load the geometry if it was flagged as delay loaded
  22326. * @param scene defines the hosting scene
  22327. * @param onLoaded defines a callback called when the geometry is loaded
  22328. */
  22329. load(scene: Scene, onLoaded?: () => void): void;
  22330. private _queueLoad;
  22331. /**
  22332. * Invert the geometry to move from a right handed system to a left handed one.
  22333. */
  22334. toLeftHanded(): void;
  22335. /** @hidden */
  22336. _resetPointsArrayCache(): void;
  22337. /** @hidden */
  22338. _generatePointsArray(): boolean;
  22339. /**
  22340. * Gets a value indicating if the geometry is disposed
  22341. * @returns true if the geometry was disposed
  22342. */
  22343. isDisposed(): boolean;
  22344. private _disposeVertexArrayObjects;
  22345. /**
  22346. * Free all associated resources
  22347. */
  22348. dispose(): void;
  22349. /**
  22350. * Clone the current geometry into a new geometry
  22351. * @param id defines the unique ID of the new geometry
  22352. * @returns a new geometry object
  22353. */
  22354. copy(id: string): Geometry;
  22355. /**
  22356. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22357. * @return a JSON representation of the current geometry data (without the vertices data)
  22358. */
  22359. serialize(): any;
  22360. private toNumberArray;
  22361. /**
  22362. * Serialize all vertices data into a JSON oject
  22363. * @returns a JSON representation of the current geometry data
  22364. */
  22365. serializeVerticeData(): any;
  22366. /**
  22367. * Extracts a clone of a mesh geometry
  22368. * @param mesh defines the source mesh
  22369. * @param id defines the unique ID of the new geometry object
  22370. * @returns the new geometry object
  22371. */
  22372. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22373. /**
  22374. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22376. * Be aware Math.random() could cause collisions, but:
  22377. * "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"
  22378. * @returns a string containing a new GUID
  22379. */
  22380. static RandomId(): string;
  22381. /** @hidden */
  22382. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22383. private static _CleanMatricesWeights;
  22384. /**
  22385. * Create a new geometry from persisted data (Using .babylon file format)
  22386. * @param parsedVertexData defines the persisted data
  22387. * @param scene defines the hosting scene
  22388. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22389. * @returns the new geometry object
  22390. */
  22391. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22392. }
  22393. }
  22394. declare module BABYLON {
  22395. /**
  22396. * Define an interface for all classes that will get and set the data on vertices
  22397. */
  22398. export interface IGetSetVerticesData {
  22399. /**
  22400. * Gets a boolean indicating if specific vertex data is present
  22401. * @param kind defines the vertex data kind to use
  22402. * @returns true is data kind is present
  22403. */
  22404. isVerticesDataPresent(kind: string): boolean;
  22405. /**
  22406. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22407. * @param kind defines the data kind (Position, normal, etc...)
  22408. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22409. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22410. * @returns a float array containing vertex data
  22411. */
  22412. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22413. /**
  22414. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22415. * @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.
  22416. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22417. * @returns the indices array or an empty array if the mesh has no geometry
  22418. */
  22419. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22420. /**
  22421. * Set specific vertex data
  22422. * @param kind defines the data kind (Position, normal, etc...)
  22423. * @param data defines the vertex data to use
  22424. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22425. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22426. */
  22427. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22428. /**
  22429. * Update a specific associated vertex buffer
  22430. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22431. * - VertexBuffer.PositionKind
  22432. * - VertexBuffer.UVKind
  22433. * - VertexBuffer.UV2Kind
  22434. * - VertexBuffer.UV3Kind
  22435. * - VertexBuffer.UV4Kind
  22436. * - VertexBuffer.UV5Kind
  22437. * - VertexBuffer.UV6Kind
  22438. * - VertexBuffer.ColorKind
  22439. * - VertexBuffer.MatricesIndicesKind
  22440. * - VertexBuffer.MatricesIndicesExtraKind
  22441. * - VertexBuffer.MatricesWeightsKind
  22442. * - VertexBuffer.MatricesWeightsExtraKind
  22443. * @param data defines the data source
  22444. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22445. * @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)
  22446. */
  22447. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22448. /**
  22449. * Creates a new index buffer
  22450. * @param indices defines the indices to store in the index buffer
  22451. * @param totalVertices defines the total number of vertices (could be null)
  22452. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22453. */
  22454. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22455. }
  22456. /**
  22457. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22458. */
  22459. export class VertexData {
  22460. /**
  22461. * Mesh side orientation : usually the external or front surface
  22462. */
  22463. static readonly FRONTSIDE: number;
  22464. /**
  22465. * Mesh side orientation : usually the internal or back surface
  22466. */
  22467. static readonly BACKSIDE: number;
  22468. /**
  22469. * Mesh side orientation : both internal and external or front and back surfaces
  22470. */
  22471. static readonly DOUBLESIDE: number;
  22472. /**
  22473. * Mesh side orientation : by default, `FRONTSIDE`
  22474. */
  22475. static readonly DEFAULTSIDE: number;
  22476. /**
  22477. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22478. */
  22479. positions: Nullable<FloatArray>;
  22480. /**
  22481. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22482. */
  22483. normals: Nullable<FloatArray>;
  22484. /**
  22485. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22486. */
  22487. tangents: Nullable<FloatArray>;
  22488. /**
  22489. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22490. */
  22491. uvs: Nullable<FloatArray>;
  22492. /**
  22493. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22494. */
  22495. uvs2: Nullable<FloatArray>;
  22496. /**
  22497. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22498. */
  22499. uvs3: Nullable<FloatArray>;
  22500. /**
  22501. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22502. */
  22503. uvs4: Nullable<FloatArray>;
  22504. /**
  22505. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22506. */
  22507. uvs5: Nullable<FloatArray>;
  22508. /**
  22509. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22510. */
  22511. uvs6: Nullable<FloatArray>;
  22512. /**
  22513. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22514. */
  22515. colors: Nullable<FloatArray>;
  22516. /**
  22517. * 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).
  22518. */
  22519. matricesIndices: Nullable<FloatArray>;
  22520. /**
  22521. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22522. */
  22523. matricesWeights: Nullable<FloatArray>;
  22524. /**
  22525. * An array extending the number of possible indices
  22526. */
  22527. matricesIndicesExtra: Nullable<FloatArray>;
  22528. /**
  22529. * An array extending the number of possible weights when the number of indices is extended
  22530. */
  22531. matricesWeightsExtra: Nullable<FloatArray>;
  22532. /**
  22533. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22534. */
  22535. indices: Nullable<IndicesArray>;
  22536. /**
  22537. * Uses the passed data array to set the set the values for the specified kind of data
  22538. * @param data a linear array of floating numbers
  22539. * @param kind the type of data that is being set, eg positions, colors etc
  22540. */
  22541. set(data: FloatArray, kind: string): void;
  22542. /**
  22543. * Associates the vertexData to the passed Mesh.
  22544. * Sets it as updatable or not (default `false`)
  22545. * @param mesh the mesh the vertexData is applied to
  22546. * @param updatable when used and having the value true allows new data to update the vertexData
  22547. * @returns the VertexData
  22548. */
  22549. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22550. /**
  22551. * Associates the vertexData to the passed Geometry.
  22552. * Sets it as updatable or not (default `false`)
  22553. * @param geometry the geometry the vertexData is applied to
  22554. * @param updatable when used and having the value true allows new data to update the vertexData
  22555. * @returns VertexData
  22556. */
  22557. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22558. /**
  22559. * Updates the associated mesh
  22560. * @param mesh the mesh to be updated
  22561. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22562. * @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
  22563. * @returns VertexData
  22564. */
  22565. updateMesh(mesh: Mesh): VertexData;
  22566. /**
  22567. * Updates the associated geometry
  22568. * @param geometry the geometry to be updated
  22569. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22570. * @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
  22571. * @returns VertexData.
  22572. */
  22573. updateGeometry(geometry: Geometry): VertexData;
  22574. private _applyTo;
  22575. private _update;
  22576. /**
  22577. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22578. * @param matrix the transforming matrix
  22579. * @returns the VertexData
  22580. */
  22581. transform(matrix: Matrix): VertexData;
  22582. /**
  22583. * Merges the passed VertexData into the current one
  22584. * @param other the VertexData to be merged into the current one
  22585. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22586. * @returns the modified VertexData
  22587. */
  22588. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22589. private _mergeElement;
  22590. private _validate;
  22591. /**
  22592. * Serializes the VertexData
  22593. * @returns a serialized object
  22594. */
  22595. serialize(): any;
  22596. /**
  22597. * Extracts the vertexData from a mesh
  22598. * @param mesh the mesh from which to extract the VertexData
  22599. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22600. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22601. * @returns the object VertexData associated to the passed mesh
  22602. */
  22603. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22604. /**
  22605. * Extracts the vertexData from the geometry
  22606. * @param geometry the geometry from which to extract the VertexData
  22607. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22608. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22609. * @returns the object VertexData associated to the passed mesh
  22610. */
  22611. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22612. private static _ExtractFrom;
  22613. /**
  22614. * Creates the VertexData for a Ribbon
  22615. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22616. * * pathArray array of paths, each of which an array of successive Vector3
  22617. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22618. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22619. * * 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
  22620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22621. * * 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)
  22622. * * 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)
  22623. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22624. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22625. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22626. * @returns the VertexData of the ribbon
  22627. */
  22628. static CreateRibbon(options: {
  22629. pathArray: Vector3[][];
  22630. closeArray?: boolean;
  22631. closePath?: boolean;
  22632. offset?: number;
  22633. sideOrientation?: number;
  22634. frontUVs?: Vector4;
  22635. backUVs?: Vector4;
  22636. invertUV?: boolean;
  22637. uvs?: Vector2[];
  22638. colors?: Color4[];
  22639. }): VertexData;
  22640. /**
  22641. * Creates the VertexData for a box
  22642. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22643. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22644. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22645. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22646. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22647. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22648. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22650. * * 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)
  22651. * * 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)
  22652. * @returns the VertexData of the box
  22653. */
  22654. static CreateBox(options: {
  22655. size?: number;
  22656. width?: number;
  22657. height?: number;
  22658. depth?: number;
  22659. faceUV?: Vector4[];
  22660. faceColors?: Color4[];
  22661. sideOrientation?: number;
  22662. frontUVs?: Vector4;
  22663. backUVs?: Vector4;
  22664. }): VertexData;
  22665. /**
  22666. * Creates the VertexData for a tiled box
  22667. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22668. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22669. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22670. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22671. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22672. * @returns the VertexData of the box
  22673. */
  22674. static CreateTiledBox(options: {
  22675. pattern?: number;
  22676. width?: number;
  22677. height?: number;
  22678. depth?: number;
  22679. tileSize?: number;
  22680. tileWidth?: number;
  22681. tileHeight?: number;
  22682. alignHorizontal?: number;
  22683. alignVertical?: number;
  22684. faceUV?: Vector4[];
  22685. faceColors?: Color4[];
  22686. sideOrientation?: number;
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a tiled plane
  22690. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22691. * * pattern a limited pattern arrangement depending on the number
  22692. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22693. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22694. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22696. * * 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)
  22697. * * 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)
  22698. * @returns the VertexData of the tiled plane
  22699. */
  22700. static CreateTiledPlane(options: {
  22701. pattern?: number;
  22702. tileSize?: number;
  22703. tileWidth?: number;
  22704. tileHeight?: number;
  22705. size?: number;
  22706. width?: number;
  22707. height?: number;
  22708. alignHorizontal?: number;
  22709. alignVertical?: number;
  22710. sideOrientation?: number;
  22711. frontUVs?: Vector4;
  22712. backUVs?: Vector4;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22716. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22717. * * segments sets the number of horizontal strips optional, default 32
  22718. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22719. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22720. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22721. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22722. * * 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
  22723. * * 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
  22724. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22725. * * 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)
  22726. * * 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)
  22727. * @returns the VertexData of the ellipsoid
  22728. */
  22729. static CreateSphere(options: {
  22730. segments?: number;
  22731. diameter?: number;
  22732. diameterX?: number;
  22733. diameterY?: number;
  22734. diameterZ?: number;
  22735. arc?: number;
  22736. slice?: number;
  22737. sideOrientation?: number;
  22738. frontUVs?: Vector4;
  22739. backUVs?: Vector4;
  22740. }): VertexData;
  22741. /**
  22742. * Creates the VertexData for a cylinder, cone or prism
  22743. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22744. * * height sets the height (y direction) of the cylinder, optional, default 2
  22745. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22746. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22747. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22748. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22749. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22750. * * 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
  22751. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22752. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22753. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22754. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22756. * * 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)
  22757. * * 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)
  22758. * @returns the VertexData of the cylinder, cone or prism
  22759. */
  22760. static CreateCylinder(options: {
  22761. height?: number;
  22762. diameterTop?: number;
  22763. diameterBottom?: number;
  22764. diameter?: number;
  22765. tessellation?: number;
  22766. subdivisions?: number;
  22767. arc?: number;
  22768. faceColors?: Color4[];
  22769. faceUV?: Vector4[];
  22770. hasRings?: boolean;
  22771. enclose?: boolean;
  22772. sideOrientation?: number;
  22773. frontUVs?: Vector4;
  22774. backUVs?: Vector4;
  22775. }): VertexData;
  22776. /**
  22777. * Creates the VertexData for a torus
  22778. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22779. * * diameter the diameter of the torus, optional default 1
  22780. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22781. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22783. * * 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)
  22784. * * 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)
  22785. * @returns the VertexData of the torus
  22786. */
  22787. static CreateTorus(options: {
  22788. diameter?: number;
  22789. thickness?: number;
  22790. tessellation?: number;
  22791. sideOrientation?: number;
  22792. frontUVs?: Vector4;
  22793. backUVs?: Vector4;
  22794. }): VertexData;
  22795. /**
  22796. * Creates the VertexData of the LineSystem
  22797. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22798. * - lines an array of lines, each line being an array of successive Vector3
  22799. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22800. * @returns the VertexData of the LineSystem
  22801. */
  22802. static CreateLineSystem(options: {
  22803. lines: Vector3[][];
  22804. colors?: Nullable<Color4[][]>;
  22805. }): VertexData;
  22806. /**
  22807. * Create the VertexData for a DashedLines
  22808. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22809. * - points an array successive Vector3
  22810. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22811. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22812. * - dashNb the intended total number of dashes, optional, default 200
  22813. * @returns the VertexData for the DashedLines
  22814. */
  22815. static CreateDashedLines(options: {
  22816. points: Vector3[];
  22817. dashSize?: number;
  22818. gapSize?: number;
  22819. dashNb?: number;
  22820. }): VertexData;
  22821. /**
  22822. * Creates the VertexData for a Ground
  22823. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22824. * - width the width (x direction) of the ground, optional, default 1
  22825. * - height the height (z direction) of the ground, optional, default 1
  22826. * - subdivisions the number of subdivisions per side, optional, default 1
  22827. * @returns the VertexData of the Ground
  22828. */
  22829. static CreateGround(options: {
  22830. width?: number;
  22831. height?: number;
  22832. subdivisions?: number;
  22833. subdivisionsX?: number;
  22834. subdivisionsY?: number;
  22835. }): VertexData;
  22836. /**
  22837. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22838. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22839. * * xmin the ground minimum X coordinate, optional, default -1
  22840. * * zmin the ground minimum Z coordinate, optional, default -1
  22841. * * xmax the ground maximum X coordinate, optional, default 1
  22842. * * zmax the ground maximum Z coordinate, optional, default 1
  22843. * * 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}
  22844. * * 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}
  22845. * @returns the VertexData of the TiledGround
  22846. */
  22847. static CreateTiledGround(options: {
  22848. xmin: number;
  22849. zmin: number;
  22850. xmax: number;
  22851. zmax: number;
  22852. subdivisions?: {
  22853. w: number;
  22854. h: number;
  22855. };
  22856. precision?: {
  22857. w: number;
  22858. h: number;
  22859. };
  22860. }): VertexData;
  22861. /**
  22862. * Creates the VertexData of the Ground designed from a heightmap
  22863. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22864. * * width the width (x direction) of the ground
  22865. * * height the height (z direction) of the ground
  22866. * * subdivisions the number of subdivisions per side
  22867. * * minHeight the minimum altitude on the ground, optional, default 0
  22868. * * maxHeight the maximum altitude on the ground, optional default 1
  22869. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22870. * * buffer the array holding the image color data
  22871. * * bufferWidth the width of image
  22872. * * bufferHeight the height of image
  22873. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22874. * @returns the VertexData of the Ground designed from a heightmap
  22875. */
  22876. static CreateGroundFromHeightMap(options: {
  22877. width: number;
  22878. height: number;
  22879. subdivisions: number;
  22880. minHeight: number;
  22881. maxHeight: number;
  22882. colorFilter: Color3;
  22883. buffer: Uint8Array;
  22884. bufferWidth: number;
  22885. bufferHeight: number;
  22886. alphaFilter: number;
  22887. }): VertexData;
  22888. /**
  22889. * Creates the VertexData for a Plane
  22890. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22891. * * size sets the width and height of the plane to the value of size, optional default 1
  22892. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22893. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22895. * * 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)
  22896. * * 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)
  22897. * @returns the VertexData of the box
  22898. */
  22899. static CreatePlane(options: {
  22900. size?: number;
  22901. width?: number;
  22902. height?: number;
  22903. sideOrientation?: number;
  22904. frontUVs?: Vector4;
  22905. backUVs?: Vector4;
  22906. }): VertexData;
  22907. /**
  22908. * Creates the VertexData of the Disc or regular Polygon
  22909. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22910. * * radius the radius of the disc, optional default 0.5
  22911. * * tessellation the number of polygon sides, optional, default 64
  22912. * * 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
  22913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22914. * * 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)
  22915. * * 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)
  22916. * @returns the VertexData of the box
  22917. */
  22918. static CreateDisc(options: {
  22919. radius?: number;
  22920. tessellation?: number;
  22921. arc?: number;
  22922. sideOrientation?: number;
  22923. frontUVs?: Vector4;
  22924. backUVs?: Vector4;
  22925. }): VertexData;
  22926. /**
  22927. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22928. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22929. * @param polygon a mesh built from polygonTriangulation.build()
  22930. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22931. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22932. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22933. * @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)
  22934. * @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)
  22935. * @returns the VertexData of the Polygon
  22936. */
  22937. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22938. /**
  22939. * Creates the VertexData of the IcoSphere
  22940. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22941. * * radius the radius of the IcoSphere, optional default 1
  22942. * * radiusX allows stretching in the x direction, optional, default radius
  22943. * * radiusY allows stretching in the y direction, optional, default radius
  22944. * * radiusZ allows stretching in the z direction, optional, default radius
  22945. * * flat when true creates a flat shaded mesh, optional, default true
  22946. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22948. * * 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)
  22949. * * 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)
  22950. * @returns the VertexData of the IcoSphere
  22951. */
  22952. static CreateIcoSphere(options: {
  22953. radius?: number;
  22954. radiusX?: number;
  22955. radiusY?: number;
  22956. radiusZ?: number;
  22957. flat?: boolean;
  22958. subdivisions?: number;
  22959. sideOrientation?: number;
  22960. frontUVs?: Vector4;
  22961. backUVs?: Vector4;
  22962. }): VertexData;
  22963. /**
  22964. * Creates the VertexData for a Polyhedron
  22965. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22966. * * type provided types are:
  22967. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22968. * * 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)
  22969. * * size the size of the IcoSphere, optional default 1
  22970. * * sizeX allows stretching in the x direction, optional, default size
  22971. * * sizeY allows stretching in the y direction, optional, default size
  22972. * * sizeZ allows stretching in the z direction, optional, default size
  22973. * * 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
  22974. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22975. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22976. * * flat when true creates a flat shaded mesh, optional, default true
  22977. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22979. * * 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)
  22980. * * 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)
  22981. * @returns the VertexData of the Polyhedron
  22982. */
  22983. static CreatePolyhedron(options: {
  22984. type?: number;
  22985. size?: number;
  22986. sizeX?: number;
  22987. sizeY?: number;
  22988. sizeZ?: number;
  22989. custom?: any;
  22990. faceUV?: Vector4[];
  22991. faceColors?: Color4[];
  22992. flat?: boolean;
  22993. sideOrientation?: number;
  22994. frontUVs?: Vector4;
  22995. backUVs?: Vector4;
  22996. }): VertexData;
  22997. /**
  22998. * Creates the VertexData for a TorusKnot
  22999. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23000. * * radius the radius of the torus knot, optional, default 2
  23001. * * tube the thickness of the tube, optional, default 0.5
  23002. * * radialSegments the number of sides on each tube segments, optional, default 32
  23003. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23004. * * p the number of windings around the z axis, optional, default 2
  23005. * * q the number of windings around the x axis, optional, default 3
  23006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23007. * * 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)
  23008. * * 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)
  23009. * @returns the VertexData of the Torus Knot
  23010. */
  23011. static CreateTorusKnot(options: {
  23012. radius?: number;
  23013. tube?: number;
  23014. radialSegments?: number;
  23015. tubularSegments?: number;
  23016. p?: number;
  23017. q?: number;
  23018. sideOrientation?: number;
  23019. frontUVs?: Vector4;
  23020. backUVs?: Vector4;
  23021. }): VertexData;
  23022. /**
  23023. * Compute normals for given positions and indices
  23024. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23025. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23026. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23027. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23028. * * facetNormals : optional array of facet normals (vector3)
  23029. * * facetPositions : optional array of facet positions (vector3)
  23030. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23031. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23032. * * bInfo : optional bounding info, required for facetPartitioning computation
  23033. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23034. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23035. * * useRightHandedSystem: optional boolean to for right handed system computation
  23036. * * depthSort : optional boolean to enable the facet depth sort computation
  23037. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23038. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23039. */
  23040. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23041. facetNormals?: any;
  23042. facetPositions?: any;
  23043. facetPartitioning?: any;
  23044. ratio?: number;
  23045. bInfo?: any;
  23046. bbSize?: Vector3;
  23047. subDiv?: any;
  23048. useRightHandedSystem?: boolean;
  23049. depthSort?: boolean;
  23050. distanceTo?: Vector3;
  23051. depthSortedFacets?: any;
  23052. }): void;
  23053. /** @hidden */
  23054. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23055. /**
  23056. * Applies VertexData created from the imported parameters to the geometry
  23057. * @param parsedVertexData the parsed data from an imported file
  23058. * @param geometry the geometry to apply the VertexData to
  23059. */
  23060. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23061. }
  23062. }
  23063. declare module BABYLON {
  23064. /**
  23065. * Defines a target to use with MorphTargetManager
  23066. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23067. */
  23068. export class MorphTarget implements IAnimatable {
  23069. /** defines the name of the target */
  23070. name: string;
  23071. /**
  23072. * Gets or sets the list of animations
  23073. */
  23074. animations: Animation[];
  23075. private _scene;
  23076. private _positions;
  23077. private _normals;
  23078. private _tangents;
  23079. private _uvs;
  23080. private _influence;
  23081. private _uniqueId;
  23082. /**
  23083. * Observable raised when the influence changes
  23084. */
  23085. onInfluenceChanged: Observable<boolean>;
  23086. /** @hidden */
  23087. _onDataLayoutChanged: Observable<void>;
  23088. /**
  23089. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23090. */
  23091. get influence(): number;
  23092. set influence(influence: number);
  23093. /**
  23094. * Gets or sets the id of the morph Target
  23095. */
  23096. id: string;
  23097. private _animationPropertiesOverride;
  23098. /**
  23099. * Gets or sets the animation properties override
  23100. */
  23101. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23102. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23103. /**
  23104. * Creates a new MorphTarget
  23105. * @param name defines the name of the target
  23106. * @param influence defines the influence to use
  23107. * @param scene defines the scene the morphtarget belongs to
  23108. */
  23109. constructor(
  23110. /** defines the name of the target */
  23111. name: string, influence?: number, scene?: Nullable<Scene>);
  23112. /**
  23113. * Gets the unique ID of this manager
  23114. */
  23115. get uniqueId(): number;
  23116. /**
  23117. * Gets a boolean defining if the target contains position data
  23118. */
  23119. get hasPositions(): boolean;
  23120. /**
  23121. * Gets a boolean defining if the target contains normal data
  23122. */
  23123. get hasNormals(): boolean;
  23124. /**
  23125. * Gets a boolean defining if the target contains tangent data
  23126. */
  23127. get hasTangents(): boolean;
  23128. /**
  23129. * Gets a boolean defining if the target contains texture coordinates data
  23130. */
  23131. get hasUVs(): boolean;
  23132. /**
  23133. * Affects position data to this target
  23134. * @param data defines the position data to use
  23135. */
  23136. setPositions(data: Nullable<FloatArray>): void;
  23137. /**
  23138. * Gets the position data stored in this target
  23139. * @returns a FloatArray containing the position data (or null if not present)
  23140. */
  23141. getPositions(): Nullable<FloatArray>;
  23142. /**
  23143. * Affects normal data to this target
  23144. * @param data defines the normal data to use
  23145. */
  23146. setNormals(data: Nullable<FloatArray>): void;
  23147. /**
  23148. * Gets the normal data stored in this target
  23149. * @returns a FloatArray containing the normal data (or null if not present)
  23150. */
  23151. getNormals(): Nullable<FloatArray>;
  23152. /**
  23153. * Affects tangent data to this target
  23154. * @param data defines the tangent data to use
  23155. */
  23156. setTangents(data: Nullable<FloatArray>): void;
  23157. /**
  23158. * Gets the tangent data stored in this target
  23159. * @returns a FloatArray containing the tangent data (or null if not present)
  23160. */
  23161. getTangents(): Nullable<FloatArray>;
  23162. /**
  23163. * Affects texture coordinates data to this target
  23164. * @param data defines the texture coordinates data to use
  23165. */
  23166. setUVs(data: Nullable<FloatArray>): void;
  23167. /**
  23168. * Gets the texture coordinates data stored in this target
  23169. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23170. */
  23171. getUVs(): Nullable<FloatArray>;
  23172. /**
  23173. * Clone the current target
  23174. * @returns a new MorphTarget
  23175. */
  23176. clone(): MorphTarget;
  23177. /**
  23178. * Serializes the current target into a Serialization object
  23179. * @returns the serialized object
  23180. */
  23181. serialize(): any;
  23182. /**
  23183. * Returns the string "MorphTarget"
  23184. * @returns "MorphTarget"
  23185. */
  23186. getClassName(): string;
  23187. /**
  23188. * Creates a new target from serialized data
  23189. * @param serializationObject defines the serialized data to use
  23190. * @returns a new MorphTarget
  23191. */
  23192. static Parse(serializationObject: any): MorphTarget;
  23193. /**
  23194. * Creates a MorphTarget from mesh data
  23195. * @param mesh defines the source mesh
  23196. * @param name defines the name to use for the new target
  23197. * @param influence defines the influence to attach to the target
  23198. * @returns a new MorphTarget
  23199. */
  23200. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23201. }
  23202. }
  23203. declare module BABYLON {
  23204. /**
  23205. * This class is used to deform meshes using morphing between different targets
  23206. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23207. */
  23208. export class MorphTargetManager {
  23209. private _targets;
  23210. private _targetInfluenceChangedObservers;
  23211. private _targetDataLayoutChangedObservers;
  23212. private _activeTargets;
  23213. private _scene;
  23214. private _influences;
  23215. private _supportsNormals;
  23216. private _supportsTangents;
  23217. private _supportsUVs;
  23218. private _vertexCount;
  23219. private _uniqueId;
  23220. private _tempInfluences;
  23221. /**
  23222. * Gets or sets a boolean indicating if normals must be morphed
  23223. */
  23224. enableNormalMorphing: boolean;
  23225. /**
  23226. * Gets or sets a boolean indicating if tangents must be morphed
  23227. */
  23228. enableTangentMorphing: boolean;
  23229. /**
  23230. * Gets or sets a boolean indicating if UV must be morphed
  23231. */
  23232. enableUVMorphing: boolean;
  23233. /**
  23234. * Creates a new MorphTargetManager
  23235. * @param scene defines the current scene
  23236. */
  23237. constructor(scene?: Nullable<Scene>);
  23238. /**
  23239. * Gets the unique ID of this manager
  23240. */
  23241. get uniqueId(): number;
  23242. /**
  23243. * Gets the number of vertices handled by this manager
  23244. */
  23245. get vertexCount(): number;
  23246. /**
  23247. * Gets a boolean indicating if this manager supports morphing of normals
  23248. */
  23249. get supportsNormals(): boolean;
  23250. /**
  23251. * Gets a boolean indicating if this manager supports morphing of tangents
  23252. */
  23253. get supportsTangents(): boolean;
  23254. /**
  23255. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23256. */
  23257. get supportsUVs(): boolean;
  23258. /**
  23259. * Gets the number of targets stored in this manager
  23260. */
  23261. get numTargets(): number;
  23262. /**
  23263. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23264. */
  23265. get numInfluencers(): number;
  23266. /**
  23267. * Gets the list of influences (one per target)
  23268. */
  23269. get influences(): Float32Array;
  23270. /**
  23271. * Gets the active target at specified index. An active target is a target with an influence > 0
  23272. * @param index defines the index to check
  23273. * @returns the requested target
  23274. */
  23275. getActiveTarget(index: number): MorphTarget;
  23276. /**
  23277. * Gets the target at specified index
  23278. * @param index defines the index to check
  23279. * @returns the requested target
  23280. */
  23281. getTarget(index: number): MorphTarget;
  23282. /**
  23283. * Add a new target to this manager
  23284. * @param target defines the target to add
  23285. */
  23286. addTarget(target: MorphTarget): void;
  23287. /**
  23288. * Removes a target from the manager
  23289. * @param target defines the target to remove
  23290. */
  23291. removeTarget(target: MorphTarget): void;
  23292. /**
  23293. * Clone the current manager
  23294. * @returns a new MorphTargetManager
  23295. */
  23296. clone(): MorphTargetManager;
  23297. /**
  23298. * Serializes the current manager into a Serialization object
  23299. * @returns the serialized object
  23300. */
  23301. serialize(): any;
  23302. private _syncActiveTargets;
  23303. /**
  23304. * Syncrhonize the targets with all the meshes using this morph target manager
  23305. */
  23306. synchronize(): void;
  23307. /**
  23308. * Creates a new MorphTargetManager from serialized data
  23309. * @param serializationObject defines the serialized data
  23310. * @param scene defines the hosting scene
  23311. * @returns the new MorphTargetManager
  23312. */
  23313. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23314. }
  23315. }
  23316. declare module BABYLON {
  23317. /**
  23318. * Class used to represent a specific level of detail of a mesh
  23319. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23320. */
  23321. export class MeshLODLevel {
  23322. /** Defines the distance where this level should start being displayed */
  23323. distance: number;
  23324. /** Defines the mesh to use to render this level */
  23325. mesh: Nullable<Mesh>;
  23326. /**
  23327. * Creates a new LOD level
  23328. * @param distance defines the distance where this level should star being displayed
  23329. * @param mesh defines the mesh to use to render this level
  23330. */
  23331. constructor(
  23332. /** Defines the distance where this level should start being displayed */
  23333. distance: number,
  23334. /** Defines the mesh to use to render this level */
  23335. mesh: Nullable<Mesh>);
  23336. }
  23337. }
  23338. declare module BABYLON {
  23339. /**
  23340. * Mesh representing the gorund
  23341. */
  23342. export class GroundMesh extends Mesh {
  23343. /** If octree should be generated */
  23344. generateOctree: boolean;
  23345. private _heightQuads;
  23346. /** @hidden */
  23347. _subdivisionsX: number;
  23348. /** @hidden */
  23349. _subdivisionsY: number;
  23350. /** @hidden */
  23351. _width: number;
  23352. /** @hidden */
  23353. _height: number;
  23354. /** @hidden */
  23355. _minX: number;
  23356. /** @hidden */
  23357. _maxX: number;
  23358. /** @hidden */
  23359. _minZ: number;
  23360. /** @hidden */
  23361. _maxZ: number;
  23362. constructor(name: string, scene: Scene);
  23363. /**
  23364. * "GroundMesh"
  23365. * @returns "GroundMesh"
  23366. */
  23367. getClassName(): string;
  23368. /**
  23369. * The minimum of x and y subdivisions
  23370. */
  23371. get subdivisions(): number;
  23372. /**
  23373. * X subdivisions
  23374. */
  23375. get subdivisionsX(): number;
  23376. /**
  23377. * Y subdivisions
  23378. */
  23379. get subdivisionsY(): number;
  23380. /**
  23381. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23382. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23383. * @param chunksCount the number of subdivisions for x and y
  23384. * @param octreeBlocksSize (Default: 32)
  23385. */
  23386. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23387. /**
  23388. * Returns a height (y) value in the Worl system :
  23389. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23390. * @param x x coordinate
  23391. * @param z z coordinate
  23392. * @returns the ground y position if (x, z) are outside the ground surface.
  23393. */
  23394. getHeightAtCoordinates(x: number, z: number): number;
  23395. /**
  23396. * Returns a normalized vector (Vector3) orthogonal to the ground
  23397. * at the ground coordinates (x, z) expressed in the World system.
  23398. * @param x x coordinate
  23399. * @param z z coordinate
  23400. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23401. */
  23402. getNormalAtCoordinates(x: number, z: number): Vector3;
  23403. /**
  23404. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23405. * at the ground coordinates (x, z) expressed in the World system.
  23406. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23407. * @param x x coordinate
  23408. * @param z z coordinate
  23409. * @param ref vector to store the result
  23410. * @returns the GroundMesh.
  23411. */
  23412. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23413. /**
  23414. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23415. * if the ground has been updated.
  23416. * This can be used in the render loop.
  23417. * @returns the GroundMesh.
  23418. */
  23419. updateCoordinateHeights(): GroundMesh;
  23420. private _getFacetAt;
  23421. private _initHeightQuads;
  23422. private _computeHeightQuads;
  23423. /**
  23424. * Serializes this ground mesh
  23425. * @param serializationObject object to write serialization to
  23426. */
  23427. serialize(serializationObject: any): void;
  23428. /**
  23429. * Parses a serialized ground mesh
  23430. * @param parsedMesh the serialized mesh
  23431. * @param scene the scene to create the ground mesh in
  23432. * @returns the created ground mesh
  23433. */
  23434. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23435. }
  23436. }
  23437. declare module BABYLON {
  23438. /**
  23439. * Interface for Physics-Joint data
  23440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23441. */
  23442. export interface PhysicsJointData {
  23443. /**
  23444. * The main pivot of the joint
  23445. */
  23446. mainPivot?: Vector3;
  23447. /**
  23448. * The connected pivot of the joint
  23449. */
  23450. connectedPivot?: Vector3;
  23451. /**
  23452. * The main axis of the joint
  23453. */
  23454. mainAxis?: Vector3;
  23455. /**
  23456. * The connected axis of the joint
  23457. */
  23458. connectedAxis?: Vector3;
  23459. /**
  23460. * The collision of the joint
  23461. */
  23462. collision?: boolean;
  23463. /**
  23464. * Native Oimo/Cannon/Energy data
  23465. */
  23466. nativeParams?: any;
  23467. }
  23468. /**
  23469. * This is a holder class for the physics joint created by the physics plugin
  23470. * It holds a set of functions to control the underlying joint
  23471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23472. */
  23473. export class PhysicsJoint {
  23474. /**
  23475. * The type of the physics joint
  23476. */
  23477. type: number;
  23478. /**
  23479. * The data for the physics joint
  23480. */
  23481. jointData: PhysicsJointData;
  23482. private _physicsJoint;
  23483. protected _physicsPlugin: IPhysicsEnginePlugin;
  23484. /**
  23485. * Initializes the physics joint
  23486. * @param type The type of the physics joint
  23487. * @param jointData The data for the physics joint
  23488. */
  23489. constructor(
  23490. /**
  23491. * The type of the physics joint
  23492. */
  23493. type: number,
  23494. /**
  23495. * The data for the physics joint
  23496. */
  23497. jointData: PhysicsJointData);
  23498. /**
  23499. * Gets the physics joint
  23500. */
  23501. get physicsJoint(): any;
  23502. /**
  23503. * Sets the physics joint
  23504. */
  23505. set physicsJoint(newJoint: any);
  23506. /**
  23507. * Sets the physics plugin
  23508. */
  23509. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23510. /**
  23511. * Execute a function that is physics-plugin specific.
  23512. * @param {Function} func the function that will be executed.
  23513. * It accepts two parameters: the physics world and the physics joint
  23514. */
  23515. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23516. /**
  23517. * Distance-Joint type
  23518. */
  23519. static DistanceJoint: number;
  23520. /**
  23521. * Hinge-Joint type
  23522. */
  23523. static HingeJoint: number;
  23524. /**
  23525. * Ball-and-Socket joint type
  23526. */
  23527. static BallAndSocketJoint: number;
  23528. /**
  23529. * Wheel-Joint type
  23530. */
  23531. static WheelJoint: number;
  23532. /**
  23533. * Slider-Joint type
  23534. */
  23535. static SliderJoint: number;
  23536. /**
  23537. * Prismatic-Joint type
  23538. */
  23539. static PrismaticJoint: number;
  23540. /**
  23541. * Universal-Joint type
  23542. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23543. */
  23544. static UniversalJoint: number;
  23545. /**
  23546. * Hinge-Joint 2 type
  23547. */
  23548. static Hinge2Joint: number;
  23549. /**
  23550. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23551. */
  23552. static PointToPointJoint: number;
  23553. /**
  23554. * Spring-Joint type
  23555. */
  23556. static SpringJoint: number;
  23557. /**
  23558. * Lock-Joint type
  23559. */
  23560. static LockJoint: number;
  23561. }
  23562. /**
  23563. * A class representing a physics distance joint
  23564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23565. */
  23566. export class DistanceJoint extends PhysicsJoint {
  23567. /**
  23568. *
  23569. * @param jointData The data for the Distance-Joint
  23570. */
  23571. constructor(jointData: DistanceJointData);
  23572. /**
  23573. * Update the predefined distance.
  23574. * @param maxDistance The maximum preferred distance
  23575. * @param minDistance The minimum preferred distance
  23576. */
  23577. updateDistance(maxDistance: number, minDistance?: number): void;
  23578. }
  23579. /**
  23580. * Represents a Motor-Enabled Joint
  23581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23582. */
  23583. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23584. /**
  23585. * Initializes the Motor-Enabled Joint
  23586. * @param type The type of the joint
  23587. * @param jointData The physica joint data for the joint
  23588. */
  23589. constructor(type: number, jointData: PhysicsJointData);
  23590. /**
  23591. * Set the motor values.
  23592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23593. * @param force the force to apply
  23594. * @param maxForce max force for this motor.
  23595. */
  23596. setMotor(force?: number, maxForce?: number): void;
  23597. /**
  23598. * Set the motor's limits.
  23599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23600. * @param upperLimit The upper limit of the motor
  23601. * @param lowerLimit The lower limit of the motor
  23602. */
  23603. setLimit(upperLimit: number, lowerLimit?: number): void;
  23604. }
  23605. /**
  23606. * This class represents a single physics Hinge-Joint
  23607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23608. */
  23609. export class HingeJoint extends MotorEnabledJoint {
  23610. /**
  23611. * Initializes the Hinge-Joint
  23612. * @param jointData The joint data for the Hinge-Joint
  23613. */
  23614. constructor(jointData: PhysicsJointData);
  23615. /**
  23616. * Set the motor values.
  23617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23618. * @param {number} force the force to apply
  23619. * @param {number} maxForce max force for this motor.
  23620. */
  23621. setMotor(force?: number, maxForce?: number): void;
  23622. /**
  23623. * Set the motor's limits.
  23624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23625. * @param upperLimit The upper limit of the motor
  23626. * @param lowerLimit The lower limit of the motor
  23627. */
  23628. setLimit(upperLimit: number, lowerLimit?: number): void;
  23629. }
  23630. /**
  23631. * This class represents a dual hinge physics joint (same as wheel joint)
  23632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23633. */
  23634. export class Hinge2Joint extends MotorEnabledJoint {
  23635. /**
  23636. * Initializes the Hinge2-Joint
  23637. * @param jointData The joint data for the Hinge2-Joint
  23638. */
  23639. constructor(jointData: PhysicsJointData);
  23640. /**
  23641. * Set the motor values.
  23642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23643. * @param {number} targetSpeed the speed the motor is to reach
  23644. * @param {number} maxForce max force for this motor.
  23645. * @param {motorIndex} the motor's index, 0 or 1.
  23646. */
  23647. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23648. /**
  23649. * Set the motor limits.
  23650. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23651. * @param {number} upperLimit the upper limit
  23652. * @param {number} lowerLimit lower limit
  23653. * @param {motorIndex} the motor's index, 0 or 1.
  23654. */
  23655. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23656. }
  23657. /**
  23658. * Interface for a motor enabled joint
  23659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23660. */
  23661. export interface IMotorEnabledJoint {
  23662. /**
  23663. * Physics joint
  23664. */
  23665. physicsJoint: any;
  23666. /**
  23667. * Sets the motor of the motor-enabled joint
  23668. * @param force The force of the motor
  23669. * @param maxForce The maximum force of the motor
  23670. * @param motorIndex The index of the motor
  23671. */
  23672. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23673. /**
  23674. * Sets the limit of the motor
  23675. * @param upperLimit The upper limit of the motor
  23676. * @param lowerLimit The lower limit of the motor
  23677. * @param motorIndex The index of the motor
  23678. */
  23679. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23680. }
  23681. /**
  23682. * Joint data for a Distance-Joint
  23683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23684. */
  23685. export interface DistanceJointData extends PhysicsJointData {
  23686. /**
  23687. * Max distance the 2 joint objects can be apart
  23688. */
  23689. maxDistance: number;
  23690. }
  23691. /**
  23692. * Joint data from a spring joint
  23693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23694. */
  23695. export interface SpringJointData extends PhysicsJointData {
  23696. /**
  23697. * Length of the spring
  23698. */
  23699. length: number;
  23700. /**
  23701. * Stiffness of the spring
  23702. */
  23703. stiffness: number;
  23704. /**
  23705. * Damping of the spring
  23706. */
  23707. damping: number;
  23708. /** this callback will be called when applying the force to the impostors. */
  23709. forceApplicationCallback: () => void;
  23710. }
  23711. }
  23712. declare module BABYLON {
  23713. /**
  23714. * Holds the data for the raycast result
  23715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23716. */
  23717. export class PhysicsRaycastResult {
  23718. private _hasHit;
  23719. private _hitDistance;
  23720. private _hitNormalWorld;
  23721. private _hitPointWorld;
  23722. private _rayFromWorld;
  23723. private _rayToWorld;
  23724. /**
  23725. * Gets if there was a hit
  23726. */
  23727. get hasHit(): boolean;
  23728. /**
  23729. * Gets the distance from the hit
  23730. */
  23731. get hitDistance(): number;
  23732. /**
  23733. * Gets the hit normal/direction in the world
  23734. */
  23735. get hitNormalWorld(): Vector3;
  23736. /**
  23737. * Gets the hit point in the world
  23738. */
  23739. get hitPointWorld(): Vector3;
  23740. /**
  23741. * Gets the ray "start point" of the ray in the world
  23742. */
  23743. get rayFromWorld(): Vector3;
  23744. /**
  23745. * Gets the ray "end point" of the ray in the world
  23746. */
  23747. get rayToWorld(): Vector3;
  23748. /**
  23749. * Sets the hit data (normal & point in world space)
  23750. * @param hitNormalWorld defines the normal in world space
  23751. * @param hitPointWorld defines the point in world space
  23752. */
  23753. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23754. /**
  23755. * Sets the distance from the start point to the hit point
  23756. * @param distance
  23757. */
  23758. setHitDistance(distance: number): void;
  23759. /**
  23760. * Calculates the distance manually
  23761. */
  23762. calculateHitDistance(): void;
  23763. /**
  23764. * Resets all the values to default
  23765. * @param from The from point on world space
  23766. * @param to The to point on world space
  23767. */
  23768. reset(from?: Vector3, to?: Vector3): void;
  23769. }
  23770. /**
  23771. * Interface for the size containing width and height
  23772. */
  23773. interface IXYZ {
  23774. /**
  23775. * X
  23776. */
  23777. x: number;
  23778. /**
  23779. * Y
  23780. */
  23781. y: number;
  23782. /**
  23783. * Z
  23784. */
  23785. z: number;
  23786. }
  23787. }
  23788. declare module BABYLON {
  23789. /**
  23790. * Interface used to describe a physics joint
  23791. */
  23792. export interface PhysicsImpostorJoint {
  23793. /** Defines the main impostor to which the joint is linked */
  23794. mainImpostor: PhysicsImpostor;
  23795. /** Defines the impostor that is connected to the main impostor using this joint */
  23796. connectedImpostor: PhysicsImpostor;
  23797. /** Defines the joint itself */
  23798. joint: PhysicsJoint;
  23799. }
  23800. /** @hidden */
  23801. export interface IPhysicsEnginePlugin {
  23802. world: any;
  23803. name: string;
  23804. setGravity(gravity: Vector3): void;
  23805. setTimeStep(timeStep: number): void;
  23806. getTimeStep(): number;
  23807. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23808. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23809. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23810. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23811. removePhysicsBody(impostor: PhysicsImpostor): void;
  23812. generateJoint(joint: PhysicsImpostorJoint): void;
  23813. removeJoint(joint: PhysicsImpostorJoint): void;
  23814. isSupported(): boolean;
  23815. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23816. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23817. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23818. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23820. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23821. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23822. getBodyMass(impostor: PhysicsImpostor): number;
  23823. getBodyFriction(impostor: PhysicsImpostor): number;
  23824. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23825. getBodyRestitution(impostor: PhysicsImpostor): number;
  23826. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23827. getBodyPressure?(impostor: PhysicsImpostor): number;
  23828. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23829. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23830. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23831. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23832. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23833. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23834. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23835. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23836. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23837. sleepBody(impostor: PhysicsImpostor): void;
  23838. wakeUpBody(impostor: PhysicsImpostor): void;
  23839. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23841. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23843. getRadius(impostor: PhysicsImpostor): number;
  23844. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23845. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23846. dispose(): void;
  23847. }
  23848. /**
  23849. * Interface used to define a physics engine
  23850. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23851. */
  23852. export interface IPhysicsEngine {
  23853. /**
  23854. * Gets the gravity vector used by the simulation
  23855. */
  23856. gravity: Vector3;
  23857. /**
  23858. * Sets the gravity vector used by the simulation
  23859. * @param gravity defines the gravity vector to use
  23860. */
  23861. setGravity(gravity: Vector3): void;
  23862. /**
  23863. * Set the time step of the physics engine.
  23864. * Default is 1/60.
  23865. * To slow it down, enter 1/600 for example.
  23866. * To speed it up, 1/30
  23867. * @param newTimeStep the new timestep to apply to this world.
  23868. */
  23869. setTimeStep(newTimeStep: number): void;
  23870. /**
  23871. * Get the time step of the physics engine.
  23872. * @returns the current time step
  23873. */
  23874. getTimeStep(): number;
  23875. /**
  23876. * Set the sub time step of the physics engine.
  23877. * Default is 0 meaning there is no sub steps
  23878. * To increase physics resolution precision, set a small value (like 1 ms)
  23879. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23880. */
  23881. setSubTimeStep(subTimeStep: number): void;
  23882. /**
  23883. * Get the sub time step of the physics engine.
  23884. * @returns the current sub time step
  23885. */
  23886. getSubTimeStep(): number;
  23887. /**
  23888. * Release all resources
  23889. */
  23890. dispose(): void;
  23891. /**
  23892. * Gets the name of the current physics plugin
  23893. * @returns the name of the plugin
  23894. */
  23895. getPhysicsPluginName(): string;
  23896. /**
  23897. * Adding a new impostor for the impostor tracking.
  23898. * This will be done by the impostor itself.
  23899. * @param impostor the impostor to add
  23900. */
  23901. addImpostor(impostor: PhysicsImpostor): void;
  23902. /**
  23903. * Remove an impostor from the engine.
  23904. * This impostor and its mesh will not longer be updated by the physics engine.
  23905. * @param impostor the impostor to remove
  23906. */
  23907. removeImpostor(impostor: PhysicsImpostor): void;
  23908. /**
  23909. * Add a joint to the physics engine
  23910. * @param mainImpostor defines the main impostor to which the joint is added.
  23911. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23912. * @param joint defines the joint that will connect both impostors.
  23913. */
  23914. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23915. /**
  23916. * Removes a joint from the simulation
  23917. * @param mainImpostor defines the impostor used with the joint
  23918. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23919. * @param joint defines the joint to remove
  23920. */
  23921. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23922. /**
  23923. * Gets the current plugin used to run the simulation
  23924. * @returns current plugin
  23925. */
  23926. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23927. /**
  23928. * Gets the list of physic impostors
  23929. * @returns an array of PhysicsImpostor
  23930. */
  23931. getImpostors(): Array<PhysicsImpostor>;
  23932. /**
  23933. * Gets the impostor for a physics enabled object
  23934. * @param object defines the object impersonated by the impostor
  23935. * @returns the PhysicsImpostor or null if not found
  23936. */
  23937. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23938. /**
  23939. * Gets the impostor for a physics body object
  23940. * @param body defines physics body used by the impostor
  23941. * @returns the PhysicsImpostor or null if not found
  23942. */
  23943. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23944. /**
  23945. * Does a raycast in the physics world
  23946. * @param from when should the ray start?
  23947. * @param to when should the ray end?
  23948. * @returns PhysicsRaycastResult
  23949. */
  23950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23951. /**
  23952. * Called by the scene. No need to call it.
  23953. * @param delta defines the timespam between frames
  23954. */
  23955. _step(delta: number): void;
  23956. }
  23957. }
  23958. declare module BABYLON {
  23959. /**
  23960. * The interface for the physics imposter parameters
  23961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23962. */
  23963. export interface PhysicsImpostorParameters {
  23964. /**
  23965. * The mass of the physics imposter
  23966. */
  23967. mass: number;
  23968. /**
  23969. * The friction of the physics imposter
  23970. */
  23971. friction?: number;
  23972. /**
  23973. * The coefficient of restitution of the physics imposter
  23974. */
  23975. restitution?: number;
  23976. /**
  23977. * The native options of the physics imposter
  23978. */
  23979. nativeOptions?: any;
  23980. /**
  23981. * Specifies if the parent should be ignored
  23982. */
  23983. ignoreParent?: boolean;
  23984. /**
  23985. * Specifies if bi-directional transformations should be disabled
  23986. */
  23987. disableBidirectionalTransformation?: boolean;
  23988. /**
  23989. * The pressure inside the physics imposter, soft object only
  23990. */
  23991. pressure?: number;
  23992. /**
  23993. * The stiffness the physics imposter, soft object only
  23994. */
  23995. stiffness?: number;
  23996. /**
  23997. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23998. */
  23999. velocityIterations?: number;
  24000. /**
  24001. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24002. */
  24003. positionIterations?: number;
  24004. /**
  24005. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24006. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24007. * Add to fix multiple points
  24008. */
  24009. fixedPoints?: number;
  24010. /**
  24011. * The collision margin around a soft object
  24012. */
  24013. margin?: number;
  24014. /**
  24015. * The collision margin around a soft object
  24016. */
  24017. damping?: number;
  24018. /**
  24019. * The path for a rope based on an extrusion
  24020. */
  24021. path?: any;
  24022. /**
  24023. * The shape of an extrusion used for a rope based on an extrusion
  24024. */
  24025. shape?: any;
  24026. }
  24027. /**
  24028. * Interface for a physics-enabled object
  24029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24030. */
  24031. export interface IPhysicsEnabledObject {
  24032. /**
  24033. * The position of the physics-enabled object
  24034. */
  24035. position: Vector3;
  24036. /**
  24037. * The rotation of the physics-enabled object
  24038. */
  24039. rotationQuaternion: Nullable<Quaternion>;
  24040. /**
  24041. * The scale of the physics-enabled object
  24042. */
  24043. scaling: Vector3;
  24044. /**
  24045. * The rotation of the physics-enabled object
  24046. */
  24047. rotation?: Vector3;
  24048. /**
  24049. * The parent of the physics-enabled object
  24050. */
  24051. parent?: any;
  24052. /**
  24053. * The bounding info of the physics-enabled object
  24054. * @returns The bounding info of the physics-enabled object
  24055. */
  24056. getBoundingInfo(): BoundingInfo;
  24057. /**
  24058. * Computes the world matrix
  24059. * @param force Specifies if the world matrix should be computed by force
  24060. * @returns A world matrix
  24061. */
  24062. computeWorldMatrix(force: boolean): Matrix;
  24063. /**
  24064. * Gets the world matrix
  24065. * @returns A world matrix
  24066. */
  24067. getWorldMatrix?(): Matrix;
  24068. /**
  24069. * Gets the child meshes
  24070. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24071. * @returns An array of abstract meshes
  24072. */
  24073. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24074. /**
  24075. * Gets the vertex data
  24076. * @param kind The type of vertex data
  24077. * @returns A nullable array of numbers, or a float32 array
  24078. */
  24079. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24080. /**
  24081. * Gets the indices from the mesh
  24082. * @returns A nullable array of index arrays
  24083. */
  24084. getIndices?(): Nullable<IndicesArray>;
  24085. /**
  24086. * Gets the scene from the mesh
  24087. * @returns the indices array or null
  24088. */
  24089. getScene?(): Scene;
  24090. /**
  24091. * Gets the absolute position from the mesh
  24092. * @returns the absolute position
  24093. */
  24094. getAbsolutePosition(): Vector3;
  24095. /**
  24096. * Gets the absolute pivot point from the mesh
  24097. * @returns the absolute pivot point
  24098. */
  24099. getAbsolutePivotPoint(): Vector3;
  24100. /**
  24101. * Rotates the mesh
  24102. * @param axis The axis of rotation
  24103. * @param amount The amount of rotation
  24104. * @param space The space of the rotation
  24105. * @returns The rotation transform node
  24106. */
  24107. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24108. /**
  24109. * Translates the mesh
  24110. * @param axis The axis of translation
  24111. * @param distance The distance of translation
  24112. * @param space The space of the translation
  24113. * @returns The transform node
  24114. */
  24115. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24116. /**
  24117. * Sets the absolute position of the mesh
  24118. * @param absolutePosition The absolute position of the mesh
  24119. * @returns The transform node
  24120. */
  24121. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24122. /**
  24123. * Gets the class name of the mesh
  24124. * @returns The class name
  24125. */
  24126. getClassName(): string;
  24127. }
  24128. /**
  24129. * Represents a physics imposter
  24130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24131. */
  24132. export class PhysicsImpostor {
  24133. /**
  24134. * The physics-enabled object used as the physics imposter
  24135. */
  24136. object: IPhysicsEnabledObject;
  24137. /**
  24138. * The type of the physics imposter
  24139. */
  24140. type: number;
  24141. private _options;
  24142. private _scene?;
  24143. /**
  24144. * The default object size of the imposter
  24145. */
  24146. static DEFAULT_OBJECT_SIZE: Vector3;
  24147. /**
  24148. * The identity quaternion of the imposter
  24149. */
  24150. static IDENTITY_QUATERNION: Quaternion;
  24151. /** @hidden */
  24152. _pluginData: any;
  24153. private _physicsEngine;
  24154. private _physicsBody;
  24155. private _bodyUpdateRequired;
  24156. private _onBeforePhysicsStepCallbacks;
  24157. private _onAfterPhysicsStepCallbacks;
  24158. /** @hidden */
  24159. _onPhysicsCollideCallbacks: Array<{
  24160. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24161. otherImpostors: Array<PhysicsImpostor>;
  24162. }>;
  24163. private _deltaPosition;
  24164. private _deltaRotation;
  24165. private _deltaRotationConjugated;
  24166. /** @hidden */
  24167. _isFromLine: boolean;
  24168. private _parent;
  24169. private _isDisposed;
  24170. private static _tmpVecs;
  24171. private static _tmpQuat;
  24172. /**
  24173. * Specifies if the physics imposter is disposed
  24174. */
  24175. get isDisposed(): boolean;
  24176. /**
  24177. * Gets the mass of the physics imposter
  24178. */
  24179. get mass(): number;
  24180. set mass(value: number);
  24181. /**
  24182. * Gets the coefficient of friction
  24183. */
  24184. get friction(): number;
  24185. /**
  24186. * Sets the coefficient of friction
  24187. */
  24188. set friction(value: number);
  24189. /**
  24190. * Gets the coefficient of restitution
  24191. */
  24192. get restitution(): number;
  24193. /**
  24194. * Sets the coefficient of restitution
  24195. */
  24196. set restitution(value: number);
  24197. /**
  24198. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24199. */
  24200. get pressure(): number;
  24201. /**
  24202. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24203. */
  24204. set pressure(value: number);
  24205. /**
  24206. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24207. */
  24208. get stiffness(): number;
  24209. /**
  24210. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24211. */
  24212. set stiffness(value: number);
  24213. /**
  24214. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24215. */
  24216. get velocityIterations(): number;
  24217. /**
  24218. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24219. */
  24220. set velocityIterations(value: number);
  24221. /**
  24222. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24223. */
  24224. get positionIterations(): number;
  24225. /**
  24226. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24227. */
  24228. set positionIterations(value: number);
  24229. /**
  24230. * The unique id of the physics imposter
  24231. * set by the physics engine when adding this impostor to the array
  24232. */
  24233. uniqueId: number;
  24234. /**
  24235. * @hidden
  24236. */
  24237. soft: boolean;
  24238. /**
  24239. * @hidden
  24240. */
  24241. segments: number;
  24242. private _joints;
  24243. /**
  24244. * Initializes the physics imposter
  24245. * @param object The physics-enabled object used as the physics imposter
  24246. * @param type The type of the physics imposter
  24247. * @param _options The options for the physics imposter
  24248. * @param _scene The Babylon scene
  24249. */
  24250. constructor(
  24251. /**
  24252. * The physics-enabled object used as the physics imposter
  24253. */
  24254. object: IPhysicsEnabledObject,
  24255. /**
  24256. * The type of the physics imposter
  24257. */
  24258. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24259. /**
  24260. * This function will completly initialize this impostor.
  24261. * It will create a new body - but only if this mesh has no parent.
  24262. * If it has, this impostor will not be used other than to define the impostor
  24263. * of the child mesh.
  24264. * @hidden
  24265. */
  24266. _init(): void;
  24267. private _getPhysicsParent;
  24268. /**
  24269. * Should a new body be generated.
  24270. * @returns boolean specifying if body initialization is required
  24271. */
  24272. isBodyInitRequired(): boolean;
  24273. /**
  24274. * Sets the updated scaling
  24275. * @param updated Specifies if the scaling is updated
  24276. */
  24277. setScalingUpdated(): void;
  24278. /**
  24279. * Force a regeneration of this or the parent's impostor's body.
  24280. * Use under cautious - This will remove all joints already implemented.
  24281. */
  24282. forceUpdate(): void;
  24283. /**
  24284. * Gets the body that holds this impostor. Either its own, or its parent.
  24285. */
  24286. get physicsBody(): any;
  24287. /**
  24288. * Get the parent of the physics imposter
  24289. * @returns Physics imposter or null
  24290. */
  24291. get parent(): Nullable<PhysicsImpostor>;
  24292. /**
  24293. * Sets the parent of the physics imposter
  24294. */
  24295. set parent(value: Nullable<PhysicsImpostor>);
  24296. /**
  24297. * Set the physics body. Used mainly by the physics engine/plugin
  24298. */
  24299. set physicsBody(physicsBody: any);
  24300. /**
  24301. * Resets the update flags
  24302. */
  24303. resetUpdateFlags(): void;
  24304. /**
  24305. * Gets the object extend size
  24306. * @returns the object extend size
  24307. */
  24308. getObjectExtendSize(): Vector3;
  24309. /**
  24310. * Gets the object center
  24311. * @returns The object center
  24312. */
  24313. getObjectCenter(): Vector3;
  24314. /**
  24315. * Get a specific parameter from the options parameters
  24316. * @param paramName The object parameter name
  24317. * @returns The object parameter
  24318. */
  24319. getParam(paramName: string): any;
  24320. /**
  24321. * Sets a specific parameter in the options given to the physics plugin
  24322. * @param paramName The parameter name
  24323. * @param value The value of the parameter
  24324. */
  24325. setParam(paramName: string, value: number): void;
  24326. /**
  24327. * Specifically change the body's mass option. Won't recreate the physics body object
  24328. * @param mass The mass of the physics imposter
  24329. */
  24330. setMass(mass: number): void;
  24331. /**
  24332. * Gets the linear velocity
  24333. * @returns linear velocity or null
  24334. */
  24335. getLinearVelocity(): Nullable<Vector3>;
  24336. /**
  24337. * Sets the linear velocity
  24338. * @param velocity linear velocity or null
  24339. */
  24340. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24341. /**
  24342. * Gets the angular velocity
  24343. * @returns angular velocity or null
  24344. */
  24345. getAngularVelocity(): Nullable<Vector3>;
  24346. /**
  24347. * Sets the angular velocity
  24348. * @param velocity The velocity or null
  24349. */
  24350. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24351. /**
  24352. * Execute a function with the physics plugin native code
  24353. * Provide a function the will have two variables - the world object and the physics body object
  24354. * @param func The function to execute with the physics plugin native code
  24355. */
  24356. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24357. /**
  24358. * Register a function that will be executed before the physics world is stepping forward
  24359. * @param func The function to execute before the physics world is stepped forward
  24360. */
  24361. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24362. /**
  24363. * Unregister a function that will be executed before the physics world is stepping forward
  24364. * @param func The function to execute before the physics world is stepped forward
  24365. */
  24366. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24367. /**
  24368. * Register a function that will be executed after the physics step
  24369. * @param func The function to execute after physics step
  24370. */
  24371. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24372. /**
  24373. * Unregisters a function that will be executed after the physics step
  24374. * @param func The function to execute after physics step
  24375. */
  24376. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24377. /**
  24378. * register a function that will be executed when this impostor collides against a different body
  24379. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24380. * @param func Callback that is executed on collision
  24381. */
  24382. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24383. /**
  24384. * Unregisters the physics imposter on contact
  24385. * @param collideAgainst The physics object to collide against
  24386. * @param func Callback to execute on collision
  24387. */
  24388. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24389. private _tmpQuat;
  24390. private _tmpQuat2;
  24391. /**
  24392. * Get the parent rotation
  24393. * @returns The parent rotation
  24394. */
  24395. getParentsRotation(): Quaternion;
  24396. /**
  24397. * this function is executed by the physics engine.
  24398. */
  24399. beforeStep: () => void;
  24400. /**
  24401. * this function is executed by the physics engine
  24402. */
  24403. afterStep: () => void;
  24404. /**
  24405. * Legacy collision detection event support
  24406. */
  24407. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24408. /**
  24409. * event and body object due to cannon's event-based architecture.
  24410. */
  24411. onCollide: (e: {
  24412. body: any;
  24413. }) => void;
  24414. /**
  24415. * Apply a force
  24416. * @param force The force to apply
  24417. * @param contactPoint The contact point for the force
  24418. * @returns The physics imposter
  24419. */
  24420. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24421. /**
  24422. * Apply an impulse
  24423. * @param force The impulse force
  24424. * @param contactPoint The contact point for the impulse force
  24425. * @returns The physics imposter
  24426. */
  24427. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24428. /**
  24429. * A help function to create a joint
  24430. * @param otherImpostor A physics imposter used to create a joint
  24431. * @param jointType The type of joint
  24432. * @param jointData The data for the joint
  24433. * @returns The physics imposter
  24434. */
  24435. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24436. /**
  24437. * Add a joint to this impostor with a different impostor
  24438. * @param otherImpostor A physics imposter used to add a joint
  24439. * @param joint The joint to add
  24440. * @returns The physics imposter
  24441. */
  24442. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24443. /**
  24444. * Add an anchor to a cloth impostor
  24445. * @param otherImpostor rigid impostor to anchor to
  24446. * @param width ratio across width from 0 to 1
  24447. * @param height ratio up height from 0 to 1
  24448. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24449. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24450. * @returns impostor the soft imposter
  24451. */
  24452. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24453. /**
  24454. * Add a hook to a rope impostor
  24455. * @param otherImpostor rigid impostor to anchor to
  24456. * @param length ratio across rope from 0 to 1
  24457. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24458. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24459. * @returns impostor the rope imposter
  24460. */
  24461. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24462. /**
  24463. * Will keep this body still, in a sleep mode.
  24464. * @returns the physics imposter
  24465. */
  24466. sleep(): PhysicsImpostor;
  24467. /**
  24468. * Wake the body up.
  24469. * @returns The physics imposter
  24470. */
  24471. wakeUp(): PhysicsImpostor;
  24472. /**
  24473. * Clones the physics imposter
  24474. * @param newObject The physics imposter clones to this physics-enabled object
  24475. * @returns A nullable physics imposter
  24476. */
  24477. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24478. /**
  24479. * Disposes the physics imposter
  24480. */
  24481. dispose(): void;
  24482. /**
  24483. * Sets the delta position
  24484. * @param position The delta position amount
  24485. */
  24486. setDeltaPosition(position: Vector3): void;
  24487. /**
  24488. * Sets the delta rotation
  24489. * @param rotation The delta rotation amount
  24490. */
  24491. setDeltaRotation(rotation: Quaternion): void;
  24492. /**
  24493. * Gets the box size of the physics imposter and stores the result in the input parameter
  24494. * @param result Stores the box size
  24495. * @returns The physics imposter
  24496. */
  24497. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24498. /**
  24499. * Gets the radius of the physics imposter
  24500. * @returns Radius of the physics imposter
  24501. */
  24502. getRadius(): number;
  24503. /**
  24504. * Sync a bone with this impostor
  24505. * @param bone The bone to sync to the impostor.
  24506. * @param boneMesh The mesh that the bone is influencing.
  24507. * @param jointPivot The pivot of the joint / bone in local space.
  24508. * @param distToJoint Optional distance from the impostor to the joint.
  24509. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24510. */
  24511. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24512. /**
  24513. * Sync impostor to a bone
  24514. * @param bone The bone that the impostor will be synced to.
  24515. * @param boneMesh The mesh that the bone is influencing.
  24516. * @param jointPivot The pivot of the joint / bone in local space.
  24517. * @param distToJoint Optional distance from the impostor to the joint.
  24518. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24519. * @param boneAxis Optional vector3 axis the bone is aligned with
  24520. */
  24521. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24522. /**
  24523. * No-Imposter type
  24524. */
  24525. static NoImpostor: number;
  24526. /**
  24527. * Sphere-Imposter type
  24528. */
  24529. static SphereImpostor: number;
  24530. /**
  24531. * Box-Imposter type
  24532. */
  24533. static BoxImpostor: number;
  24534. /**
  24535. * Plane-Imposter type
  24536. */
  24537. static PlaneImpostor: number;
  24538. /**
  24539. * Mesh-imposter type
  24540. */
  24541. static MeshImpostor: number;
  24542. /**
  24543. * Capsule-Impostor type (Ammo.js plugin only)
  24544. */
  24545. static CapsuleImpostor: number;
  24546. /**
  24547. * Cylinder-Imposter type
  24548. */
  24549. static CylinderImpostor: number;
  24550. /**
  24551. * Particle-Imposter type
  24552. */
  24553. static ParticleImpostor: number;
  24554. /**
  24555. * Heightmap-Imposter type
  24556. */
  24557. static HeightmapImpostor: number;
  24558. /**
  24559. * ConvexHull-Impostor type (Ammo.js plugin only)
  24560. */
  24561. static ConvexHullImpostor: number;
  24562. /**
  24563. * Custom-Imposter type (Ammo.js plugin only)
  24564. */
  24565. static CustomImpostor: number;
  24566. /**
  24567. * Rope-Imposter type
  24568. */
  24569. static RopeImpostor: number;
  24570. /**
  24571. * Cloth-Imposter type
  24572. */
  24573. static ClothImpostor: number;
  24574. /**
  24575. * Softbody-Imposter type
  24576. */
  24577. static SoftbodyImpostor: number;
  24578. }
  24579. }
  24580. declare module BABYLON {
  24581. /**
  24582. * @hidden
  24583. **/
  24584. export class _CreationDataStorage {
  24585. closePath?: boolean;
  24586. closeArray?: boolean;
  24587. idx: number[];
  24588. dashSize: number;
  24589. gapSize: number;
  24590. path3D: Path3D;
  24591. pathArray: Vector3[][];
  24592. arc: number;
  24593. radius: number;
  24594. cap: number;
  24595. tessellation: number;
  24596. }
  24597. /**
  24598. * @hidden
  24599. **/
  24600. class _InstanceDataStorage {
  24601. visibleInstances: any;
  24602. batchCache: _InstancesBatch;
  24603. instancesBufferSize: number;
  24604. instancesBuffer: Nullable<Buffer>;
  24605. instancesData: Float32Array;
  24606. overridenInstanceCount: number;
  24607. isFrozen: boolean;
  24608. previousBatch: Nullable<_InstancesBatch>;
  24609. hardwareInstancedRendering: boolean;
  24610. sideOrientation: number;
  24611. manualUpdate: boolean;
  24612. }
  24613. /**
  24614. * @hidden
  24615. **/
  24616. export class _InstancesBatch {
  24617. mustReturn: boolean;
  24618. visibleInstances: Nullable<InstancedMesh[]>[];
  24619. renderSelf: boolean[];
  24620. hardwareInstancedRendering: boolean[];
  24621. }
  24622. /**
  24623. * Class used to represent renderable models
  24624. */
  24625. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24626. /**
  24627. * Mesh side orientation : usually the external or front surface
  24628. */
  24629. static readonly FRONTSIDE: number;
  24630. /**
  24631. * Mesh side orientation : usually the internal or back surface
  24632. */
  24633. static readonly BACKSIDE: number;
  24634. /**
  24635. * Mesh side orientation : both internal and external or front and back surfaces
  24636. */
  24637. static readonly DOUBLESIDE: number;
  24638. /**
  24639. * Mesh side orientation : by default, `FRONTSIDE`
  24640. */
  24641. static readonly DEFAULTSIDE: number;
  24642. /**
  24643. * Mesh cap setting : no cap
  24644. */
  24645. static readonly NO_CAP: number;
  24646. /**
  24647. * Mesh cap setting : one cap at the beginning of the mesh
  24648. */
  24649. static readonly CAP_START: number;
  24650. /**
  24651. * Mesh cap setting : one cap at the end of the mesh
  24652. */
  24653. static readonly CAP_END: number;
  24654. /**
  24655. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24656. */
  24657. static readonly CAP_ALL: number;
  24658. /**
  24659. * Mesh pattern setting : no flip or rotate
  24660. */
  24661. static readonly NO_FLIP: number;
  24662. /**
  24663. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24664. */
  24665. static readonly FLIP_TILE: number;
  24666. /**
  24667. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24668. */
  24669. static readonly ROTATE_TILE: number;
  24670. /**
  24671. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24672. */
  24673. static readonly FLIP_ROW: number;
  24674. /**
  24675. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24676. */
  24677. static readonly ROTATE_ROW: number;
  24678. /**
  24679. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24680. */
  24681. static readonly FLIP_N_ROTATE_TILE: number;
  24682. /**
  24683. * Mesh pattern setting : rotate pattern and rotate
  24684. */
  24685. static readonly FLIP_N_ROTATE_ROW: number;
  24686. /**
  24687. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24688. */
  24689. static readonly CENTER: number;
  24690. /**
  24691. * Mesh tile positioning : part tiles on left
  24692. */
  24693. static readonly LEFT: number;
  24694. /**
  24695. * Mesh tile positioning : part tiles on right
  24696. */
  24697. static readonly RIGHT: number;
  24698. /**
  24699. * Mesh tile positioning : part tiles on top
  24700. */
  24701. static readonly TOP: number;
  24702. /**
  24703. * Mesh tile positioning : part tiles on bottom
  24704. */
  24705. static readonly BOTTOM: number;
  24706. /**
  24707. * Gets the default side orientation.
  24708. * @param orientation the orientation to value to attempt to get
  24709. * @returns the default orientation
  24710. * @hidden
  24711. */
  24712. static _GetDefaultSideOrientation(orientation?: number): number;
  24713. private _internalMeshDataInfo;
  24714. /**
  24715. * An event triggered before rendering the mesh
  24716. */
  24717. get onBeforeRenderObservable(): Observable<Mesh>;
  24718. /**
  24719. * An event triggered before binding the mesh
  24720. */
  24721. get onBeforeBindObservable(): Observable<Mesh>;
  24722. /**
  24723. * An event triggered after rendering the mesh
  24724. */
  24725. get onAfterRenderObservable(): Observable<Mesh>;
  24726. /**
  24727. * An event triggered before drawing the mesh
  24728. */
  24729. get onBeforeDrawObservable(): Observable<Mesh>;
  24730. private _onBeforeDrawObserver;
  24731. /**
  24732. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24733. */
  24734. set onBeforeDraw(callback: () => void);
  24735. get hasInstances(): boolean;
  24736. /**
  24737. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24738. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24739. */
  24740. delayLoadState: number;
  24741. /**
  24742. * Gets the list of instances created from this mesh
  24743. * it is not supposed to be modified manually.
  24744. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24745. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24746. */
  24747. instances: InstancedMesh[];
  24748. /**
  24749. * Gets the file containing delay loading data for this mesh
  24750. */
  24751. delayLoadingFile: string;
  24752. /** @hidden */
  24753. _binaryInfo: any;
  24754. /**
  24755. * User defined function used to change how LOD level selection is done
  24756. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24757. */
  24758. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24759. /**
  24760. * Gets or sets the morph target manager
  24761. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24762. */
  24763. get morphTargetManager(): Nullable<MorphTargetManager>;
  24764. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24765. /** @hidden */
  24766. _creationDataStorage: Nullable<_CreationDataStorage>;
  24767. /** @hidden */
  24768. _geometry: Nullable<Geometry>;
  24769. /** @hidden */
  24770. _delayInfo: Array<string>;
  24771. /** @hidden */
  24772. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24773. /** @hidden */
  24774. _instanceDataStorage: _InstanceDataStorage;
  24775. private _effectiveMaterial;
  24776. /** @hidden */
  24777. _shouldGenerateFlatShading: boolean;
  24778. /** @hidden */
  24779. _originalBuilderSideOrientation: number;
  24780. /**
  24781. * Use this property to change the original side orientation defined at construction time
  24782. */
  24783. overrideMaterialSideOrientation: Nullable<number>;
  24784. /**
  24785. * Gets the source mesh (the one used to clone this one from)
  24786. */
  24787. get source(): Nullable<Mesh>;
  24788. /**
  24789. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24790. */
  24791. get isUnIndexed(): boolean;
  24792. set isUnIndexed(value: boolean);
  24793. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24794. get worldMatrixInstancedBuffer(): Float32Array;
  24795. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24796. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24797. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24798. /**
  24799. * @constructor
  24800. * @param name The value used by scene.getMeshByName() to do a lookup.
  24801. * @param scene The scene to add this mesh to.
  24802. * @param parent The parent of this mesh, if it has one
  24803. * @param source An optional Mesh from which geometry is shared, cloned.
  24804. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24805. * When false, achieved by calling a clone(), also passing False.
  24806. * This will make creation of children, recursive.
  24807. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24808. */
  24809. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24810. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24811. doNotInstantiate: boolean;
  24812. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24813. /**
  24814. * Gets the class name
  24815. * @returns the string "Mesh".
  24816. */
  24817. getClassName(): string;
  24818. /** @hidden */
  24819. get _isMesh(): boolean;
  24820. /**
  24821. * Returns a description of this mesh
  24822. * @param fullDetails define if full details about this mesh must be used
  24823. * @returns a descriptive string representing this mesh
  24824. */
  24825. toString(fullDetails?: boolean): string;
  24826. /** @hidden */
  24827. _unBindEffect(): void;
  24828. /**
  24829. * Gets a boolean indicating if this mesh has LOD
  24830. */
  24831. get hasLODLevels(): boolean;
  24832. /**
  24833. * Gets the list of MeshLODLevel associated with the current mesh
  24834. * @returns an array of MeshLODLevel
  24835. */
  24836. getLODLevels(): MeshLODLevel[];
  24837. private _sortLODLevels;
  24838. /**
  24839. * Add a mesh as LOD level triggered at the given distance.
  24840. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24841. * @param distance The distance from the center of the object to show this level
  24842. * @param mesh The mesh to be added as LOD level (can be null)
  24843. * @return This mesh (for chaining)
  24844. */
  24845. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24846. /**
  24847. * Returns the LOD level mesh at the passed distance or null if not found.
  24848. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24849. * @param distance The distance from the center of the object to show this level
  24850. * @returns a Mesh or `null`
  24851. */
  24852. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24853. /**
  24854. * Remove a mesh from the LOD array
  24855. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24856. * @param mesh defines the mesh to be removed
  24857. * @return This mesh (for chaining)
  24858. */
  24859. removeLODLevel(mesh: Mesh): Mesh;
  24860. /**
  24861. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24862. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24863. * @param camera defines the camera to use to compute distance
  24864. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24865. * @return This mesh (for chaining)
  24866. */
  24867. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24868. /**
  24869. * Gets the mesh internal Geometry object
  24870. */
  24871. get geometry(): Nullable<Geometry>;
  24872. /**
  24873. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24874. * @returns the total number of vertices
  24875. */
  24876. getTotalVertices(): number;
  24877. /**
  24878. * Returns the content of an associated vertex buffer
  24879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24880. * - VertexBuffer.PositionKind
  24881. * - VertexBuffer.UVKind
  24882. * - VertexBuffer.UV2Kind
  24883. * - VertexBuffer.UV3Kind
  24884. * - VertexBuffer.UV4Kind
  24885. * - VertexBuffer.UV5Kind
  24886. * - VertexBuffer.UV6Kind
  24887. * - VertexBuffer.ColorKind
  24888. * - VertexBuffer.MatricesIndicesKind
  24889. * - VertexBuffer.MatricesIndicesExtraKind
  24890. * - VertexBuffer.MatricesWeightsKind
  24891. * - VertexBuffer.MatricesWeightsExtraKind
  24892. * @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
  24893. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24894. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24895. */
  24896. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24897. /**
  24898. * Returns the mesh VertexBuffer object from the requested `kind`
  24899. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24900. * - VertexBuffer.PositionKind
  24901. * - VertexBuffer.NormalKind
  24902. * - VertexBuffer.UVKind
  24903. * - VertexBuffer.UV2Kind
  24904. * - VertexBuffer.UV3Kind
  24905. * - VertexBuffer.UV4Kind
  24906. * - VertexBuffer.UV5Kind
  24907. * - VertexBuffer.UV6Kind
  24908. * - VertexBuffer.ColorKind
  24909. * - VertexBuffer.MatricesIndicesKind
  24910. * - VertexBuffer.MatricesIndicesExtraKind
  24911. * - VertexBuffer.MatricesWeightsKind
  24912. * - VertexBuffer.MatricesWeightsExtraKind
  24913. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24914. */
  24915. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24916. /**
  24917. * Tests if a specific vertex buffer is associated with this mesh
  24918. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24919. * - VertexBuffer.PositionKind
  24920. * - VertexBuffer.NormalKind
  24921. * - VertexBuffer.UVKind
  24922. * - VertexBuffer.UV2Kind
  24923. * - VertexBuffer.UV3Kind
  24924. * - VertexBuffer.UV4Kind
  24925. * - VertexBuffer.UV5Kind
  24926. * - VertexBuffer.UV6Kind
  24927. * - VertexBuffer.ColorKind
  24928. * - VertexBuffer.MatricesIndicesKind
  24929. * - VertexBuffer.MatricesIndicesExtraKind
  24930. * - VertexBuffer.MatricesWeightsKind
  24931. * - VertexBuffer.MatricesWeightsExtraKind
  24932. * @returns a boolean
  24933. */
  24934. isVerticesDataPresent(kind: string): boolean;
  24935. /**
  24936. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24937. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24938. * - VertexBuffer.PositionKind
  24939. * - VertexBuffer.UVKind
  24940. * - VertexBuffer.UV2Kind
  24941. * - VertexBuffer.UV3Kind
  24942. * - VertexBuffer.UV4Kind
  24943. * - VertexBuffer.UV5Kind
  24944. * - VertexBuffer.UV6Kind
  24945. * - VertexBuffer.ColorKind
  24946. * - VertexBuffer.MatricesIndicesKind
  24947. * - VertexBuffer.MatricesIndicesExtraKind
  24948. * - VertexBuffer.MatricesWeightsKind
  24949. * - VertexBuffer.MatricesWeightsExtraKind
  24950. * @returns a boolean
  24951. */
  24952. isVertexBufferUpdatable(kind: string): boolean;
  24953. /**
  24954. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24955. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24956. * - VertexBuffer.PositionKind
  24957. * - VertexBuffer.NormalKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @returns an array of strings
  24970. */
  24971. getVerticesDataKinds(): string[];
  24972. /**
  24973. * Returns a positive integer : the total number of indices in this mesh geometry.
  24974. * @returns the numner of indices or zero if the mesh has no geometry.
  24975. */
  24976. getTotalIndices(): number;
  24977. /**
  24978. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24979. * @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.
  24980. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24981. * @returns the indices array or an empty array if the mesh has no geometry
  24982. */
  24983. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24984. get isBlocked(): boolean;
  24985. /**
  24986. * Determine if the current mesh is ready to be rendered
  24987. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24988. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24989. * @returns true if all associated assets are ready (material, textures, shaders)
  24990. */
  24991. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24992. /**
  24993. * 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.
  24994. */
  24995. get areNormalsFrozen(): boolean;
  24996. /**
  24997. * 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.
  24998. * @returns the current mesh
  24999. */
  25000. freezeNormals(): Mesh;
  25001. /**
  25002. * 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
  25003. * @returns the current mesh
  25004. */
  25005. unfreezeNormals(): Mesh;
  25006. /**
  25007. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25008. */
  25009. set overridenInstanceCount(count: number);
  25010. /** @hidden */
  25011. _preActivate(): Mesh;
  25012. /** @hidden */
  25013. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25014. /** @hidden */
  25015. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25016. /**
  25017. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25018. * This means the mesh underlying bounding box and sphere are recomputed.
  25019. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25020. * @returns the current mesh
  25021. */
  25022. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25023. /** @hidden */
  25024. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25025. /**
  25026. * This function will subdivide the mesh into multiple submeshes
  25027. * @param count defines the expected number of submeshes
  25028. */
  25029. subdivide(count: number): void;
  25030. /**
  25031. * Copy a FloatArray into a specific associated vertex buffer
  25032. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25033. * - VertexBuffer.PositionKind
  25034. * - VertexBuffer.UVKind
  25035. * - VertexBuffer.UV2Kind
  25036. * - VertexBuffer.UV3Kind
  25037. * - VertexBuffer.UV4Kind
  25038. * - VertexBuffer.UV5Kind
  25039. * - VertexBuffer.UV6Kind
  25040. * - VertexBuffer.ColorKind
  25041. * - VertexBuffer.MatricesIndicesKind
  25042. * - VertexBuffer.MatricesIndicesExtraKind
  25043. * - VertexBuffer.MatricesWeightsKind
  25044. * - VertexBuffer.MatricesWeightsExtraKind
  25045. * @param data defines the data source
  25046. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25047. * @param stride defines the data stride size (can be null)
  25048. * @returns the current mesh
  25049. */
  25050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25051. /**
  25052. * Delete a vertex buffer associated with this mesh
  25053. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25054. * - VertexBuffer.PositionKind
  25055. * - VertexBuffer.UVKind
  25056. * - VertexBuffer.UV2Kind
  25057. * - VertexBuffer.UV3Kind
  25058. * - VertexBuffer.UV4Kind
  25059. * - VertexBuffer.UV5Kind
  25060. * - VertexBuffer.UV6Kind
  25061. * - VertexBuffer.ColorKind
  25062. * - VertexBuffer.MatricesIndicesKind
  25063. * - VertexBuffer.MatricesIndicesExtraKind
  25064. * - VertexBuffer.MatricesWeightsKind
  25065. * - VertexBuffer.MatricesWeightsExtraKind
  25066. */
  25067. removeVerticesData(kind: string): void;
  25068. /**
  25069. * Flags an associated vertex buffer as updatable
  25070. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25071. * - VertexBuffer.PositionKind
  25072. * - VertexBuffer.UVKind
  25073. * - VertexBuffer.UV2Kind
  25074. * - VertexBuffer.UV3Kind
  25075. * - VertexBuffer.UV4Kind
  25076. * - VertexBuffer.UV5Kind
  25077. * - VertexBuffer.UV6Kind
  25078. * - VertexBuffer.ColorKind
  25079. * - VertexBuffer.MatricesIndicesKind
  25080. * - VertexBuffer.MatricesIndicesExtraKind
  25081. * - VertexBuffer.MatricesWeightsKind
  25082. * - VertexBuffer.MatricesWeightsExtraKind
  25083. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25084. */
  25085. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25086. /**
  25087. * Sets the mesh global Vertex Buffer
  25088. * @param buffer defines the buffer to use
  25089. * @returns the current mesh
  25090. */
  25091. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25092. /**
  25093. * Update a specific associated vertex buffer
  25094. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25095. * - VertexBuffer.PositionKind
  25096. * - VertexBuffer.UVKind
  25097. * - VertexBuffer.UV2Kind
  25098. * - VertexBuffer.UV3Kind
  25099. * - VertexBuffer.UV4Kind
  25100. * - VertexBuffer.UV5Kind
  25101. * - VertexBuffer.UV6Kind
  25102. * - VertexBuffer.ColorKind
  25103. * - VertexBuffer.MatricesIndicesKind
  25104. * - VertexBuffer.MatricesIndicesExtraKind
  25105. * - VertexBuffer.MatricesWeightsKind
  25106. * - VertexBuffer.MatricesWeightsExtraKind
  25107. * @param data defines the data source
  25108. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25109. * @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)
  25110. * @returns the current mesh
  25111. */
  25112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25113. /**
  25114. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25115. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25116. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25117. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25118. * @returns the current mesh
  25119. */
  25120. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25121. /**
  25122. * Creates a un-shared specific occurence of the geometry for the mesh.
  25123. * @returns the current mesh
  25124. */
  25125. makeGeometryUnique(): Mesh;
  25126. /**
  25127. * Set the index buffer of this mesh
  25128. * @param indices defines the source data
  25129. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25130. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25131. * @returns the current mesh
  25132. */
  25133. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25134. /**
  25135. * Update the current index buffer
  25136. * @param indices defines the source data
  25137. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25138. * @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)
  25139. * @returns the current mesh
  25140. */
  25141. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25142. /**
  25143. * Invert the geometry to move from a right handed system to a left handed one.
  25144. * @returns the current mesh
  25145. */
  25146. toLeftHanded(): Mesh;
  25147. /** @hidden */
  25148. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25149. /** @hidden */
  25150. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25151. /**
  25152. * Registers for this mesh a javascript function called just before the rendering process
  25153. * @param func defines the function to call before rendering this mesh
  25154. * @returns the current mesh
  25155. */
  25156. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25157. /**
  25158. * Disposes a previously registered javascript function called before the rendering
  25159. * @param func defines the function to remove
  25160. * @returns the current mesh
  25161. */
  25162. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25163. /**
  25164. * Registers for this mesh a javascript function called just after the rendering is complete
  25165. * @param func defines the function to call after rendering this mesh
  25166. * @returns the current mesh
  25167. */
  25168. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25169. /**
  25170. * Disposes a previously registered javascript function called after the rendering.
  25171. * @param func defines the function to remove
  25172. * @returns the current mesh
  25173. */
  25174. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25175. /** @hidden */
  25176. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25177. /** @hidden */
  25178. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25179. /** @hidden */
  25180. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25181. /** @hidden */
  25182. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25183. /** @hidden */
  25184. _rebuild(): void;
  25185. /** @hidden */
  25186. _freeze(): void;
  25187. /** @hidden */
  25188. _unFreeze(): void;
  25189. /**
  25190. * 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
  25191. * @param subMesh defines the subMesh to render
  25192. * @param enableAlphaMode defines if alpha mode can be changed
  25193. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25194. * @returns the current mesh
  25195. */
  25196. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25197. private _onBeforeDraw;
  25198. /**
  25199. * Renormalize the mesh and patch it up if there are no weights
  25200. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25201. * However in the case of zero weights then we set just a single influence to 1.
  25202. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25203. */
  25204. cleanMatrixWeights(): void;
  25205. private normalizeSkinFourWeights;
  25206. private normalizeSkinWeightsAndExtra;
  25207. /**
  25208. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25209. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25210. * the user know there was an issue with importing the mesh
  25211. * @returns a validation object with skinned, valid and report string
  25212. */
  25213. validateSkinning(): {
  25214. skinned: boolean;
  25215. valid: boolean;
  25216. report: string;
  25217. };
  25218. /** @hidden */
  25219. _checkDelayState(): Mesh;
  25220. private _queueLoad;
  25221. /**
  25222. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25223. * A mesh is in the frustum if its bounding box intersects the frustum
  25224. * @param frustumPlanes defines the frustum to test
  25225. * @returns true if the mesh is in the frustum planes
  25226. */
  25227. isInFrustum(frustumPlanes: Plane[]): boolean;
  25228. /**
  25229. * Sets the mesh material by the material or multiMaterial `id` property
  25230. * @param id is a string identifying the material or the multiMaterial
  25231. * @returns the current mesh
  25232. */
  25233. setMaterialByID(id: string): Mesh;
  25234. /**
  25235. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25236. * @returns an array of IAnimatable
  25237. */
  25238. getAnimatables(): IAnimatable[];
  25239. /**
  25240. * Modifies the mesh geometry according to the passed transformation matrix.
  25241. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25242. * The mesh normals are modified using the same transformation.
  25243. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25244. * @param transform defines the transform matrix to use
  25245. * @see http://doc.babylonjs.com/resources/baking_transformations
  25246. * @returns the current mesh
  25247. */
  25248. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25249. /**
  25250. * Modifies the mesh geometry according to its own current World Matrix.
  25251. * The mesh World Matrix is then reset.
  25252. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25253. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25254. * @see http://doc.babylonjs.com/resources/baking_transformations
  25255. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25256. * @returns the current mesh
  25257. */
  25258. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25259. /** @hidden */
  25260. get _positions(): Nullable<Vector3[]>;
  25261. /** @hidden */
  25262. _resetPointsArrayCache(): Mesh;
  25263. /** @hidden */
  25264. _generatePointsArray(): boolean;
  25265. /**
  25266. * Returns a new Mesh object generated from the current mesh properties.
  25267. * This method must not get confused with createInstance()
  25268. * @param name is a string, the name given to the new mesh
  25269. * @param newParent can be any Node object (default `null`)
  25270. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25271. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25272. * @returns a new mesh
  25273. */
  25274. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25275. /**
  25276. * Releases resources associated with this mesh.
  25277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25279. */
  25280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25281. /** @hidden */
  25282. _disposeInstanceSpecificData(): void;
  25283. /**
  25284. * Modifies the mesh geometry according to a displacement map.
  25285. * 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.
  25286. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25287. * @param url is a string, the URL from the image file is to be downloaded.
  25288. * @param minHeight is the lower limit of the displacement.
  25289. * @param maxHeight is the upper limit of the displacement.
  25290. * @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.
  25291. * @param uvOffset is an optional vector2 used to offset UV.
  25292. * @param uvScale is an optional vector2 used to scale UV.
  25293. * @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.
  25294. * @returns the Mesh.
  25295. */
  25296. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25297. /**
  25298. * Modifies the mesh geometry according to a displacementMap buffer.
  25299. * 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.
  25300. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25301. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25302. * @param heightMapWidth is the width of the buffer image.
  25303. * @param heightMapHeight is the height of the buffer image.
  25304. * @param minHeight is the lower limit of the displacement.
  25305. * @param maxHeight is the upper limit of the displacement.
  25306. * @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.
  25307. * @param uvOffset is an optional vector2 used to offset UV.
  25308. * @param uvScale is an optional vector2 used to scale UV.
  25309. * @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.
  25310. * @returns the Mesh.
  25311. */
  25312. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25313. /**
  25314. * Modify the mesh to get a flat shading rendering.
  25315. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25316. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25317. * @returns current mesh
  25318. */
  25319. convertToFlatShadedMesh(): Mesh;
  25320. /**
  25321. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25322. * In other words, more vertices, no more indices and a single bigger VBO.
  25323. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25324. * @returns current mesh
  25325. */
  25326. convertToUnIndexedMesh(): Mesh;
  25327. /**
  25328. * Inverses facet orientations.
  25329. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25330. * @param flipNormals will also inverts the normals
  25331. * @returns current mesh
  25332. */
  25333. flipFaces(flipNormals?: boolean): Mesh;
  25334. /**
  25335. * Increase the number of facets and hence vertices in a mesh
  25336. * Vertex normals are interpolated from existing vertex normals
  25337. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25338. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25339. */
  25340. increaseVertices(numberPerEdge: number): void;
  25341. /**
  25342. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25343. * This will undo any application of covertToFlatShadedMesh
  25344. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25345. */
  25346. forceSharedVertices(): void;
  25347. /** @hidden */
  25348. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25349. /** @hidden */
  25350. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25351. /**
  25352. * Creates a new InstancedMesh object from the mesh model.
  25353. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25354. * @param name defines the name of the new instance
  25355. * @returns a new InstancedMesh
  25356. */
  25357. createInstance(name: string): InstancedMesh;
  25358. /**
  25359. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25360. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25361. * @returns the current mesh
  25362. */
  25363. synchronizeInstances(): Mesh;
  25364. /**
  25365. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25366. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25367. * This should be used together with the simplification to avoid disappearing triangles.
  25368. * @param successCallback an optional success callback to be called after the optimization finished.
  25369. * @returns the current mesh
  25370. */
  25371. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25372. /**
  25373. * Serialize current mesh
  25374. * @param serializationObject defines the object which will receive the serialization data
  25375. */
  25376. serialize(serializationObject: any): void;
  25377. /** @hidden */
  25378. _syncGeometryWithMorphTargetManager(): void;
  25379. /** @hidden */
  25380. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25381. /**
  25382. * Returns a new Mesh object parsed from the source provided.
  25383. * @param parsedMesh is the source
  25384. * @param scene defines the hosting scene
  25385. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25386. * @returns a new Mesh
  25387. */
  25388. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25389. /**
  25390. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25391. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25392. * @param name defines the name of the mesh to create
  25393. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25394. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25395. * @param closePath creates a seam between the first and the last points of each path of the path array
  25396. * @param offset is taken in account only if the `pathArray` is containing a single path
  25397. * @param scene defines the hosting scene
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25400. * @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)
  25401. * @returns a new Mesh
  25402. */
  25403. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25404. /**
  25405. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25406. * @param name defines the name of the mesh to create
  25407. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25408. * @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
  25409. * @param scene defines the hosting scene
  25410. * @param updatable defines if the mesh must be flagged as updatable
  25411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25412. * @returns a new Mesh
  25413. */
  25414. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25415. /**
  25416. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25417. * @param name defines the name of the mesh to create
  25418. * @param size sets the size (float) of each box side (default 1)
  25419. * @param scene defines the hosting scene
  25420. * @param updatable defines if the mesh must be flagged as updatable
  25421. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25422. * @returns a new Mesh
  25423. */
  25424. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25425. /**
  25426. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25427. * @param name defines the name of the mesh to create
  25428. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25429. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25430. * @param scene defines the hosting scene
  25431. * @param updatable defines if the mesh must be flagged as updatable
  25432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25433. * @returns a new Mesh
  25434. */
  25435. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25436. /**
  25437. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25438. * @param name defines the name of the mesh to create
  25439. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25440. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25441. * @param scene defines the hosting scene
  25442. * @returns a new Mesh
  25443. */
  25444. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25445. /**
  25446. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25449. * @param diameterTop set the top cap diameter (floats, default 1)
  25450. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25451. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25452. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25453. * @param scene defines the hosting scene
  25454. * @param updatable defines if the mesh must be flagged as updatable
  25455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25456. * @returns a new Mesh
  25457. */
  25458. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25459. /**
  25460. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25461. * @param name defines the name of the mesh to create
  25462. * @param diameter sets the diameter size (float) of the torus (default 1)
  25463. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25464. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25465. * @param scene defines the hosting scene
  25466. * @param updatable defines if the mesh must be flagged as updatable
  25467. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25468. * @returns a new Mesh
  25469. */
  25470. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25471. /**
  25472. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25473. * @param name defines the name of the mesh to create
  25474. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25475. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25476. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25477. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25478. * @param p the number of windings on X axis (positive integers, default 2)
  25479. * @param q the number of windings on Y axis (positive integers, default 3)
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25483. * @returns a new Mesh
  25484. */
  25485. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25486. /**
  25487. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25488. * @param name defines the name of the mesh to create
  25489. * @param points is an array successive Vector3
  25490. * @param scene defines the hosting scene
  25491. * @param updatable defines if the mesh must be flagged as updatable
  25492. * @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).
  25493. * @returns a new Mesh
  25494. */
  25495. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25496. /**
  25497. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25498. * @param name defines the name of the mesh to create
  25499. * @param points is an array successive Vector3
  25500. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25501. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25502. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25503. * @param scene defines the hosting scene
  25504. * @param updatable defines if the mesh must be flagged as updatable
  25505. * @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)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25509. /**
  25510. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25511. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25512. * 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.
  25513. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25514. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25515. * Remember you can only change the shape positions, not their number when updating a polygon.
  25516. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25517. * @param name defines the name of the mesh to create
  25518. * @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
  25519. * @param scene defines the hosting scene
  25520. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25521. * @param updatable defines if the mesh must be flagged as updatable
  25522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25523. * @param earcutInjection can be used to inject your own earcut reference
  25524. * @returns a new Mesh
  25525. */
  25526. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25527. /**
  25528. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25529. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25530. * @param name defines the name of the mesh to create
  25531. * @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
  25532. * @param depth defines the height of extrusion
  25533. * @param scene defines the hosting scene
  25534. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25537. * @param earcutInjection can be used to inject your own earcut reference
  25538. * @returns a new Mesh
  25539. */
  25540. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25541. /**
  25542. * Creates an extruded shape mesh.
  25543. * 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
  25544. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25545. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25546. * @param name defines the name of the mesh to create
  25547. * @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
  25548. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25549. * @param scale is the value to scale the shape
  25550. * @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
  25551. * @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
  25552. * @param scene defines the hosting scene
  25553. * @param updatable defines if the mesh must be flagged as updatable
  25554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25555. * @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)
  25556. * @returns a new Mesh
  25557. */
  25558. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25559. /**
  25560. * Creates an custom extruded shape mesh.
  25561. * The custom extrusion is a parametric shape.
  25562. * It has no predefined shape. Its final shape will depend on the input parameters.
  25563. * Please consider using the same method from the MeshBuilder class instead
  25564. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25565. * @param name defines the name of the mesh to create
  25566. * @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
  25567. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25568. * @param scaleFunction is a custom Javascript function called on each path point
  25569. * @param rotationFunction is a custom Javascript function called on each path point
  25570. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25571. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25572. * @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
  25573. * @param scene defines the hosting scene
  25574. * @param updatable defines if the mesh must be flagged as updatable
  25575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25576. * @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)
  25577. * @returns a new Mesh
  25578. */
  25579. 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;
  25580. /**
  25581. * Creates lathe mesh.
  25582. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25583. * Please consider using the same method from the MeshBuilder class instead
  25584. * @param name defines the name of the mesh to create
  25585. * @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
  25586. * @param radius is the radius value of the lathe
  25587. * @param tessellation is the side number of the lathe.
  25588. * @param scene defines the hosting scene
  25589. * @param updatable defines if the mesh must be flagged as updatable
  25590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25591. * @returns a new Mesh
  25592. */
  25593. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25594. /**
  25595. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25596. * @param name defines the name of the mesh to create
  25597. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25598. * @param scene defines the hosting scene
  25599. * @param updatable defines if the mesh must be flagged as updatable
  25600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25601. * @returns a new Mesh
  25602. */
  25603. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25604. /**
  25605. * Creates a ground mesh.
  25606. * Please consider using the same method from the MeshBuilder class instead
  25607. * @param name defines the name of the mesh to create
  25608. * @param width set the width of the ground
  25609. * @param height set the height of the ground
  25610. * @param subdivisions sets the number of subdivisions per side
  25611. * @param scene defines the hosting scene
  25612. * @param updatable defines if the mesh must be flagged as updatable
  25613. * @returns a new Mesh
  25614. */
  25615. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25616. /**
  25617. * Creates a tiled ground mesh.
  25618. * Please consider using the same method from the MeshBuilder class instead
  25619. * @param name defines the name of the mesh to create
  25620. * @param xmin set the ground minimum X coordinate
  25621. * @param zmin set the ground minimum Y coordinate
  25622. * @param xmax set the ground maximum X coordinate
  25623. * @param zmax set the ground maximum Z coordinate
  25624. * @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
  25625. * @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
  25626. * @param scene defines the hosting scene
  25627. * @param updatable defines if the mesh must be flagged as updatable
  25628. * @returns a new Mesh
  25629. */
  25630. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25631. w: number;
  25632. h: number;
  25633. }, precision: {
  25634. w: number;
  25635. h: number;
  25636. }, scene: Scene, updatable?: boolean): Mesh;
  25637. /**
  25638. * Creates a ground mesh from a height map.
  25639. * Please consider using the same method from the MeshBuilder class instead
  25640. * @see http://doc.babylonjs.com/babylon101/height_map
  25641. * @param name defines the name of the mesh to create
  25642. * @param url sets the URL of the height map image resource
  25643. * @param width set the ground width size
  25644. * @param height set the ground height size
  25645. * @param subdivisions sets the number of subdivision per side
  25646. * @param minHeight is the minimum altitude on the ground
  25647. * @param maxHeight is the maximum altitude on the ground
  25648. * @param scene defines the hosting scene
  25649. * @param updatable defines if the mesh must be flagged as updatable
  25650. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25651. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25652. * @returns a new Mesh
  25653. */
  25654. 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;
  25655. /**
  25656. * Creates a tube mesh.
  25657. * The tube is a parametric shape.
  25658. * It has no predefined shape. Its final shape will depend on the input parameters.
  25659. * Please consider using the same method from the MeshBuilder class instead
  25660. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25661. * @param name defines the name of the mesh to create
  25662. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25663. * @param radius sets the tube radius size
  25664. * @param tessellation is the number of sides on the tubular surface
  25665. * @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
  25666. * @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
  25667. * @param scene defines the hosting scene
  25668. * @param updatable defines if the mesh must be flagged as updatable
  25669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25670. * @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)
  25671. * @returns a new Mesh
  25672. */
  25673. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25674. (i: number, distance: number): number;
  25675. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25676. /**
  25677. * Creates a polyhedron mesh.
  25678. * Please consider using the same method from the MeshBuilder class instead.
  25679. * * 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
  25680. * * The parameter `size` (positive float, default 1) sets the polygon size
  25681. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25682. * * 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`
  25683. * * 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
  25684. * * 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)`)
  25685. * * 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
  25686. * * 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
  25687. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25688. * * 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
  25689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25690. * @param name defines the name of the mesh to create
  25691. * @param options defines the options used to create the mesh
  25692. * @param scene defines the hosting scene
  25693. * @returns a new Mesh
  25694. */
  25695. static CreatePolyhedron(name: string, options: {
  25696. type?: number;
  25697. size?: number;
  25698. sizeX?: number;
  25699. sizeY?: number;
  25700. sizeZ?: number;
  25701. custom?: any;
  25702. faceUV?: Vector4[];
  25703. faceColors?: Color4[];
  25704. updatable?: boolean;
  25705. sideOrientation?: number;
  25706. }, scene: Scene): Mesh;
  25707. /**
  25708. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25709. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25710. * * 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`)
  25711. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25712. * * 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
  25713. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25714. * * 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
  25715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25716. * @param name defines the name of the mesh
  25717. * @param options defines the options used to create the mesh
  25718. * @param scene defines the hosting scene
  25719. * @returns a new Mesh
  25720. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25721. */
  25722. static CreateIcoSphere(name: string, options: {
  25723. radius?: number;
  25724. flat?: boolean;
  25725. subdivisions?: number;
  25726. sideOrientation?: number;
  25727. updatable?: boolean;
  25728. }, scene: Scene): Mesh;
  25729. /**
  25730. * Creates a decal mesh.
  25731. * Please consider using the same method from the MeshBuilder class instead.
  25732. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25733. * @param name defines the name of the mesh
  25734. * @param sourceMesh defines the mesh receiving the decal
  25735. * @param position sets the position of the decal in world coordinates
  25736. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25737. * @param size sets the decal scaling
  25738. * @param angle sets the angle to rotate the decal
  25739. * @returns a new Mesh
  25740. */
  25741. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25742. /**
  25743. * Prepare internal position array for software CPU skinning
  25744. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25745. */
  25746. setPositionsForCPUSkinning(): Float32Array;
  25747. /**
  25748. * Prepare internal normal array for software CPU skinning
  25749. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25750. */
  25751. setNormalsForCPUSkinning(): Float32Array;
  25752. /**
  25753. * Updates the vertex buffer by applying transformation from the bones
  25754. * @param skeleton defines the skeleton to apply to current mesh
  25755. * @returns the current mesh
  25756. */
  25757. applySkeleton(skeleton: Skeleton): Mesh;
  25758. /**
  25759. * 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
  25760. * @param meshes defines the list of meshes to scan
  25761. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25762. */
  25763. static MinMax(meshes: AbstractMesh[]): {
  25764. min: Vector3;
  25765. max: Vector3;
  25766. };
  25767. /**
  25768. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25769. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25770. * @returns a vector3
  25771. */
  25772. static Center(meshesOrMinMaxVector: {
  25773. min: Vector3;
  25774. max: Vector3;
  25775. } | AbstractMesh[]): Vector3;
  25776. /**
  25777. * Merge the array of meshes into a single mesh for performance reasons.
  25778. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25779. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25780. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25781. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25782. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25783. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25784. * @returns a new mesh
  25785. */
  25786. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25787. /** @hidden */
  25788. addInstance(instance: InstancedMesh): void;
  25789. /** @hidden */
  25790. removeInstance(instance: InstancedMesh): void;
  25791. }
  25792. }
  25793. declare module BABYLON {
  25794. /**
  25795. * This is the base class of all the camera used in the application.
  25796. * @see http://doc.babylonjs.com/features/cameras
  25797. */
  25798. export class Camera extends Node {
  25799. /** @hidden */
  25800. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25801. /**
  25802. * This is the default projection mode used by the cameras.
  25803. * It helps recreating a feeling of perspective and better appreciate depth.
  25804. * This is the best way to simulate real life cameras.
  25805. */
  25806. static readonly PERSPECTIVE_CAMERA: number;
  25807. /**
  25808. * This helps creating camera with an orthographic mode.
  25809. * 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.
  25810. */
  25811. static readonly ORTHOGRAPHIC_CAMERA: number;
  25812. /**
  25813. * This is the default FOV mode for perspective cameras.
  25814. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25815. */
  25816. static readonly FOVMODE_VERTICAL_FIXED: number;
  25817. /**
  25818. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25819. */
  25820. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25821. /**
  25822. * This specifies ther is no need for a camera rig.
  25823. * Basically only one eye is rendered corresponding to the camera.
  25824. */
  25825. static readonly RIG_MODE_NONE: number;
  25826. /**
  25827. * Simulates a camera Rig with one blue eye and one red eye.
  25828. * This can be use with 3d blue and red glasses.
  25829. */
  25830. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25831. /**
  25832. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25833. */
  25834. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25835. /**
  25836. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25837. */
  25838. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25839. /**
  25840. * Defines that both eyes of the camera will be rendered over under each other.
  25841. */
  25842. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25843. /**
  25844. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25845. */
  25846. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25847. /**
  25848. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25849. */
  25850. static readonly RIG_MODE_VR: number;
  25851. /**
  25852. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25853. */
  25854. static readonly RIG_MODE_WEBVR: number;
  25855. /**
  25856. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25857. */
  25858. static readonly RIG_MODE_CUSTOM: number;
  25859. /**
  25860. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25861. */
  25862. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25863. /**
  25864. * Define the input manager associated with the camera.
  25865. */
  25866. inputs: CameraInputsManager<Camera>;
  25867. /** @hidden */
  25868. _position: Vector3;
  25869. /**
  25870. * Define the current local position of the camera in the scene
  25871. */
  25872. get position(): Vector3;
  25873. set position(newPosition: Vector3);
  25874. /**
  25875. * The vector the camera should consider as up.
  25876. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25877. */
  25878. upVector: Vector3;
  25879. /**
  25880. * Define the current limit on the left side for an orthographic camera
  25881. * In scene unit
  25882. */
  25883. orthoLeft: Nullable<number>;
  25884. /**
  25885. * Define the current limit on the right side for an orthographic camera
  25886. * In scene unit
  25887. */
  25888. orthoRight: Nullable<number>;
  25889. /**
  25890. * Define the current limit on the bottom side for an orthographic camera
  25891. * In scene unit
  25892. */
  25893. orthoBottom: Nullable<number>;
  25894. /**
  25895. * Define the current limit on the top side for an orthographic camera
  25896. * In scene unit
  25897. */
  25898. orthoTop: Nullable<number>;
  25899. /**
  25900. * Field Of View is set in Radians. (default is 0.8)
  25901. */
  25902. fov: number;
  25903. /**
  25904. * Define the minimum distance the camera can see from.
  25905. * This is important to note that the depth buffer are not infinite and the closer it starts
  25906. * the more your scene might encounter depth fighting issue.
  25907. */
  25908. minZ: number;
  25909. /**
  25910. * Define the maximum distance the camera can see to.
  25911. * This is important to note that the depth buffer are not infinite and the further it end
  25912. * the more your scene might encounter depth fighting issue.
  25913. */
  25914. maxZ: number;
  25915. /**
  25916. * Define the default inertia of the camera.
  25917. * This helps giving a smooth feeling to the camera movement.
  25918. */
  25919. inertia: number;
  25920. /**
  25921. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25922. */
  25923. mode: number;
  25924. /**
  25925. * Define whether the camera is intermediate.
  25926. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25927. */
  25928. isIntermediate: boolean;
  25929. /**
  25930. * Define the viewport of the camera.
  25931. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25932. */
  25933. viewport: Viewport;
  25934. /**
  25935. * Restricts the camera to viewing objects with the same layerMask.
  25936. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25937. */
  25938. layerMask: number;
  25939. /**
  25940. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25941. */
  25942. fovMode: number;
  25943. /**
  25944. * Rig mode of the camera.
  25945. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25946. * This is normally controlled byt the camera themselves as internal use.
  25947. */
  25948. cameraRigMode: number;
  25949. /**
  25950. * Defines the distance between both "eyes" in case of a RIG
  25951. */
  25952. interaxialDistance: number;
  25953. /**
  25954. * Defines if stereoscopic rendering is done side by side or over under.
  25955. */
  25956. isStereoscopicSideBySide: boolean;
  25957. /**
  25958. * 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
  25959. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25960. * else in the scene. (Eg. security camera)
  25961. *
  25962. * 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)
  25963. */
  25964. customRenderTargets: RenderTargetTexture[];
  25965. /**
  25966. * When set, the camera will render to this render target instead of the default canvas
  25967. *
  25968. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25969. */
  25970. outputRenderTarget: Nullable<RenderTargetTexture>;
  25971. /**
  25972. * Observable triggered when the camera view matrix has changed.
  25973. */
  25974. onViewMatrixChangedObservable: Observable<Camera>;
  25975. /**
  25976. * Observable triggered when the camera Projection matrix has changed.
  25977. */
  25978. onProjectionMatrixChangedObservable: Observable<Camera>;
  25979. /**
  25980. * Observable triggered when the inputs have been processed.
  25981. */
  25982. onAfterCheckInputsObservable: Observable<Camera>;
  25983. /**
  25984. * Observable triggered when reset has been called and applied to the camera.
  25985. */
  25986. onRestoreStateObservable: Observable<Camera>;
  25987. /**
  25988. * Is this camera a part of a rig system?
  25989. */
  25990. isRigCamera: boolean;
  25991. /**
  25992. * If isRigCamera set to true this will be set with the parent camera.
  25993. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25994. */
  25995. rigParent?: Camera;
  25996. /** @hidden */
  25997. _cameraRigParams: any;
  25998. /** @hidden */
  25999. _rigCameras: Camera[];
  26000. /** @hidden */
  26001. _rigPostProcess: Nullable<PostProcess>;
  26002. protected _webvrViewMatrix: Matrix;
  26003. /** @hidden */
  26004. _skipRendering: boolean;
  26005. /** @hidden */
  26006. _projectionMatrix: Matrix;
  26007. /** @hidden */
  26008. _postProcesses: Nullable<PostProcess>[];
  26009. /** @hidden */
  26010. _activeMeshes: SmartArray<AbstractMesh>;
  26011. protected _globalPosition: Vector3;
  26012. /** @hidden */
  26013. _computedViewMatrix: Matrix;
  26014. private _doNotComputeProjectionMatrix;
  26015. private _transformMatrix;
  26016. private _frustumPlanes;
  26017. private _refreshFrustumPlanes;
  26018. private _storedFov;
  26019. private _stateStored;
  26020. /**
  26021. * Instantiates a new camera object.
  26022. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26023. * @see http://doc.babylonjs.com/features/cameras
  26024. * @param name Defines the name of the camera in the scene
  26025. * @param position Defines the position of the camera
  26026. * @param scene Defines the scene the camera belongs too
  26027. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26028. */
  26029. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26030. /**
  26031. * Store current camera state (fov, position, etc..)
  26032. * @returns the camera
  26033. */
  26034. storeState(): Camera;
  26035. /**
  26036. * Restores the camera state values if it has been stored. You must call storeState() first
  26037. */
  26038. protected _restoreStateValues(): boolean;
  26039. /**
  26040. * Restored camera state. You must call storeState() first.
  26041. * @returns true if restored and false otherwise
  26042. */
  26043. restoreState(): boolean;
  26044. /**
  26045. * Gets the class name of the camera.
  26046. * @returns the class name
  26047. */
  26048. getClassName(): string;
  26049. /** @hidden */
  26050. readonly _isCamera: boolean;
  26051. /**
  26052. * Gets a string representation of the camera useful for debug purpose.
  26053. * @param fullDetails Defines that a more verboe level of logging is required
  26054. * @returns the string representation
  26055. */
  26056. toString(fullDetails?: boolean): string;
  26057. /**
  26058. * Gets the current world space position of the camera.
  26059. */
  26060. get globalPosition(): Vector3;
  26061. /**
  26062. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26063. * @returns the active meshe list
  26064. */
  26065. getActiveMeshes(): SmartArray<AbstractMesh>;
  26066. /**
  26067. * Check whether a mesh is part of the current active mesh list of the camera
  26068. * @param mesh Defines the mesh to check
  26069. * @returns true if active, false otherwise
  26070. */
  26071. isActiveMesh(mesh: Mesh): boolean;
  26072. /**
  26073. * Is this camera ready to be used/rendered
  26074. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26075. * @return true if the camera is ready
  26076. */
  26077. isReady(completeCheck?: boolean): boolean;
  26078. /** @hidden */
  26079. _initCache(): void;
  26080. /** @hidden */
  26081. _updateCache(ignoreParentClass?: boolean): void;
  26082. /** @hidden */
  26083. _isSynchronized(): boolean;
  26084. /** @hidden */
  26085. _isSynchronizedViewMatrix(): boolean;
  26086. /** @hidden */
  26087. _isSynchronizedProjectionMatrix(): boolean;
  26088. /**
  26089. * Attach the input controls to a specific dom element to get the input from.
  26090. * @param element Defines the element the controls should be listened from
  26091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26092. */
  26093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26094. /**
  26095. * Detach the current controls from the specified dom element.
  26096. * @param element Defines the element to stop listening the inputs from
  26097. */
  26098. detachControl(element: HTMLElement): void;
  26099. /**
  26100. * Update the camera state according to the different inputs gathered during the frame.
  26101. */
  26102. update(): void;
  26103. /** @hidden */
  26104. _checkInputs(): void;
  26105. /** @hidden */
  26106. get rigCameras(): Camera[];
  26107. /**
  26108. * Gets the post process used by the rig cameras
  26109. */
  26110. get rigPostProcess(): Nullable<PostProcess>;
  26111. /**
  26112. * Internal, gets the first post proces.
  26113. * @returns the first post process to be run on this camera.
  26114. */
  26115. _getFirstPostProcess(): Nullable<PostProcess>;
  26116. private _cascadePostProcessesToRigCams;
  26117. /**
  26118. * Attach a post process to the camera.
  26119. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26120. * @param postProcess The post process to attach to the camera
  26121. * @param insertAt The position of the post process in case several of them are in use in the scene
  26122. * @returns the position the post process has been inserted at
  26123. */
  26124. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26125. /**
  26126. * Detach a post process to the camera.
  26127. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26128. * @param postProcess The post process to detach from the camera
  26129. */
  26130. detachPostProcess(postProcess: PostProcess): void;
  26131. /**
  26132. * Gets the current world matrix of the camera
  26133. */
  26134. getWorldMatrix(): Matrix;
  26135. /** @hidden */
  26136. _getViewMatrix(): Matrix;
  26137. /**
  26138. * Gets the current view matrix of the camera.
  26139. * @param force forces the camera to recompute the matrix without looking at the cached state
  26140. * @returns the view matrix
  26141. */
  26142. getViewMatrix(force?: boolean): Matrix;
  26143. /**
  26144. * Freeze the projection matrix.
  26145. * It will prevent the cache check of the camera projection compute and can speed up perf
  26146. * if no parameter of the camera are meant to change
  26147. * @param projection Defines manually a projection if necessary
  26148. */
  26149. freezeProjectionMatrix(projection?: Matrix): void;
  26150. /**
  26151. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26152. */
  26153. unfreezeProjectionMatrix(): void;
  26154. /**
  26155. * Gets the current projection matrix of the camera.
  26156. * @param force forces the camera to recompute the matrix without looking at the cached state
  26157. * @returns the projection matrix
  26158. */
  26159. getProjectionMatrix(force?: boolean): Matrix;
  26160. /**
  26161. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26162. * @returns a Matrix
  26163. */
  26164. getTransformationMatrix(): Matrix;
  26165. private _updateFrustumPlanes;
  26166. /**
  26167. * Checks if a cullable object (mesh...) is in the camera frustum
  26168. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26169. * @param target The object to check
  26170. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26171. * @returns true if the object is in frustum otherwise false
  26172. */
  26173. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26174. /**
  26175. * Checks if a cullable object (mesh...) is in the camera frustum
  26176. * Unlike isInFrustum this cheks the full bounding box
  26177. * @param target The object to check
  26178. * @returns true if the object is in frustum otherwise false
  26179. */
  26180. isCompletelyInFrustum(target: ICullable): boolean;
  26181. /**
  26182. * Gets a ray in the forward direction from the camera.
  26183. * @param length Defines the length of the ray to create
  26184. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26185. * @param origin Defines the start point of the ray which defaults to the camera position
  26186. * @returns the forward ray
  26187. */
  26188. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26189. /**
  26190. * Releases resources associated with this node.
  26191. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26192. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26193. */
  26194. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26195. /** @hidden */
  26196. _isLeftCamera: boolean;
  26197. /**
  26198. * Gets the left camera of a rig setup in case of Rigged Camera
  26199. */
  26200. get isLeftCamera(): boolean;
  26201. /** @hidden */
  26202. _isRightCamera: boolean;
  26203. /**
  26204. * Gets the right camera of a rig setup in case of Rigged Camera
  26205. */
  26206. get isRightCamera(): boolean;
  26207. /**
  26208. * Gets the left camera of a rig setup in case of Rigged Camera
  26209. */
  26210. get leftCamera(): Nullable<FreeCamera>;
  26211. /**
  26212. * Gets the right camera of a rig setup in case of Rigged Camera
  26213. */
  26214. get rightCamera(): Nullable<FreeCamera>;
  26215. /**
  26216. * Gets the left camera target of a rig setup in case of Rigged Camera
  26217. * @returns the target position
  26218. */
  26219. getLeftTarget(): Nullable<Vector3>;
  26220. /**
  26221. * Gets the right camera target of a rig setup in case of Rigged Camera
  26222. * @returns the target position
  26223. */
  26224. getRightTarget(): Nullable<Vector3>;
  26225. /**
  26226. * @hidden
  26227. */
  26228. setCameraRigMode(mode: number, rigParams: any): void;
  26229. /** @hidden */
  26230. static _setStereoscopicRigMode(camera: Camera): void;
  26231. /** @hidden */
  26232. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26233. /** @hidden */
  26234. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26235. /** @hidden */
  26236. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26237. /** @hidden */
  26238. _getVRProjectionMatrix(): Matrix;
  26239. protected _updateCameraRotationMatrix(): void;
  26240. protected _updateWebVRCameraRotationMatrix(): void;
  26241. /**
  26242. * This function MUST be overwritten by the different WebVR cameras available.
  26243. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26244. * @hidden
  26245. */
  26246. _getWebVRProjectionMatrix(): Matrix;
  26247. /**
  26248. * This function MUST be overwritten by the different WebVR cameras available.
  26249. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26250. * @hidden
  26251. */
  26252. _getWebVRViewMatrix(): Matrix;
  26253. /** @hidden */
  26254. setCameraRigParameter(name: string, value: any): void;
  26255. /**
  26256. * needs to be overridden by children so sub has required properties to be copied
  26257. * @hidden
  26258. */
  26259. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26260. /**
  26261. * May need to be overridden by children
  26262. * @hidden
  26263. */
  26264. _updateRigCameras(): void;
  26265. /** @hidden */
  26266. _setupInputs(): void;
  26267. /**
  26268. * Serialiaze the camera setup to a json represention
  26269. * @returns the JSON representation
  26270. */
  26271. serialize(): any;
  26272. /**
  26273. * Clones the current camera.
  26274. * @param name The cloned camera name
  26275. * @returns the cloned camera
  26276. */
  26277. clone(name: string): Camera;
  26278. /**
  26279. * Gets the direction of the camera relative to a given local axis.
  26280. * @param localAxis Defines the reference axis to provide a relative direction.
  26281. * @return the direction
  26282. */
  26283. getDirection(localAxis: Vector3): Vector3;
  26284. /**
  26285. * Returns the current camera absolute rotation
  26286. */
  26287. get absoluteRotation(): Quaternion;
  26288. /**
  26289. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26290. * @param localAxis Defines the reference axis to provide a relative direction.
  26291. * @param result Defines the vector to store the result in
  26292. */
  26293. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26294. /**
  26295. * Gets a camera constructor for a given camera type
  26296. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26297. * @param name The name of the camera the result will be able to instantiate
  26298. * @param scene The scene the result will construct the camera in
  26299. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26300. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26301. * @returns a factory method to construc the camera
  26302. */
  26303. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26304. /**
  26305. * Compute the world matrix of the camera.
  26306. * @returns the camera world matrix
  26307. */
  26308. computeWorldMatrix(): Matrix;
  26309. /**
  26310. * Parse a JSON and creates the camera from the parsed information
  26311. * @param parsedCamera The JSON to parse
  26312. * @param scene The scene to instantiate the camera in
  26313. * @returns the newly constructed camera
  26314. */
  26315. static Parse(parsedCamera: any, scene: Scene): Camera;
  26316. }
  26317. }
  26318. declare module BABYLON {
  26319. /**
  26320. * Class containing static functions to help procedurally build meshes
  26321. */
  26322. export class DiscBuilder {
  26323. /**
  26324. * Creates a plane polygonal mesh. By default, this is a disc
  26325. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26326. * * 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
  26327. * * 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
  26328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26329. * * 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
  26330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26331. * @param name defines the name of the mesh
  26332. * @param options defines the options used to create the mesh
  26333. * @param scene defines the hosting scene
  26334. * @returns the plane polygonal mesh
  26335. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26336. */
  26337. static CreateDisc(name: string, options: {
  26338. radius?: number;
  26339. tessellation?: number;
  26340. arc?: number;
  26341. updatable?: boolean;
  26342. sideOrientation?: number;
  26343. frontUVs?: Vector4;
  26344. backUVs?: Vector4;
  26345. }, scene?: Nullable<Scene>): Mesh;
  26346. }
  26347. }
  26348. declare module BABYLON {
  26349. /**
  26350. * Options to be used when creating a FresnelParameters.
  26351. */
  26352. export type IFresnelParametersCreationOptions = {
  26353. /**
  26354. * Define the color used on edges (grazing angle)
  26355. */
  26356. leftColor?: Color3;
  26357. /**
  26358. * Define the color used on center
  26359. */
  26360. rightColor?: Color3;
  26361. /**
  26362. * Define bias applied to computed fresnel term
  26363. */
  26364. bias?: number;
  26365. /**
  26366. * Defined the power exponent applied to fresnel term
  26367. */
  26368. power?: number;
  26369. /**
  26370. * Define if the fresnel effect is enable or not.
  26371. */
  26372. isEnabled?: boolean;
  26373. };
  26374. /**
  26375. * Serialized format for FresnelParameters.
  26376. */
  26377. export type IFresnelParametersSerialized = {
  26378. /**
  26379. * Define the color used on edges (grazing angle) [as an array]
  26380. */
  26381. leftColor: number[];
  26382. /**
  26383. * Define the color used on center [as an array]
  26384. */
  26385. rightColor: number[];
  26386. /**
  26387. * Define bias applied to computed fresnel term
  26388. */
  26389. bias: number;
  26390. /**
  26391. * Defined the power exponent applied to fresnel term
  26392. */
  26393. power?: number;
  26394. /**
  26395. * Define if the fresnel effect is enable or not.
  26396. */
  26397. isEnabled: boolean;
  26398. };
  26399. /**
  26400. * This represents all the required information to add a fresnel effect on a material:
  26401. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26402. */
  26403. export class FresnelParameters {
  26404. private _isEnabled;
  26405. /**
  26406. * Define if the fresnel effect is enable or not.
  26407. */
  26408. get isEnabled(): boolean;
  26409. set isEnabled(value: boolean);
  26410. /**
  26411. * Define the color used on edges (grazing angle)
  26412. */
  26413. leftColor: Color3;
  26414. /**
  26415. * Define the color used on center
  26416. */
  26417. rightColor: Color3;
  26418. /**
  26419. * Define bias applied to computed fresnel term
  26420. */
  26421. bias: number;
  26422. /**
  26423. * Defined the power exponent applied to fresnel term
  26424. */
  26425. power: number;
  26426. /**
  26427. * Creates a new FresnelParameters object.
  26428. *
  26429. * @param options provide your own settings to optionally to override defaults
  26430. */
  26431. constructor(options?: IFresnelParametersCreationOptions);
  26432. /**
  26433. * Clones the current fresnel and its valuues
  26434. * @returns a clone fresnel configuration
  26435. */
  26436. clone(): FresnelParameters;
  26437. /**
  26438. * Determines equality between FresnelParameters objects
  26439. * @param otherFresnelParameters defines the second operand
  26440. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26441. */
  26442. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26443. /**
  26444. * Serializes the current fresnel parameters to a JSON representation.
  26445. * @return the JSON serialization
  26446. */
  26447. serialize(): IFresnelParametersSerialized;
  26448. /**
  26449. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26450. * @param parsedFresnelParameters Define the JSON representation
  26451. * @returns the parsed parameters
  26452. */
  26453. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26454. }
  26455. }
  26456. declare module BABYLON {
  26457. /**
  26458. * Base class of materials working in push mode in babylon JS
  26459. * @hidden
  26460. */
  26461. export class PushMaterial extends Material {
  26462. protected _activeEffect: Effect;
  26463. protected _normalMatrix: Matrix;
  26464. /**
  26465. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26466. * This means that the material can keep using a previous shader while a new one is being compiled.
  26467. * This is mostly used when shader parallel compilation is supported (true by default)
  26468. */
  26469. allowShaderHotSwapping: boolean;
  26470. constructor(name: string, scene: Scene);
  26471. getEffect(): Effect;
  26472. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26473. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26474. /**
  26475. * Binds the given world matrix to the active effect
  26476. *
  26477. * @param world the matrix to bind
  26478. */
  26479. bindOnlyWorldMatrix(world: Matrix): void;
  26480. /**
  26481. * Binds the given normal matrix to the active effect
  26482. *
  26483. * @param normalMatrix the matrix to bind
  26484. */
  26485. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26486. bind(world: Matrix, mesh?: Mesh): void;
  26487. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26488. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26489. }
  26490. }
  26491. declare module BABYLON {
  26492. /**
  26493. * This groups all the flags used to control the materials channel.
  26494. */
  26495. export class MaterialFlags {
  26496. private static _DiffuseTextureEnabled;
  26497. /**
  26498. * Are diffuse textures enabled in the application.
  26499. */
  26500. static get DiffuseTextureEnabled(): boolean;
  26501. static set DiffuseTextureEnabled(value: boolean);
  26502. private static _AmbientTextureEnabled;
  26503. /**
  26504. * Are ambient textures enabled in the application.
  26505. */
  26506. static get AmbientTextureEnabled(): boolean;
  26507. static set AmbientTextureEnabled(value: boolean);
  26508. private static _OpacityTextureEnabled;
  26509. /**
  26510. * Are opacity textures enabled in the application.
  26511. */
  26512. static get OpacityTextureEnabled(): boolean;
  26513. static set OpacityTextureEnabled(value: boolean);
  26514. private static _ReflectionTextureEnabled;
  26515. /**
  26516. * Are reflection textures enabled in the application.
  26517. */
  26518. static get ReflectionTextureEnabled(): boolean;
  26519. static set ReflectionTextureEnabled(value: boolean);
  26520. private static _EmissiveTextureEnabled;
  26521. /**
  26522. * Are emissive textures enabled in the application.
  26523. */
  26524. static get EmissiveTextureEnabled(): boolean;
  26525. static set EmissiveTextureEnabled(value: boolean);
  26526. private static _SpecularTextureEnabled;
  26527. /**
  26528. * Are specular textures enabled in the application.
  26529. */
  26530. static get SpecularTextureEnabled(): boolean;
  26531. static set SpecularTextureEnabled(value: boolean);
  26532. private static _BumpTextureEnabled;
  26533. /**
  26534. * Are bump textures enabled in the application.
  26535. */
  26536. static get BumpTextureEnabled(): boolean;
  26537. static set BumpTextureEnabled(value: boolean);
  26538. private static _LightmapTextureEnabled;
  26539. /**
  26540. * Are lightmap textures enabled in the application.
  26541. */
  26542. static get LightmapTextureEnabled(): boolean;
  26543. static set LightmapTextureEnabled(value: boolean);
  26544. private static _RefractionTextureEnabled;
  26545. /**
  26546. * Are refraction textures enabled in the application.
  26547. */
  26548. static get RefractionTextureEnabled(): boolean;
  26549. static set RefractionTextureEnabled(value: boolean);
  26550. private static _ColorGradingTextureEnabled;
  26551. /**
  26552. * Are color grading textures enabled in the application.
  26553. */
  26554. static get ColorGradingTextureEnabled(): boolean;
  26555. static set ColorGradingTextureEnabled(value: boolean);
  26556. private static _FresnelEnabled;
  26557. /**
  26558. * Are fresnels enabled in the application.
  26559. */
  26560. static get FresnelEnabled(): boolean;
  26561. static set FresnelEnabled(value: boolean);
  26562. private static _ClearCoatTextureEnabled;
  26563. /**
  26564. * Are clear coat textures enabled in the application.
  26565. */
  26566. static get ClearCoatTextureEnabled(): boolean;
  26567. static set ClearCoatTextureEnabled(value: boolean);
  26568. private static _ClearCoatBumpTextureEnabled;
  26569. /**
  26570. * Are clear coat bump textures enabled in the application.
  26571. */
  26572. static get ClearCoatBumpTextureEnabled(): boolean;
  26573. static set ClearCoatBumpTextureEnabled(value: boolean);
  26574. private static _ClearCoatTintTextureEnabled;
  26575. /**
  26576. * Are clear coat tint textures enabled in the application.
  26577. */
  26578. static get ClearCoatTintTextureEnabled(): boolean;
  26579. static set ClearCoatTintTextureEnabled(value: boolean);
  26580. private static _SheenTextureEnabled;
  26581. /**
  26582. * Are sheen textures enabled in the application.
  26583. */
  26584. static get SheenTextureEnabled(): boolean;
  26585. static set SheenTextureEnabled(value: boolean);
  26586. private static _AnisotropicTextureEnabled;
  26587. /**
  26588. * Are anisotropic textures enabled in the application.
  26589. */
  26590. static get AnisotropicTextureEnabled(): boolean;
  26591. static set AnisotropicTextureEnabled(value: boolean);
  26592. private static _ThicknessTextureEnabled;
  26593. /**
  26594. * Are thickness textures enabled in the application.
  26595. */
  26596. static get ThicknessTextureEnabled(): boolean;
  26597. static set ThicknessTextureEnabled(value: boolean);
  26598. }
  26599. }
  26600. declare module BABYLON {
  26601. /** @hidden */
  26602. export var defaultFragmentDeclaration: {
  26603. name: string;
  26604. shader: string;
  26605. };
  26606. }
  26607. declare module BABYLON {
  26608. /** @hidden */
  26609. export var defaultUboDeclaration: {
  26610. name: string;
  26611. shader: string;
  26612. };
  26613. }
  26614. declare module BABYLON {
  26615. /** @hidden */
  26616. export var lightFragmentDeclaration: {
  26617. name: string;
  26618. shader: string;
  26619. };
  26620. }
  26621. declare module BABYLON {
  26622. /** @hidden */
  26623. export var lightUboDeclaration: {
  26624. name: string;
  26625. shader: string;
  26626. };
  26627. }
  26628. declare module BABYLON {
  26629. /** @hidden */
  26630. export var lightsFragmentFunctions: {
  26631. name: string;
  26632. shader: string;
  26633. };
  26634. }
  26635. declare module BABYLON {
  26636. /** @hidden */
  26637. export var shadowsFragmentFunctions: {
  26638. name: string;
  26639. shader: string;
  26640. };
  26641. }
  26642. declare module BABYLON {
  26643. /** @hidden */
  26644. export var fresnelFunction: {
  26645. name: string;
  26646. shader: string;
  26647. };
  26648. }
  26649. declare module BABYLON {
  26650. /** @hidden */
  26651. export var reflectionFunction: {
  26652. name: string;
  26653. shader: string;
  26654. };
  26655. }
  26656. declare module BABYLON {
  26657. /** @hidden */
  26658. export var bumpFragmentFunctions: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module BABYLON {
  26664. /** @hidden */
  26665. export var logDepthDeclaration: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module BABYLON {
  26671. /** @hidden */
  26672. export var bumpFragment: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module BABYLON {
  26678. /** @hidden */
  26679. export var depthPrePass: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module BABYLON {
  26685. /** @hidden */
  26686. export var lightFragment: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module BABYLON {
  26692. /** @hidden */
  26693. export var logDepthFragment: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module BABYLON {
  26699. /** @hidden */
  26700. export var defaultPixelShader: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module BABYLON {
  26706. /** @hidden */
  26707. export var defaultVertexDeclaration: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module BABYLON {
  26713. /** @hidden */
  26714. export var bumpVertexDeclaration: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module BABYLON {
  26720. /** @hidden */
  26721. export var bumpVertex: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module BABYLON {
  26727. /** @hidden */
  26728. export var fogVertex: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module BABYLON {
  26734. /** @hidden */
  26735. export var shadowsVertex: {
  26736. name: string;
  26737. shader: string;
  26738. };
  26739. }
  26740. declare module BABYLON {
  26741. /** @hidden */
  26742. export var pointCloudVertex: {
  26743. name: string;
  26744. shader: string;
  26745. };
  26746. }
  26747. declare module BABYLON {
  26748. /** @hidden */
  26749. export var logDepthVertex: {
  26750. name: string;
  26751. shader: string;
  26752. };
  26753. }
  26754. declare module BABYLON {
  26755. /** @hidden */
  26756. export var defaultVertexShader: {
  26757. name: string;
  26758. shader: string;
  26759. };
  26760. }
  26761. declare module BABYLON {
  26762. /** @hidden */
  26763. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26764. MAINUV1: boolean;
  26765. MAINUV2: boolean;
  26766. DIFFUSE: boolean;
  26767. DIFFUSEDIRECTUV: number;
  26768. AMBIENT: boolean;
  26769. AMBIENTDIRECTUV: number;
  26770. OPACITY: boolean;
  26771. OPACITYDIRECTUV: number;
  26772. OPACITYRGB: boolean;
  26773. REFLECTION: boolean;
  26774. EMISSIVE: boolean;
  26775. EMISSIVEDIRECTUV: number;
  26776. SPECULAR: boolean;
  26777. SPECULARDIRECTUV: number;
  26778. BUMP: boolean;
  26779. BUMPDIRECTUV: number;
  26780. PARALLAX: boolean;
  26781. PARALLAXOCCLUSION: boolean;
  26782. SPECULAROVERALPHA: boolean;
  26783. CLIPPLANE: boolean;
  26784. CLIPPLANE2: boolean;
  26785. CLIPPLANE3: boolean;
  26786. CLIPPLANE4: boolean;
  26787. CLIPPLANE5: boolean;
  26788. CLIPPLANE6: boolean;
  26789. ALPHATEST: boolean;
  26790. DEPTHPREPASS: boolean;
  26791. ALPHAFROMDIFFUSE: boolean;
  26792. POINTSIZE: boolean;
  26793. FOG: boolean;
  26794. SPECULARTERM: boolean;
  26795. DIFFUSEFRESNEL: boolean;
  26796. OPACITYFRESNEL: boolean;
  26797. REFLECTIONFRESNEL: boolean;
  26798. REFRACTIONFRESNEL: boolean;
  26799. EMISSIVEFRESNEL: boolean;
  26800. FRESNEL: boolean;
  26801. NORMAL: boolean;
  26802. UV1: boolean;
  26803. UV2: boolean;
  26804. VERTEXCOLOR: boolean;
  26805. VERTEXALPHA: boolean;
  26806. NUM_BONE_INFLUENCERS: number;
  26807. BonesPerMesh: number;
  26808. BONETEXTURE: boolean;
  26809. INSTANCES: boolean;
  26810. GLOSSINESS: boolean;
  26811. ROUGHNESS: boolean;
  26812. EMISSIVEASILLUMINATION: boolean;
  26813. LINKEMISSIVEWITHDIFFUSE: boolean;
  26814. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26815. LIGHTMAP: boolean;
  26816. LIGHTMAPDIRECTUV: number;
  26817. OBJECTSPACE_NORMALMAP: boolean;
  26818. USELIGHTMAPASSHADOWMAP: boolean;
  26819. REFLECTIONMAP_3D: boolean;
  26820. REFLECTIONMAP_SPHERICAL: boolean;
  26821. REFLECTIONMAP_PLANAR: boolean;
  26822. REFLECTIONMAP_CUBIC: boolean;
  26823. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26824. REFLECTIONMAP_PROJECTION: boolean;
  26825. REFLECTIONMAP_SKYBOX: boolean;
  26826. REFLECTIONMAP_EXPLICIT: boolean;
  26827. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26828. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26829. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26830. INVERTCUBICMAP: boolean;
  26831. LOGARITHMICDEPTH: boolean;
  26832. REFRACTION: boolean;
  26833. REFRACTIONMAP_3D: boolean;
  26834. REFLECTIONOVERALPHA: boolean;
  26835. TWOSIDEDLIGHTING: boolean;
  26836. SHADOWFLOAT: boolean;
  26837. MORPHTARGETS: boolean;
  26838. MORPHTARGETS_NORMAL: boolean;
  26839. MORPHTARGETS_TANGENT: boolean;
  26840. MORPHTARGETS_UV: boolean;
  26841. NUM_MORPH_INFLUENCERS: number;
  26842. NONUNIFORMSCALING: boolean;
  26843. PREMULTIPLYALPHA: boolean;
  26844. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26845. ALPHABLEND: boolean;
  26846. IMAGEPROCESSING: boolean;
  26847. VIGNETTE: boolean;
  26848. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26849. VIGNETTEBLENDMODEOPAQUE: boolean;
  26850. TONEMAPPING: boolean;
  26851. TONEMAPPING_ACES: boolean;
  26852. CONTRAST: boolean;
  26853. COLORCURVES: boolean;
  26854. COLORGRADING: boolean;
  26855. COLORGRADING3D: boolean;
  26856. SAMPLER3DGREENDEPTH: boolean;
  26857. SAMPLER3DBGRMAP: boolean;
  26858. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26859. MULTIVIEW: boolean;
  26860. /**
  26861. * If the reflection texture on this material is in linear color space
  26862. * @hidden
  26863. */
  26864. IS_REFLECTION_LINEAR: boolean;
  26865. /**
  26866. * If the refraction texture on this material is in linear color space
  26867. * @hidden
  26868. */
  26869. IS_REFRACTION_LINEAR: boolean;
  26870. EXPOSURE: boolean;
  26871. constructor();
  26872. setReflectionMode(modeToEnable: string): void;
  26873. }
  26874. /**
  26875. * This is the default material used in Babylon. It is the best trade off between quality
  26876. * and performances.
  26877. * @see http://doc.babylonjs.com/babylon101/materials
  26878. */
  26879. export class StandardMaterial extends PushMaterial {
  26880. private _diffuseTexture;
  26881. /**
  26882. * The basic texture of the material as viewed under a light.
  26883. */
  26884. diffuseTexture: Nullable<BaseTexture>;
  26885. private _ambientTexture;
  26886. /**
  26887. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26888. */
  26889. ambientTexture: Nullable<BaseTexture>;
  26890. private _opacityTexture;
  26891. /**
  26892. * Define the transparency of the material from a texture.
  26893. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26894. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26895. */
  26896. opacityTexture: Nullable<BaseTexture>;
  26897. private _reflectionTexture;
  26898. /**
  26899. * Define the texture used to display the reflection.
  26900. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26901. */
  26902. reflectionTexture: Nullable<BaseTexture>;
  26903. private _emissiveTexture;
  26904. /**
  26905. * Define texture of the material as if self lit.
  26906. * This will be mixed in the final result even in the absence of light.
  26907. */
  26908. emissiveTexture: Nullable<BaseTexture>;
  26909. private _specularTexture;
  26910. /**
  26911. * Define how the color and intensity of the highlight given by the light in the material.
  26912. */
  26913. specularTexture: Nullable<BaseTexture>;
  26914. private _bumpTexture;
  26915. /**
  26916. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26917. * 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.
  26918. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26919. */
  26920. bumpTexture: Nullable<BaseTexture>;
  26921. private _lightmapTexture;
  26922. /**
  26923. * Complex lighting can be computationally expensive to compute at runtime.
  26924. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26925. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26926. */
  26927. lightmapTexture: Nullable<BaseTexture>;
  26928. private _refractionTexture;
  26929. /**
  26930. * Define the texture used to display the refraction.
  26931. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26932. */
  26933. refractionTexture: Nullable<BaseTexture>;
  26934. /**
  26935. * The color of the material lit by the environmental background lighting.
  26936. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26937. */
  26938. ambientColor: Color3;
  26939. /**
  26940. * The basic color of the material as viewed under a light.
  26941. */
  26942. diffuseColor: Color3;
  26943. /**
  26944. * Define how the color and intensity of the highlight given by the light in the material.
  26945. */
  26946. specularColor: Color3;
  26947. /**
  26948. * Define the color of the material as if self lit.
  26949. * This will be mixed in the final result even in the absence of light.
  26950. */
  26951. emissiveColor: Color3;
  26952. /**
  26953. * Defines how sharp are the highlights in the material.
  26954. * The bigger the value the sharper giving a more glossy feeling to the result.
  26955. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26956. */
  26957. specularPower: number;
  26958. private _useAlphaFromDiffuseTexture;
  26959. /**
  26960. * Does the transparency come from the diffuse texture alpha channel.
  26961. */
  26962. useAlphaFromDiffuseTexture: boolean;
  26963. private _useEmissiveAsIllumination;
  26964. /**
  26965. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26966. */
  26967. useEmissiveAsIllumination: boolean;
  26968. private _linkEmissiveWithDiffuse;
  26969. /**
  26970. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26971. * the emissive level when the final color is close to one.
  26972. */
  26973. linkEmissiveWithDiffuse: boolean;
  26974. private _useSpecularOverAlpha;
  26975. /**
  26976. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26977. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26978. */
  26979. useSpecularOverAlpha: boolean;
  26980. private _useReflectionOverAlpha;
  26981. /**
  26982. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26983. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26984. */
  26985. useReflectionOverAlpha: boolean;
  26986. private _disableLighting;
  26987. /**
  26988. * Does lights from the scene impacts this material.
  26989. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26990. */
  26991. disableLighting: boolean;
  26992. private _useObjectSpaceNormalMap;
  26993. /**
  26994. * Allows using an object space normal map (instead of tangent space).
  26995. */
  26996. useObjectSpaceNormalMap: boolean;
  26997. private _useParallax;
  26998. /**
  26999. * Is parallax enabled or not.
  27000. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27001. */
  27002. useParallax: boolean;
  27003. private _useParallaxOcclusion;
  27004. /**
  27005. * Is parallax occlusion enabled or not.
  27006. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27007. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27008. */
  27009. useParallaxOcclusion: boolean;
  27010. /**
  27011. * 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.
  27012. */
  27013. parallaxScaleBias: number;
  27014. private _roughness;
  27015. /**
  27016. * Helps to define how blurry the reflections should appears in the material.
  27017. */
  27018. roughness: number;
  27019. /**
  27020. * In case of refraction, define the value of the index of refraction.
  27021. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27022. */
  27023. indexOfRefraction: number;
  27024. /**
  27025. * Invert the refraction texture alongside the y axis.
  27026. * It can be useful with procedural textures or probe for instance.
  27027. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27028. */
  27029. invertRefractionY: boolean;
  27030. /**
  27031. * Defines the alpha limits in alpha test mode.
  27032. */
  27033. alphaCutOff: number;
  27034. private _useLightmapAsShadowmap;
  27035. /**
  27036. * In case of light mapping, define whether the map contains light or shadow informations.
  27037. */
  27038. useLightmapAsShadowmap: boolean;
  27039. private _diffuseFresnelParameters;
  27040. /**
  27041. * Define the diffuse fresnel parameters of the material.
  27042. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27043. */
  27044. diffuseFresnelParameters: FresnelParameters;
  27045. private _opacityFresnelParameters;
  27046. /**
  27047. * Define the opacity fresnel parameters of the material.
  27048. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27049. */
  27050. opacityFresnelParameters: FresnelParameters;
  27051. private _reflectionFresnelParameters;
  27052. /**
  27053. * Define the reflection fresnel parameters of the material.
  27054. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27055. */
  27056. reflectionFresnelParameters: FresnelParameters;
  27057. private _refractionFresnelParameters;
  27058. /**
  27059. * Define the refraction fresnel parameters of the material.
  27060. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27061. */
  27062. refractionFresnelParameters: FresnelParameters;
  27063. private _emissiveFresnelParameters;
  27064. /**
  27065. * Define the emissive fresnel parameters of the material.
  27066. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27067. */
  27068. emissiveFresnelParameters: FresnelParameters;
  27069. private _useReflectionFresnelFromSpecular;
  27070. /**
  27071. * If true automatically deducts the fresnels values from the material specularity.
  27072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27073. */
  27074. useReflectionFresnelFromSpecular: boolean;
  27075. private _useGlossinessFromSpecularMapAlpha;
  27076. /**
  27077. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27078. */
  27079. useGlossinessFromSpecularMapAlpha: boolean;
  27080. private _maxSimultaneousLights;
  27081. /**
  27082. * Defines the maximum number of lights that can be used in the material
  27083. */
  27084. maxSimultaneousLights: number;
  27085. private _invertNormalMapX;
  27086. /**
  27087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27088. */
  27089. invertNormalMapX: boolean;
  27090. private _invertNormalMapY;
  27091. /**
  27092. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27093. */
  27094. invertNormalMapY: boolean;
  27095. private _twoSidedLighting;
  27096. /**
  27097. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27098. */
  27099. twoSidedLighting: boolean;
  27100. /**
  27101. * Default configuration related to image processing available in the standard Material.
  27102. */
  27103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27104. /**
  27105. * Gets the image processing configuration used either in this material.
  27106. */
  27107. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27108. /**
  27109. * Sets the Default image processing configuration used either in the this material.
  27110. *
  27111. * If sets to null, the scene one is in use.
  27112. */
  27113. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27114. /**
  27115. * Keep track of the image processing observer to allow dispose and replace.
  27116. */
  27117. private _imageProcessingObserver;
  27118. /**
  27119. * Attaches a new image processing configuration to the Standard Material.
  27120. * @param configuration
  27121. */
  27122. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27123. /**
  27124. * Gets wether the color curves effect is enabled.
  27125. */
  27126. get cameraColorCurvesEnabled(): boolean;
  27127. /**
  27128. * Sets wether the color curves effect is enabled.
  27129. */
  27130. set cameraColorCurvesEnabled(value: boolean);
  27131. /**
  27132. * Gets wether the color grading effect is enabled.
  27133. */
  27134. get cameraColorGradingEnabled(): boolean;
  27135. /**
  27136. * Gets wether the color grading effect is enabled.
  27137. */
  27138. set cameraColorGradingEnabled(value: boolean);
  27139. /**
  27140. * Gets wether tonemapping is enabled or not.
  27141. */
  27142. get cameraToneMappingEnabled(): boolean;
  27143. /**
  27144. * Sets wether tonemapping is enabled or not
  27145. */
  27146. set cameraToneMappingEnabled(value: boolean);
  27147. /**
  27148. * The camera exposure used on this material.
  27149. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27150. * This corresponds to a photographic exposure.
  27151. */
  27152. get cameraExposure(): number;
  27153. /**
  27154. * The camera exposure used on this material.
  27155. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27156. * This corresponds to a photographic exposure.
  27157. */
  27158. set cameraExposure(value: number);
  27159. /**
  27160. * Gets The camera contrast used on this material.
  27161. */
  27162. get cameraContrast(): number;
  27163. /**
  27164. * Sets The camera contrast used on this material.
  27165. */
  27166. set cameraContrast(value: number);
  27167. /**
  27168. * Gets the Color Grading 2D Lookup Texture.
  27169. */
  27170. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27171. /**
  27172. * Sets the Color Grading 2D Lookup Texture.
  27173. */
  27174. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27175. /**
  27176. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27177. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27178. * 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;
  27179. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27180. */
  27181. get cameraColorCurves(): Nullable<ColorCurves>;
  27182. /**
  27183. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27184. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27185. * 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;
  27186. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27187. */
  27188. set cameraColorCurves(value: Nullable<ColorCurves>);
  27189. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27190. protected _worldViewProjectionMatrix: Matrix;
  27191. protected _globalAmbientColor: Color3;
  27192. protected _useLogarithmicDepth: boolean;
  27193. protected _rebuildInParallel: boolean;
  27194. /**
  27195. * Instantiates a new standard material.
  27196. * This is the default material used in Babylon. It is the best trade off between quality
  27197. * and performances.
  27198. * @see http://doc.babylonjs.com/babylon101/materials
  27199. * @param name Define the name of the material in the scene
  27200. * @param scene Define the scene the material belong to
  27201. */
  27202. constructor(name: string, scene: Scene);
  27203. /**
  27204. * Gets a boolean indicating that current material needs to register RTT
  27205. */
  27206. get hasRenderTargetTextures(): boolean;
  27207. /**
  27208. * Gets the current class name of the material e.g. "StandardMaterial"
  27209. * Mainly use in serialization.
  27210. * @returns the class name
  27211. */
  27212. getClassName(): string;
  27213. /**
  27214. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27215. * You can try switching to logarithmic depth.
  27216. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27217. */
  27218. get useLogarithmicDepth(): boolean;
  27219. set useLogarithmicDepth(value: boolean);
  27220. /**
  27221. * Specifies if the material will require alpha blending
  27222. * @returns a boolean specifying if alpha blending is needed
  27223. */
  27224. needAlphaBlending(): boolean;
  27225. /**
  27226. * Specifies if this material should be rendered in alpha test mode
  27227. * @returns a boolean specifying if an alpha test is needed.
  27228. */
  27229. needAlphaTesting(): boolean;
  27230. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27231. /**
  27232. * Get the texture used for alpha test purpose.
  27233. * @returns the diffuse texture in case of the standard material.
  27234. */
  27235. getAlphaTestTexture(): Nullable<BaseTexture>;
  27236. /**
  27237. * Get if the submesh is ready to be used and all its information available.
  27238. * Child classes can use it to update shaders
  27239. * @param mesh defines the mesh to check
  27240. * @param subMesh defines which submesh to check
  27241. * @param useInstances specifies that instances should be used
  27242. * @returns a boolean indicating that the submesh is ready or not
  27243. */
  27244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27245. /**
  27246. * Builds the material UBO layouts.
  27247. * Used internally during the effect preparation.
  27248. */
  27249. buildUniformLayout(): void;
  27250. /**
  27251. * Unbinds the material from the mesh
  27252. */
  27253. unbind(): void;
  27254. /**
  27255. * Binds the submesh to this material by preparing the effect and shader to draw
  27256. * @param world defines the world transformation matrix
  27257. * @param mesh defines the mesh containing the submesh
  27258. * @param subMesh defines the submesh to bind the material to
  27259. */
  27260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27261. /**
  27262. * Get the list of animatables in the material.
  27263. * @returns the list of animatables object used in the material
  27264. */
  27265. getAnimatables(): IAnimatable[];
  27266. /**
  27267. * Gets the active textures from the material
  27268. * @returns an array of textures
  27269. */
  27270. getActiveTextures(): BaseTexture[];
  27271. /**
  27272. * Specifies if the material uses a texture
  27273. * @param texture defines the texture to check against the material
  27274. * @returns a boolean specifying if the material uses the texture
  27275. */
  27276. hasTexture(texture: BaseTexture): boolean;
  27277. /**
  27278. * Disposes the material
  27279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27281. */
  27282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27283. /**
  27284. * Makes a duplicate of the material, and gives it a new name
  27285. * @param name defines the new name for the duplicated material
  27286. * @returns the cloned material
  27287. */
  27288. clone(name: string): StandardMaterial;
  27289. /**
  27290. * Serializes this material in a JSON representation
  27291. * @returns the serialized material object
  27292. */
  27293. serialize(): any;
  27294. /**
  27295. * Creates a standard material from parsed material data
  27296. * @param source defines the JSON representation of the material
  27297. * @param scene defines the hosting scene
  27298. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27299. * @returns a new standard material
  27300. */
  27301. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27302. /**
  27303. * Are diffuse textures enabled in the application.
  27304. */
  27305. static get DiffuseTextureEnabled(): boolean;
  27306. static set DiffuseTextureEnabled(value: boolean);
  27307. /**
  27308. * Are ambient textures enabled in the application.
  27309. */
  27310. static get AmbientTextureEnabled(): boolean;
  27311. static set AmbientTextureEnabled(value: boolean);
  27312. /**
  27313. * Are opacity textures enabled in the application.
  27314. */
  27315. static get OpacityTextureEnabled(): boolean;
  27316. static set OpacityTextureEnabled(value: boolean);
  27317. /**
  27318. * Are reflection textures enabled in the application.
  27319. */
  27320. static get ReflectionTextureEnabled(): boolean;
  27321. static set ReflectionTextureEnabled(value: boolean);
  27322. /**
  27323. * Are emissive textures enabled in the application.
  27324. */
  27325. static get EmissiveTextureEnabled(): boolean;
  27326. static set EmissiveTextureEnabled(value: boolean);
  27327. /**
  27328. * Are specular textures enabled in the application.
  27329. */
  27330. static get SpecularTextureEnabled(): boolean;
  27331. static set SpecularTextureEnabled(value: boolean);
  27332. /**
  27333. * Are bump textures enabled in the application.
  27334. */
  27335. static get BumpTextureEnabled(): boolean;
  27336. static set BumpTextureEnabled(value: boolean);
  27337. /**
  27338. * Are lightmap textures enabled in the application.
  27339. */
  27340. static get LightmapTextureEnabled(): boolean;
  27341. static set LightmapTextureEnabled(value: boolean);
  27342. /**
  27343. * Are refraction textures enabled in the application.
  27344. */
  27345. static get RefractionTextureEnabled(): boolean;
  27346. static set RefractionTextureEnabled(value: boolean);
  27347. /**
  27348. * Are color grading textures enabled in the application.
  27349. */
  27350. static get ColorGradingTextureEnabled(): boolean;
  27351. static set ColorGradingTextureEnabled(value: boolean);
  27352. /**
  27353. * Are fresnels enabled in the application.
  27354. */
  27355. static get FresnelEnabled(): boolean;
  27356. static set FresnelEnabled(value: boolean);
  27357. }
  27358. }
  27359. declare module BABYLON {
  27360. /**
  27361. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27362. *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.
  27363. * The SPS is also a particle system. It provides some methods to manage the particles.
  27364. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27365. *
  27366. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27367. */
  27368. export class SolidParticleSystem implements IDisposable {
  27369. /**
  27370. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27371. * Example : var p = SPS.particles[i];
  27372. */
  27373. particles: SolidParticle[];
  27374. /**
  27375. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27376. */
  27377. nbParticles: number;
  27378. /**
  27379. * If the particles must ever face the camera (default false). Useful for planar particles.
  27380. */
  27381. billboard: boolean;
  27382. /**
  27383. * Recompute normals when adding a shape
  27384. */
  27385. recomputeNormals: boolean;
  27386. /**
  27387. * This a counter ofr your own usage. It's not set by any SPS functions.
  27388. */
  27389. counter: number;
  27390. /**
  27391. * The SPS name. This name is also given to the underlying mesh.
  27392. */
  27393. name: string;
  27394. /**
  27395. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27396. */
  27397. mesh: Mesh;
  27398. /**
  27399. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27400. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27401. */
  27402. vars: any;
  27403. /**
  27404. * This array is populated when the SPS is set as 'pickable'.
  27405. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27406. * Each element of this array is an object `{idx: int, faceId: int}`.
  27407. * `idx` is the picked particle index in the `SPS.particles` array
  27408. * `faceId` is the picked face index counted within this particle.
  27409. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27410. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27411. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27412. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27413. */
  27414. pickedParticles: {
  27415. idx: number;
  27416. faceId: number;
  27417. }[];
  27418. /**
  27419. * This array is populated when the SPS is set as 'pickable'
  27420. * Each key of this array is a submesh index.
  27421. * Each element of this array is a second array defined like this :
  27422. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27423. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27424. * `idx` is the picked particle index in the `SPS.particles` array
  27425. * `faceId` is the picked face index counted within this particle.
  27426. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27427. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27428. */
  27429. pickedBySubMesh: {
  27430. idx: number;
  27431. faceId: number;
  27432. }[][];
  27433. /**
  27434. * This array is populated when `enableDepthSort` is set to true.
  27435. * Each element of this array is an instance of the class DepthSortedParticle.
  27436. */
  27437. depthSortedParticles: DepthSortedParticle[];
  27438. /**
  27439. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27440. * @hidden
  27441. */
  27442. _bSphereOnly: boolean;
  27443. /**
  27444. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27445. * @hidden
  27446. */
  27447. _bSphereRadiusFactor: number;
  27448. private _scene;
  27449. private _positions;
  27450. private _indices;
  27451. private _normals;
  27452. private _colors;
  27453. private _uvs;
  27454. private _indices32;
  27455. private _positions32;
  27456. private _normals32;
  27457. private _fixedNormal32;
  27458. private _colors32;
  27459. private _uvs32;
  27460. private _index;
  27461. private _updatable;
  27462. private _pickable;
  27463. private _isVisibilityBoxLocked;
  27464. private _alwaysVisible;
  27465. private _depthSort;
  27466. private _expandable;
  27467. private _shapeCounter;
  27468. private _copy;
  27469. private _color;
  27470. private _computeParticleColor;
  27471. private _computeParticleTexture;
  27472. private _computeParticleRotation;
  27473. private _computeParticleVertex;
  27474. private _computeBoundingBox;
  27475. private _depthSortParticles;
  27476. private _camera;
  27477. private _mustUnrotateFixedNormals;
  27478. private _particlesIntersect;
  27479. private _needs32Bits;
  27480. private _isNotBuilt;
  27481. private _lastParticleId;
  27482. private _idxOfId;
  27483. private _multimaterialEnabled;
  27484. private _useModelMaterial;
  27485. private _indicesByMaterial;
  27486. private _materialIndexes;
  27487. private _depthSortFunction;
  27488. private _materialSortFunction;
  27489. private _materials;
  27490. private _multimaterial;
  27491. private _materialIndexesById;
  27492. private _defaultMaterial;
  27493. private _autoUpdateSubMeshes;
  27494. /**
  27495. * Creates a SPS (Solid Particle System) object.
  27496. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27497. * @param scene (Scene) is the scene in which the SPS is added.
  27498. * @param options defines the options of the sps e.g.
  27499. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27500. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27501. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27502. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27503. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27504. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27505. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27506. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27507. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27508. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27509. */
  27510. constructor(name: string, scene: Scene, options?: {
  27511. updatable?: boolean;
  27512. isPickable?: boolean;
  27513. enableDepthSort?: boolean;
  27514. particleIntersection?: boolean;
  27515. boundingSphereOnly?: boolean;
  27516. bSphereRadiusFactor?: number;
  27517. expandable?: boolean;
  27518. useModelMaterial?: boolean;
  27519. enableMultiMaterial?: boolean;
  27520. });
  27521. /**
  27522. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27523. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27524. * @returns the created mesh
  27525. */
  27526. buildMesh(): Mesh;
  27527. /**
  27528. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27529. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27530. * Thus the particles generated from `digest()` have their property `position` set yet.
  27531. * @param mesh ( Mesh ) is the mesh to be digested
  27532. * @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
  27533. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27534. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27535. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27536. * @returns the current SPS
  27537. */
  27538. digest(mesh: Mesh, options?: {
  27539. facetNb?: number;
  27540. number?: number;
  27541. delta?: number;
  27542. storage?: [];
  27543. }): SolidParticleSystem;
  27544. /**
  27545. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27546. * @hidden
  27547. */
  27548. private _unrotateFixedNormals;
  27549. /**
  27550. * Resets the temporary working copy particle
  27551. * @hidden
  27552. */
  27553. private _resetCopy;
  27554. /**
  27555. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27556. * @param p the current index in the positions array to be updated
  27557. * @param ind the current index in the indices array
  27558. * @param shape a Vector3 array, the shape geometry
  27559. * @param positions the positions array to be updated
  27560. * @param meshInd the shape indices array
  27561. * @param indices the indices array to be updated
  27562. * @param meshUV the shape uv array
  27563. * @param uvs the uv array to be updated
  27564. * @param meshCol the shape color array
  27565. * @param colors the color array to be updated
  27566. * @param meshNor the shape normals array
  27567. * @param normals the normals array to be updated
  27568. * @param idx the particle index
  27569. * @param idxInShape the particle index in its shape
  27570. * @param options the addShape() method passed options
  27571. * @model the particle model
  27572. * @hidden
  27573. */
  27574. private _meshBuilder;
  27575. /**
  27576. * Returns a shape Vector3 array from positions float array
  27577. * @param positions float array
  27578. * @returns a vector3 array
  27579. * @hidden
  27580. */
  27581. private _posToShape;
  27582. /**
  27583. * Returns a shapeUV array from a float uvs (array deep copy)
  27584. * @param uvs as a float array
  27585. * @returns a shapeUV array
  27586. * @hidden
  27587. */
  27588. private _uvsToShapeUV;
  27589. /**
  27590. * Adds a new particle object in the particles array
  27591. * @param idx particle index in particles array
  27592. * @param id particle id
  27593. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27594. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27595. * @param model particle ModelShape object
  27596. * @param shapeId model shape identifier
  27597. * @param idxInShape index of the particle in the current model
  27598. * @param bInfo model bounding info object
  27599. * @param storage target storage array, if any
  27600. * @hidden
  27601. */
  27602. private _addParticle;
  27603. /**
  27604. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27605. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27606. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27607. * @param nb (positive integer) the number of particles to be created from this model
  27608. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27609. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27610. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27611. * @returns the number of shapes in the system
  27612. */
  27613. addShape(mesh: Mesh, nb: number, options?: {
  27614. positionFunction?: any;
  27615. vertexFunction?: any;
  27616. storage?: [];
  27617. }): number;
  27618. /**
  27619. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27620. * @hidden
  27621. */
  27622. private _rebuildParticle;
  27623. /**
  27624. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27625. * @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.
  27626. * @returns the SPS.
  27627. */
  27628. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27629. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27630. * Returns an array with the removed particles.
  27631. * 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.
  27632. * The SPS can't be empty so at least one particle needs to remain in place.
  27633. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27634. * @param start index of the first particle to remove
  27635. * @param end index of the last particle to remove (included)
  27636. * @returns an array populated with the removed particles
  27637. */
  27638. removeParticles(start: number, end: number): SolidParticle[];
  27639. /**
  27640. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27641. * @param solidParticleArray an array populated with Solid Particles objects
  27642. * @returns the SPS
  27643. */
  27644. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27645. /**
  27646. * Creates a new particle and modifies the SPS mesh geometry :
  27647. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27648. * - calls _addParticle() to populate the particle array
  27649. * factorized code from addShape() and insertParticlesFromArray()
  27650. * @param idx particle index in the particles array
  27651. * @param i particle index in its shape
  27652. * @param modelShape particle ModelShape object
  27653. * @param shape shape vertex array
  27654. * @param meshInd shape indices array
  27655. * @param meshUV shape uv array
  27656. * @param meshCol shape color array
  27657. * @param meshNor shape normals array
  27658. * @param bbInfo shape bounding info
  27659. * @param storage target particle storage
  27660. * @options addShape() passed options
  27661. * @hidden
  27662. */
  27663. private _insertNewParticle;
  27664. /**
  27665. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27666. * This method calls `updateParticle()` for each particle of the SPS.
  27667. * For an animated SPS, it is usually called within the render loop.
  27668. * 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.
  27669. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27670. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27671. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27672. * @returns the SPS.
  27673. */
  27674. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27675. /**
  27676. * Disposes the SPS.
  27677. */
  27678. dispose(): void;
  27679. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27680. * idx is the particle index in the SPS
  27681. * faceId is the picked face index counted within this particle.
  27682. * Returns null if the pickInfo can't identify a picked particle.
  27683. * @param pickingInfo (PickingInfo object)
  27684. * @returns {idx: number, faceId: number} or null
  27685. */
  27686. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27687. idx: number;
  27688. faceId: number;
  27689. }>;
  27690. /**
  27691. * Returns a SolidParticle object from its identifier : particle.id
  27692. * @param id (integer) the particle Id
  27693. * @returns the searched particle or null if not found in the SPS.
  27694. */
  27695. getParticleById(id: number): Nullable<SolidParticle>;
  27696. /**
  27697. * Returns a new array populated with the particles having the passed shapeId.
  27698. * @param shapeId (integer) the shape identifier
  27699. * @returns a new solid particle array
  27700. */
  27701. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27702. /**
  27703. * Populates the passed array "ref" with the particles having the passed shapeId.
  27704. * @param shapeId the shape identifier
  27705. * @returns the SPS
  27706. * @param ref
  27707. */
  27708. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27709. /**
  27710. * Computes the required SubMeshes according the materials assigned to the particles.
  27711. * @returns the solid particle system.
  27712. * Does nothing if called before the SPS mesh is built.
  27713. */
  27714. computeSubMeshes(): SolidParticleSystem;
  27715. /**
  27716. * Sorts the solid particles by material when MultiMaterial is enabled.
  27717. * Updates the indices32 array.
  27718. * Updates the indicesByMaterial array.
  27719. * Updates the mesh indices array.
  27720. * @returns the SPS
  27721. * @hidden
  27722. */
  27723. private _sortParticlesByMaterial;
  27724. /**
  27725. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27726. * @hidden
  27727. */
  27728. private _setMaterialIndexesById;
  27729. /**
  27730. * Returns an array with unique values of Materials from the passed array
  27731. * @param array the material array to be checked and filtered
  27732. * @hidden
  27733. */
  27734. private _filterUniqueMaterialId;
  27735. /**
  27736. * Sets a new Standard Material as _defaultMaterial if not already set.
  27737. * @hidden
  27738. */
  27739. private _setDefaultMaterial;
  27740. /**
  27741. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27743. * @returns the SPS.
  27744. */
  27745. refreshVisibleSize(): SolidParticleSystem;
  27746. /**
  27747. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27748. * @param size the size (float) of the visibility box
  27749. * note : this doesn't lock the SPS mesh bounding box.
  27750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27751. */
  27752. setVisibilityBox(size: number): void;
  27753. /**
  27754. * Gets whether the SPS as always visible or not
  27755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27756. */
  27757. get isAlwaysVisible(): boolean;
  27758. /**
  27759. * Sets the SPS as always visible or not
  27760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27761. */
  27762. set isAlwaysVisible(val: boolean);
  27763. /**
  27764. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27766. */
  27767. set isVisibilityBoxLocked(val: boolean);
  27768. /**
  27769. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27770. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27771. */
  27772. get isVisibilityBoxLocked(): boolean;
  27773. /**
  27774. * Tells to `setParticles()` to compute the particle rotations or not.
  27775. * Default value : true. The SPS is faster when it's set to false.
  27776. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27777. */
  27778. set computeParticleRotation(val: boolean);
  27779. /**
  27780. * Tells to `setParticles()` to compute the particle colors or not.
  27781. * Default value : true. The SPS is faster when it's set to false.
  27782. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27783. */
  27784. set computeParticleColor(val: boolean);
  27785. set computeParticleTexture(val: boolean);
  27786. /**
  27787. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27788. * Default value : false. The SPS is faster when it's set to false.
  27789. * Note : the particle custom vertex positions aren't stored values.
  27790. */
  27791. set computeParticleVertex(val: boolean);
  27792. /**
  27793. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27794. */
  27795. set computeBoundingBox(val: boolean);
  27796. /**
  27797. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27798. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27799. * Default : `true`
  27800. */
  27801. set depthSortParticles(val: boolean);
  27802. /**
  27803. * Gets if `setParticles()` computes the particle rotations or not.
  27804. * Default value : true. The SPS is faster when it's set to false.
  27805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27806. */
  27807. get computeParticleRotation(): boolean;
  27808. /**
  27809. * Gets if `setParticles()` computes the particle colors or not.
  27810. * Default value : true. The SPS is faster when it's set to false.
  27811. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27812. */
  27813. get computeParticleColor(): boolean;
  27814. /**
  27815. * Gets if `setParticles()` computes the particle textures or not.
  27816. * Default value : true. The SPS is faster when it's set to false.
  27817. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27818. */
  27819. get computeParticleTexture(): boolean;
  27820. /**
  27821. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27822. * Default value : false. The SPS is faster when it's set to false.
  27823. * Note : the particle custom vertex positions aren't stored values.
  27824. */
  27825. get computeParticleVertex(): boolean;
  27826. /**
  27827. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27828. */
  27829. get computeBoundingBox(): boolean;
  27830. /**
  27831. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27832. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27833. * Default : `true`
  27834. */
  27835. get depthSortParticles(): boolean;
  27836. /**
  27837. * Gets if the SPS is created as expandable at construction time.
  27838. * Default : `false`
  27839. */
  27840. get expandable(): boolean;
  27841. /**
  27842. * Gets if the SPS supports the Multi Materials
  27843. */
  27844. get multimaterialEnabled(): boolean;
  27845. /**
  27846. * Gets if the SPS uses the model materials for its own multimaterial.
  27847. */
  27848. get useModelMaterial(): boolean;
  27849. /**
  27850. * The SPS used material array.
  27851. */
  27852. get materials(): Material[];
  27853. /**
  27854. * Sets the SPS MultiMaterial from the passed materials.
  27855. * Note : the passed array is internally copied and not used then by reference.
  27856. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27857. */
  27858. setMultiMaterial(materials: Material[]): void;
  27859. /**
  27860. * The SPS computed multimaterial object
  27861. */
  27862. get multimaterial(): MultiMaterial;
  27863. set multimaterial(mm: MultiMaterial);
  27864. /**
  27865. * If the subMeshes must be updated on the next call to setParticles()
  27866. */
  27867. get autoUpdateSubMeshes(): boolean;
  27868. set autoUpdateSubMeshes(val: boolean);
  27869. /**
  27870. * This function does nothing. It may be overwritten to set all the particle first values.
  27871. * The SPS doesn't call this function, you may have to call it by your own.
  27872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27873. */
  27874. initParticles(): void;
  27875. /**
  27876. * This function does nothing. It may be overwritten to recycle a particle.
  27877. * The SPS doesn't call this function, you may have to call it by your own.
  27878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27879. * @param particle The particle to recycle
  27880. * @returns the recycled particle
  27881. */
  27882. recycleParticle(particle: SolidParticle): SolidParticle;
  27883. /**
  27884. * Updates a particle : this function should be overwritten by the user.
  27885. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27887. * @example : just set a particle position or velocity and recycle conditions
  27888. * @param particle The particle to update
  27889. * @returns the updated particle
  27890. */
  27891. updateParticle(particle: SolidParticle): SolidParticle;
  27892. /**
  27893. * Updates a vertex of a particle : it can be overwritten by the user.
  27894. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27895. * @param particle the current particle
  27896. * @param vertex the current index of the current particle
  27897. * @param pt the index of the current vertex in the particle shape
  27898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27899. * @example : just set a vertex particle position
  27900. * @returns the updated vertex
  27901. */
  27902. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27903. /**
  27904. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27905. * This does nothing and may be overwritten by the user.
  27906. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27907. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27908. * @param update the boolean update value actually passed to setParticles()
  27909. */
  27910. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27911. /**
  27912. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27913. * This will be passed three parameters.
  27914. * This does nothing and may be overwritten by the user.
  27915. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27917. * @param update the boolean update value actually passed to setParticles()
  27918. */
  27919. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27920. }
  27921. }
  27922. declare module BABYLON {
  27923. /**
  27924. * Represents one particle of a solid particle system.
  27925. */
  27926. export class SolidParticle {
  27927. /**
  27928. * particle global index
  27929. */
  27930. idx: number;
  27931. /**
  27932. * particle identifier
  27933. */
  27934. id: number;
  27935. /**
  27936. * The color of the particle
  27937. */
  27938. color: Nullable<Color4>;
  27939. /**
  27940. * The world space position of the particle.
  27941. */
  27942. position: Vector3;
  27943. /**
  27944. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27945. */
  27946. rotation: Vector3;
  27947. /**
  27948. * The world space rotation quaternion of the particle.
  27949. */
  27950. rotationQuaternion: Nullable<Quaternion>;
  27951. /**
  27952. * The scaling of the particle.
  27953. */
  27954. scaling: Vector3;
  27955. /**
  27956. * The uvs of the particle.
  27957. */
  27958. uvs: Vector4;
  27959. /**
  27960. * The current speed of the particle.
  27961. */
  27962. velocity: Vector3;
  27963. /**
  27964. * The pivot point in the particle local space.
  27965. */
  27966. pivot: Vector3;
  27967. /**
  27968. * Must the particle be translated from its pivot point in its local space ?
  27969. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27970. * Default : false
  27971. */
  27972. translateFromPivot: boolean;
  27973. /**
  27974. * Is the particle active or not ?
  27975. */
  27976. alive: boolean;
  27977. /**
  27978. * Is the particle visible or not ?
  27979. */
  27980. isVisible: boolean;
  27981. /**
  27982. * Index of this particle in the global "positions" array (Internal use)
  27983. * @hidden
  27984. */
  27985. _pos: number;
  27986. /**
  27987. * @hidden Index of this particle in the global "indices" array (Internal use)
  27988. */
  27989. _ind: number;
  27990. /**
  27991. * @hidden ModelShape of this particle (Internal use)
  27992. */
  27993. _model: ModelShape;
  27994. /**
  27995. * ModelShape id of this particle
  27996. */
  27997. shapeId: number;
  27998. /**
  27999. * Index of the particle in its shape id
  28000. */
  28001. idxInShape: number;
  28002. /**
  28003. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28004. */
  28005. _modelBoundingInfo: BoundingInfo;
  28006. /**
  28007. * @hidden Particle BoundingInfo object (Internal use)
  28008. */
  28009. _boundingInfo: BoundingInfo;
  28010. /**
  28011. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28012. */
  28013. _sps: SolidParticleSystem;
  28014. /**
  28015. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28016. */
  28017. _stillInvisible: boolean;
  28018. /**
  28019. * @hidden Last computed particle rotation matrix
  28020. */
  28021. _rotationMatrix: number[];
  28022. /**
  28023. * Parent particle Id, if any.
  28024. * Default null.
  28025. */
  28026. parentId: Nullable<number>;
  28027. /**
  28028. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28029. */
  28030. materialIndex: Nullable<number>;
  28031. /**
  28032. * Custom object or properties.
  28033. */
  28034. props: Nullable<any>;
  28035. /**
  28036. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28037. * The possible values are :
  28038. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28039. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28040. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28041. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28042. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28043. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28044. * */
  28045. cullingStrategy: number;
  28046. /**
  28047. * @hidden Internal global position in the SPS.
  28048. */
  28049. _globalPosition: Vector3;
  28050. /**
  28051. * Creates a Solid Particle object.
  28052. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28053. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28054. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28055. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28056. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28057. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28058. * @param shapeId (integer) is the model shape identifier in the SPS.
  28059. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28060. * @param sps defines the sps it is associated to
  28061. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28062. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28063. */
  28064. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28065. /**
  28066. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28067. * @param target the particle target
  28068. * @returns the current particle
  28069. */
  28070. copyToRef(target: SolidParticle): SolidParticle;
  28071. /**
  28072. * Legacy support, changed scale to scaling
  28073. */
  28074. get scale(): Vector3;
  28075. /**
  28076. * Legacy support, changed scale to scaling
  28077. */
  28078. set scale(scale: Vector3);
  28079. /**
  28080. * Legacy support, changed quaternion to rotationQuaternion
  28081. */
  28082. get quaternion(): Nullable<Quaternion>;
  28083. /**
  28084. * Legacy support, changed quaternion to rotationQuaternion
  28085. */
  28086. set quaternion(q: Nullable<Quaternion>);
  28087. /**
  28088. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28089. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28090. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28091. * @returns true if it intersects
  28092. */
  28093. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28094. /**
  28095. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28096. * A particle is in the frustum if its bounding box intersects the frustum
  28097. * @param frustumPlanes defines the frustum to test
  28098. * @returns true if the particle is in the frustum planes
  28099. */
  28100. isInFrustum(frustumPlanes: Plane[]): boolean;
  28101. /**
  28102. * get the rotation matrix of the particle
  28103. * @hidden
  28104. */
  28105. getRotationMatrix(m: Matrix): void;
  28106. }
  28107. /**
  28108. * Represents the shape of the model used by one particle of a solid particle system.
  28109. * SPS internal tool, don't use it manually.
  28110. */
  28111. export class ModelShape {
  28112. /**
  28113. * The shape id
  28114. * @hidden
  28115. */
  28116. shapeID: number;
  28117. /**
  28118. * flat array of model positions (internal use)
  28119. * @hidden
  28120. */
  28121. _shape: Vector3[];
  28122. /**
  28123. * flat array of model UVs (internal use)
  28124. * @hidden
  28125. */
  28126. _shapeUV: number[];
  28127. /**
  28128. * color array of the model
  28129. * @hidden
  28130. */
  28131. _shapeColors: number[];
  28132. /**
  28133. * indices array of the model
  28134. * @hidden
  28135. */
  28136. _indices: number[];
  28137. /**
  28138. * normals array of the model
  28139. * @hidden
  28140. */
  28141. _normals: number[];
  28142. /**
  28143. * length of the shape in the model indices array (internal use)
  28144. * @hidden
  28145. */
  28146. _indicesLength: number;
  28147. /**
  28148. * Custom position function (internal use)
  28149. * @hidden
  28150. */
  28151. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28152. /**
  28153. * Custom vertex function (internal use)
  28154. * @hidden
  28155. */
  28156. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28157. /**
  28158. * Model material (internal use)
  28159. * @hidden
  28160. */
  28161. _material: Nullable<Material>;
  28162. /**
  28163. * 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.
  28164. * SPS internal tool, don't use it manually.
  28165. * @hidden
  28166. */
  28167. 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>, material: Nullable<Material>);
  28168. }
  28169. /**
  28170. * Represents a Depth Sorted Particle in the solid particle system.
  28171. * @hidden
  28172. */
  28173. export class DepthSortedParticle {
  28174. /**
  28175. * Particle index
  28176. */
  28177. idx: number;
  28178. /**
  28179. * Index of the particle in the "indices" array
  28180. */
  28181. ind: number;
  28182. /**
  28183. * Length of the particle shape in the "indices" array
  28184. */
  28185. indicesLength: number;
  28186. /**
  28187. * Squared distance from the particle to the camera
  28188. */
  28189. sqDistance: number;
  28190. /**
  28191. * Material index when used with MultiMaterials
  28192. */
  28193. materialIndex: number;
  28194. /**
  28195. * Creates a new sorted particle
  28196. * @param materialIndex
  28197. */
  28198. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28199. }
  28200. }
  28201. declare module BABYLON {
  28202. /**
  28203. * @hidden
  28204. */
  28205. export class _MeshCollisionData {
  28206. _checkCollisions: boolean;
  28207. _collisionMask: number;
  28208. _collisionGroup: number;
  28209. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28210. _collider: Nullable<Collider>;
  28211. _oldPositionForCollisions: Vector3;
  28212. _diffPositionForCollisions: Vector3;
  28213. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28214. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28215. }
  28216. }
  28217. declare module BABYLON {
  28218. /** @hidden */
  28219. class _FacetDataStorage {
  28220. facetPositions: Vector3[];
  28221. facetNormals: Vector3[];
  28222. facetPartitioning: number[][];
  28223. facetNb: number;
  28224. partitioningSubdivisions: number;
  28225. partitioningBBoxRatio: number;
  28226. facetDataEnabled: boolean;
  28227. facetParameters: any;
  28228. bbSize: Vector3;
  28229. subDiv: {
  28230. max: number;
  28231. X: number;
  28232. Y: number;
  28233. Z: number;
  28234. };
  28235. facetDepthSort: boolean;
  28236. facetDepthSortEnabled: boolean;
  28237. depthSortedIndices: IndicesArray;
  28238. depthSortedFacets: {
  28239. ind: number;
  28240. sqDistance: number;
  28241. }[];
  28242. facetDepthSortFunction: (f1: {
  28243. ind: number;
  28244. sqDistance: number;
  28245. }, f2: {
  28246. ind: number;
  28247. sqDistance: number;
  28248. }) => number;
  28249. facetDepthSortFrom: Vector3;
  28250. facetDepthSortOrigin: Vector3;
  28251. invertedMatrix: Matrix;
  28252. }
  28253. /**
  28254. * @hidden
  28255. **/
  28256. class _InternalAbstractMeshDataInfo {
  28257. _hasVertexAlpha: boolean;
  28258. _useVertexColors: boolean;
  28259. _numBoneInfluencers: number;
  28260. _applyFog: boolean;
  28261. _receiveShadows: boolean;
  28262. _facetData: _FacetDataStorage;
  28263. _visibility: number;
  28264. _skeleton: Nullable<Skeleton>;
  28265. _layerMask: number;
  28266. _computeBonesUsingShaders: boolean;
  28267. _isActive: boolean;
  28268. _onlyForInstances: boolean;
  28269. _isActiveIntermediate: boolean;
  28270. _onlyForInstancesIntermediate: boolean;
  28271. _actAsRegularMesh: boolean;
  28272. }
  28273. /**
  28274. * Class used to store all common mesh properties
  28275. */
  28276. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28277. /** No occlusion */
  28278. static OCCLUSION_TYPE_NONE: number;
  28279. /** Occlusion set to optimisitic */
  28280. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28281. /** Occlusion set to strict */
  28282. static OCCLUSION_TYPE_STRICT: number;
  28283. /** Use an accurante occlusion algorithm */
  28284. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28285. /** Use a conservative occlusion algorithm */
  28286. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28287. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28288. * Test order :
  28289. * Is the bounding sphere outside the frustum ?
  28290. * If not, are the bounding box vertices outside the frustum ?
  28291. * It not, then the cullable object is in the frustum.
  28292. */
  28293. static readonly CULLINGSTRATEGY_STANDARD: number;
  28294. /** Culling strategy : Bounding Sphere Only.
  28295. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28296. * It's also less accurate than the standard because some not visible objects can still be selected.
  28297. * Test : is the bounding sphere outside the frustum ?
  28298. * If not, then the cullable object is in the frustum.
  28299. */
  28300. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28301. /** Culling strategy : Optimistic Inclusion.
  28302. * This in an inclusion test first, then the standard exclusion test.
  28303. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28304. * 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.
  28305. * Anyway, it's as accurate as the standard strategy.
  28306. * Test :
  28307. * Is the cullable object bounding sphere center in the frustum ?
  28308. * If not, apply the default culling strategy.
  28309. */
  28310. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28311. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28312. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28313. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28314. * 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.
  28315. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28316. * Test :
  28317. * Is the cullable object bounding sphere center in the frustum ?
  28318. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28319. */
  28320. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28321. /**
  28322. * No billboard
  28323. */
  28324. static get BILLBOARDMODE_NONE(): number;
  28325. /** Billboard on X axis */
  28326. static get BILLBOARDMODE_X(): number;
  28327. /** Billboard on Y axis */
  28328. static get BILLBOARDMODE_Y(): number;
  28329. /** Billboard on Z axis */
  28330. static get BILLBOARDMODE_Z(): number;
  28331. /** Billboard on all axes */
  28332. static get BILLBOARDMODE_ALL(): number;
  28333. /** Billboard on using position instead of orientation */
  28334. static get BILLBOARDMODE_USE_POSITION(): number;
  28335. /** @hidden */
  28336. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28337. /**
  28338. * The culling strategy to use to check whether the mesh must be rendered or not.
  28339. * This value can be changed at any time and will be used on the next render mesh selection.
  28340. * The possible values are :
  28341. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28342. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28343. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28344. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28345. * Please read each static variable documentation to get details about the culling process.
  28346. * */
  28347. cullingStrategy: number;
  28348. /**
  28349. * Gets the number of facets in the mesh
  28350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28351. */
  28352. get facetNb(): number;
  28353. /**
  28354. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28356. */
  28357. get partitioningSubdivisions(): number;
  28358. set partitioningSubdivisions(nb: number);
  28359. /**
  28360. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28361. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28363. */
  28364. get partitioningBBoxRatio(): number;
  28365. set partitioningBBoxRatio(ratio: number);
  28366. /**
  28367. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28368. * Works only for updatable meshes.
  28369. * Doesn't work with multi-materials
  28370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28371. */
  28372. get mustDepthSortFacets(): boolean;
  28373. set mustDepthSortFacets(sort: boolean);
  28374. /**
  28375. * The location (Vector3) where the facet depth sort must be computed from.
  28376. * By default, the active camera position.
  28377. * Used only when facet depth sort is enabled
  28378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28379. */
  28380. get facetDepthSortFrom(): Vector3;
  28381. set facetDepthSortFrom(location: Vector3);
  28382. /**
  28383. * gets a boolean indicating if facetData is enabled
  28384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28385. */
  28386. get isFacetDataEnabled(): boolean;
  28387. /** @hidden */
  28388. _updateNonUniformScalingState(value: boolean): boolean;
  28389. /**
  28390. * An event triggered when this mesh collides with another one
  28391. */
  28392. onCollideObservable: Observable<AbstractMesh>;
  28393. /** Set a function to call when this mesh collides with another one */
  28394. set onCollide(callback: () => void);
  28395. /**
  28396. * An event triggered when the collision's position changes
  28397. */
  28398. onCollisionPositionChangeObservable: Observable<Vector3>;
  28399. /** Set a function to call when the collision's position changes */
  28400. set onCollisionPositionChange(callback: () => void);
  28401. /**
  28402. * An event triggered when material is changed
  28403. */
  28404. onMaterialChangedObservable: Observable<AbstractMesh>;
  28405. /**
  28406. * Gets or sets the orientation for POV movement & rotation
  28407. */
  28408. definedFacingForward: boolean;
  28409. /** @hidden */
  28410. _occlusionQuery: Nullable<WebGLQuery>;
  28411. /** @hidden */
  28412. _renderingGroup: Nullable<RenderingGroup>;
  28413. /**
  28414. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28415. */
  28416. get visibility(): number;
  28417. /**
  28418. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28419. */
  28420. set visibility(value: number);
  28421. /** Gets or sets the alpha index used to sort transparent meshes
  28422. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28423. */
  28424. alphaIndex: number;
  28425. /**
  28426. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28427. */
  28428. isVisible: boolean;
  28429. /**
  28430. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28431. */
  28432. isPickable: boolean;
  28433. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28434. showSubMeshesBoundingBox: boolean;
  28435. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28436. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28437. */
  28438. isBlocker: boolean;
  28439. /**
  28440. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28441. */
  28442. enablePointerMoveEvents: boolean;
  28443. /**
  28444. * Specifies the rendering group id for this mesh (0 by default)
  28445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28446. */
  28447. renderingGroupId: number;
  28448. private _material;
  28449. /** Gets or sets current material */
  28450. get material(): Nullable<Material>;
  28451. set material(value: Nullable<Material>);
  28452. /**
  28453. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28454. * @see http://doc.babylonjs.com/babylon101/shadows
  28455. */
  28456. get receiveShadows(): boolean;
  28457. set receiveShadows(value: boolean);
  28458. /** Defines color to use when rendering outline */
  28459. outlineColor: Color3;
  28460. /** Define width to use when rendering outline */
  28461. outlineWidth: number;
  28462. /** Defines color to use when rendering overlay */
  28463. overlayColor: Color3;
  28464. /** Defines alpha to use when rendering overlay */
  28465. overlayAlpha: number;
  28466. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28467. get hasVertexAlpha(): boolean;
  28468. set hasVertexAlpha(value: boolean);
  28469. /** 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) */
  28470. get useVertexColors(): boolean;
  28471. set useVertexColors(value: boolean);
  28472. /**
  28473. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28474. */
  28475. get computeBonesUsingShaders(): boolean;
  28476. set computeBonesUsingShaders(value: boolean);
  28477. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28478. get numBoneInfluencers(): number;
  28479. set numBoneInfluencers(value: number);
  28480. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28481. get applyFog(): boolean;
  28482. set applyFog(value: boolean);
  28483. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28484. useOctreeForRenderingSelection: boolean;
  28485. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28486. useOctreeForPicking: boolean;
  28487. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28488. useOctreeForCollisions: boolean;
  28489. /**
  28490. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28491. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28492. */
  28493. get layerMask(): number;
  28494. set layerMask(value: number);
  28495. /**
  28496. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28497. */
  28498. alwaysSelectAsActiveMesh: boolean;
  28499. /**
  28500. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28501. */
  28502. doNotSyncBoundingInfo: boolean;
  28503. /**
  28504. * Gets or sets the current action manager
  28505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28506. */
  28507. actionManager: Nullable<AbstractActionManager>;
  28508. private _meshCollisionData;
  28509. /**
  28510. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28512. */
  28513. ellipsoid: Vector3;
  28514. /**
  28515. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28517. */
  28518. ellipsoidOffset: Vector3;
  28519. /**
  28520. * Gets or sets a collision mask used to mask collisions (default is -1).
  28521. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28522. */
  28523. get collisionMask(): number;
  28524. set collisionMask(mask: number);
  28525. /**
  28526. * Gets or sets the current collision group mask (-1 by default).
  28527. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28528. */
  28529. get collisionGroup(): number;
  28530. set collisionGroup(mask: number);
  28531. /**
  28532. * Gets or sets current surrounding meshes (null by default).
  28533. *
  28534. * By default collision detection is tested against every mesh in the scene.
  28535. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28536. * meshes will be tested for the collision.
  28537. *
  28538. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28539. */
  28540. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28541. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28542. /**
  28543. * Defines edge width used when edgesRenderer is enabled
  28544. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28545. */
  28546. edgesWidth: number;
  28547. /**
  28548. * Defines edge color used when edgesRenderer is enabled
  28549. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28550. */
  28551. edgesColor: Color4;
  28552. /** @hidden */
  28553. _edgesRenderer: Nullable<IEdgesRenderer>;
  28554. /** @hidden */
  28555. _masterMesh: Nullable<AbstractMesh>;
  28556. /** @hidden */
  28557. _boundingInfo: Nullable<BoundingInfo>;
  28558. /** @hidden */
  28559. _renderId: number;
  28560. /**
  28561. * Gets or sets the list of subMeshes
  28562. * @see http://doc.babylonjs.com/how_to/multi_materials
  28563. */
  28564. subMeshes: SubMesh[];
  28565. /** @hidden */
  28566. _intersectionsInProgress: AbstractMesh[];
  28567. /** @hidden */
  28568. _unIndexed: boolean;
  28569. /** @hidden */
  28570. _lightSources: Light[];
  28571. /** Gets the list of lights affecting that mesh */
  28572. get lightSources(): Light[];
  28573. /** @hidden */
  28574. get _positions(): Nullable<Vector3[]>;
  28575. /** @hidden */
  28576. _waitingData: {
  28577. lods: Nullable<any>;
  28578. actions: Nullable<any>;
  28579. freezeWorldMatrix: Nullable<boolean>;
  28580. };
  28581. /** @hidden */
  28582. _bonesTransformMatrices: Nullable<Float32Array>;
  28583. /** @hidden */
  28584. _transformMatrixTexture: Nullable<RawTexture>;
  28585. /**
  28586. * Gets or sets a skeleton to apply skining transformations
  28587. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28588. */
  28589. set skeleton(value: Nullable<Skeleton>);
  28590. get skeleton(): Nullable<Skeleton>;
  28591. /**
  28592. * An event triggered when the mesh is rebuilt.
  28593. */
  28594. onRebuildObservable: Observable<AbstractMesh>;
  28595. /**
  28596. * Creates a new AbstractMesh
  28597. * @param name defines the name of the mesh
  28598. * @param scene defines the hosting scene
  28599. */
  28600. constructor(name: string, scene?: Nullable<Scene>);
  28601. /**
  28602. * Returns the string "AbstractMesh"
  28603. * @returns "AbstractMesh"
  28604. */
  28605. getClassName(): string;
  28606. /**
  28607. * Gets a string representation of the current mesh
  28608. * @param fullDetails defines a boolean indicating if full details must be included
  28609. * @returns a string representation of the current mesh
  28610. */
  28611. toString(fullDetails?: boolean): string;
  28612. /**
  28613. * @hidden
  28614. */
  28615. protected _getEffectiveParent(): Nullable<Node>;
  28616. /** @hidden */
  28617. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28618. /** @hidden */
  28619. _rebuild(): void;
  28620. /** @hidden */
  28621. _resyncLightSources(): void;
  28622. /** @hidden */
  28623. _resyncLightSource(light: Light): void;
  28624. /** @hidden */
  28625. _unBindEffect(): void;
  28626. /** @hidden */
  28627. _removeLightSource(light: Light, dispose: boolean): void;
  28628. private _markSubMeshesAsDirty;
  28629. /** @hidden */
  28630. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28631. /** @hidden */
  28632. _markSubMeshesAsAttributesDirty(): void;
  28633. /** @hidden */
  28634. _markSubMeshesAsMiscDirty(): void;
  28635. /**
  28636. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28637. */
  28638. get scaling(): Vector3;
  28639. set scaling(newScaling: Vector3);
  28640. /**
  28641. * Returns true if the mesh is blocked. Implemented by child classes
  28642. */
  28643. get isBlocked(): boolean;
  28644. /**
  28645. * Returns the mesh itself by default. Implemented by child classes
  28646. * @param camera defines the camera to use to pick the right LOD level
  28647. * @returns the currentAbstractMesh
  28648. */
  28649. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28650. /**
  28651. * Returns 0 by default. Implemented by child classes
  28652. * @returns an integer
  28653. */
  28654. getTotalVertices(): number;
  28655. /**
  28656. * Returns a positive integer : the total number of indices in this mesh geometry.
  28657. * @returns the numner of indices or zero if the mesh has no geometry.
  28658. */
  28659. getTotalIndices(): number;
  28660. /**
  28661. * Returns null by default. Implemented by child classes
  28662. * @returns null
  28663. */
  28664. getIndices(): Nullable<IndicesArray>;
  28665. /**
  28666. * Returns the array of the requested vertex data kind. Implemented by child classes
  28667. * @param kind defines the vertex data kind to use
  28668. * @returns null
  28669. */
  28670. getVerticesData(kind: string): Nullable<FloatArray>;
  28671. /**
  28672. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28673. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28674. * Note that a new underlying VertexBuffer object is created each call.
  28675. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28676. * @param kind defines vertex data kind:
  28677. * * VertexBuffer.PositionKind
  28678. * * VertexBuffer.UVKind
  28679. * * VertexBuffer.UV2Kind
  28680. * * VertexBuffer.UV3Kind
  28681. * * VertexBuffer.UV4Kind
  28682. * * VertexBuffer.UV5Kind
  28683. * * VertexBuffer.UV6Kind
  28684. * * VertexBuffer.ColorKind
  28685. * * VertexBuffer.MatricesIndicesKind
  28686. * * VertexBuffer.MatricesIndicesExtraKind
  28687. * * VertexBuffer.MatricesWeightsKind
  28688. * * VertexBuffer.MatricesWeightsExtraKind
  28689. * @param data defines the data source
  28690. * @param updatable defines if the data must be flagged as updatable (or static)
  28691. * @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
  28692. * @returns the current mesh
  28693. */
  28694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28695. /**
  28696. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28697. * If the mesh has no geometry, it is simply returned as it is.
  28698. * @param kind defines vertex data kind:
  28699. * * VertexBuffer.PositionKind
  28700. * * VertexBuffer.UVKind
  28701. * * VertexBuffer.UV2Kind
  28702. * * VertexBuffer.UV3Kind
  28703. * * VertexBuffer.UV4Kind
  28704. * * VertexBuffer.UV5Kind
  28705. * * VertexBuffer.UV6Kind
  28706. * * VertexBuffer.ColorKind
  28707. * * VertexBuffer.MatricesIndicesKind
  28708. * * VertexBuffer.MatricesIndicesExtraKind
  28709. * * VertexBuffer.MatricesWeightsKind
  28710. * * VertexBuffer.MatricesWeightsExtraKind
  28711. * @param data defines the data source
  28712. * @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
  28713. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28714. * @returns the current mesh
  28715. */
  28716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28717. /**
  28718. * Sets the mesh indices,
  28719. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28720. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28721. * @param totalVertices Defines the total number of vertices
  28722. * @returns the current mesh
  28723. */
  28724. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28725. /**
  28726. * Gets a boolean indicating if specific vertex data is present
  28727. * @param kind defines the vertex data kind to use
  28728. * @returns true is data kind is present
  28729. */
  28730. isVerticesDataPresent(kind: string): boolean;
  28731. /**
  28732. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28733. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28734. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28735. * @returns a BoundingInfo
  28736. */
  28737. getBoundingInfo(): BoundingInfo;
  28738. /**
  28739. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28740. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28741. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28742. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28743. * @returns the current mesh
  28744. */
  28745. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28746. /**
  28747. * Overwrite the current bounding info
  28748. * @param boundingInfo defines the new bounding info
  28749. * @returns the current mesh
  28750. */
  28751. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28752. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28753. get useBones(): boolean;
  28754. /** @hidden */
  28755. _preActivate(): void;
  28756. /** @hidden */
  28757. _preActivateForIntermediateRendering(renderId: number): void;
  28758. /** @hidden */
  28759. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28760. /** @hidden */
  28761. _postActivate(): void;
  28762. /** @hidden */
  28763. _freeze(): void;
  28764. /** @hidden */
  28765. _unFreeze(): void;
  28766. /**
  28767. * Gets the current world matrix
  28768. * @returns a Matrix
  28769. */
  28770. getWorldMatrix(): Matrix;
  28771. /** @hidden */
  28772. _getWorldMatrixDeterminant(): number;
  28773. /**
  28774. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28775. */
  28776. get isAnInstance(): boolean;
  28777. /**
  28778. * Gets a boolean indicating if this mesh has instances
  28779. */
  28780. get hasInstances(): boolean;
  28781. /**
  28782. * Perform relative position change from the point of view of behind the front of the mesh.
  28783. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28784. * Supports definition of mesh facing forward or backward
  28785. * @param amountRight defines the distance on the right axis
  28786. * @param amountUp defines the distance on the up axis
  28787. * @param amountForward defines the distance on the forward axis
  28788. * @returns the current mesh
  28789. */
  28790. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28791. /**
  28792. * Calculate relative position change from the point of view of behind the front of the mesh.
  28793. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28794. * Supports definition of mesh facing forward or backward
  28795. * @param amountRight defines the distance on the right axis
  28796. * @param amountUp defines the distance on the up axis
  28797. * @param amountForward defines the distance on the forward axis
  28798. * @returns the new displacement vector
  28799. */
  28800. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28801. /**
  28802. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28803. * Supports definition of mesh facing forward or backward
  28804. * @param flipBack defines the flip
  28805. * @param twirlClockwise defines the twirl
  28806. * @param tiltRight defines the tilt
  28807. * @returns the current mesh
  28808. */
  28809. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28810. /**
  28811. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28812. * Supports definition of mesh facing forward or backward.
  28813. * @param flipBack defines the flip
  28814. * @param twirlClockwise defines the twirl
  28815. * @param tiltRight defines the tilt
  28816. * @returns the new rotation vector
  28817. */
  28818. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28819. /**
  28820. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28821. * This means the mesh underlying bounding box and sphere are recomputed.
  28822. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28823. * @returns the current mesh
  28824. */
  28825. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28826. /** @hidden */
  28827. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28828. /** @hidden */
  28829. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28830. /** @hidden */
  28831. _updateBoundingInfo(): AbstractMesh;
  28832. /** @hidden */
  28833. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28834. /** @hidden */
  28835. protected _afterComputeWorldMatrix(): void;
  28836. /** @hidden */
  28837. get _effectiveMesh(): AbstractMesh;
  28838. /**
  28839. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28840. * A mesh is in the frustum if its bounding box intersects the frustum
  28841. * @param frustumPlanes defines the frustum to test
  28842. * @returns true if the mesh is in the frustum planes
  28843. */
  28844. isInFrustum(frustumPlanes: Plane[]): boolean;
  28845. /**
  28846. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28847. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28848. * @param frustumPlanes defines the frustum to test
  28849. * @returns true if the mesh is completely in the frustum planes
  28850. */
  28851. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28852. /**
  28853. * True if the mesh intersects another mesh or a SolidParticle object
  28854. * @param mesh defines a target mesh or SolidParticle to test
  28855. * @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)
  28856. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28857. * @returns true if there is an intersection
  28858. */
  28859. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28860. /**
  28861. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28862. * @param point defines the point to test
  28863. * @returns true if there is an intersection
  28864. */
  28865. intersectsPoint(point: Vector3): boolean;
  28866. /**
  28867. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28869. */
  28870. get checkCollisions(): boolean;
  28871. set checkCollisions(collisionEnabled: boolean);
  28872. /**
  28873. * Gets Collider object used to compute collisions (not physics)
  28874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28875. */
  28876. get collider(): Nullable<Collider>;
  28877. /**
  28878. * Move the mesh using collision engine
  28879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28880. * @param displacement defines the requested displacement vector
  28881. * @returns the current mesh
  28882. */
  28883. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28884. private _onCollisionPositionChange;
  28885. /** @hidden */
  28886. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28887. /** @hidden */
  28888. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28889. /** @hidden */
  28890. _checkCollision(collider: Collider): AbstractMesh;
  28891. /** @hidden */
  28892. _generatePointsArray(): boolean;
  28893. /**
  28894. * Checks if the passed Ray intersects with the mesh
  28895. * @param ray defines the ray to use
  28896. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28898. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28899. * @returns the picking info
  28900. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28901. */
  28902. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28903. /**
  28904. * Clones the current mesh
  28905. * @param name defines the mesh name
  28906. * @param newParent defines the new mesh parent
  28907. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28908. * @returns the new mesh
  28909. */
  28910. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28911. /**
  28912. * Disposes all the submeshes of the current meshnp
  28913. * @returns the current mesh
  28914. */
  28915. releaseSubMeshes(): AbstractMesh;
  28916. /**
  28917. * Releases resources associated with this abstract mesh.
  28918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28920. */
  28921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28922. /**
  28923. * Adds the passed mesh as a child to the current mesh
  28924. * @param mesh defines the child mesh
  28925. * @returns the current mesh
  28926. */
  28927. addChild(mesh: AbstractMesh): AbstractMesh;
  28928. /**
  28929. * Removes the passed mesh from the current mesh children list
  28930. * @param mesh defines the child mesh
  28931. * @returns the current mesh
  28932. */
  28933. removeChild(mesh: AbstractMesh): AbstractMesh;
  28934. /** @hidden */
  28935. private _initFacetData;
  28936. /**
  28937. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28938. * This method can be called within the render loop.
  28939. * 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
  28940. * @returns the current mesh
  28941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28942. */
  28943. updateFacetData(): AbstractMesh;
  28944. /**
  28945. * Returns the facetLocalNormals array.
  28946. * The normals are expressed in the mesh local spac
  28947. * @returns an array of Vector3
  28948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28949. */
  28950. getFacetLocalNormals(): Vector3[];
  28951. /**
  28952. * Returns the facetLocalPositions array.
  28953. * The facet positions are expressed in the mesh local space
  28954. * @returns an array of Vector3
  28955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28956. */
  28957. getFacetLocalPositions(): Vector3[];
  28958. /**
  28959. * Returns the facetLocalPartioning array
  28960. * @returns an array of array of numbers
  28961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28962. */
  28963. getFacetLocalPartitioning(): number[][];
  28964. /**
  28965. * Returns the i-th facet position in the world system.
  28966. * This method allocates a new Vector3 per call
  28967. * @param i defines the facet index
  28968. * @returns a new Vector3
  28969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28970. */
  28971. getFacetPosition(i: number): Vector3;
  28972. /**
  28973. * Sets the reference Vector3 with the i-th facet position in the world system
  28974. * @param i defines the facet index
  28975. * @param ref defines the target vector
  28976. * @returns the current mesh
  28977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28978. */
  28979. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28980. /**
  28981. * Returns the i-th facet normal in the world system.
  28982. * This method allocates a new Vector3 per call
  28983. * @param i defines the facet index
  28984. * @returns a new Vector3
  28985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28986. */
  28987. getFacetNormal(i: number): Vector3;
  28988. /**
  28989. * Sets the reference Vector3 with the i-th facet normal in the world system
  28990. * @param i defines the facet index
  28991. * @param ref defines the target vector
  28992. * @returns the current mesh
  28993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28994. */
  28995. getFacetNormalToRef(i: number, ref: Vector3): this;
  28996. /**
  28997. * 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)
  28998. * @param x defines x coordinate
  28999. * @param y defines y coordinate
  29000. * @param z defines z coordinate
  29001. * @returns the array of facet indexes
  29002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29003. */
  29004. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29005. /**
  29006. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29007. * @param projected sets as the (x,y,z) world projection on the facet
  29008. * @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
  29009. * @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
  29010. * @param x defines x coordinate
  29011. * @param y defines y coordinate
  29012. * @param z defines z coordinate
  29013. * @returns the face index if found (or null instead)
  29014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29015. */
  29016. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29017. /**
  29018. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29019. * @param projected sets as the (x,y,z) local projection on the facet
  29020. * @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
  29021. * @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
  29022. * @param x defines x coordinate
  29023. * @param y defines y coordinate
  29024. * @param z defines z coordinate
  29025. * @returns the face index if found (or null instead)
  29026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29027. */
  29028. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29029. /**
  29030. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29031. * @returns the parameters
  29032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29033. */
  29034. getFacetDataParameters(): any;
  29035. /**
  29036. * Disables the feature FacetData and frees the related memory
  29037. * @returns the current mesh
  29038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29039. */
  29040. disableFacetData(): AbstractMesh;
  29041. /**
  29042. * Updates the AbstractMesh indices array
  29043. * @param indices defines the data source
  29044. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29045. * @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)
  29046. * @returns the current mesh
  29047. */
  29048. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29049. /**
  29050. * Creates new normals data for the mesh
  29051. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29052. * @returns the current mesh
  29053. */
  29054. createNormals(updatable: boolean): AbstractMesh;
  29055. /**
  29056. * Align the mesh with a normal
  29057. * @param normal defines the normal to use
  29058. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29059. * @returns the current mesh
  29060. */
  29061. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29062. /** @hidden */
  29063. _checkOcclusionQuery(): boolean;
  29064. /**
  29065. * Disables the mesh edge rendering mode
  29066. * @returns the currentAbstractMesh
  29067. */
  29068. disableEdgesRendering(): AbstractMesh;
  29069. /**
  29070. * Enables the edge rendering mode on the mesh.
  29071. * This mode makes the mesh edges visible
  29072. * @param epsilon defines the maximal distance between two angles to detect a face
  29073. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29074. * @returns the currentAbstractMesh
  29075. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29076. */
  29077. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29078. }
  29079. }
  29080. declare module BABYLON {
  29081. /**
  29082. * Interface used to define ActionEvent
  29083. */
  29084. export interface IActionEvent {
  29085. /** The mesh or sprite that triggered the action */
  29086. source: any;
  29087. /** The X mouse cursor position at the time of the event */
  29088. pointerX: number;
  29089. /** The Y mouse cursor position at the time of the event */
  29090. pointerY: number;
  29091. /** The mesh that is currently pointed at (can be null) */
  29092. meshUnderPointer: Nullable<AbstractMesh>;
  29093. /** the original (browser) event that triggered the ActionEvent */
  29094. sourceEvent?: any;
  29095. /** additional data for the event */
  29096. additionalData?: any;
  29097. }
  29098. /**
  29099. * ActionEvent is the event being sent when an action is triggered.
  29100. */
  29101. export class ActionEvent implements IActionEvent {
  29102. /** The mesh or sprite that triggered the action */
  29103. source: any;
  29104. /** The X mouse cursor position at the time of the event */
  29105. pointerX: number;
  29106. /** The Y mouse cursor position at the time of the event */
  29107. pointerY: number;
  29108. /** The mesh that is currently pointed at (can be null) */
  29109. meshUnderPointer: Nullable<AbstractMesh>;
  29110. /** the original (browser) event that triggered the ActionEvent */
  29111. sourceEvent?: any;
  29112. /** additional data for the event */
  29113. additionalData?: any;
  29114. /**
  29115. * Creates a new ActionEvent
  29116. * @param source The mesh or sprite that triggered the action
  29117. * @param pointerX The X mouse cursor position at the time of the event
  29118. * @param pointerY The Y mouse cursor position at the time of the event
  29119. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29120. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29121. * @param additionalData additional data for the event
  29122. */
  29123. constructor(
  29124. /** The mesh or sprite that triggered the action */
  29125. source: any,
  29126. /** The X mouse cursor position at the time of the event */
  29127. pointerX: number,
  29128. /** The Y mouse cursor position at the time of the event */
  29129. pointerY: number,
  29130. /** The mesh that is currently pointed at (can be null) */
  29131. meshUnderPointer: Nullable<AbstractMesh>,
  29132. /** the original (browser) event that triggered the ActionEvent */
  29133. sourceEvent?: any,
  29134. /** additional data for the event */
  29135. additionalData?: any);
  29136. /**
  29137. * Helper function to auto-create an ActionEvent from a source mesh.
  29138. * @param source The source mesh that triggered the event
  29139. * @param evt The original (browser) event
  29140. * @param additionalData additional data for the event
  29141. * @returns the new ActionEvent
  29142. */
  29143. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29144. /**
  29145. * Helper function to auto-create an ActionEvent from a source sprite
  29146. * @param source The source sprite that triggered the event
  29147. * @param scene Scene associated with the sprite
  29148. * @param evt The original (browser) event
  29149. * @param additionalData additional data for the event
  29150. * @returns the new ActionEvent
  29151. */
  29152. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29153. /**
  29154. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29155. * @param scene the scene where the event occurred
  29156. * @param evt The original (browser) event
  29157. * @returns the new ActionEvent
  29158. */
  29159. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29160. /**
  29161. * Helper function to auto-create an ActionEvent from a primitive
  29162. * @param prim defines the target primitive
  29163. * @param pointerPos defines the pointer position
  29164. * @param evt The original (browser) event
  29165. * @param additionalData additional data for the event
  29166. * @returns the new ActionEvent
  29167. */
  29168. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29169. }
  29170. }
  29171. declare module BABYLON {
  29172. /**
  29173. * Abstract class used to decouple action Manager from scene and meshes.
  29174. * Do not instantiate.
  29175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29176. */
  29177. export abstract class AbstractActionManager implements IDisposable {
  29178. /** Gets the list of active triggers */
  29179. static Triggers: {
  29180. [key: string]: number;
  29181. };
  29182. /** Gets the cursor to use when hovering items */
  29183. hoverCursor: string;
  29184. /** Gets the list of actions */
  29185. actions: IAction[];
  29186. /**
  29187. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29188. */
  29189. isRecursive: boolean;
  29190. /**
  29191. * Releases all associated resources
  29192. */
  29193. abstract dispose(): void;
  29194. /**
  29195. * Does this action manager has pointer triggers
  29196. */
  29197. abstract get hasPointerTriggers(): boolean;
  29198. /**
  29199. * Does this action manager has pick triggers
  29200. */
  29201. abstract get hasPickTriggers(): boolean;
  29202. /**
  29203. * Process a specific trigger
  29204. * @param trigger defines the trigger to process
  29205. * @param evt defines the event details to be processed
  29206. */
  29207. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29208. /**
  29209. * Does this action manager handles actions of any of the given triggers
  29210. * @param triggers defines the triggers to be tested
  29211. * @return a boolean indicating whether one (or more) of the triggers is handled
  29212. */
  29213. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29214. /**
  29215. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29216. * speed.
  29217. * @param triggerA defines the trigger to be tested
  29218. * @param triggerB defines the trigger to be tested
  29219. * @return a boolean indicating whether one (or more) of the triggers is handled
  29220. */
  29221. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29222. /**
  29223. * Does this action manager handles actions of a given trigger
  29224. * @param trigger defines the trigger to be tested
  29225. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29226. * @return whether the trigger is handled
  29227. */
  29228. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29229. /**
  29230. * Serialize this manager to a JSON object
  29231. * @param name defines the property name to store this manager
  29232. * @returns a JSON representation of this manager
  29233. */
  29234. abstract serialize(name: string): any;
  29235. /**
  29236. * Registers an action to this action manager
  29237. * @param action defines the action to be registered
  29238. * @return the action amended (prepared) after registration
  29239. */
  29240. abstract registerAction(action: IAction): Nullable<IAction>;
  29241. /**
  29242. * Unregisters an action to this action manager
  29243. * @param action defines the action to be unregistered
  29244. * @return a boolean indicating whether the action has been unregistered
  29245. */
  29246. abstract unregisterAction(action: IAction): Boolean;
  29247. /**
  29248. * Does exist one action manager with at least one trigger
  29249. **/
  29250. static get HasTriggers(): boolean;
  29251. /**
  29252. * Does exist one action manager with at least one pick trigger
  29253. **/
  29254. static get HasPickTriggers(): boolean;
  29255. /**
  29256. * Does exist one action manager that handles actions of a given trigger
  29257. * @param trigger defines the trigger to be tested
  29258. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29259. **/
  29260. static HasSpecificTrigger(trigger: number): boolean;
  29261. }
  29262. }
  29263. declare module BABYLON {
  29264. /**
  29265. * Defines how a node can be built from a string name.
  29266. */
  29267. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29268. /**
  29269. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29270. */
  29271. export class Node implements IBehaviorAware<Node> {
  29272. /** @hidden */
  29273. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29274. private static _NodeConstructors;
  29275. /**
  29276. * Add a new node constructor
  29277. * @param type defines the type name of the node to construct
  29278. * @param constructorFunc defines the constructor function
  29279. */
  29280. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29281. /**
  29282. * Returns a node constructor based on type name
  29283. * @param type defines the type name
  29284. * @param name defines the new node name
  29285. * @param scene defines the hosting scene
  29286. * @param options defines optional options to transmit to constructors
  29287. * @returns the new constructor or null
  29288. */
  29289. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29290. /**
  29291. * Gets or sets the name of the node
  29292. */
  29293. name: string;
  29294. /**
  29295. * Gets or sets the id of the node
  29296. */
  29297. id: string;
  29298. /**
  29299. * Gets or sets the unique id of the node
  29300. */
  29301. uniqueId: number;
  29302. /**
  29303. * Gets or sets a string used to store user defined state for the node
  29304. */
  29305. state: string;
  29306. /**
  29307. * Gets or sets an object used to store user defined information for the node
  29308. */
  29309. metadata: any;
  29310. /**
  29311. * For internal use only. Please do not use.
  29312. */
  29313. reservedDataStore: any;
  29314. /**
  29315. * List of inspectable custom properties (used by the Inspector)
  29316. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29317. */
  29318. inspectableCustomProperties: IInspectable[];
  29319. private _doNotSerialize;
  29320. /**
  29321. * Gets or sets a boolean used to define if the node must be serialized
  29322. */
  29323. get doNotSerialize(): boolean;
  29324. set doNotSerialize(value: boolean);
  29325. /** @hidden */
  29326. _isDisposed: boolean;
  29327. /**
  29328. * Gets a list of Animations associated with the node
  29329. */
  29330. animations: Animation[];
  29331. protected _ranges: {
  29332. [name: string]: Nullable<AnimationRange>;
  29333. };
  29334. /**
  29335. * Callback raised when the node is ready to be used
  29336. */
  29337. onReady: Nullable<(node: Node) => void>;
  29338. private _isEnabled;
  29339. private _isParentEnabled;
  29340. private _isReady;
  29341. /** @hidden */
  29342. _currentRenderId: number;
  29343. private _parentUpdateId;
  29344. /** @hidden */
  29345. _childUpdateId: number;
  29346. /** @hidden */
  29347. _waitingParentId: Nullable<string>;
  29348. /** @hidden */
  29349. _scene: Scene;
  29350. /** @hidden */
  29351. _cache: any;
  29352. private _parentNode;
  29353. private _children;
  29354. /** @hidden */
  29355. _worldMatrix: Matrix;
  29356. /** @hidden */
  29357. _worldMatrixDeterminant: number;
  29358. /** @hidden */
  29359. _worldMatrixDeterminantIsDirty: boolean;
  29360. /** @hidden */
  29361. private _sceneRootNodesIndex;
  29362. /**
  29363. * Gets a boolean indicating if the node has been disposed
  29364. * @returns true if the node was disposed
  29365. */
  29366. isDisposed(): boolean;
  29367. /**
  29368. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29369. * @see https://doc.babylonjs.com/how_to/parenting
  29370. */
  29371. set parent(parent: Nullable<Node>);
  29372. get parent(): Nullable<Node>;
  29373. /** @hidden */
  29374. _addToSceneRootNodes(): void;
  29375. /** @hidden */
  29376. _removeFromSceneRootNodes(): void;
  29377. private _animationPropertiesOverride;
  29378. /**
  29379. * Gets or sets the animation properties override
  29380. */
  29381. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29382. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29383. /**
  29384. * Gets a string idenfifying the name of the class
  29385. * @returns "Node" string
  29386. */
  29387. getClassName(): string;
  29388. /** @hidden */
  29389. readonly _isNode: boolean;
  29390. /**
  29391. * An event triggered when the mesh is disposed
  29392. */
  29393. onDisposeObservable: Observable<Node>;
  29394. private _onDisposeObserver;
  29395. /**
  29396. * Sets a callback that will be raised when the node will be disposed
  29397. */
  29398. set onDispose(callback: () => void);
  29399. /**
  29400. * Creates a new Node
  29401. * @param name the name and id to be given to this node
  29402. * @param scene the scene this node will be added to
  29403. */
  29404. constructor(name: string, scene?: Nullable<Scene>);
  29405. /**
  29406. * Gets the scene of the node
  29407. * @returns a scene
  29408. */
  29409. getScene(): Scene;
  29410. /**
  29411. * Gets the engine of the node
  29412. * @returns a Engine
  29413. */
  29414. getEngine(): Engine;
  29415. private _behaviors;
  29416. /**
  29417. * Attach a behavior to the node
  29418. * @see http://doc.babylonjs.com/features/behaviour
  29419. * @param behavior defines the behavior to attach
  29420. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29421. * @returns the current Node
  29422. */
  29423. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29424. /**
  29425. * Remove an attached behavior
  29426. * @see http://doc.babylonjs.com/features/behaviour
  29427. * @param behavior defines the behavior to attach
  29428. * @returns the current Node
  29429. */
  29430. removeBehavior(behavior: Behavior<Node>): Node;
  29431. /**
  29432. * Gets the list of attached behaviors
  29433. * @see http://doc.babylonjs.com/features/behaviour
  29434. */
  29435. get behaviors(): Behavior<Node>[];
  29436. /**
  29437. * Gets an attached behavior by name
  29438. * @param name defines the name of the behavior to look for
  29439. * @see http://doc.babylonjs.com/features/behaviour
  29440. * @returns null if behavior was not found else the requested behavior
  29441. */
  29442. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29443. /**
  29444. * Returns the latest update of the World matrix
  29445. * @returns a Matrix
  29446. */
  29447. getWorldMatrix(): Matrix;
  29448. /** @hidden */
  29449. _getWorldMatrixDeterminant(): number;
  29450. /**
  29451. * Returns directly the latest state of the mesh World matrix.
  29452. * A Matrix is returned.
  29453. */
  29454. get worldMatrixFromCache(): Matrix;
  29455. /** @hidden */
  29456. _initCache(): void;
  29457. /** @hidden */
  29458. updateCache(force?: boolean): void;
  29459. /** @hidden */
  29460. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29461. /** @hidden */
  29462. _updateCache(ignoreParentClass?: boolean): void;
  29463. /** @hidden */
  29464. _isSynchronized(): boolean;
  29465. /** @hidden */
  29466. _markSyncedWithParent(): void;
  29467. /** @hidden */
  29468. isSynchronizedWithParent(): boolean;
  29469. /** @hidden */
  29470. isSynchronized(): boolean;
  29471. /**
  29472. * Is this node ready to be used/rendered
  29473. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29474. * @return true if the node is ready
  29475. */
  29476. isReady(completeCheck?: boolean): boolean;
  29477. /**
  29478. * Is this node enabled?
  29479. * 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
  29480. * @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
  29481. * @return whether this node (and its parent) is enabled
  29482. */
  29483. isEnabled(checkAncestors?: boolean): boolean;
  29484. /** @hidden */
  29485. protected _syncParentEnabledState(): void;
  29486. /**
  29487. * Set the enabled state of this node
  29488. * @param value defines the new enabled state
  29489. */
  29490. setEnabled(value: boolean): void;
  29491. /**
  29492. * Is this node a descendant of the given node?
  29493. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29494. * @param ancestor defines the parent node to inspect
  29495. * @returns a boolean indicating if this node is a descendant of the given node
  29496. */
  29497. isDescendantOf(ancestor: Node): boolean;
  29498. /** @hidden */
  29499. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29500. /**
  29501. * Will return all nodes that have this node as ascendant
  29502. * @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
  29503. * @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
  29504. * @return all children nodes of all types
  29505. */
  29506. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29507. /**
  29508. * Get all child-meshes of this node
  29509. * @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)
  29510. * @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
  29511. * @returns an array of AbstractMesh
  29512. */
  29513. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29514. /**
  29515. * Get all direct children of this node
  29516. * @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
  29517. * @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)
  29518. * @returns an array of Node
  29519. */
  29520. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29521. /** @hidden */
  29522. _setReady(state: boolean): void;
  29523. /**
  29524. * Get an animation by name
  29525. * @param name defines the name of the animation to look for
  29526. * @returns null if not found else the requested animation
  29527. */
  29528. getAnimationByName(name: string): Nullable<Animation>;
  29529. /**
  29530. * Creates an animation range for this node
  29531. * @param name defines the name of the range
  29532. * @param from defines the starting key
  29533. * @param to defines the end key
  29534. */
  29535. createAnimationRange(name: string, from: number, to: number): void;
  29536. /**
  29537. * Delete a specific animation range
  29538. * @param name defines the name of the range to delete
  29539. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29540. */
  29541. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29542. /**
  29543. * Get an animation range by name
  29544. * @param name defines the name of the animation range to look for
  29545. * @returns null if not found else the requested animation range
  29546. */
  29547. getAnimationRange(name: string): Nullable<AnimationRange>;
  29548. /**
  29549. * Gets the list of all animation ranges defined on this node
  29550. * @returns an array
  29551. */
  29552. getAnimationRanges(): Nullable<AnimationRange>[];
  29553. /**
  29554. * Will start the animation sequence
  29555. * @param name defines the range frames for animation sequence
  29556. * @param loop defines if the animation should loop (false by default)
  29557. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29558. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29559. * @returns the object created for this animation. If range does not exist, it will return null
  29560. */
  29561. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29562. /**
  29563. * Serialize animation ranges into a JSON compatible object
  29564. * @returns serialization object
  29565. */
  29566. serializeAnimationRanges(): any;
  29567. /**
  29568. * Computes the world matrix of the node
  29569. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29570. * @returns the world matrix
  29571. */
  29572. computeWorldMatrix(force?: boolean): Matrix;
  29573. /**
  29574. * Releases resources associated with this node.
  29575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29577. */
  29578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29579. /**
  29580. * Parse animation range data from a serialization object and store them into a given node
  29581. * @param node defines where to store the animation ranges
  29582. * @param parsedNode defines the serialization object to read data from
  29583. * @param scene defines the hosting scene
  29584. */
  29585. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29586. /**
  29587. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29588. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29589. * @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
  29590. * @returns the new bounding vectors
  29591. */
  29592. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29593. min: Vector3;
  29594. max: Vector3;
  29595. };
  29596. }
  29597. }
  29598. declare module BABYLON {
  29599. /**
  29600. * @hidden
  29601. */
  29602. export class _IAnimationState {
  29603. key: number;
  29604. repeatCount: number;
  29605. workValue?: any;
  29606. loopMode?: number;
  29607. offsetValue?: any;
  29608. highLimitValue?: any;
  29609. }
  29610. /**
  29611. * Class used to store any kind of animation
  29612. */
  29613. export class Animation {
  29614. /**Name of the animation */
  29615. name: string;
  29616. /**Property to animate */
  29617. targetProperty: string;
  29618. /**The frames per second of the animation */
  29619. framePerSecond: number;
  29620. /**The data type of the animation */
  29621. dataType: number;
  29622. /**The loop mode of the animation */
  29623. loopMode?: number | undefined;
  29624. /**Specifies if blending should be enabled */
  29625. enableBlending?: boolean | undefined;
  29626. /**
  29627. * Use matrix interpolation instead of using direct key value when animating matrices
  29628. */
  29629. static AllowMatricesInterpolation: boolean;
  29630. /**
  29631. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29632. */
  29633. static AllowMatrixDecomposeForInterpolation: boolean;
  29634. /**
  29635. * Stores the key frames of the animation
  29636. */
  29637. private _keys;
  29638. /**
  29639. * Stores the easing function of the animation
  29640. */
  29641. private _easingFunction;
  29642. /**
  29643. * @hidden Internal use only
  29644. */
  29645. _runtimeAnimations: RuntimeAnimation[];
  29646. /**
  29647. * The set of event that will be linked to this animation
  29648. */
  29649. private _events;
  29650. /**
  29651. * Stores an array of target property paths
  29652. */
  29653. targetPropertyPath: string[];
  29654. /**
  29655. * Stores the blending speed of the animation
  29656. */
  29657. blendingSpeed: number;
  29658. /**
  29659. * Stores the animation ranges for the animation
  29660. */
  29661. private _ranges;
  29662. /**
  29663. * @hidden Internal use
  29664. */
  29665. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29666. /**
  29667. * Sets up an animation
  29668. * @param property The property to animate
  29669. * @param animationType The animation type to apply
  29670. * @param framePerSecond The frames per second of the animation
  29671. * @param easingFunction The easing function used in the animation
  29672. * @returns The created animation
  29673. */
  29674. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29675. /**
  29676. * Create and start an animation on a node
  29677. * @param name defines the name of the global animation that will be run on all nodes
  29678. * @param node defines the root node where the animation will take place
  29679. * @param targetProperty defines property to animate
  29680. * @param framePerSecond defines the number of frame per second yo use
  29681. * @param totalFrame defines the number of frames in total
  29682. * @param from defines the initial value
  29683. * @param to defines the final value
  29684. * @param loopMode defines which loop mode you want to use (off by default)
  29685. * @param easingFunction defines the easing function to use (linear by default)
  29686. * @param onAnimationEnd defines the callback to call when animation end
  29687. * @returns the animatable created for this animation
  29688. */
  29689. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29690. /**
  29691. * Create and start an animation on a node and its descendants
  29692. * @param name defines the name of the global animation that will be run on all nodes
  29693. * @param node defines the root node where the animation will take place
  29694. * @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
  29695. * @param targetProperty defines property to animate
  29696. * @param framePerSecond defines the number of frame per second to use
  29697. * @param totalFrame defines the number of frames in total
  29698. * @param from defines the initial value
  29699. * @param to defines the final value
  29700. * @param loopMode defines which loop mode you want to use (off by default)
  29701. * @param easingFunction defines the easing function to use (linear by default)
  29702. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29703. * @returns the list of animatables created for all nodes
  29704. * @example https://www.babylonjs-playground.com/#MH0VLI
  29705. */
  29706. 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[]>;
  29707. /**
  29708. * Creates a new animation, merges it with the existing animations and starts it
  29709. * @param name Name of the animation
  29710. * @param node Node which contains the scene that begins the animations
  29711. * @param targetProperty Specifies which property to animate
  29712. * @param framePerSecond The frames per second of the animation
  29713. * @param totalFrame The total number of frames
  29714. * @param from The frame at the beginning of the animation
  29715. * @param to The frame at the end of the animation
  29716. * @param loopMode Specifies the loop mode of the animation
  29717. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29718. * @param onAnimationEnd Callback to run once the animation is complete
  29719. * @returns Nullable animation
  29720. */
  29721. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29722. /**
  29723. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29724. * @param sourceAnimation defines the Animation containing keyframes to convert
  29725. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29726. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29727. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29728. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29729. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29730. */
  29731. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29732. /**
  29733. * Transition property of an host to the target Value
  29734. * @param property The property to transition
  29735. * @param targetValue The target Value of the property
  29736. * @param host The object where the property to animate belongs
  29737. * @param scene Scene used to run the animation
  29738. * @param frameRate Framerate (in frame/s) to use
  29739. * @param transition The transition type we want to use
  29740. * @param duration The duration of the animation, in milliseconds
  29741. * @param onAnimationEnd Callback trigger at the end of the animation
  29742. * @returns Nullable animation
  29743. */
  29744. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29745. /**
  29746. * Return the array of runtime animations currently using this animation
  29747. */
  29748. get runtimeAnimations(): RuntimeAnimation[];
  29749. /**
  29750. * Specifies if any of the runtime animations are currently running
  29751. */
  29752. get hasRunningRuntimeAnimations(): boolean;
  29753. /**
  29754. * Initializes the animation
  29755. * @param name Name of the animation
  29756. * @param targetProperty Property to animate
  29757. * @param framePerSecond The frames per second of the animation
  29758. * @param dataType The data type of the animation
  29759. * @param loopMode The loop mode of the animation
  29760. * @param enableBlending Specifies if blending should be enabled
  29761. */
  29762. constructor(
  29763. /**Name of the animation */
  29764. name: string,
  29765. /**Property to animate */
  29766. targetProperty: string,
  29767. /**The frames per second of the animation */
  29768. framePerSecond: number,
  29769. /**The data type of the animation */
  29770. dataType: number,
  29771. /**The loop mode of the animation */
  29772. loopMode?: number | undefined,
  29773. /**Specifies if blending should be enabled */
  29774. enableBlending?: boolean | undefined);
  29775. /**
  29776. * Converts the animation to a string
  29777. * @param fullDetails support for multiple levels of logging within scene loading
  29778. * @returns String form of the animation
  29779. */
  29780. toString(fullDetails?: boolean): string;
  29781. /**
  29782. * Add an event to this animation
  29783. * @param event Event to add
  29784. */
  29785. addEvent(event: AnimationEvent): void;
  29786. /**
  29787. * Remove all events found at the given frame
  29788. * @param frame The frame to remove events from
  29789. */
  29790. removeEvents(frame: number): void;
  29791. /**
  29792. * Retrieves all the events from the animation
  29793. * @returns Events from the animation
  29794. */
  29795. getEvents(): AnimationEvent[];
  29796. /**
  29797. * Creates an animation range
  29798. * @param name Name of the animation range
  29799. * @param from Starting frame of the animation range
  29800. * @param to Ending frame of the animation
  29801. */
  29802. createRange(name: string, from: number, to: number): void;
  29803. /**
  29804. * Deletes an animation range by name
  29805. * @param name Name of the animation range to delete
  29806. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29807. */
  29808. deleteRange(name: string, deleteFrames?: boolean): void;
  29809. /**
  29810. * Gets the animation range by name, or null if not defined
  29811. * @param name Name of the animation range
  29812. * @returns Nullable animation range
  29813. */
  29814. getRange(name: string): Nullable<AnimationRange>;
  29815. /**
  29816. * Gets the key frames from the animation
  29817. * @returns The key frames of the animation
  29818. */
  29819. getKeys(): Array<IAnimationKey>;
  29820. /**
  29821. * Gets the highest frame rate of the animation
  29822. * @returns Highest frame rate of the animation
  29823. */
  29824. getHighestFrame(): number;
  29825. /**
  29826. * Gets the easing function of the animation
  29827. * @returns Easing function of the animation
  29828. */
  29829. getEasingFunction(): IEasingFunction;
  29830. /**
  29831. * Sets the easing function of the animation
  29832. * @param easingFunction A custom mathematical formula for animation
  29833. */
  29834. setEasingFunction(easingFunction: EasingFunction): void;
  29835. /**
  29836. * Interpolates a scalar linearly
  29837. * @param startValue Start value of the animation curve
  29838. * @param endValue End value of the animation curve
  29839. * @param gradient Scalar amount to interpolate
  29840. * @returns Interpolated scalar value
  29841. */
  29842. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29843. /**
  29844. * Interpolates a scalar cubically
  29845. * @param startValue Start value of the animation curve
  29846. * @param outTangent End tangent of the animation
  29847. * @param endValue End value of the animation curve
  29848. * @param inTangent Start tangent of the animation curve
  29849. * @param gradient Scalar amount to interpolate
  29850. * @returns Interpolated scalar value
  29851. */
  29852. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29853. /**
  29854. * Interpolates a quaternion using a spherical linear interpolation
  29855. * @param startValue Start value of the animation curve
  29856. * @param endValue End value of the animation curve
  29857. * @param gradient Scalar amount to interpolate
  29858. * @returns Interpolated quaternion value
  29859. */
  29860. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29861. /**
  29862. * Interpolates a quaternion cubically
  29863. * @param startValue Start value of the animation curve
  29864. * @param outTangent End tangent of the animation curve
  29865. * @param endValue End value of the animation curve
  29866. * @param inTangent Start tangent of the animation curve
  29867. * @param gradient Scalar amount to interpolate
  29868. * @returns Interpolated quaternion value
  29869. */
  29870. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29871. /**
  29872. * Interpolates a Vector3 linearl
  29873. * @param startValue Start value of the animation curve
  29874. * @param endValue End value of the animation curve
  29875. * @param gradient Scalar amount to interpolate
  29876. * @returns Interpolated scalar value
  29877. */
  29878. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29879. /**
  29880. * Interpolates a Vector3 cubically
  29881. * @param startValue Start value of the animation curve
  29882. * @param outTangent End tangent of the animation
  29883. * @param endValue End value of the animation curve
  29884. * @param inTangent Start tangent of the animation curve
  29885. * @param gradient Scalar amount to interpolate
  29886. * @returns InterpolatedVector3 value
  29887. */
  29888. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29889. /**
  29890. * Interpolates a Vector2 linearly
  29891. * @param startValue Start value of the animation curve
  29892. * @param endValue End value of the animation curve
  29893. * @param gradient Scalar amount to interpolate
  29894. * @returns Interpolated Vector2 value
  29895. */
  29896. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29897. /**
  29898. * Interpolates a Vector2 cubically
  29899. * @param startValue Start value of the animation curve
  29900. * @param outTangent End tangent of the animation
  29901. * @param endValue End value of the animation curve
  29902. * @param inTangent Start tangent of the animation curve
  29903. * @param gradient Scalar amount to interpolate
  29904. * @returns Interpolated Vector2 value
  29905. */
  29906. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29907. /**
  29908. * Interpolates a size linearly
  29909. * @param startValue Start value of the animation curve
  29910. * @param endValue End value of the animation curve
  29911. * @param gradient Scalar amount to interpolate
  29912. * @returns Interpolated Size value
  29913. */
  29914. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29915. /**
  29916. * Interpolates a Color3 linearly
  29917. * @param startValue Start value of the animation curve
  29918. * @param endValue End value of the animation curve
  29919. * @param gradient Scalar amount to interpolate
  29920. * @returns Interpolated Color3 value
  29921. */
  29922. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29923. /**
  29924. * Interpolates a Color4 linearly
  29925. * @param startValue Start value of the animation curve
  29926. * @param endValue End value of the animation curve
  29927. * @param gradient Scalar amount to interpolate
  29928. * @returns Interpolated Color3 value
  29929. */
  29930. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29931. /**
  29932. * @hidden Internal use only
  29933. */
  29934. _getKeyValue(value: any): any;
  29935. /**
  29936. * @hidden Internal use only
  29937. */
  29938. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29939. /**
  29940. * Defines the function to use to interpolate matrices
  29941. * @param startValue defines the start matrix
  29942. * @param endValue defines the end matrix
  29943. * @param gradient defines the gradient between both matrices
  29944. * @param result defines an optional target matrix where to store the interpolation
  29945. * @returns the interpolated matrix
  29946. */
  29947. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29948. /**
  29949. * Makes a copy of the animation
  29950. * @returns Cloned animation
  29951. */
  29952. clone(): Animation;
  29953. /**
  29954. * Sets the key frames of the animation
  29955. * @param values The animation key frames to set
  29956. */
  29957. setKeys(values: Array<IAnimationKey>): void;
  29958. /**
  29959. * Serializes the animation to an object
  29960. * @returns Serialized object
  29961. */
  29962. serialize(): any;
  29963. /**
  29964. * Float animation type
  29965. */
  29966. static readonly ANIMATIONTYPE_FLOAT: number;
  29967. /**
  29968. * Vector3 animation type
  29969. */
  29970. static readonly ANIMATIONTYPE_VECTOR3: number;
  29971. /**
  29972. * Quaternion animation type
  29973. */
  29974. static readonly ANIMATIONTYPE_QUATERNION: number;
  29975. /**
  29976. * Matrix animation type
  29977. */
  29978. static readonly ANIMATIONTYPE_MATRIX: number;
  29979. /**
  29980. * Color3 animation type
  29981. */
  29982. static readonly ANIMATIONTYPE_COLOR3: number;
  29983. /**
  29984. * Color3 animation type
  29985. */
  29986. static readonly ANIMATIONTYPE_COLOR4: number;
  29987. /**
  29988. * Vector2 animation type
  29989. */
  29990. static readonly ANIMATIONTYPE_VECTOR2: number;
  29991. /**
  29992. * Size animation type
  29993. */
  29994. static readonly ANIMATIONTYPE_SIZE: number;
  29995. /**
  29996. * Relative Loop Mode
  29997. */
  29998. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29999. /**
  30000. * Cycle Loop Mode
  30001. */
  30002. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30003. /**
  30004. * Constant Loop Mode
  30005. */
  30006. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30007. /** @hidden */
  30008. static _UniversalLerp(left: any, right: any, amount: number): any;
  30009. /**
  30010. * Parses an animation object and creates an animation
  30011. * @param parsedAnimation Parsed animation object
  30012. * @returns Animation object
  30013. */
  30014. static Parse(parsedAnimation: any): Animation;
  30015. /**
  30016. * Appends the serialized animations from the source animations
  30017. * @param source Source containing the animations
  30018. * @param destination Target to store the animations
  30019. */
  30020. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30021. }
  30022. }
  30023. declare module BABYLON {
  30024. /**
  30025. * Interface containing an array of animations
  30026. */
  30027. export interface IAnimatable {
  30028. /**
  30029. * Array of animations
  30030. */
  30031. animations: Nullable<Array<Animation>>;
  30032. }
  30033. }
  30034. declare module BABYLON {
  30035. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30036. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30037. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30038. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30039. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30040. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30041. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30042. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30043. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30044. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30045. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30046. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30047. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30048. /**
  30049. * Decorator used to define property that can be serialized as reference to a camera
  30050. * @param sourceName defines the name of the property to decorate
  30051. */
  30052. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30053. /**
  30054. * Class used to help serialization objects
  30055. */
  30056. export class SerializationHelper {
  30057. /** @hidden */
  30058. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30059. /** @hidden */
  30060. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30061. /** @hidden */
  30062. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30063. /** @hidden */
  30064. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30065. /**
  30066. * Appends the serialized animations from the source animations
  30067. * @param source Source containing the animations
  30068. * @param destination Target to store the animations
  30069. */
  30070. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30071. /**
  30072. * Static function used to serialized a specific entity
  30073. * @param entity defines the entity to serialize
  30074. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30075. * @returns a JSON compatible object representing the serialization of the entity
  30076. */
  30077. static Serialize<T>(entity: T, serializationObject?: any): any;
  30078. /**
  30079. * Creates a new entity from a serialization data object
  30080. * @param creationFunction defines a function used to instanciated the new entity
  30081. * @param source defines the source serialization data
  30082. * @param scene defines the hosting scene
  30083. * @param rootUrl defines the root url for resources
  30084. * @returns a new entity
  30085. */
  30086. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30087. /**
  30088. * Clones an object
  30089. * @param creationFunction defines the function used to instanciate the new object
  30090. * @param source defines the source object
  30091. * @returns the cloned object
  30092. */
  30093. static Clone<T>(creationFunction: () => T, source: T): T;
  30094. /**
  30095. * Instanciates a new object based on a source one (some data will be shared between both object)
  30096. * @param creationFunction defines the function used to instanciate the new object
  30097. * @param source defines the source object
  30098. * @returns the new object
  30099. */
  30100. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30101. }
  30102. }
  30103. declare module BABYLON {
  30104. /**
  30105. * Base class of all the textures in babylon.
  30106. * It groups all the common properties the materials, post process, lights... might need
  30107. * in order to make a correct use of the texture.
  30108. */
  30109. export class BaseTexture implements IAnimatable {
  30110. /**
  30111. * Default anisotropic filtering level for the application.
  30112. * It is set to 4 as a good tradeoff between perf and quality.
  30113. */
  30114. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30115. /**
  30116. * Gets or sets the unique id of the texture
  30117. */
  30118. uniqueId: number;
  30119. /**
  30120. * Define the name of the texture.
  30121. */
  30122. name: string;
  30123. /**
  30124. * Gets or sets an object used to store user defined information.
  30125. */
  30126. metadata: any;
  30127. /**
  30128. * For internal use only. Please do not use.
  30129. */
  30130. reservedDataStore: any;
  30131. private _hasAlpha;
  30132. /**
  30133. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30134. */
  30135. set hasAlpha(value: boolean);
  30136. get hasAlpha(): boolean;
  30137. /**
  30138. * Defines if the alpha value should be determined via the rgb values.
  30139. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30140. */
  30141. getAlphaFromRGB: boolean;
  30142. /**
  30143. * Intensity or strength of the texture.
  30144. * It is commonly used by materials to fine tune the intensity of the texture
  30145. */
  30146. level: number;
  30147. /**
  30148. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30149. * This is part of the texture as textures usually maps to one uv set.
  30150. */
  30151. coordinatesIndex: number;
  30152. private _coordinatesMode;
  30153. /**
  30154. * How a texture is mapped.
  30155. *
  30156. * | Value | Type | Description |
  30157. * | ----- | ----------------------------------- | ----------- |
  30158. * | 0 | EXPLICIT_MODE | |
  30159. * | 1 | SPHERICAL_MODE | |
  30160. * | 2 | PLANAR_MODE | |
  30161. * | 3 | CUBIC_MODE | |
  30162. * | 4 | PROJECTION_MODE | |
  30163. * | 5 | SKYBOX_MODE | |
  30164. * | 6 | INVCUBIC_MODE | |
  30165. * | 7 | EQUIRECTANGULAR_MODE | |
  30166. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30167. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30168. */
  30169. set coordinatesMode(value: number);
  30170. get coordinatesMode(): number;
  30171. /**
  30172. * | Value | Type | Description |
  30173. * | ----- | ------------------ | ----------- |
  30174. * | 0 | CLAMP_ADDRESSMODE | |
  30175. * | 1 | WRAP_ADDRESSMODE | |
  30176. * | 2 | MIRROR_ADDRESSMODE | |
  30177. */
  30178. wrapU: number;
  30179. /**
  30180. * | Value | Type | Description |
  30181. * | ----- | ------------------ | ----------- |
  30182. * | 0 | CLAMP_ADDRESSMODE | |
  30183. * | 1 | WRAP_ADDRESSMODE | |
  30184. * | 2 | MIRROR_ADDRESSMODE | |
  30185. */
  30186. wrapV: number;
  30187. /**
  30188. * | Value | Type | Description |
  30189. * | ----- | ------------------ | ----------- |
  30190. * | 0 | CLAMP_ADDRESSMODE | |
  30191. * | 1 | WRAP_ADDRESSMODE | |
  30192. * | 2 | MIRROR_ADDRESSMODE | |
  30193. */
  30194. wrapR: number;
  30195. /**
  30196. * With compliant hardware and browser (supporting anisotropic filtering)
  30197. * this defines the level of anisotropic filtering in the texture.
  30198. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30199. */
  30200. anisotropicFilteringLevel: number;
  30201. /**
  30202. * Define if the texture is a cube texture or if false a 2d texture.
  30203. */
  30204. get isCube(): boolean;
  30205. set isCube(value: boolean);
  30206. /**
  30207. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30208. */
  30209. get is3D(): boolean;
  30210. set is3D(value: boolean);
  30211. /**
  30212. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30213. */
  30214. get is2DArray(): boolean;
  30215. set is2DArray(value: boolean);
  30216. /**
  30217. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30218. * HDR texture are usually stored in linear space.
  30219. * This only impacts the PBR and Background materials
  30220. */
  30221. gammaSpace: boolean;
  30222. /**
  30223. * Gets or sets whether or not the texture contains RGBD data.
  30224. */
  30225. get isRGBD(): boolean;
  30226. set isRGBD(value: boolean);
  30227. /**
  30228. * Is Z inverted in the texture (useful in a cube texture).
  30229. */
  30230. invertZ: boolean;
  30231. /**
  30232. * Are mip maps generated for this texture or not.
  30233. */
  30234. get noMipmap(): boolean;
  30235. /**
  30236. * @hidden
  30237. */
  30238. lodLevelInAlpha: boolean;
  30239. /**
  30240. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30241. */
  30242. get lodGenerationOffset(): number;
  30243. set lodGenerationOffset(value: number);
  30244. /**
  30245. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30246. */
  30247. get lodGenerationScale(): number;
  30248. set lodGenerationScale(value: number);
  30249. /**
  30250. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30251. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30252. * average roughness values.
  30253. */
  30254. get linearSpecularLOD(): boolean;
  30255. set linearSpecularLOD(value: boolean);
  30256. /**
  30257. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30258. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30259. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30260. */
  30261. get irradianceTexture(): Nullable<BaseTexture>;
  30262. set irradianceTexture(value: Nullable<BaseTexture>);
  30263. /**
  30264. * Define if the texture is a render target.
  30265. */
  30266. isRenderTarget: boolean;
  30267. /**
  30268. * Define the unique id of the texture in the scene.
  30269. */
  30270. get uid(): string;
  30271. /**
  30272. * Return a string representation of the texture.
  30273. * @returns the texture as a string
  30274. */
  30275. toString(): string;
  30276. /**
  30277. * Get the class name of the texture.
  30278. * @returns "BaseTexture"
  30279. */
  30280. getClassName(): string;
  30281. /**
  30282. * Define the list of animation attached to the texture.
  30283. */
  30284. animations: Animation[];
  30285. /**
  30286. * An event triggered when the texture is disposed.
  30287. */
  30288. onDisposeObservable: Observable<BaseTexture>;
  30289. private _onDisposeObserver;
  30290. /**
  30291. * Callback triggered when the texture has been disposed.
  30292. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30293. */
  30294. set onDispose(callback: () => void);
  30295. /**
  30296. * Define the current state of the loading sequence when in delayed load mode.
  30297. */
  30298. delayLoadState: number;
  30299. private _scene;
  30300. /** @hidden */
  30301. _texture: Nullable<InternalTexture>;
  30302. private _uid;
  30303. /**
  30304. * Define if the texture is preventinga material to render or not.
  30305. * If not and the texture is not ready, the engine will use a default black texture instead.
  30306. */
  30307. get isBlocking(): boolean;
  30308. /**
  30309. * Instantiates a new BaseTexture.
  30310. * Base class of all the textures in babylon.
  30311. * It groups all the common properties the materials, post process, lights... might need
  30312. * in order to make a correct use of the texture.
  30313. * @param scene Define the scene the texture blongs to
  30314. */
  30315. constructor(scene: Nullable<Scene>);
  30316. /**
  30317. * Get the scene the texture belongs to.
  30318. * @returns the scene or null if undefined
  30319. */
  30320. getScene(): Nullable<Scene>;
  30321. /**
  30322. * Get the texture transform matrix used to offset tile the texture for istance.
  30323. * @returns the transformation matrix
  30324. */
  30325. getTextureMatrix(): Matrix;
  30326. /**
  30327. * Get the texture reflection matrix used to rotate/transform the reflection.
  30328. * @returns the reflection matrix
  30329. */
  30330. getReflectionTextureMatrix(): Matrix;
  30331. /**
  30332. * Get the underlying lower level texture from Babylon.
  30333. * @returns the insternal texture
  30334. */
  30335. getInternalTexture(): Nullable<InternalTexture>;
  30336. /**
  30337. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30338. * @returns true if ready or not blocking
  30339. */
  30340. isReadyOrNotBlocking(): boolean;
  30341. /**
  30342. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30343. * @returns true if fully ready
  30344. */
  30345. isReady(): boolean;
  30346. private _cachedSize;
  30347. /**
  30348. * Get the size of the texture.
  30349. * @returns the texture size.
  30350. */
  30351. getSize(): ISize;
  30352. /**
  30353. * Get the base size of the texture.
  30354. * It can be different from the size if the texture has been resized for POT for instance
  30355. * @returns the base size
  30356. */
  30357. getBaseSize(): ISize;
  30358. /**
  30359. * Update the sampling mode of the texture.
  30360. * Default is Trilinear mode.
  30361. *
  30362. * | Value | Type | Description |
  30363. * | ----- | ------------------ | ----------- |
  30364. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30365. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30366. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30367. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30368. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30369. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30370. * | 7 | NEAREST_LINEAR | |
  30371. * | 8 | NEAREST_NEAREST | |
  30372. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30373. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30374. * | 11 | LINEAR_LINEAR | |
  30375. * | 12 | LINEAR_NEAREST | |
  30376. *
  30377. * > _mag_: magnification filter (close to the viewer)
  30378. * > _min_: minification filter (far from the viewer)
  30379. * > _mip_: filter used between mip map levels
  30380. *@param samplingMode Define the new sampling mode of the texture
  30381. */
  30382. updateSamplingMode(samplingMode: number): void;
  30383. /**
  30384. * Scales the texture if is `canRescale()`
  30385. * @param ratio the resize factor we want to use to rescale
  30386. */
  30387. scale(ratio: number): void;
  30388. /**
  30389. * Get if the texture can rescale.
  30390. */
  30391. get canRescale(): boolean;
  30392. /** @hidden */
  30393. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30394. /** @hidden */
  30395. _rebuild(): void;
  30396. /**
  30397. * Triggers the load sequence in delayed load mode.
  30398. */
  30399. delayLoad(): void;
  30400. /**
  30401. * Clones the texture.
  30402. * @returns the cloned texture
  30403. */
  30404. clone(): Nullable<BaseTexture>;
  30405. /**
  30406. * Get the texture underlying type (INT, FLOAT...)
  30407. */
  30408. get textureType(): number;
  30409. /**
  30410. * Get the texture underlying format (RGB, RGBA...)
  30411. */
  30412. get textureFormat(): number;
  30413. /**
  30414. * Indicates that textures need to be re-calculated for all materials
  30415. */
  30416. protected _markAllSubMeshesAsTexturesDirty(): void;
  30417. /**
  30418. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30419. * This will returns an RGBA array buffer containing either in values (0-255) or
  30420. * float values (0-1) depending of the underlying buffer type.
  30421. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30422. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30423. * @param buffer defines a user defined buffer to fill with data (can be null)
  30424. * @returns The Array buffer containing the pixels data.
  30425. */
  30426. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30427. /**
  30428. * Release and destroy the underlying lower level texture aka internalTexture.
  30429. */
  30430. releaseInternalTexture(): void;
  30431. /** @hidden */
  30432. get _lodTextureHigh(): Nullable<BaseTexture>;
  30433. /** @hidden */
  30434. get _lodTextureMid(): Nullable<BaseTexture>;
  30435. /** @hidden */
  30436. get _lodTextureLow(): Nullable<BaseTexture>;
  30437. /**
  30438. * Dispose the texture and release its associated resources.
  30439. */
  30440. dispose(): void;
  30441. /**
  30442. * Serialize the texture into a JSON representation that can be parsed later on.
  30443. * @returns the JSON representation of the texture
  30444. */
  30445. serialize(): any;
  30446. /**
  30447. * Helper function to be called back once a list of texture contains only ready textures.
  30448. * @param textures Define the list of textures to wait for
  30449. * @param callback Define the callback triggered once the entire list will be ready
  30450. */
  30451. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /**
  30456. * Options to be used when creating an effect.
  30457. */
  30458. export interface IEffectCreationOptions {
  30459. /**
  30460. * Atrributes that will be used in the shader.
  30461. */
  30462. attributes: string[];
  30463. /**
  30464. * Uniform varible names that will be set in the shader.
  30465. */
  30466. uniformsNames: string[];
  30467. /**
  30468. * Uniform buffer variable names that will be set in the shader.
  30469. */
  30470. uniformBuffersNames: string[];
  30471. /**
  30472. * Sampler texture variable names that will be set in the shader.
  30473. */
  30474. samplers: string[];
  30475. /**
  30476. * Define statements that will be set in the shader.
  30477. */
  30478. defines: any;
  30479. /**
  30480. * Possible fallbacks for this effect to improve performance when needed.
  30481. */
  30482. fallbacks: Nullable<IEffectFallbacks>;
  30483. /**
  30484. * Callback that will be called when the shader is compiled.
  30485. */
  30486. onCompiled: Nullable<(effect: Effect) => void>;
  30487. /**
  30488. * Callback that will be called if an error occurs during shader compilation.
  30489. */
  30490. onError: Nullable<(effect: Effect, errors: string) => void>;
  30491. /**
  30492. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30493. */
  30494. indexParameters?: any;
  30495. /**
  30496. * Max number of lights that can be used in the shader.
  30497. */
  30498. maxSimultaneousLights?: number;
  30499. /**
  30500. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30501. */
  30502. transformFeedbackVaryings?: Nullable<string[]>;
  30503. }
  30504. /**
  30505. * Effect containing vertex and fragment shader that can be executed on an object.
  30506. */
  30507. export class Effect implements IDisposable {
  30508. /**
  30509. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30510. */
  30511. static ShadersRepository: string;
  30512. /**
  30513. * Enable logging of the shader code when a compilation error occurs
  30514. */
  30515. static LogShaderCodeOnCompilationError: boolean;
  30516. /**
  30517. * Name of the effect.
  30518. */
  30519. name: any;
  30520. /**
  30521. * String container all the define statements that should be set on the shader.
  30522. */
  30523. defines: string;
  30524. /**
  30525. * Callback that will be called when the shader is compiled.
  30526. */
  30527. onCompiled: Nullable<(effect: Effect) => void>;
  30528. /**
  30529. * Callback that will be called if an error occurs during shader compilation.
  30530. */
  30531. onError: Nullable<(effect: Effect, errors: string) => void>;
  30532. /**
  30533. * Callback that will be called when effect is bound.
  30534. */
  30535. onBind: Nullable<(effect: Effect) => void>;
  30536. /**
  30537. * Unique ID of the effect.
  30538. */
  30539. uniqueId: number;
  30540. /**
  30541. * Observable that will be called when the shader is compiled.
  30542. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30543. */
  30544. onCompileObservable: Observable<Effect>;
  30545. /**
  30546. * Observable that will be called if an error occurs during shader compilation.
  30547. */
  30548. onErrorObservable: Observable<Effect>;
  30549. /** @hidden */
  30550. _onBindObservable: Nullable<Observable<Effect>>;
  30551. /**
  30552. * @hidden
  30553. * Specifies if the effect was previously ready
  30554. */
  30555. _wasPreviouslyReady: boolean;
  30556. /**
  30557. * Observable that will be called when effect is bound.
  30558. */
  30559. get onBindObservable(): Observable<Effect>;
  30560. /** @hidden */
  30561. _bonesComputationForcedToCPU: boolean;
  30562. private static _uniqueIdSeed;
  30563. private _engine;
  30564. private _uniformBuffersNames;
  30565. private _uniformBuffersNamesList;
  30566. private _uniformsNames;
  30567. private _samplerList;
  30568. private _samplers;
  30569. private _isReady;
  30570. private _compilationError;
  30571. private _allFallbacksProcessed;
  30572. private _attributesNames;
  30573. private _attributes;
  30574. private _attributeLocationByName;
  30575. private _uniforms;
  30576. /**
  30577. * Key for the effect.
  30578. * @hidden
  30579. */
  30580. _key: string;
  30581. private _indexParameters;
  30582. private _fallbacks;
  30583. private _vertexSourceCode;
  30584. private _fragmentSourceCode;
  30585. private _vertexSourceCodeOverride;
  30586. private _fragmentSourceCodeOverride;
  30587. private _transformFeedbackVaryings;
  30588. /**
  30589. * Compiled shader to webGL program.
  30590. * @hidden
  30591. */
  30592. _pipelineContext: Nullable<IPipelineContext>;
  30593. private _valueCache;
  30594. private static _baseCache;
  30595. /**
  30596. * Instantiates an effect.
  30597. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30598. * @param baseName Name of the effect.
  30599. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30600. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30601. * @param samplers List of sampler variables that will be passed to the shader.
  30602. * @param engine Engine to be used to render the effect
  30603. * @param defines Define statements to be added to the shader.
  30604. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30605. * @param onCompiled Callback that will be called when the shader is compiled.
  30606. * @param onError Callback that will be called if an error occurs during shader compilation.
  30607. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30608. */
  30609. 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);
  30610. private _useFinalCode;
  30611. /**
  30612. * Unique key for this effect
  30613. */
  30614. get key(): string;
  30615. /**
  30616. * If the effect has been compiled and prepared.
  30617. * @returns if the effect is compiled and prepared.
  30618. */
  30619. isReady(): boolean;
  30620. private _isReadyInternal;
  30621. /**
  30622. * The engine the effect was initialized with.
  30623. * @returns the engine.
  30624. */
  30625. getEngine(): Engine;
  30626. /**
  30627. * The pipeline context for this effect
  30628. * @returns the associated pipeline context
  30629. */
  30630. getPipelineContext(): Nullable<IPipelineContext>;
  30631. /**
  30632. * The set of names of attribute variables for the shader.
  30633. * @returns An array of attribute names.
  30634. */
  30635. getAttributesNames(): string[];
  30636. /**
  30637. * Returns the attribute at the given index.
  30638. * @param index The index of the attribute.
  30639. * @returns The location of the attribute.
  30640. */
  30641. getAttributeLocation(index: number): number;
  30642. /**
  30643. * Returns the attribute based on the name of the variable.
  30644. * @param name of the attribute to look up.
  30645. * @returns the attribute location.
  30646. */
  30647. getAttributeLocationByName(name: string): number;
  30648. /**
  30649. * The number of attributes.
  30650. * @returns the numnber of attributes.
  30651. */
  30652. getAttributesCount(): number;
  30653. /**
  30654. * Gets the index of a uniform variable.
  30655. * @param uniformName of the uniform to look up.
  30656. * @returns the index.
  30657. */
  30658. getUniformIndex(uniformName: string): number;
  30659. /**
  30660. * Returns the attribute based on the name of the variable.
  30661. * @param uniformName of the uniform to look up.
  30662. * @returns the location of the uniform.
  30663. */
  30664. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30665. /**
  30666. * Returns an array of sampler variable names
  30667. * @returns The array of sampler variable names.
  30668. */
  30669. getSamplers(): string[];
  30670. /**
  30671. * Returns an array of uniform variable names
  30672. * @returns The array of uniform variable names.
  30673. */
  30674. getUniformNames(): string[];
  30675. /**
  30676. * Returns an array of uniform buffer variable names
  30677. * @returns The array of uniform buffer variable names.
  30678. */
  30679. getUniformBuffersNames(): string[];
  30680. /**
  30681. * Returns the index parameters used to create the effect
  30682. * @returns The index parameters object
  30683. */
  30684. getIndexParameters(): any;
  30685. /**
  30686. * The error from the last compilation.
  30687. * @returns the error string.
  30688. */
  30689. getCompilationError(): string;
  30690. /**
  30691. * Gets a boolean indicating that all fallbacks were used during compilation
  30692. * @returns true if all fallbacks were used
  30693. */
  30694. allFallbacksProcessed(): boolean;
  30695. /**
  30696. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30697. * @param func The callback to be used.
  30698. */
  30699. executeWhenCompiled(func: (effect: Effect) => void): void;
  30700. private _checkIsReady;
  30701. private _loadShader;
  30702. /**
  30703. * Gets the vertex shader source code of this effect
  30704. */
  30705. get vertexSourceCode(): string;
  30706. /**
  30707. * Gets the fragment shader source code of this effect
  30708. */
  30709. get fragmentSourceCode(): string;
  30710. /**
  30711. * Recompiles the webGL program
  30712. * @param vertexSourceCode The source code for the vertex shader.
  30713. * @param fragmentSourceCode The source code for the fragment shader.
  30714. * @param onCompiled Callback called when completed.
  30715. * @param onError Callback called on error.
  30716. * @hidden
  30717. */
  30718. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30719. /**
  30720. * Prepares the effect
  30721. * @hidden
  30722. */
  30723. _prepareEffect(): void;
  30724. private _getShaderCodeAndErrorLine;
  30725. private _processCompilationErrors;
  30726. /**
  30727. * Checks if the effect is supported. (Must be called after compilation)
  30728. */
  30729. get isSupported(): boolean;
  30730. /**
  30731. * Binds a texture to the engine to be used as output of the shader.
  30732. * @param channel Name of the output variable.
  30733. * @param texture Texture to bind.
  30734. * @hidden
  30735. */
  30736. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30737. /**
  30738. * Sets a texture on the engine to be used in the shader.
  30739. * @param channel Name of the sampler variable.
  30740. * @param texture Texture to set.
  30741. */
  30742. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30743. /**
  30744. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30745. * @param channel Name of the sampler variable.
  30746. * @param texture Texture to set.
  30747. */
  30748. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30749. /**
  30750. * Sets an array of textures on the engine to be used in the shader.
  30751. * @param channel Name of the variable.
  30752. * @param textures Textures to set.
  30753. */
  30754. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30755. /**
  30756. * 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)
  30757. * @param channel Name of the sampler variable.
  30758. * @param postProcess Post process to get the input texture from.
  30759. */
  30760. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30761. /**
  30762. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30763. * 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)
  30764. * @param channel Name of the sampler variable.
  30765. * @param postProcess Post process to get the output texture from.
  30766. */
  30767. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30768. /** @hidden */
  30769. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30770. /** @hidden */
  30771. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30772. /** @hidden */
  30773. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30774. /** @hidden */
  30775. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30776. /**
  30777. * Binds a buffer to a uniform.
  30778. * @param buffer Buffer to bind.
  30779. * @param name Name of the uniform variable to bind to.
  30780. */
  30781. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30782. /**
  30783. * Binds block to a uniform.
  30784. * @param blockName Name of the block to bind.
  30785. * @param index Index to bind.
  30786. */
  30787. bindUniformBlock(blockName: string, index: number): void;
  30788. /**
  30789. * Sets an interger value on a uniform variable.
  30790. * @param uniformName Name of the variable.
  30791. * @param value Value to be set.
  30792. * @returns this effect.
  30793. */
  30794. setInt(uniformName: string, value: number): Effect;
  30795. /**
  30796. * Sets an int array on a uniform variable.
  30797. * @param uniformName Name of the variable.
  30798. * @param array array to be set.
  30799. * @returns this effect.
  30800. */
  30801. setIntArray(uniformName: string, array: Int32Array): Effect;
  30802. /**
  30803. * 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)
  30804. * @param uniformName Name of the variable.
  30805. * @param array array to be set.
  30806. * @returns this effect.
  30807. */
  30808. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30809. /**
  30810. * 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)
  30811. * @param uniformName Name of the variable.
  30812. * @param array array to be set.
  30813. * @returns this effect.
  30814. */
  30815. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30816. /**
  30817. * 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)
  30818. * @param uniformName Name of the variable.
  30819. * @param array array to be set.
  30820. * @returns this effect.
  30821. */
  30822. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30823. /**
  30824. * Sets an float array on a uniform variable.
  30825. * @param uniformName Name of the variable.
  30826. * @param array array to be set.
  30827. * @returns this effect.
  30828. */
  30829. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30830. /**
  30831. * 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)
  30832. * @param uniformName Name of the variable.
  30833. * @param array array to be set.
  30834. * @returns this effect.
  30835. */
  30836. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30837. /**
  30838. * 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)
  30839. * @param uniformName Name of the variable.
  30840. * @param array array to be set.
  30841. * @returns this effect.
  30842. */
  30843. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30844. /**
  30845. * 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)
  30846. * @param uniformName Name of the variable.
  30847. * @param array array to be set.
  30848. * @returns this effect.
  30849. */
  30850. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30851. /**
  30852. * Sets an array on a uniform variable.
  30853. * @param uniformName Name of the variable.
  30854. * @param array array to be set.
  30855. * @returns this effect.
  30856. */
  30857. setArray(uniformName: string, array: number[]): Effect;
  30858. /**
  30859. * 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)
  30860. * @param uniformName Name of the variable.
  30861. * @param array array to be set.
  30862. * @returns this effect.
  30863. */
  30864. setArray2(uniformName: string, array: number[]): Effect;
  30865. /**
  30866. * 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)
  30867. * @param uniformName Name of the variable.
  30868. * @param array array to be set.
  30869. * @returns this effect.
  30870. */
  30871. setArray3(uniformName: string, array: number[]): Effect;
  30872. /**
  30873. * 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)
  30874. * @param uniformName Name of the variable.
  30875. * @param array array to be set.
  30876. * @returns this effect.
  30877. */
  30878. setArray4(uniformName: string, array: number[]): Effect;
  30879. /**
  30880. * Sets matrices on a uniform variable.
  30881. * @param uniformName Name of the variable.
  30882. * @param matrices matrices to be set.
  30883. * @returns this effect.
  30884. */
  30885. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30886. /**
  30887. * Sets matrix on a uniform variable.
  30888. * @param uniformName Name of the variable.
  30889. * @param matrix matrix to be set.
  30890. * @returns this effect.
  30891. */
  30892. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30893. /**
  30894. * 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)
  30895. * @param uniformName Name of the variable.
  30896. * @param matrix matrix to be set.
  30897. * @returns this effect.
  30898. */
  30899. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30900. /**
  30901. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30902. * @param uniformName Name of the variable.
  30903. * @param matrix matrix to be set.
  30904. * @returns this effect.
  30905. */
  30906. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30907. /**
  30908. * Sets a float on a uniform variable.
  30909. * @param uniformName Name of the variable.
  30910. * @param value value to be set.
  30911. * @returns this effect.
  30912. */
  30913. setFloat(uniformName: string, value: number): Effect;
  30914. /**
  30915. * Sets a boolean on a uniform variable.
  30916. * @param uniformName Name of the variable.
  30917. * @param bool value to be set.
  30918. * @returns this effect.
  30919. */
  30920. setBool(uniformName: string, bool: boolean): Effect;
  30921. /**
  30922. * Sets a Vector2 on a uniform variable.
  30923. * @param uniformName Name of the variable.
  30924. * @param vector2 vector2 to be set.
  30925. * @returns this effect.
  30926. */
  30927. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30928. /**
  30929. * Sets a float2 on a uniform variable.
  30930. * @param uniformName Name of the variable.
  30931. * @param x First float in float2.
  30932. * @param y Second float in float2.
  30933. * @returns this effect.
  30934. */
  30935. setFloat2(uniformName: string, x: number, y: number): Effect;
  30936. /**
  30937. * Sets a Vector3 on a uniform variable.
  30938. * @param uniformName Name of the variable.
  30939. * @param vector3 Value to be set.
  30940. * @returns this effect.
  30941. */
  30942. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30943. /**
  30944. * Sets a float3 on a uniform variable.
  30945. * @param uniformName Name of the variable.
  30946. * @param x First float in float3.
  30947. * @param y Second float in float3.
  30948. * @param z Third float in float3.
  30949. * @returns this effect.
  30950. */
  30951. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30952. /**
  30953. * Sets a Vector4 on a uniform variable.
  30954. * @param uniformName Name of the variable.
  30955. * @param vector4 Value to be set.
  30956. * @returns this effect.
  30957. */
  30958. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30959. /**
  30960. * Sets a float4 on a uniform variable.
  30961. * @param uniformName Name of the variable.
  30962. * @param x First float in float4.
  30963. * @param y Second float in float4.
  30964. * @param z Third float in float4.
  30965. * @param w Fourth float in float4.
  30966. * @returns this effect.
  30967. */
  30968. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30969. /**
  30970. * Sets a Color3 on a uniform variable.
  30971. * @param uniformName Name of the variable.
  30972. * @param color3 Value to be set.
  30973. * @returns this effect.
  30974. */
  30975. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30976. /**
  30977. * Sets a Color4 on a uniform variable.
  30978. * @param uniformName Name of the variable.
  30979. * @param color3 Value to be set.
  30980. * @param alpha Alpha value to be set.
  30981. * @returns this effect.
  30982. */
  30983. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30984. /**
  30985. * Sets a Color4 on a uniform variable
  30986. * @param uniformName defines the name of the variable
  30987. * @param color4 defines the value to be set
  30988. * @returns this effect.
  30989. */
  30990. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30991. /** Release all associated resources */
  30992. dispose(): void;
  30993. /**
  30994. * This function will add a new shader to the shader store
  30995. * @param name the name of the shader
  30996. * @param pixelShader optional pixel shader content
  30997. * @param vertexShader optional vertex shader content
  30998. */
  30999. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31000. /**
  31001. * Store of each shader (The can be looked up using effect.key)
  31002. */
  31003. static ShadersStore: {
  31004. [key: string]: string;
  31005. };
  31006. /**
  31007. * Store of each included file for a shader (The can be looked up using effect.key)
  31008. */
  31009. static IncludesShadersStore: {
  31010. [key: string]: string;
  31011. };
  31012. /**
  31013. * Resets the cache of effects.
  31014. */
  31015. static ResetCache(): void;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * Interface used to describe the capabilities of the engine relatively to the current browser
  31021. */
  31022. export interface EngineCapabilities {
  31023. /** Maximum textures units per fragment shader */
  31024. maxTexturesImageUnits: number;
  31025. /** Maximum texture units per vertex shader */
  31026. maxVertexTextureImageUnits: number;
  31027. /** Maximum textures units in the entire pipeline */
  31028. maxCombinedTexturesImageUnits: number;
  31029. /** Maximum texture size */
  31030. maxTextureSize: number;
  31031. /** Maximum texture samples */
  31032. maxSamples?: number;
  31033. /** Maximum cube texture size */
  31034. maxCubemapTextureSize: number;
  31035. /** Maximum render texture size */
  31036. maxRenderTextureSize: number;
  31037. /** Maximum number of vertex attributes */
  31038. maxVertexAttribs: number;
  31039. /** Maximum number of varyings */
  31040. maxVaryingVectors: number;
  31041. /** Maximum number of uniforms per vertex shader */
  31042. maxVertexUniformVectors: number;
  31043. /** Maximum number of uniforms per fragment shader */
  31044. maxFragmentUniformVectors: number;
  31045. /** Defines if standard derivates (dx/dy) are supported */
  31046. standardDerivatives: boolean;
  31047. /** Defines if s3tc texture compression is supported */
  31048. s3tc?: WEBGL_compressed_texture_s3tc;
  31049. /** Defines if pvrtc texture compression is supported */
  31050. pvrtc: any;
  31051. /** Defines if etc1 texture compression is supported */
  31052. etc1: any;
  31053. /** Defines if etc2 texture compression is supported */
  31054. etc2: any;
  31055. /** Defines if astc texture compression is supported */
  31056. astc: any;
  31057. /** Defines if float textures are supported */
  31058. textureFloat: boolean;
  31059. /** Defines if vertex array objects are supported */
  31060. vertexArrayObject: boolean;
  31061. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31062. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31063. /** Gets the maximum level of anisotropy supported */
  31064. maxAnisotropy: number;
  31065. /** Defines if instancing is supported */
  31066. instancedArrays: boolean;
  31067. /** Defines if 32 bits indices are supported */
  31068. uintIndices: boolean;
  31069. /** Defines if high precision shaders are supported */
  31070. highPrecisionShaderSupported: boolean;
  31071. /** Defines if depth reading in the fragment shader is supported */
  31072. fragmentDepthSupported: boolean;
  31073. /** Defines if float texture linear filtering is supported*/
  31074. textureFloatLinearFiltering: boolean;
  31075. /** Defines if rendering to float textures is supported */
  31076. textureFloatRender: boolean;
  31077. /** Defines if half float textures are supported*/
  31078. textureHalfFloat: boolean;
  31079. /** Defines if half float texture linear filtering is supported*/
  31080. textureHalfFloatLinearFiltering: boolean;
  31081. /** Defines if rendering to half float textures is supported */
  31082. textureHalfFloatRender: boolean;
  31083. /** Defines if textureLOD shader command is supported */
  31084. textureLOD: boolean;
  31085. /** Defines if draw buffers extension is supported */
  31086. drawBuffersExtension: boolean;
  31087. /** Defines if depth textures are supported */
  31088. depthTextureExtension: boolean;
  31089. /** Defines if float color buffer are supported */
  31090. colorBufferFloat: boolean;
  31091. /** Gets disjoint timer query extension (null if not supported) */
  31092. timerQuery?: EXT_disjoint_timer_query;
  31093. /** Defines if timestamp can be used with timer query */
  31094. canUseTimestampForTimerQuery: boolean;
  31095. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31096. multiview?: any;
  31097. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31098. oculusMultiview?: any;
  31099. /** Function used to let the system compiles shaders in background */
  31100. parallelShaderCompile?: {
  31101. COMPLETION_STATUS_KHR: number;
  31102. };
  31103. /** Max number of texture samples for MSAA */
  31104. maxMSAASamples: number;
  31105. /** Defines if the blend min max extension is supported */
  31106. blendMinMax: boolean;
  31107. }
  31108. }
  31109. declare module BABYLON {
  31110. /**
  31111. * @hidden
  31112. **/
  31113. export class DepthCullingState {
  31114. private _isDepthTestDirty;
  31115. private _isDepthMaskDirty;
  31116. private _isDepthFuncDirty;
  31117. private _isCullFaceDirty;
  31118. private _isCullDirty;
  31119. private _isZOffsetDirty;
  31120. private _isFrontFaceDirty;
  31121. private _depthTest;
  31122. private _depthMask;
  31123. private _depthFunc;
  31124. private _cull;
  31125. private _cullFace;
  31126. private _zOffset;
  31127. private _frontFace;
  31128. /**
  31129. * Initializes the state.
  31130. */
  31131. constructor();
  31132. get isDirty(): boolean;
  31133. get zOffset(): number;
  31134. set zOffset(value: number);
  31135. get cullFace(): Nullable<number>;
  31136. set cullFace(value: Nullable<number>);
  31137. get cull(): Nullable<boolean>;
  31138. set cull(value: Nullable<boolean>);
  31139. get depthFunc(): Nullable<number>;
  31140. set depthFunc(value: Nullable<number>);
  31141. get depthMask(): boolean;
  31142. set depthMask(value: boolean);
  31143. get depthTest(): boolean;
  31144. set depthTest(value: boolean);
  31145. get frontFace(): Nullable<number>;
  31146. set frontFace(value: Nullable<number>);
  31147. reset(): void;
  31148. apply(gl: WebGLRenderingContext): void;
  31149. }
  31150. }
  31151. declare module BABYLON {
  31152. /**
  31153. * @hidden
  31154. **/
  31155. export class StencilState {
  31156. /** 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 */
  31157. static readonly ALWAYS: number;
  31158. /** Passed to stencilOperation to specify that stencil value must be kept */
  31159. static readonly KEEP: number;
  31160. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31161. static readonly REPLACE: number;
  31162. private _isStencilTestDirty;
  31163. private _isStencilMaskDirty;
  31164. private _isStencilFuncDirty;
  31165. private _isStencilOpDirty;
  31166. private _stencilTest;
  31167. private _stencilMask;
  31168. private _stencilFunc;
  31169. private _stencilFuncRef;
  31170. private _stencilFuncMask;
  31171. private _stencilOpStencilFail;
  31172. private _stencilOpDepthFail;
  31173. private _stencilOpStencilDepthPass;
  31174. get isDirty(): boolean;
  31175. get stencilFunc(): number;
  31176. set stencilFunc(value: number);
  31177. get stencilFuncRef(): number;
  31178. set stencilFuncRef(value: number);
  31179. get stencilFuncMask(): number;
  31180. set stencilFuncMask(value: number);
  31181. get stencilOpStencilFail(): number;
  31182. set stencilOpStencilFail(value: number);
  31183. get stencilOpDepthFail(): number;
  31184. set stencilOpDepthFail(value: number);
  31185. get stencilOpStencilDepthPass(): number;
  31186. set stencilOpStencilDepthPass(value: number);
  31187. get stencilMask(): number;
  31188. set stencilMask(value: number);
  31189. get stencilTest(): boolean;
  31190. set stencilTest(value: boolean);
  31191. constructor();
  31192. reset(): void;
  31193. apply(gl: WebGLRenderingContext): void;
  31194. }
  31195. }
  31196. declare module BABYLON {
  31197. /**
  31198. * @hidden
  31199. **/
  31200. export class AlphaState {
  31201. private _isAlphaBlendDirty;
  31202. private _isBlendFunctionParametersDirty;
  31203. private _isBlendEquationParametersDirty;
  31204. private _isBlendConstantsDirty;
  31205. private _alphaBlend;
  31206. private _blendFunctionParameters;
  31207. private _blendEquationParameters;
  31208. private _blendConstants;
  31209. /**
  31210. * Initializes the state.
  31211. */
  31212. constructor();
  31213. get isDirty(): boolean;
  31214. get alphaBlend(): boolean;
  31215. set alphaBlend(value: boolean);
  31216. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31217. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31218. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31219. reset(): void;
  31220. apply(gl: WebGLRenderingContext): void;
  31221. }
  31222. }
  31223. declare module BABYLON {
  31224. /** @hidden */
  31225. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31226. attributeProcessor(attribute: string): string;
  31227. varyingProcessor(varying: string, isFragment: boolean): string;
  31228. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31229. }
  31230. }
  31231. declare module BABYLON {
  31232. /**
  31233. * Interface for attribute information associated with buffer instanciation
  31234. */
  31235. export interface InstancingAttributeInfo {
  31236. /**
  31237. * Name of the GLSL attribute
  31238. * if attribute index is not specified, this is used to retrieve the index from the effect
  31239. */
  31240. attributeName: string;
  31241. /**
  31242. * Index/offset of the attribute in the vertex shader
  31243. * if not specified, this will be computes from the name.
  31244. */
  31245. index?: number;
  31246. /**
  31247. * size of the attribute, 1, 2, 3 or 4
  31248. */
  31249. attributeSize: number;
  31250. /**
  31251. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31252. */
  31253. offset: number;
  31254. /**
  31255. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31256. * default to 1
  31257. */
  31258. divisor?: number;
  31259. /**
  31260. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31261. * default is FLOAT
  31262. */
  31263. attributeType?: number;
  31264. /**
  31265. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31266. */
  31267. normalized?: boolean;
  31268. }
  31269. }
  31270. declare module BABYLON {
  31271. interface ThinEngine {
  31272. /**
  31273. * Update a video texture
  31274. * @param texture defines the texture to update
  31275. * @param video defines the video element to use
  31276. * @param invertY defines if data must be stored with Y axis inverted
  31277. */
  31278. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31279. }
  31280. }
  31281. declare module BABYLON {
  31282. /**
  31283. * Settings for finer control over video usage
  31284. */
  31285. export interface VideoTextureSettings {
  31286. /**
  31287. * Applies `autoplay` to video, if specified
  31288. */
  31289. autoPlay?: boolean;
  31290. /**
  31291. * Applies `loop` to video, if specified
  31292. */
  31293. loop?: boolean;
  31294. /**
  31295. * Automatically updates internal texture from video at every frame in the render loop
  31296. */
  31297. autoUpdateTexture: boolean;
  31298. /**
  31299. * Image src displayed during the video loading or until the user interacts with the video.
  31300. */
  31301. poster?: string;
  31302. }
  31303. /**
  31304. * If you want to display a video in your scene, this is the special texture for that.
  31305. * This special texture works similar to other textures, with the exception of a few parameters.
  31306. * @see https://doc.babylonjs.com/how_to/video_texture
  31307. */
  31308. export class VideoTexture extends Texture {
  31309. /**
  31310. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31311. */
  31312. readonly autoUpdateTexture: boolean;
  31313. /**
  31314. * The video instance used by the texture internally
  31315. */
  31316. readonly video: HTMLVideoElement;
  31317. private _onUserActionRequestedObservable;
  31318. /**
  31319. * Event triggerd when a dom action is required by the user to play the video.
  31320. * This happens due to recent changes in browser policies preventing video to auto start.
  31321. */
  31322. get onUserActionRequestedObservable(): Observable<Texture>;
  31323. private _generateMipMaps;
  31324. private _engine;
  31325. private _stillImageCaptured;
  31326. private _displayingPosterTexture;
  31327. private _settings;
  31328. private _createInternalTextureOnEvent;
  31329. private _frameId;
  31330. private _currentSrc;
  31331. /**
  31332. * Creates a video texture.
  31333. * If you want to display a video in your scene, this is the special texture for that.
  31334. * This special texture works similar to other textures, with the exception of a few parameters.
  31335. * @see https://doc.babylonjs.com/how_to/video_texture
  31336. * @param name optional name, will detect from video source, if not defined
  31337. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31338. * @param scene is obviously the current scene.
  31339. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31340. * @param invertY is false by default but can be used to invert video on Y axis
  31341. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31342. * @param settings allows finer control over video usage
  31343. */
  31344. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31345. private _getName;
  31346. private _getVideo;
  31347. private _createInternalTexture;
  31348. private reset;
  31349. /**
  31350. * @hidden Internal method to initiate `update`.
  31351. */
  31352. _rebuild(): void;
  31353. /**
  31354. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31355. */
  31356. update(): void;
  31357. /**
  31358. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31359. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31360. */
  31361. updateTexture(isVisible: boolean): void;
  31362. protected _updateInternalTexture: () => void;
  31363. /**
  31364. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31365. * @param url New url.
  31366. */
  31367. updateURL(url: string): void;
  31368. /**
  31369. * Clones the texture.
  31370. * @returns the cloned texture
  31371. */
  31372. clone(): VideoTexture;
  31373. /**
  31374. * Dispose the texture and release its associated resources.
  31375. */
  31376. dispose(): void;
  31377. /**
  31378. * Creates a video texture straight from a stream.
  31379. * @param scene Define the scene the texture should be created in
  31380. * @param stream Define the stream the texture should be created from
  31381. * @returns The created video texture as a promise
  31382. */
  31383. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31384. /**
  31385. * Creates a video texture straight from your WebCam video feed.
  31386. * @param scene Define the scene the texture should be created in
  31387. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31388. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31389. * @returns The created video texture as a promise
  31390. */
  31391. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31392. minWidth: number;
  31393. maxWidth: number;
  31394. minHeight: number;
  31395. maxHeight: number;
  31396. deviceId: string;
  31397. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31398. /**
  31399. * Creates a video texture straight from your WebCam video feed.
  31400. * @param scene Define the scene the texture should be created in
  31401. * @param onReady Define a callback to triggered once the texture will be ready
  31402. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31403. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31404. */
  31405. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31406. minWidth: number;
  31407. maxWidth: number;
  31408. minHeight: number;
  31409. maxHeight: number;
  31410. deviceId: string;
  31411. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31412. }
  31413. }
  31414. declare module BABYLON {
  31415. /**
  31416. * Defines the interface used by objects working like Scene
  31417. * @hidden
  31418. */
  31419. export interface ISceneLike {
  31420. _addPendingData(data: any): void;
  31421. _removePendingData(data: any): void;
  31422. offlineProvider: IOfflineProvider;
  31423. }
  31424. /** Interface defining initialization parameters for Engine class */
  31425. export interface EngineOptions extends WebGLContextAttributes {
  31426. /**
  31427. * Defines if the engine should no exceed a specified device ratio
  31428. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31429. */
  31430. limitDeviceRatio?: number;
  31431. /**
  31432. * Defines if webvr should be enabled automatically
  31433. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31434. */
  31435. autoEnableWebVR?: boolean;
  31436. /**
  31437. * Defines if webgl2 should be turned off even if supported
  31438. * @see http://doc.babylonjs.com/features/webgl2
  31439. */
  31440. disableWebGL2Support?: boolean;
  31441. /**
  31442. * Defines if webaudio should be initialized as well
  31443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31444. */
  31445. audioEngine?: boolean;
  31446. /**
  31447. * Defines if animations should run using a deterministic lock step
  31448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31449. */
  31450. deterministicLockstep?: boolean;
  31451. /** Defines the maximum steps to use with deterministic lock step mode */
  31452. lockstepMaxSteps?: number;
  31453. /** Defines the seconds between each deterministic lock step */
  31454. timeStep?: number;
  31455. /**
  31456. * Defines that engine should ignore context lost events
  31457. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31458. */
  31459. doNotHandleContextLost?: boolean;
  31460. /**
  31461. * Defines that engine should ignore modifying touch action attribute and style
  31462. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31463. */
  31464. doNotHandleTouchAction?: boolean;
  31465. /**
  31466. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31467. */
  31468. useHighPrecisionFloats?: boolean;
  31469. }
  31470. /**
  31471. * The base engine class (root of all engines)
  31472. */
  31473. export class ThinEngine {
  31474. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31475. static ExceptionList: ({
  31476. key: string;
  31477. capture: string;
  31478. captureConstraint: number;
  31479. targets: string[];
  31480. } | {
  31481. key: string;
  31482. capture: null;
  31483. captureConstraint: null;
  31484. targets: string[];
  31485. })[];
  31486. /** @hidden */
  31487. static _TextureLoaders: IInternalTextureLoader[];
  31488. /**
  31489. * Returns the current npm package of the sdk
  31490. */
  31491. static get NpmPackage(): string;
  31492. /**
  31493. * Returns the current version of the framework
  31494. */
  31495. static get Version(): string;
  31496. /**
  31497. * Returns a string describing the current engine
  31498. */
  31499. get description(): string;
  31500. /**
  31501. * Gets or sets the epsilon value used by collision engine
  31502. */
  31503. static CollisionsEpsilon: number;
  31504. /**
  31505. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31506. */
  31507. static get ShadersRepository(): string;
  31508. static set ShadersRepository(value: string);
  31509. /** @hidden */
  31510. _shaderProcessor: IShaderProcessor;
  31511. /**
  31512. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31513. */
  31514. forcePOTTextures: boolean;
  31515. /**
  31516. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31517. */
  31518. isFullscreen: boolean;
  31519. /**
  31520. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31521. */
  31522. cullBackFaces: boolean;
  31523. /**
  31524. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31525. */
  31526. renderEvenInBackground: boolean;
  31527. /**
  31528. * Gets or sets a boolean indicating that cache can be kept between frames
  31529. */
  31530. preventCacheWipeBetweenFrames: boolean;
  31531. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31532. validateShaderPrograms: boolean;
  31533. /**
  31534. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31535. * This can provide greater z depth for distant objects.
  31536. */
  31537. useReverseDepthBuffer: boolean;
  31538. /**
  31539. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31540. */
  31541. disableUniformBuffers: boolean;
  31542. /** @hidden */
  31543. _uniformBuffers: UniformBuffer[];
  31544. /**
  31545. * Gets a boolean indicating that the engine supports uniform buffers
  31546. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31547. */
  31548. get supportsUniformBuffers(): boolean;
  31549. /** @hidden */
  31550. _gl: WebGLRenderingContext;
  31551. /** @hidden */
  31552. _webGLVersion: number;
  31553. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31554. protected _windowIsBackground: boolean;
  31555. protected _creationOptions: EngineOptions;
  31556. protected _highPrecisionShadersAllowed: boolean;
  31557. /** @hidden */
  31558. get _shouldUseHighPrecisionShader(): boolean;
  31559. /**
  31560. * Gets a boolean indicating that only power of 2 textures are supported
  31561. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31562. */
  31563. get needPOTTextures(): boolean;
  31564. /** @hidden */
  31565. _badOS: boolean;
  31566. /** @hidden */
  31567. _badDesktopOS: boolean;
  31568. private _hardwareScalingLevel;
  31569. /** @hidden */
  31570. _caps: EngineCapabilities;
  31571. private _isStencilEnable;
  31572. private _glVersion;
  31573. private _glRenderer;
  31574. private _glVendor;
  31575. /** @hidden */
  31576. _videoTextureSupported: boolean;
  31577. protected _renderingQueueLaunched: boolean;
  31578. protected _activeRenderLoops: (() => void)[];
  31579. /**
  31580. * Observable signaled when a context lost event is raised
  31581. */
  31582. onContextLostObservable: Observable<ThinEngine>;
  31583. /**
  31584. * Observable signaled when a context restored event is raised
  31585. */
  31586. onContextRestoredObservable: Observable<ThinEngine>;
  31587. private _onContextLost;
  31588. private _onContextRestored;
  31589. protected _contextWasLost: boolean;
  31590. /** @hidden */
  31591. _doNotHandleContextLost: boolean;
  31592. /**
  31593. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31595. */
  31596. get doNotHandleContextLost(): boolean;
  31597. set doNotHandleContextLost(value: boolean);
  31598. /**
  31599. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31600. */
  31601. disableVertexArrayObjects: boolean;
  31602. /** @hidden */
  31603. protected _colorWrite: boolean;
  31604. /** @hidden */
  31605. protected _colorWriteChanged: boolean;
  31606. /** @hidden */
  31607. protected _depthCullingState: DepthCullingState;
  31608. /** @hidden */
  31609. protected _stencilState: StencilState;
  31610. /** @hidden */
  31611. _alphaState: AlphaState;
  31612. /** @hidden */
  31613. _alphaMode: number;
  31614. /** @hidden */
  31615. _alphaEquation: number;
  31616. /** @hidden */
  31617. _internalTexturesCache: InternalTexture[];
  31618. /** @hidden */
  31619. protected _activeChannel: number;
  31620. private _currentTextureChannel;
  31621. /** @hidden */
  31622. protected _boundTexturesCache: {
  31623. [key: string]: Nullable<InternalTexture>;
  31624. };
  31625. /** @hidden */
  31626. protected _currentEffect: Nullable<Effect>;
  31627. /** @hidden */
  31628. protected _currentProgram: Nullable<WebGLProgram>;
  31629. private _compiledEffects;
  31630. private _vertexAttribArraysEnabled;
  31631. /** @hidden */
  31632. protected _cachedViewport: Nullable<IViewportLike>;
  31633. private _cachedVertexArrayObject;
  31634. /** @hidden */
  31635. protected _cachedVertexBuffers: any;
  31636. /** @hidden */
  31637. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31638. /** @hidden */
  31639. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31640. /** @hidden */
  31641. _currentRenderTarget: Nullable<InternalTexture>;
  31642. private _uintIndicesCurrentlySet;
  31643. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31644. /** @hidden */
  31645. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31646. private _currentBufferPointers;
  31647. private _currentInstanceLocations;
  31648. private _currentInstanceBuffers;
  31649. private _textureUnits;
  31650. /** @hidden */
  31651. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31652. /** @hidden */
  31653. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31654. /** @hidden */
  31655. _boundRenderFunction: any;
  31656. private _vaoRecordInProgress;
  31657. private _mustWipeVertexAttributes;
  31658. private _emptyTexture;
  31659. private _emptyCubeTexture;
  31660. private _emptyTexture3D;
  31661. private _emptyTexture2DArray;
  31662. /** @hidden */
  31663. _frameHandler: number;
  31664. private _nextFreeTextureSlots;
  31665. private _maxSimultaneousTextures;
  31666. private _activeRequests;
  31667. /** @hidden */
  31668. _transformTextureUrl: Nullable<(url: string) => string>;
  31669. protected get _supportsHardwareTextureRescaling(): boolean;
  31670. private _framebufferDimensionsObject;
  31671. /**
  31672. * sets the object from which width and height will be taken from when getting render width and height
  31673. * Will fallback to the gl object
  31674. * @param dimensions the framebuffer width and height that will be used.
  31675. */
  31676. set framebufferDimensionsObject(dimensions: Nullable<{
  31677. framebufferWidth: number;
  31678. framebufferHeight: number;
  31679. }>);
  31680. /**
  31681. * Gets the current viewport
  31682. */
  31683. get currentViewport(): Nullable<IViewportLike>;
  31684. /**
  31685. * Gets the default empty texture
  31686. */
  31687. get emptyTexture(): InternalTexture;
  31688. /**
  31689. * Gets the default empty 3D texture
  31690. */
  31691. get emptyTexture3D(): InternalTexture;
  31692. /**
  31693. * Gets the default empty 2D array texture
  31694. */
  31695. get emptyTexture2DArray(): InternalTexture;
  31696. /**
  31697. * Gets the default empty cube texture
  31698. */
  31699. get emptyCubeTexture(): InternalTexture;
  31700. /**
  31701. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31702. */
  31703. readonly premultipliedAlpha: boolean;
  31704. /**
  31705. * Observable event triggered before each texture is initialized
  31706. */
  31707. onBeforeTextureInitObservable: Observable<Texture>;
  31708. /**
  31709. * Creates a new engine
  31710. * @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
  31711. * @param antialias defines enable antialiasing (default: false)
  31712. * @param options defines further options to be sent to the getContext() function
  31713. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31714. */
  31715. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31716. private _rebuildInternalTextures;
  31717. private _rebuildEffects;
  31718. /**
  31719. * Gets a boolean indicating if all created effects are ready
  31720. * @returns true if all effects are ready
  31721. */
  31722. areAllEffectsReady(): boolean;
  31723. protected _rebuildBuffers(): void;
  31724. protected _initGLContext(): void;
  31725. /**
  31726. * Gets version of the current webGL context
  31727. */
  31728. get webGLVersion(): number;
  31729. /**
  31730. * Gets a string idenfifying the name of the class
  31731. * @returns "Engine" string
  31732. */
  31733. getClassName(): string;
  31734. /**
  31735. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31736. */
  31737. get isStencilEnable(): boolean;
  31738. /** @hidden */
  31739. _prepareWorkingCanvas(): void;
  31740. /**
  31741. * Reset the texture cache to empty state
  31742. */
  31743. resetTextureCache(): void;
  31744. /**
  31745. * Gets an object containing information about the current webGL context
  31746. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31747. */
  31748. getGlInfo(): {
  31749. vendor: string;
  31750. renderer: string;
  31751. version: string;
  31752. };
  31753. /**
  31754. * Defines the hardware scaling level.
  31755. * By default the hardware scaling level is computed from the window device ratio.
  31756. * 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.
  31757. * @param level defines the level to use
  31758. */
  31759. setHardwareScalingLevel(level: number): void;
  31760. /**
  31761. * Gets the current hardware scaling level.
  31762. * By default the hardware scaling level is computed from the window device ratio.
  31763. * 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.
  31764. * @returns a number indicating the current hardware scaling level
  31765. */
  31766. getHardwareScalingLevel(): number;
  31767. /**
  31768. * Gets the list of loaded textures
  31769. * @returns an array containing all loaded textures
  31770. */
  31771. getLoadedTexturesCache(): InternalTexture[];
  31772. /**
  31773. * Gets the object containing all engine capabilities
  31774. * @returns the EngineCapabilities object
  31775. */
  31776. getCaps(): EngineCapabilities;
  31777. /**
  31778. * stop executing a render loop function and remove it from the execution array
  31779. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31780. */
  31781. stopRenderLoop(renderFunction?: () => void): void;
  31782. /** @hidden */
  31783. _renderLoop(): void;
  31784. /**
  31785. * Gets the HTML canvas attached with the current webGL context
  31786. * @returns a HTML canvas
  31787. */
  31788. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31789. /**
  31790. * Gets host window
  31791. * @returns the host window object
  31792. */
  31793. getHostWindow(): Nullable<Window>;
  31794. /**
  31795. * Gets the current render width
  31796. * @param useScreen defines if screen size must be used (or the current render target if any)
  31797. * @returns a number defining the current render width
  31798. */
  31799. getRenderWidth(useScreen?: boolean): number;
  31800. /**
  31801. * Gets the current render height
  31802. * @param useScreen defines if screen size must be used (or the current render target if any)
  31803. * @returns a number defining the current render height
  31804. */
  31805. getRenderHeight(useScreen?: boolean): number;
  31806. /**
  31807. * Can be used to override the current requestAnimationFrame requester.
  31808. * @hidden
  31809. */
  31810. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31811. /**
  31812. * Register and execute a render loop. The engine can have more than one render function
  31813. * @param renderFunction defines the function to continuously execute
  31814. */
  31815. runRenderLoop(renderFunction: () => void): void;
  31816. /**
  31817. * Clear the current render buffer or the current render target (if any is set up)
  31818. * @param color defines the color to use
  31819. * @param backBuffer defines if the back buffer must be cleared
  31820. * @param depth defines if the depth buffer must be cleared
  31821. * @param stencil defines if the stencil buffer must be cleared
  31822. */
  31823. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31824. private _viewportCached;
  31825. /** @hidden */
  31826. _viewport(x: number, y: number, width: number, height: number): void;
  31827. /**
  31828. * Set the WebGL's viewport
  31829. * @param viewport defines the viewport element to be used
  31830. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31831. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31832. */
  31833. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31834. /**
  31835. * Begin a new frame
  31836. */
  31837. beginFrame(): void;
  31838. /**
  31839. * Enf the current frame
  31840. */
  31841. endFrame(): void;
  31842. /**
  31843. * Resize the view according to the canvas' size
  31844. */
  31845. resize(): void;
  31846. /**
  31847. * Force a specific size of the canvas
  31848. * @param width defines the new canvas' width
  31849. * @param height defines the new canvas' height
  31850. */
  31851. setSize(width: number, height: number): void;
  31852. /**
  31853. * Binds the frame buffer to the specified texture.
  31854. * @param texture The texture to render to or null for the default canvas
  31855. * @param faceIndex The face of the texture to render to in case of cube texture
  31856. * @param requiredWidth The width of the target to render to
  31857. * @param requiredHeight The height of the target to render to
  31858. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31859. * @param lodLevel defines the lod level to bind to the frame buffer
  31860. * @param layer defines the 2d array index to bind to frame buffer to
  31861. */
  31862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31863. /** @hidden */
  31864. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31865. /**
  31866. * Unbind the current render target texture from the webGL context
  31867. * @param texture defines the render target texture to unbind
  31868. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31869. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31870. */
  31871. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31872. /**
  31873. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31874. */
  31875. flushFramebuffer(): void;
  31876. /**
  31877. * Unbind the current render target and bind the default framebuffer
  31878. */
  31879. restoreDefaultFramebuffer(): void;
  31880. /** @hidden */
  31881. protected _resetVertexBufferBinding(): void;
  31882. /**
  31883. * Creates a vertex buffer
  31884. * @param data the data for the vertex buffer
  31885. * @returns the new WebGL static buffer
  31886. */
  31887. createVertexBuffer(data: DataArray): DataBuffer;
  31888. private _createVertexBuffer;
  31889. /**
  31890. * Creates a dynamic vertex buffer
  31891. * @param data the data for the dynamic vertex buffer
  31892. * @returns the new WebGL dynamic buffer
  31893. */
  31894. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31895. protected _resetIndexBufferBinding(): void;
  31896. /**
  31897. * Creates a new index buffer
  31898. * @param indices defines the content of the index buffer
  31899. * @param updatable defines if the index buffer must be updatable
  31900. * @returns a new webGL buffer
  31901. */
  31902. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31903. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31904. /**
  31905. * Bind a webGL buffer to the webGL context
  31906. * @param buffer defines the buffer to bind
  31907. */
  31908. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31909. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31910. private bindBuffer;
  31911. /**
  31912. * update the bound buffer with the given data
  31913. * @param data defines the data to update
  31914. */
  31915. updateArrayBuffer(data: Float32Array): void;
  31916. private _vertexAttribPointer;
  31917. /** @hidden */
  31918. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31919. private _bindVertexBuffersAttributes;
  31920. /**
  31921. * Records a vertex array object
  31922. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31923. * @param vertexBuffers defines the list of vertex buffers to store
  31924. * @param indexBuffer defines the index buffer to store
  31925. * @param effect defines the effect to store
  31926. * @returns the new vertex array object
  31927. */
  31928. recordVertexArrayObject(vertexBuffers: {
  31929. [key: string]: VertexBuffer;
  31930. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31931. /**
  31932. * Bind a specific vertex array object
  31933. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31934. * @param vertexArrayObject defines the vertex array object to bind
  31935. * @param indexBuffer defines the index buffer to bind
  31936. */
  31937. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31938. /**
  31939. * Bind webGl buffers directly to the webGL context
  31940. * @param vertexBuffer defines the vertex buffer to bind
  31941. * @param indexBuffer defines the index buffer to bind
  31942. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31943. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31944. * @param effect defines the effect associated with the vertex buffer
  31945. */
  31946. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31947. private _unbindVertexArrayObject;
  31948. /**
  31949. * Bind a list of vertex buffers to the webGL context
  31950. * @param vertexBuffers defines the list of vertex buffers to bind
  31951. * @param indexBuffer defines the index buffer to bind
  31952. * @param effect defines the effect associated with the vertex buffers
  31953. */
  31954. bindBuffers(vertexBuffers: {
  31955. [key: string]: Nullable<VertexBuffer>;
  31956. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31957. /**
  31958. * Unbind all instance attributes
  31959. */
  31960. unbindInstanceAttributes(): void;
  31961. /**
  31962. * Release and free the memory of a vertex array object
  31963. * @param vao defines the vertex array object to delete
  31964. */
  31965. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31966. /** @hidden */
  31967. _releaseBuffer(buffer: DataBuffer): boolean;
  31968. protected _deleteBuffer(buffer: DataBuffer): void;
  31969. /**
  31970. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31971. * @param instancesBuffer defines the webGL buffer to update and bind
  31972. * @param data defines the data to store in the buffer
  31973. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31974. */
  31975. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31976. /**
  31977. * Bind the content of a webGL buffer used with instantiation
  31978. * @param instancesBuffer defines the webGL buffer to bind
  31979. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31980. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31981. */
  31982. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31983. /**
  31984. * Disable the instance attribute corresponding to the name in parameter
  31985. * @param name defines the name of the attribute to disable
  31986. */
  31987. disableInstanceAttributeByName(name: string): void;
  31988. /**
  31989. * Disable the instance attribute corresponding to the location in parameter
  31990. * @param attributeLocation defines the attribute location of the attribute to disable
  31991. */
  31992. disableInstanceAttribute(attributeLocation: number): void;
  31993. /**
  31994. * Disable the attribute corresponding to the location in parameter
  31995. * @param attributeLocation defines the attribute location of the attribute to disable
  31996. */
  31997. disableAttributeByIndex(attributeLocation: number): void;
  31998. /**
  31999. * Send a draw order
  32000. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32001. * @param indexStart defines the starting index
  32002. * @param indexCount defines the number of index to draw
  32003. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32004. */
  32005. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32006. /**
  32007. * Draw a list of points
  32008. * @param verticesStart defines the index of first vertex to draw
  32009. * @param verticesCount defines the count of vertices to draw
  32010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32011. */
  32012. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32013. /**
  32014. * Draw a list of unindexed primitives
  32015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32016. * @param verticesStart defines the index of first vertex to draw
  32017. * @param verticesCount defines the count of vertices to draw
  32018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32019. */
  32020. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32021. /**
  32022. * Draw a list of indexed primitives
  32023. * @param fillMode defines the primitive to use
  32024. * @param indexStart defines the starting index
  32025. * @param indexCount defines the number of index to draw
  32026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32027. */
  32028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32029. /**
  32030. * Draw a list of unindexed primitives
  32031. * @param fillMode defines the primitive to use
  32032. * @param verticesStart defines the index of first vertex to draw
  32033. * @param verticesCount defines the count of vertices to draw
  32034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32035. */
  32036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32037. private _drawMode;
  32038. /** @hidden */
  32039. protected _reportDrawCall(): void;
  32040. /** @hidden */
  32041. _releaseEffect(effect: Effect): void;
  32042. /** @hidden */
  32043. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32044. /**
  32045. * Create a new effect (used to store vertex/fragment shaders)
  32046. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32047. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32048. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32049. * @param samplers defines an array of string used to represent textures
  32050. * @param defines defines the string containing the defines to use to compile the shaders
  32051. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32052. * @param onCompiled defines a function to call when the effect creation is successful
  32053. * @param onError defines a function to call when the effect creation has failed
  32054. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32055. * @returns the new Effect
  32056. */
  32057. 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;
  32058. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32059. private _compileShader;
  32060. private _compileRawShader;
  32061. /** @hidden */
  32062. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32063. /**
  32064. * Directly creates a webGL program
  32065. * @param pipelineContext defines the pipeline context to attach to
  32066. * @param vertexCode defines the vertex shader code to use
  32067. * @param fragmentCode defines the fragment shader code to use
  32068. * @param context defines the webGL context to use (if not set, the current one will be used)
  32069. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32070. * @returns the new webGL program
  32071. */
  32072. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32073. /**
  32074. * Creates a webGL program
  32075. * @param pipelineContext defines the pipeline context to attach to
  32076. * @param vertexCode defines the vertex shader code to use
  32077. * @param fragmentCode defines the fragment shader code to use
  32078. * @param defines defines the string containing the defines to use to compile the shaders
  32079. * @param context defines the webGL context to use (if not set, the current one will be used)
  32080. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32081. * @returns the new webGL program
  32082. */
  32083. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32084. /**
  32085. * Creates a new pipeline context
  32086. * @returns the new pipeline
  32087. */
  32088. createPipelineContext(): IPipelineContext;
  32089. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32090. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32091. /** @hidden */
  32092. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32093. /** @hidden */
  32094. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32095. /** @hidden */
  32096. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32097. /**
  32098. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32099. * @param pipelineContext defines the pipeline context to use
  32100. * @param uniformsNames defines the list of uniform names
  32101. * @returns an array of webGL uniform locations
  32102. */
  32103. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32104. /**
  32105. * Gets the lsit of active attributes for a given webGL program
  32106. * @param pipelineContext defines the pipeline context to use
  32107. * @param attributesNames defines the list of attribute names to get
  32108. * @returns an array of indices indicating the offset of each attribute
  32109. */
  32110. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32111. /**
  32112. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32113. * @param effect defines the effect to activate
  32114. */
  32115. enableEffect(effect: Nullable<Effect>): void;
  32116. /**
  32117. * Set the value of an uniform to a number (int)
  32118. * @param uniform defines the webGL uniform location where to store the value
  32119. * @param value defines the int number to store
  32120. */
  32121. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32122. /**
  32123. * Set the value of an uniform to an array of int32
  32124. * @param uniform defines the webGL uniform location where to store the value
  32125. * @param array defines the array of int32 to store
  32126. */
  32127. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32128. /**
  32129. * Set the value of an uniform to an array of int32 (stored as vec2)
  32130. * @param uniform defines the webGL uniform location where to store the value
  32131. * @param array defines the array of int32 to store
  32132. */
  32133. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32134. /**
  32135. * Set the value of an uniform to an array of int32 (stored as vec3)
  32136. * @param uniform defines the webGL uniform location where to store the value
  32137. * @param array defines the array of int32 to store
  32138. */
  32139. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32140. /**
  32141. * Set the value of an uniform to an array of int32 (stored as vec4)
  32142. * @param uniform defines the webGL uniform location where to store the value
  32143. * @param array defines the array of int32 to store
  32144. */
  32145. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32146. /**
  32147. * Set the value of an uniform to an array of number
  32148. * @param uniform defines the webGL uniform location where to store the value
  32149. * @param array defines the array of number to store
  32150. */
  32151. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32152. /**
  32153. * Set the value of an uniform to an array of number (stored as vec2)
  32154. * @param uniform defines the webGL uniform location where to store the value
  32155. * @param array defines the array of number to store
  32156. */
  32157. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32158. /**
  32159. * Set the value of an uniform to an array of number (stored as vec3)
  32160. * @param uniform defines the webGL uniform location where to store the value
  32161. * @param array defines the array of number to store
  32162. */
  32163. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32164. /**
  32165. * Set the value of an uniform to an array of number (stored as vec4)
  32166. * @param uniform defines the webGL uniform location where to store the value
  32167. * @param array defines the array of number to store
  32168. */
  32169. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32170. /**
  32171. * Set the value of an uniform to an array of float32 (stored as matrices)
  32172. * @param uniform defines the webGL uniform location where to store the value
  32173. * @param matrices defines the array of float32 to store
  32174. */
  32175. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32176. /**
  32177. * Set the value of an uniform to a matrix (3x3)
  32178. * @param uniform defines the webGL uniform location where to store the value
  32179. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32180. */
  32181. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32182. /**
  32183. * Set the value of an uniform to a matrix (2x2)
  32184. * @param uniform defines the webGL uniform location where to store the value
  32185. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32186. */
  32187. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32188. /**
  32189. * Set the value of an uniform to a number (float)
  32190. * @param uniform defines the webGL uniform location where to store the value
  32191. * @param value defines the float number to store
  32192. */
  32193. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32194. /**
  32195. * Set the value of an uniform to a vec2
  32196. * @param uniform defines the webGL uniform location where to store the value
  32197. * @param x defines the 1st component of the value
  32198. * @param y defines the 2nd component of the value
  32199. */
  32200. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32201. /**
  32202. * Set the value of an uniform to a vec3
  32203. * @param uniform defines the webGL uniform location where to store the value
  32204. * @param x defines the 1st component of the value
  32205. * @param y defines the 2nd component of the value
  32206. * @param z defines the 3rd component of the value
  32207. */
  32208. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32209. /**
  32210. * Set the value of an uniform to a vec4
  32211. * @param uniform defines the webGL uniform location where to store the value
  32212. * @param x defines the 1st component of the value
  32213. * @param y defines the 2nd component of the value
  32214. * @param z defines the 3rd component of the value
  32215. * @param w defines the 4th component of the value
  32216. */
  32217. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32218. /**
  32219. * Apply all cached states (depth, culling, stencil and alpha)
  32220. */
  32221. applyStates(): void;
  32222. /**
  32223. * Enable or disable color writing
  32224. * @param enable defines the state to set
  32225. */
  32226. setColorWrite(enable: boolean): void;
  32227. /**
  32228. * Gets a boolean indicating if color writing is enabled
  32229. * @returns the current color writing state
  32230. */
  32231. getColorWrite(): boolean;
  32232. /**
  32233. * Gets the depth culling state manager
  32234. */
  32235. get depthCullingState(): DepthCullingState;
  32236. /**
  32237. * Gets the alpha state manager
  32238. */
  32239. get alphaState(): AlphaState;
  32240. /**
  32241. * Gets the stencil state manager
  32242. */
  32243. get stencilState(): StencilState;
  32244. /**
  32245. * Clears the list of texture accessible through engine.
  32246. * This can help preventing texture load conflict due to name collision.
  32247. */
  32248. clearInternalTexturesCache(): void;
  32249. /**
  32250. * Force the entire cache to be cleared
  32251. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32252. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32253. */
  32254. wipeCaches(bruteForce?: boolean): void;
  32255. /** @hidden */
  32256. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32257. min: number;
  32258. mag: number;
  32259. };
  32260. /** @hidden */
  32261. _createTexture(): WebGLTexture;
  32262. /**
  32263. * Usually called from Texture.ts.
  32264. * Passed information to create a WebGLTexture
  32265. * @param url defines a value which contains one of the following:
  32266. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32267. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32268. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32269. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32270. * @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)
  32271. * @param scene needed for loading to the correct scene
  32272. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32273. * @param onLoad optional callback to be called upon successful completion
  32274. * @param onError optional callback to be called upon failure
  32275. * @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
  32276. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32277. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32278. * @param forcedExtension defines the extension to use to pick the right loader
  32279. * @param mimeType defines an optional mime type
  32280. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32281. */
  32282. createTexture(url: 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>, mimeType?: string): InternalTexture;
  32283. /**
  32284. * Loads an image as an HTMLImageElement.
  32285. * @param input url string, ArrayBuffer, or Blob to load
  32286. * @param onLoad callback called when the image successfully loads
  32287. * @param onError callback called when the image fails to load
  32288. * @param offlineProvider offline provider for caching
  32289. * @param mimeType optional mime type
  32290. * @returns the HTMLImageElement of the loaded image
  32291. * @hidden
  32292. */
  32293. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32294. /**
  32295. * @hidden
  32296. */
  32297. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32298. private _unpackFlipYCached;
  32299. /**
  32300. * In case you are sharing the context with other applications, it might
  32301. * be interested to not cache the unpack flip y state to ensure a consistent
  32302. * value would be set.
  32303. */
  32304. enableUnpackFlipYCached: boolean;
  32305. /** @hidden */
  32306. _unpackFlipY(value: boolean): void;
  32307. /** @hidden */
  32308. _getUnpackAlignement(): number;
  32309. private _getTextureTarget;
  32310. /**
  32311. * Update the sampling mode of a given texture
  32312. * @param samplingMode defines the required sampling mode
  32313. * @param texture defines the texture to update
  32314. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32315. */
  32316. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32317. /**
  32318. * Update the sampling mode of a given texture
  32319. * @param texture defines the texture to update
  32320. * @param wrapU defines the texture wrap mode of the u coordinates
  32321. * @param wrapV defines the texture wrap mode of the v coordinates
  32322. * @param wrapR defines the texture wrap mode of the r coordinates
  32323. */
  32324. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32325. /** @hidden */
  32326. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32327. width: number;
  32328. height: number;
  32329. layers?: number;
  32330. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32331. /** @hidden */
  32332. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32333. /** @hidden */
  32334. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32335. /**
  32336. * Update a portion of an internal texture
  32337. * @param texture defines the texture to update
  32338. * @param imageData defines the data to store into the texture
  32339. * @param xOffset defines the x coordinates of the update rectangle
  32340. * @param yOffset defines the y coordinates of the update rectangle
  32341. * @param width defines the width of the update rectangle
  32342. * @param height defines the height of the update rectangle
  32343. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32344. * @param lod defines the lod level to update (0 by default)
  32345. */
  32346. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32347. /** @hidden */
  32348. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32353. private _getDepthStencilBuffer;
  32354. /** @hidden */
  32355. _releaseFramebufferObjects(texture: InternalTexture): void;
  32356. /** @hidden */
  32357. _releaseTexture(texture: InternalTexture): void;
  32358. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32359. protected _setProgram(program: WebGLProgram): void;
  32360. protected _boundUniforms: {
  32361. [key: number]: WebGLUniformLocation;
  32362. };
  32363. /**
  32364. * Binds an effect to the webGL context
  32365. * @param effect defines the effect to bind
  32366. */
  32367. bindSamplers(effect: Effect): void;
  32368. private _activateCurrentTexture;
  32369. /** @hidden */
  32370. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32371. /** @hidden */
  32372. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32373. /**
  32374. * Unbind all textures from the webGL context
  32375. */
  32376. unbindAllTextures(): void;
  32377. /**
  32378. * Sets a texture to the according uniform.
  32379. * @param channel The texture channel
  32380. * @param uniform The uniform to set
  32381. * @param texture The texture to apply
  32382. */
  32383. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32384. private _bindSamplerUniformToChannel;
  32385. private _getTextureWrapMode;
  32386. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32387. /**
  32388. * Sets an array of texture to the webGL context
  32389. * @param channel defines the channel where the texture array must be set
  32390. * @param uniform defines the associated uniform location
  32391. * @param textures defines the array of textures to bind
  32392. */
  32393. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32394. /** @hidden */
  32395. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32396. private _setTextureParameterFloat;
  32397. private _setTextureParameterInteger;
  32398. /**
  32399. * Unbind all vertex attributes from the webGL context
  32400. */
  32401. unbindAllAttributes(): void;
  32402. /**
  32403. * 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
  32404. */
  32405. releaseEffects(): void;
  32406. /**
  32407. * Dispose and release all associated resources
  32408. */
  32409. dispose(): void;
  32410. /**
  32411. * Attach a new callback raised when context lost event is fired
  32412. * @param callback defines the callback to call
  32413. */
  32414. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32415. /**
  32416. * Attach a new callback raised when context restored event is fired
  32417. * @param callback defines the callback to call
  32418. */
  32419. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32420. /**
  32421. * Get the current error code of the webGL context
  32422. * @returns the error code
  32423. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32424. */
  32425. getError(): number;
  32426. private _canRenderToFloatFramebuffer;
  32427. private _canRenderToHalfFloatFramebuffer;
  32428. private _canRenderToFramebuffer;
  32429. /** @hidden */
  32430. _getWebGLTextureType(type: number): number;
  32431. /** @hidden */
  32432. _getInternalFormat(format: number): number;
  32433. /** @hidden */
  32434. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32435. /** @hidden */
  32436. _getRGBAMultiSampleBufferFormat(type: number): number;
  32437. /** @hidden */
  32438. _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;
  32439. /**
  32440. * Loads a file from a url
  32441. * @param url url to load
  32442. * @param onSuccess callback called when the file successfully loads
  32443. * @param onProgress callback called while file is loading (if the server supports this mode)
  32444. * @param offlineProvider defines the offline provider for caching
  32445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32446. * @param onError callback called when the file fails to load
  32447. * @returns a file request object
  32448. * @hidden
  32449. */
  32450. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32451. /**
  32452. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32453. * @param x defines the x coordinate of the rectangle where pixels must be read
  32454. * @param y defines the y coordinate of the rectangle where pixels must be read
  32455. * @param width defines the width of the rectangle where pixels must be read
  32456. * @param height defines the height of the rectangle where pixels must be read
  32457. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32458. * @returns a Uint8Array containing RGBA colors
  32459. */
  32460. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32461. private static _isSupported;
  32462. /**
  32463. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32464. * @returns true if the engine can be created
  32465. * @ignorenaming
  32466. */
  32467. static isSupported(): boolean;
  32468. /**
  32469. * Find the next highest power of two.
  32470. * @param x Number to start search from.
  32471. * @return Next highest power of two.
  32472. */
  32473. static CeilingPOT(x: number): number;
  32474. /**
  32475. * Find the next lowest power of two.
  32476. * @param x Number to start search from.
  32477. * @return Next lowest power of two.
  32478. */
  32479. static FloorPOT(x: number): number;
  32480. /**
  32481. * Find the nearest power of two.
  32482. * @param x Number to start search from.
  32483. * @return Next nearest power of two.
  32484. */
  32485. static NearestPOT(x: number): number;
  32486. /**
  32487. * Get the closest exponent of two
  32488. * @param value defines the value to approximate
  32489. * @param max defines the maximum value to return
  32490. * @param mode defines how to define the closest value
  32491. * @returns closest exponent of two of the given value
  32492. */
  32493. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32494. /**
  32495. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32496. * @param func - the function to be called
  32497. * @param requester - the object that will request the next frame. Falls back to window.
  32498. * @returns frame number
  32499. */
  32500. static QueueNewFrame(func: () => void, requester?: any): number;
  32501. /**
  32502. * Gets host document
  32503. * @returns the host document object
  32504. */
  32505. getHostDocument(): Nullable<Document>;
  32506. }
  32507. }
  32508. declare module BABYLON {
  32509. /**
  32510. * Class representing spherical harmonics coefficients to the 3rd degree
  32511. */
  32512. export class SphericalHarmonics {
  32513. /**
  32514. * Defines whether or not the harmonics have been prescaled for rendering.
  32515. */
  32516. preScaled: boolean;
  32517. /**
  32518. * The l0,0 coefficients of the spherical harmonics
  32519. */
  32520. l00: Vector3;
  32521. /**
  32522. * The l1,-1 coefficients of the spherical harmonics
  32523. */
  32524. l1_1: Vector3;
  32525. /**
  32526. * The l1,0 coefficients of the spherical harmonics
  32527. */
  32528. l10: Vector3;
  32529. /**
  32530. * The l1,1 coefficients of the spherical harmonics
  32531. */
  32532. l11: Vector3;
  32533. /**
  32534. * The l2,-2 coefficients of the spherical harmonics
  32535. */
  32536. l2_2: Vector3;
  32537. /**
  32538. * The l2,-1 coefficients of the spherical harmonics
  32539. */
  32540. l2_1: Vector3;
  32541. /**
  32542. * The l2,0 coefficients of the spherical harmonics
  32543. */
  32544. l20: Vector3;
  32545. /**
  32546. * The l2,1 coefficients of the spherical harmonics
  32547. */
  32548. l21: Vector3;
  32549. /**
  32550. * The l2,2 coefficients of the spherical harmonics
  32551. */
  32552. l22: Vector3;
  32553. /**
  32554. * Adds a light to the spherical harmonics
  32555. * @param direction the direction of the light
  32556. * @param color the color of the light
  32557. * @param deltaSolidAngle the delta solid angle of the light
  32558. */
  32559. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32560. /**
  32561. * Scales the spherical harmonics by the given amount
  32562. * @param scale the amount to scale
  32563. */
  32564. scaleInPlace(scale: number): void;
  32565. /**
  32566. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32567. *
  32568. * ```
  32569. * E_lm = A_l * L_lm
  32570. * ```
  32571. *
  32572. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32573. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32574. * the scaling factors are given in equation 9.
  32575. */
  32576. convertIncidentRadianceToIrradiance(): void;
  32577. /**
  32578. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32579. *
  32580. * ```
  32581. * L = (1/pi) * E * rho
  32582. * ```
  32583. *
  32584. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32585. */
  32586. convertIrradianceToLambertianRadiance(): void;
  32587. /**
  32588. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32589. * required operations at run time.
  32590. *
  32591. * This is simply done by scaling back the SH with Ylm constants parameter.
  32592. * The trigonometric part being applied by the shader at run time.
  32593. */
  32594. preScaleForRendering(): void;
  32595. /**
  32596. * Constructs a spherical harmonics from an array.
  32597. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32598. * @returns the spherical harmonics
  32599. */
  32600. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32601. /**
  32602. * Gets the spherical harmonics from polynomial
  32603. * @param polynomial the spherical polynomial
  32604. * @returns the spherical harmonics
  32605. */
  32606. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32607. }
  32608. /**
  32609. * Class representing spherical polynomial coefficients to the 3rd degree
  32610. */
  32611. export class SphericalPolynomial {
  32612. private _harmonics;
  32613. /**
  32614. * The spherical harmonics used to create the polynomials.
  32615. */
  32616. get preScaledHarmonics(): SphericalHarmonics;
  32617. /**
  32618. * The x coefficients of the spherical polynomial
  32619. */
  32620. x: Vector3;
  32621. /**
  32622. * The y coefficients of the spherical polynomial
  32623. */
  32624. y: Vector3;
  32625. /**
  32626. * The z coefficients of the spherical polynomial
  32627. */
  32628. z: Vector3;
  32629. /**
  32630. * The xx coefficients of the spherical polynomial
  32631. */
  32632. xx: Vector3;
  32633. /**
  32634. * The yy coefficients of the spherical polynomial
  32635. */
  32636. yy: Vector3;
  32637. /**
  32638. * The zz coefficients of the spherical polynomial
  32639. */
  32640. zz: Vector3;
  32641. /**
  32642. * The xy coefficients of the spherical polynomial
  32643. */
  32644. xy: Vector3;
  32645. /**
  32646. * The yz coefficients of the spherical polynomial
  32647. */
  32648. yz: Vector3;
  32649. /**
  32650. * The zx coefficients of the spherical polynomial
  32651. */
  32652. zx: Vector3;
  32653. /**
  32654. * Adds an ambient color to the spherical polynomial
  32655. * @param color the color to add
  32656. */
  32657. addAmbient(color: Color3): void;
  32658. /**
  32659. * Scales the spherical polynomial by the given amount
  32660. * @param scale the amount to scale
  32661. */
  32662. scaleInPlace(scale: number): void;
  32663. /**
  32664. * Gets the spherical polynomial from harmonics
  32665. * @param harmonics the spherical harmonics
  32666. * @returns the spherical polynomial
  32667. */
  32668. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32669. /**
  32670. * Constructs a spherical polynomial from an array.
  32671. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32672. * @returns the spherical polynomial
  32673. */
  32674. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32675. }
  32676. }
  32677. declare module BABYLON {
  32678. /**
  32679. * Defines the source of the internal texture
  32680. */
  32681. export enum InternalTextureSource {
  32682. /**
  32683. * The source of the texture data is unknown
  32684. */
  32685. Unknown = 0,
  32686. /**
  32687. * Texture data comes from an URL
  32688. */
  32689. Url = 1,
  32690. /**
  32691. * Texture data is only used for temporary storage
  32692. */
  32693. Temp = 2,
  32694. /**
  32695. * Texture data comes from raw data (ArrayBuffer)
  32696. */
  32697. Raw = 3,
  32698. /**
  32699. * Texture content is dynamic (video or dynamic texture)
  32700. */
  32701. Dynamic = 4,
  32702. /**
  32703. * Texture content is generated by rendering to it
  32704. */
  32705. RenderTarget = 5,
  32706. /**
  32707. * Texture content is part of a multi render target process
  32708. */
  32709. MultiRenderTarget = 6,
  32710. /**
  32711. * Texture data comes from a cube data file
  32712. */
  32713. Cube = 7,
  32714. /**
  32715. * Texture data comes from a raw cube data
  32716. */
  32717. CubeRaw = 8,
  32718. /**
  32719. * Texture data come from a prefiltered cube data file
  32720. */
  32721. CubePrefiltered = 9,
  32722. /**
  32723. * Texture content is raw 3D data
  32724. */
  32725. Raw3D = 10,
  32726. /**
  32727. * Texture content is raw 2D array data
  32728. */
  32729. Raw2DArray = 11,
  32730. /**
  32731. * Texture content is a depth texture
  32732. */
  32733. Depth = 12,
  32734. /**
  32735. * Texture data comes from a raw cube data encoded with RGBD
  32736. */
  32737. CubeRawRGBD = 13
  32738. }
  32739. /**
  32740. * Class used to store data associated with WebGL texture data for the engine
  32741. * This class should not be used directly
  32742. */
  32743. export class InternalTexture {
  32744. /** @hidden */
  32745. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32746. /**
  32747. * Defines if the texture is ready
  32748. */
  32749. isReady: boolean;
  32750. /**
  32751. * Defines if the texture is a cube texture
  32752. */
  32753. isCube: boolean;
  32754. /**
  32755. * Defines if the texture contains 3D data
  32756. */
  32757. is3D: boolean;
  32758. /**
  32759. * Defines if the texture contains 2D array data
  32760. */
  32761. is2DArray: boolean;
  32762. /**
  32763. * Defines if the texture contains multiview data
  32764. */
  32765. isMultiview: boolean;
  32766. /**
  32767. * Gets the URL used to load this texture
  32768. */
  32769. url: string;
  32770. /**
  32771. * Gets the sampling mode of the texture
  32772. */
  32773. samplingMode: number;
  32774. /**
  32775. * Gets a boolean indicating if the texture needs mipmaps generation
  32776. */
  32777. generateMipMaps: boolean;
  32778. /**
  32779. * Gets the number of samples used by the texture (WebGL2+ only)
  32780. */
  32781. samples: number;
  32782. /**
  32783. * Gets the type of the texture (int, float...)
  32784. */
  32785. type: number;
  32786. /**
  32787. * Gets the format of the texture (RGB, RGBA...)
  32788. */
  32789. format: number;
  32790. /**
  32791. * Observable called when the texture is loaded
  32792. */
  32793. onLoadedObservable: Observable<InternalTexture>;
  32794. /**
  32795. * Gets the width of the texture
  32796. */
  32797. width: number;
  32798. /**
  32799. * Gets the height of the texture
  32800. */
  32801. height: number;
  32802. /**
  32803. * Gets the depth of the texture
  32804. */
  32805. depth: number;
  32806. /**
  32807. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32808. */
  32809. baseWidth: number;
  32810. /**
  32811. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32812. */
  32813. baseHeight: number;
  32814. /**
  32815. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32816. */
  32817. baseDepth: number;
  32818. /**
  32819. * Gets a boolean indicating if the texture is inverted on Y axis
  32820. */
  32821. invertY: boolean;
  32822. /** @hidden */
  32823. _invertVScale: boolean;
  32824. /** @hidden */
  32825. _associatedChannel: number;
  32826. /** @hidden */
  32827. _source: InternalTextureSource;
  32828. /** @hidden */
  32829. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32830. /** @hidden */
  32831. _bufferView: Nullable<ArrayBufferView>;
  32832. /** @hidden */
  32833. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32834. /** @hidden */
  32835. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32836. /** @hidden */
  32837. _size: number;
  32838. /** @hidden */
  32839. _extension: string;
  32840. /** @hidden */
  32841. _files: Nullable<string[]>;
  32842. /** @hidden */
  32843. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32844. /** @hidden */
  32845. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32846. /** @hidden */
  32847. _framebuffer: Nullable<WebGLFramebuffer>;
  32848. /** @hidden */
  32849. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32850. /** @hidden */
  32851. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32852. /** @hidden */
  32853. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32854. /** @hidden */
  32855. _attachments: Nullable<number[]>;
  32856. /** @hidden */
  32857. _cachedCoordinatesMode: Nullable<number>;
  32858. /** @hidden */
  32859. _cachedWrapU: Nullable<number>;
  32860. /** @hidden */
  32861. _cachedWrapV: Nullable<number>;
  32862. /** @hidden */
  32863. _cachedWrapR: Nullable<number>;
  32864. /** @hidden */
  32865. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32866. /** @hidden */
  32867. _isDisabled: boolean;
  32868. /** @hidden */
  32869. _compression: Nullable<string>;
  32870. /** @hidden */
  32871. _generateStencilBuffer: boolean;
  32872. /** @hidden */
  32873. _generateDepthBuffer: boolean;
  32874. /** @hidden */
  32875. _comparisonFunction: number;
  32876. /** @hidden */
  32877. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32878. /** @hidden */
  32879. _lodGenerationScale: number;
  32880. /** @hidden */
  32881. _lodGenerationOffset: number;
  32882. /** @hidden */
  32883. _depthStencilTexture: Nullable<InternalTexture>;
  32884. /** @hidden */
  32885. _colorTextureArray: Nullable<WebGLTexture>;
  32886. /** @hidden */
  32887. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32888. /** @hidden */
  32889. _lodTextureHigh: Nullable<BaseTexture>;
  32890. /** @hidden */
  32891. _lodTextureMid: Nullable<BaseTexture>;
  32892. /** @hidden */
  32893. _lodTextureLow: Nullable<BaseTexture>;
  32894. /** @hidden */
  32895. _isRGBD: boolean;
  32896. /** @hidden */
  32897. _linearSpecularLOD: boolean;
  32898. /** @hidden */
  32899. _irradianceTexture: Nullable<BaseTexture>;
  32900. /** @hidden */
  32901. _webGLTexture: Nullable<WebGLTexture>;
  32902. /** @hidden */
  32903. _references: number;
  32904. private _engine;
  32905. /**
  32906. * Gets the Engine the texture belongs to.
  32907. * @returns The babylon engine
  32908. */
  32909. getEngine(): ThinEngine;
  32910. /**
  32911. * Gets the data source type of the texture
  32912. */
  32913. get source(): InternalTextureSource;
  32914. /**
  32915. * Creates a new InternalTexture
  32916. * @param engine defines the engine to use
  32917. * @param source defines the type of data that will be used
  32918. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32919. */
  32920. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32921. /**
  32922. * Increments the number of references (ie. the number of Texture that point to it)
  32923. */
  32924. incrementReferences(): void;
  32925. /**
  32926. * Change the size of the texture (not the size of the content)
  32927. * @param width defines the new width
  32928. * @param height defines the new height
  32929. * @param depth defines the new depth (1 by default)
  32930. */
  32931. updateSize(width: int, height: int, depth?: int): void;
  32932. /** @hidden */
  32933. _rebuild(): void;
  32934. /** @hidden */
  32935. _swapAndDie(target: InternalTexture): void;
  32936. /**
  32937. * Dispose the current allocated resources
  32938. */
  32939. dispose(): void;
  32940. }
  32941. }
  32942. declare module BABYLON {
  32943. /**
  32944. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32946. */
  32947. export class Analyser {
  32948. /**
  32949. * Gets or sets the smoothing
  32950. * @ignorenaming
  32951. */
  32952. SMOOTHING: number;
  32953. /**
  32954. * Gets or sets the FFT table size
  32955. * @ignorenaming
  32956. */
  32957. FFT_SIZE: number;
  32958. /**
  32959. * Gets or sets the bar graph amplitude
  32960. * @ignorenaming
  32961. */
  32962. BARGRAPHAMPLITUDE: number;
  32963. /**
  32964. * Gets or sets the position of the debug canvas
  32965. * @ignorenaming
  32966. */
  32967. DEBUGCANVASPOS: {
  32968. x: number;
  32969. y: number;
  32970. };
  32971. /**
  32972. * Gets or sets the debug canvas size
  32973. * @ignorenaming
  32974. */
  32975. DEBUGCANVASSIZE: {
  32976. width: number;
  32977. height: number;
  32978. };
  32979. private _byteFreqs;
  32980. private _byteTime;
  32981. private _floatFreqs;
  32982. private _webAudioAnalyser;
  32983. private _debugCanvas;
  32984. private _debugCanvasContext;
  32985. private _scene;
  32986. private _registerFunc;
  32987. private _audioEngine;
  32988. /**
  32989. * Creates a new analyser
  32990. * @param scene defines hosting scene
  32991. */
  32992. constructor(scene: Scene);
  32993. /**
  32994. * Get the number of data values you will have to play with for the visualization
  32995. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32996. * @returns a number
  32997. */
  32998. getFrequencyBinCount(): number;
  32999. /**
  33000. * Gets the current frequency data as a byte array
  33001. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33002. * @returns a Uint8Array
  33003. */
  33004. getByteFrequencyData(): Uint8Array;
  33005. /**
  33006. * Gets the current waveform as a byte array
  33007. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33008. * @returns a Uint8Array
  33009. */
  33010. getByteTimeDomainData(): Uint8Array;
  33011. /**
  33012. * Gets the current frequency data as a float array
  33013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33014. * @returns a Float32Array
  33015. */
  33016. getFloatFrequencyData(): Float32Array;
  33017. /**
  33018. * Renders the debug canvas
  33019. */
  33020. drawDebugCanvas(): void;
  33021. /**
  33022. * Stops rendering the debug canvas and removes it
  33023. */
  33024. stopDebugCanvas(): void;
  33025. /**
  33026. * Connects two audio nodes
  33027. * @param inputAudioNode defines first node to connect
  33028. * @param outputAudioNode defines second node to connect
  33029. */
  33030. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33031. /**
  33032. * Releases all associated resources
  33033. */
  33034. dispose(): void;
  33035. }
  33036. }
  33037. declare module BABYLON {
  33038. /**
  33039. * This represents an audio engine and it is responsible
  33040. * to play, synchronize and analyse sounds throughout the application.
  33041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33042. */
  33043. export interface IAudioEngine extends IDisposable {
  33044. /**
  33045. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33046. */
  33047. readonly canUseWebAudio: boolean;
  33048. /**
  33049. * Gets the current AudioContext if available.
  33050. */
  33051. readonly audioContext: Nullable<AudioContext>;
  33052. /**
  33053. * The master gain node defines the global audio volume of your audio engine.
  33054. */
  33055. readonly masterGain: GainNode;
  33056. /**
  33057. * Gets whether or not mp3 are supported by your browser.
  33058. */
  33059. readonly isMP3supported: boolean;
  33060. /**
  33061. * Gets whether or not ogg are supported by your browser.
  33062. */
  33063. readonly isOGGsupported: boolean;
  33064. /**
  33065. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33066. * @ignoreNaming
  33067. */
  33068. WarnedWebAudioUnsupported: boolean;
  33069. /**
  33070. * Defines if the audio engine relies on a custom unlocked button.
  33071. * In this case, the embedded button will not be displayed.
  33072. */
  33073. useCustomUnlockedButton: boolean;
  33074. /**
  33075. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33076. */
  33077. readonly unlocked: boolean;
  33078. /**
  33079. * Event raised when audio has been unlocked on the browser.
  33080. */
  33081. onAudioUnlockedObservable: Observable<AudioEngine>;
  33082. /**
  33083. * Event raised when audio has been locked on the browser.
  33084. */
  33085. onAudioLockedObservable: Observable<AudioEngine>;
  33086. /**
  33087. * Flags the audio engine in Locked state.
  33088. * This happens due to new browser policies preventing audio to autoplay.
  33089. */
  33090. lock(): void;
  33091. /**
  33092. * Unlocks the audio engine once a user action has been done on the dom.
  33093. * This is helpful to resume play once browser policies have been satisfied.
  33094. */
  33095. unlock(): void;
  33096. /**
  33097. * Gets the global volume sets on the master gain.
  33098. * @returns the global volume if set or -1 otherwise
  33099. */
  33100. getGlobalVolume(): number;
  33101. /**
  33102. * Sets the global volume of your experience (sets on the master gain).
  33103. * @param newVolume Defines the new global volume of the application
  33104. */
  33105. setGlobalVolume(newVolume: number): void;
  33106. /**
  33107. * Connect the audio engine to an audio analyser allowing some amazing
  33108. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33110. * @param analyser The analyser to connect to the engine
  33111. */
  33112. connectToAnalyser(analyser: Analyser): void;
  33113. }
  33114. /**
  33115. * This represents the default audio engine used in babylon.
  33116. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33118. */
  33119. export class AudioEngine implements IAudioEngine {
  33120. private _audioContext;
  33121. private _audioContextInitialized;
  33122. private _muteButton;
  33123. private _hostElement;
  33124. /**
  33125. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33126. */
  33127. canUseWebAudio: boolean;
  33128. /**
  33129. * The master gain node defines the global audio volume of your audio engine.
  33130. */
  33131. masterGain: GainNode;
  33132. /**
  33133. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33134. * @ignoreNaming
  33135. */
  33136. WarnedWebAudioUnsupported: boolean;
  33137. /**
  33138. * Gets whether or not mp3 are supported by your browser.
  33139. */
  33140. isMP3supported: boolean;
  33141. /**
  33142. * Gets whether or not ogg are supported by your browser.
  33143. */
  33144. isOGGsupported: boolean;
  33145. /**
  33146. * Gets whether audio has been unlocked on the device.
  33147. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33148. * a user interaction has happened.
  33149. */
  33150. unlocked: boolean;
  33151. /**
  33152. * Defines if the audio engine relies on a custom unlocked button.
  33153. * In this case, the embedded button will not be displayed.
  33154. */
  33155. useCustomUnlockedButton: boolean;
  33156. /**
  33157. * Event raised when audio has been unlocked on the browser.
  33158. */
  33159. onAudioUnlockedObservable: Observable<AudioEngine>;
  33160. /**
  33161. * Event raised when audio has been locked on the browser.
  33162. */
  33163. onAudioLockedObservable: Observable<AudioEngine>;
  33164. /**
  33165. * Gets the current AudioContext if available.
  33166. */
  33167. get audioContext(): Nullable<AudioContext>;
  33168. private _connectedAnalyser;
  33169. /**
  33170. * Instantiates a new audio engine.
  33171. *
  33172. * There should be only one per page as some browsers restrict the number
  33173. * of audio contexts you can create.
  33174. * @param hostElement defines the host element where to display the mute icon if necessary
  33175. */
  33176. constructor(hostElement?: Nullable<HTMLElement>);
  33177. /**
  33178. * Flags the audio engine in Locked state.
  33179. * This happens due to new browser policies preventing audio to autoplay.
  33180. */
  33181. lock(): void;
  33182. /**
  33183. * Unlocks the audio engine once a user action has been done on the dom.
  33184. * This is helpful to resume play once browser policies have been satisfied.
  33185. */
  33186. unlock(): void;
  33187. private _resumeAudioContext;
  33188. private _initializeAudioContext;
  33189. private _tryToRun;
  33190. private _triggerRunningState;
  33191. private _triggerSuspendedState;
  33192. private _displayMuteButton;
  33193. private _moveButtonToTopLeft;
  33194. private _onResize;
  33195. private _hideMuteButton;
  33196. /**
  33197. * Destroy and release the resources associated with the audio ccontext.
  33198. */
  33199. dispose(): void;
  33200. /**
  33201. * Gets the global volume sets on the master gain.
  33202. * @returns the global volume if set or -1 otherwise
  33203. */
  33204. getGlobalVolume(): number;
  33205. /**
  33206. * Sets the global volume of your experience (sets on the master gain).
  33207. * @param newVolume Defines the new global volume of the application
  33208. */
  33209. setGlobalVolume(newVolume: number): void;
  33210. /**
  33211. * Connect the audio engine to an audio analyser allowing some amazing
  33212. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33214. * @param analyser The analyser to connect to the engine
  33215. */
  33216. connectToAnalyser(analyser: Analyser): void;
  33217. }
  33218. }
  33219. declare module BABYLON {
  33220. /**
  33221. * Interface used to present a loading screen while loading a scene
  33222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33223. */
  33224. export interface ILoadingScreen {
  33225. /**
  33226. * Function called to display the loading screen
  33227. */
  33228. displayLoadingUI: () => void;
  33229. /**
  33230. * Function called to hide the loading screen
  33231. */
  33232. hideLoadingUI: () => void;
  33233. /**
  33234. * Gets or sets the color to use for the background
  33235. */
  33236. loadingUIBackgroundColor: string;
  33237. /**
  33238. * Gets or sets the text to display while loading
  33239. */
  33240. loadingUIText: string;
  33241. }
  33242. /**
  33243. * Class used for the default loading screen
  33244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33245. */
  33246. export class DefaultLoadingScreen implements ILoadingScreen {
  33247. private _renderingCanvas;
  33248. private _loadingText;
  33249. private _loadingDivBackgroundColor;
  33250. private _loadingDiv;
  33251. private _loadingTextDiv;
  33252. /** Gets or sets the logo url to use for the default loading screen */
  33253. static DefaultLogoUrl: string;
  33254. /** Gets or sets the spinner url to use for the default loading screen */
  33255. static DefaultSpinnerUrl: string;
  33256. /**
  33257. * Creates a new default loading screen
  33258. * @param _renderingCanvas defines the canvas used to render the scene
  33259. * @param _loadingText defines the default text to display
  33260. * @param _loadingDivBackgroundColor defines the default background color
  33261. */
  33262. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33263. /**
  33264. * Function called to display the loading screen
  33265. */
  33266. displayLoadingUI(): void;
  33267. /**
  33268. * Function called to hide the loading screen
  33269. */
  33270. hideLoadingUI(): void;
  33271. /**
  33272. * Gets or sets the text to display while loading
  33273. */
  33274. set loadingUIText(text: string);
  33275. get loadingUIText(): string;
  33276. /**
  33277. * Gets or sets the color to use for the background
  33278. */
  33279. get loadingUIBackgroundColor(): string;
  33280. set loadingUIBackgroundColor(color: string);
  33281. private _resizeLoadingUI;
  33282. }
  33283. }
  33284. declare module BABYLON {
  33285. /**
  33286. * Interface for any object that can request an animation frame
  33287. */
  33288. export interface ICustomAnimationFrameRequester {
  33289. /**
  33290. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33291. */
  33292. renderFunction?: Function;
  33293. /**
  33294. * Called to request the next frame to render to
  33295. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33296. */
  33297. requestAnimationFrame: Function;
  33298. /**
  33299. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33300. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33301. */
  33302. requestID?: number;
  33303. }
  33304. }
  33305. declare module BABYLON {
  33306. /**
  33307. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33308. */
  33309. export class PerformanceMonitor {
  33310. private _enabled;
  33311. private _rollingFrameTime;
  33312. private _lastFrameTimeMs;
  33313. /**
  33314. * constructor
  33315. * @param frameSampleSize The number of samples required to saturate the sliding window
  33316. */
  33317. constructor(frameSampleSize?: number);
  33318. /**
  33319. * Samples current frame
  33320. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33321. */
  33322. sampleFrame(timeMs?: number): void;
  33323. /**
  33324. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33325. */
  33326. get averageFrameTime(): number;
  33327. /**
  33328. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33329. */
  33330. get averageFrameTimeVariance(): number;
  33331. /**
  33332. * Returns the frame time of the most recent frame
  33333. */
  33334. get instantaneousFrameTime(): number;
  33335. /**
  33336. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33337. */
  33338. get averageFPS(): number;
  33339. /**
  33340. * Returns the average framerate in frames per second using the most recent frame time
  33341. */
  33342. get instantaneousFPS(): number;
  33343. /**
  33344. * Returns true if enough samples have been taken to completely fill the sliding window
  33345. */
  33346. get isSaturated(): boolean;
  33347. /**
  33348. * Enables contributions to the sliding window sample set
  33349. */
  33350. enable(): void;
  33351. /**
  33352. * Disables contributions to the sliding window sample set
  33353. * Samples will not be interpolated over the disabled period
  33354. */
  33355. disable(): void;
  33356. /**
  33357. * Returns true if sampling is enabled
  33358. */
  33359. get isEnabled(): boolean;
  33360. /**
  33361. * Resets performance monitor
  33362. */
  33363. reset(): void;
  33364. }
  33365. /**
  33366. * RollingAverage
  33367. *
  33368. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33369. */
  33370. export class RollingAverage {
  33371. /**
  33372. * Current average
  33373. */
  33374. average: number;
  33375. /**
  33376. * Current variance
  33377. */
  33378. variance: number;
  33379. protected _samples: Array<number>;
  33380. protected _sampleCount: number;
  33381. protected _pos: number;
  33382. protected _m2: number;
  33383. /**
  33384. * constructor
  33385. * @param length The number of samples required to saturate the sliding window
  33386. */
  33387. constructor(length: number);
  33388. /**
  33389. * Adds a sample to the sample set
  33390. * @param v The sample value
  33391. */
  33392. add(v: number): void;
  33393. /**
  33394. * Returns previously added values or null if outside of history or outside the sliding window domain
  33395. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33396. * @return Value previously recorded with add() or null if outside of range
  33397. */
  33398. history(i: number): number;
  33399. /**
  33400. * Returns true if enough samples have been taken to completely fill the sliding window
  33401. * @return true if sample-set saturated
  33402. */
  33403. isSaturated(): boolean;
  33404. /**
  33405. * Resets the rolling average (equivalent to 0 samples taken so far)
  33406. */
  33407. reset(): void;
  33408. /**
  33409. * Wraps a value around the sample range boundaries
  33410. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33411. * @return Wrapped position in sample range
  33412. */
  33413. protected _wrapPosition(i: number): number;
  33414. }
  33415. }
  33416. declare module BABYLON {
  33417. /**
  33418. * This class is used to track a performance counter which is number based.
  33419. * The user has access to many properties which give statistics of different nature.
  33420. *
  33421. * The implementer can track two kinds of Performance Counter: time and count.
  33422. * 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.
  33423. * 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.
  33424. */
  33425. export class PerfCounter {
  33426. /**
  33427. * Gets or sets a global boolean to turn on and off all the counters
  33428. */
  33429. static Enabled: boolean;
  33430. /**
  33431. * Returns the smallest value ever
  33432. */
  33433. get min(): number;
  33434. /**
  33435. * Returns the biggest value ever
  33436. */
  33437. get max(): number;
  33438. /**
  33439. * Returns the average value since the performance counter is running
  33440. */
  33441. get average(): number;
  33442. /**
  33443. * Returns the average value of the last second the counter was monitored
  33444. */
  33445. get lastSecAverage(): number;
  33446. /**
  33447. * Returns the current value
  33448. */
  33449. get current(): number;
  33450. /**
  33451. * Gets the accumulated total
  33452. */
  33453. get total(): number;
  33454. /**
  33455. * Gets the total value count
  33456. */
  33457. get count(): number;
  33458. /**
  33459. * Creates a new counter
  33460. */
  33461. constructor();
  33462. /**
  33463. * Call this method to start monitoring a new frame.
  33464. * 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.
  33465. */
  33466. fetchNewFrame(): void;
  33467. /**
  33468. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33469. * @param newCount the count value to add to the monitored count
  33470. * @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.
  33471. */
  33472. addCount(newCount: number, fetchResult: boolean): void;
  33473. /**
  33474. * Start monitoring this performance counter
  33475. */
  33476. beginMonitoring(): void;
  33477. /**
  33478. * Compute the time lapsed since the previous beginMonitoring() call.
  33479. * @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
  33480. */
  33481. endMonitoring(newFrame?: boolean): void;
  33482. private _fetchResult;
  33483. private _startMonitoringTime;
  33484. private _min;
  33485. private _max;
  33486. private _average;
  33487. private _current;
  33488. private _totalValueCount;
  33489. private _totalAccumulated;
  33490. private _lastSecAverage;
  33491. private _lastSecAccumulated;
  33492. private _lastSecTime;
  33493. private _lastSecValueCount;
  33494. }
  33495. }
  33496. declare module BABYLON {
  33497. interface ThinEngine {
  33498. /**
  33499. * Sets alpha constants used by some alpha blending modes
  33500. * @param r defines the red component
  33501. * @param g defines the green component
  33502. * @param b defines the blue component
  33503. * @param a defines the alpha component
  33504. */
  33505. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33506. /**
  33507. * Sets the current alpha mode
  33508. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33511. */
  33512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33513. /**
  33514. * Gets the current alpha mode
  33515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33516. * @returns the current alpha mode
  33517. */
  33518. getAlphaMode(): number;
  33519. /**
  33520. * Sets the current alpha equation
  33521. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33522. */
  33523. setAlphaEquation(equation: number): void;
  33524. /**
  33525. * Gets the current alpha equation.
  33526. * @returns the current alpha equation
  33527. */
  33528. getAlphaEquation(): number;
  33529. }
  33530. }
  33531. declare module BABYLON {
  33532. /**
  33533. * Defines the interface used by display changed events
  33534. */
  33535. export interface IDisplayChangedEventArgs {
  33536. /** Gets the vrDisplay object (if any) */
  33537. vrDisplay: Nullable<any>;
  33538. /** Gets a boolean indicating if webVR is supported */
  33539. vrSupported: boolean;
  33540. }
  33541. /**
  33542. * Defines the interface used by objects containing a viewport (like a camera)
  33543. */
  33544. interface IViewportOwnerLike {
  33545. /**
  33546. * Gets or sets the viewport
  33547. */
  33548. viewport: IViewportLike;
  33549. }
  33550. /**
  33551. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33552. */
  33553. export class Engine extends ThinEngine {
  33554. /** Defines that alpha blending is disabled */
  33555. static readonly ALPHA_DISABLE: number;
  33556. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33557. static readonly ALPHA_ADD: number;
  33558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33559. static readonly ALPHA_COMBINE: number;
  33560. /** Defines that alpha blending to DEST - SRC * DEST */
  33561. static readonly ALPHA_SUBTRACT: number;
  33562. /** Defines that alpha blending to SRC * DEST */
  33563. static readonly ALPHA_MULTIPLY: number;
  33564. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33565. static readonly ALPHA_MAXIMIZED: number;
  33566. /** Defines that alpha blending to SRC + DEST */
  33567. static readonly ALPHA_ONEONE: number;
  33568. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33569. static readonly ALPHA_PREMULTIPLIED: number;
  33570. /**
  33571. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33572. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33573. */
  33574. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33575. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33576. static readonly ALPHA_INTERPOLATE: number;
  33577. /**
  33578. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33579. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33580. */
  33581. static readonly ALPHA_SCREENMODE: number;
  33582. /** Defines that the ressource is not delayed*/
  33583. static readonly DELAYLOADSTATE_NONE: number;
  33584. /** Defines that the ressource was successfully delay loaded */
  33585. static readonly DELAYLOADSTATE_LOADED: number;
  33586. /** Defines that the ressource is currently delay loading */
  33587. static readonly DELAYLOADSTATE_LOADING: number;
  33588. /** Defines that the ressource is delayed and has not started loading */
  33589. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33591. static readonly NEVER: number;
  33592. /** 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 */
  33593. static readonly ALWAYS: number;
  33594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33595. static readonly LESS: number;
  33596. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33597. static readonly EQUAL: number;
  33598. /** 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 */
  33599. static readonly LEQUAL: number;
  33600. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33601. static readonly GREATER: number;
  33602. /** 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 */
  33603. static readonly GEQUAL: number;
  33604. /** 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 */
  33605. static readonly NOTEQUAL: number;
  33606. /** Passed to stencilOperation to specify that stencil value must be kept */
  33607. static readonly KEEP: number;
  33608. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33609. static readonly REPLACE: number;
  33610. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33611. static readonly INCR: number;
  33612. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33613. static readonly DECR: number;
  33614. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33615. static readonly INVERT: number;
  33616. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33617. static readonly INCR_WRAP: number;
  33618. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33619. static readonly DECR_WRAP: number;
  33620. /** Texture is not repeating outside of 0..1 UVs */
  33621. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33622. /** Texture is repeating outside of 0..1 UVs */
  33623. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33624. /** Texture is repeating and mirrored */
  33625. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33626. /** ALPHA */
  33627. static readonly TEXTUREFORMAT_ALPHA: number;
  33628. /** LUMINANCE */
  33629. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33630. /** LUMINANCE_ALPHA */
  33631. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33632. /** RGB */
  33633. static readonly TEXTUREFORMAT_RGB: number;
  33634. /** RGBA */
  33635. static readonly TEXTUREFORMAT_RGBA: number;
  33636. /** RED */
  33637. static readonly TEXTUREFORMAT_RED: number;
  33638. /** RED (2nd reference) */
  33639. static readonly TEXTUREFORMAT_R: number;
  33640. /** RG */
  33641. static readonly TEXTUREFORMAT_RG: number;
  33642. /** RED_INTEGER */
  33643. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33644. /** RED_INTEGER (2nd reference) */
  33645. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33646. /** RG_INTEGER */
  33647. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33648. /** RGB_INTEGER */
  33649. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33650. /** RGBA_INTEGER */
  33651. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33652. /** UNSIGNED_BYTE */
  33653. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33654. /** UNSIGNED_BYTE (2nd reference) */
  33655. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33656. /** FLOAT */
  33657. static readonly TEXTURETYPE_FLOAT: number;
  33658. /** HALF_FLOAT */
  33659. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33660. /** BYTE */
  33661. static readonly TEXTURETYPE_BYTE: number;
  33662. /** SHORT */
  33663. static readonly TEXTURETYPE_SHORT: number;
  33664. /** UNSIGNED_SHORT */
  33665. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33666. /** INT */
  33667. static readonly TEXTURETYPE_INT: number;
  33668. /** UNSIGNED_INT */
  33669. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33670. /** UNSIGNED_SHORT_4_4_4_4 */
  33671. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33672. /** UNSIGNED_SHORT_5_5_5_1 */
  33673. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33674. /** UNSIGNED_SHORT_5_6_5 */
  33675. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33676. /** UNSIGNED_INT_2_10_10_10_REV */
  33677. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33678. /** UNSIGNED_INT_24_8 */
  33679. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33680. /** UNSIGNED_INT_10F_11F_11F_REV */
  33681. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33682. /** UNSIGNED_INT_5_9_9_9_REV */
  33683. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33684. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33685. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33686. /** nearest is mag = nearest and min = nearest and mip = linear */
  33687. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33689. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33690. /** Trilinear is mag = linear and min = linear and mip = linear */
  33691. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33692. /** nearest is mag = nearest and min = nearest and mip = linear */
  33693. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33694. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33695. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33696. /** Trilinear is mag = linear and min = linear and mip = linear */
  33697. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33698. /** mag = nearest and min = nearest and mip = nearest */
  33699. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33700. /** mag = nearest and min = linear and mip = nearest */
  33701. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33702. /** mag = nearest and min = linear and mip = linear */
  33703. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33704. /** mag = nearest and min = linear and mip = none */
  33705. static readonly TEXTURE_NEAREST_LINEAR: number;
  33706. /** mag = nearest and min = nearest and mip = none */
  33707. static readonly TEXTURE_NEAREST_NEAREST: number;
  33708. /** mag = linear and min = nearest and mip = nearest */
  33709. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33710. /** mag = linear and min = nearest and mip = linear */
  33711. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33712. /** mag = linear and min = linear and mip = none */
  33713. static readonly TEXTURE_LINEAR_LINEAR: number;
  33714. /** mag = linear and min = nearest and mip = none */
  33715. static readonly TEXTURE_LINEAR_NEAREST: number;
  33716. /** Explicit coordinates mode */
  33717. static readonly TEXTURE_EXPLICIT_MODE: number;
  33718. /** Spherical coordinates mode */
  33719. static readonly TEXTURE_SPHERICAL_MODE: number;
  33720. /** Planar coordinates mode */
  33721. static readonly TEXTURE_PLANAR_MODE: number;
  33722. /** Cubic coordinates mode */
  33723. static readonly TEXTURE_CUBIC_MODE: number;
  33724. /** Projection coordinates mode */
  33725. static readonly TEXTURE_PROJECTION_MODE: number;
  33726. /** Skybox coordinates mode */
  33727. static readonly TEXTURE_SKYBOX_MODE: number;
  33728. /** Inverse Cubic coordinates mode */
  33729. static readonly TEXTURE_INVCUBIC_MODE: number;
  33730. /** Equirectangular coordinates mode */
  33731. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33732. /** Equirectangular Fixed coordinates mode */
  33733. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33734. /** Equirectangular Fixed Mirrored coordinates mode */
  33735. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33736. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33737. static readonly SCALEMODE_FLOOR: number;
  33738. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33739. static readonly SCALEMODE_NEAREST: number;
  33740. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33741. static readonly SCALEMODE_CEILING: number;
  33742. /**
  33743. * Returns the current npm package of the sdk
  33744. */
  33745. static get NpmPackage(): string;
  33746. /**
  33747. * Returns the current version of the framework
  33748. */
  33749. static get Version(): string;
  33750. /** Gets the list of created engines */
  33751. static get Instances(): Engine[];
  33752. /**
  33753. * Gets the latest created engine
  33754. */
  33755. static get LastCreatedEngine(): Nullable<Engine>;
  33756. /**
  33757. * Gets the latest created scene
  33758. */
  33759. static get LastCreatedScene(): Nullable<Scene>;
  33760. /**
  33761. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33762. * @param flag defines which part of the materials must be marked as dirty
  33763. * @param predicate defines a predicate used to filter which materials should be affected
  33764. */
  33765. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33766. /**
  33767. * Method called to create the default loading screen.
  33768. * This can be overriden in your own app.
  33769. * @param canvas The rendering canvas element
  33770. * @returns The loading screen
  33771. */
  33772. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33773. /**
  33774. * Method called to create the default rescale post process on each engine.
  33775. */
  33776. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33777. /**
  33778. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33779. **/
  33780. enableOfflineSupport: boolean;
  33781. /**
  33782. * 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)
  33783. **/
  33784. disableManifestCheck: boolean;
  33785. /**
  33786. * Gets the list of created scenes
  33787. */
  33788. scenes: Scene[];
  33789. /**
  33790. * Event raised when a new scene is created
  33791. */
  33792. onNewSceneAddedObservable: Observable<Scene>;
  33793. /**
  33794. * Gets the list of created postprocesses
  33795. */
  33796. postProcesses: PostProcess[];
  33797. /**
  33798. * Gets a boolean indicating if the pointer is currently locked
  33799. */
  33800. isPointerLock: boolean;
  33801. /**
  33802. * Observable event triggered each time the rendering canvas is resized
  33803. */
  33804. onResizeObservable: Observable<Engine>;
  33805. /**
  33806. * Observable event triggered each time the canvas loses focus
  33807. */
  33808. onCanvasBlurObservable: Observable<Engine>;
  33809. /**
  33810. * Observable event triggered each time the canvas gains focus
  33811. */
  33812. onCanvasFocusObservable: Observable<Engine>;
  33813. /**
  33814. * Observable event triggered each time the canvas receives pointerout event
  33815. */
  33816. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33817. /**
  33818. * Observable raised when the engine begins a new frame
  33819. */
  33820. onBeginFrameObservable: Observable<Engine>;
  33821. /**
  33822. * If set, will be used to request the next animation frame for the render loop
  33823. */
  33824. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33825. /**
  33826. * Observable raised when the engine ends the current frame
  33827. */
  33828. onEndFrameObservable: Observable<Engine>;
  33829. /**
  33830. * Observable raised when the engine is about to compile a shader
  33831. */
  33832. onBeforeShaderCompilationObservable: Observable<Engine>;
  33833. /**
  33834. * Observable raised when the engine has jsut compiled a shader
  33835. */
  33836. onAfterShaderCompilationObservable: Observable<Engine>;
  33837. /**
  33838. * Gets the audio engine
  33839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33840. * @ignorenaming
  33841. */
  33842. static audioEngine: IAudioEngine;
  33843. /**
  33844. * Default AudioEngine factory responsible of creating the Audio Engine.
  33845. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33846. */
  33847. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33848. /**
  33849. * Default offline support factory responsible of creating a tool used to store data locally.
  33850. * By default, this will create a Database object if the workload has been embedded.
  33851. */
  33852. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33853. private _loadingScreen;
  33854. private _pointerLockRequested;
  33855. private _dummyFramebuffer;
  33856. private _rescalePostProcess;
  33857. private _deterministicLockstep;
  33858. private _lockstepMaxSteps;
  33859. private _timeStep;
  33860. protected get _supportsHardwareTextureRescaling(): boolean;
  33861. private _fps;
  33862. private _deltaTime;
  33863. /** @hidden */
  33864. _drawCalls: PerfCounter;
  33865. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33866. canvasTabIndex: number;
  33867. /**
  33868. * Turn this value on if you want to pause FPS computation when in background
  33869. */
  33870. disablePerformanceMonitorInBackground: boolean;
  33871. private _performanceMonitor;
  33872. /**
  33873. * Gets the performance monitor attached to this engine
  33874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33875. */
  33876. get performanceMonitor(): PerformanceMonitor;
  33877. private _onFocus;
  33878. private _onBlur;
  33879. private _onCanvasPointerOut;
  33880. private _onCanvasBlur;
  33881. private _onCanvasFocus;
  33882. private _onFullscreenChange;
  33883. private _onPointerLockChange;
  33884. /**
  33885. * Gets the HTML element used to attach event listeners
  33886. * @returns a HTML element
  33887. */
  33888. getInputElement(): Nullable<HTMLElement>;
  33889. /**
  33890. * Creates a new engine
  33891. * @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
  33892. * @param antialias defines enable antialiasing (default: false)
  33893. * @param options defines further options to be sent to the getContext() function
  33894. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33895. */
  33896. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33897. /**
  33898. * Gets current aspect ratio
  33899. * @param viewportOwner defines the camera to use to get the aspect ratio
  33900. * @param useScreen defines if screen size must be used (or the current render target if any)
  33901. * @returns a number defining the aspect ratio
  33902. */
  33903. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33904. /**
  33905. * Gets current screen aspect ratio
  33906. * @returns a number defining the aspect ratio
  33907. */
  33908. getScreenAspectRatio(): number;
  33909. /**
  33910. * Gets the client rect of the HTML canvas attached with the current webGL context
  33911. * @returns a client rectanglee
  33912. */
  33913. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33914. /**
  33915. * Gets the client rect of the HTML element used for events
  33916. * @returns a client rectanglee
  33917. */
  33918. getInputElementClientRect(): Nullable<ClientRect>;
  33919. /**
  33920. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33922. * @returns true if engine is in deterministic lock step mode
  33923. */
  33924. isDeterministicLockStep(): boolean;
  33925. /**
  33926. * Gets the max steps when engine is running in deterministic lock step
  33927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33928. * @returns the max steps
  33929. */
  33930. getLockstepMaxSteps(): number;
  33931. /**
  33932. * Returns the time in ms between steps when using deterministic lock step.
  33933. * @returns time step in (ms)
  33934. */
  33935. getTimeStep(): number;
  33936. /**
  33937. * Force the mipmap generation for the given render target texture
  33938. * @param texture defines the render target texture to use
  33939. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33940. */
  33941. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33942. /** States */
  33943. /**
  33944. * Set various states to the webGL context
  33945. * @param culling defines backface culling state
  33946. * @param zOffset defines the value to apply to zOffset (0 by default)
  33947. * @param force defines if states must be applied even if cache is up to date
  33948. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33949. */
  33950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33951. /**
  33952. * Set the z offset to apply to current rendering
  33953. * @param value defines the offset to apply
  33954. */
  33955. setZOffset(value: number): void;
  33956. /**
  33957. * Gets the current value of the zOffset
  33958. * @returns the current zOffset state
  33959. */
  33960. getZOffset(): number;
  33961. /**
  33962. * Enable or disable depth buffering
  33963. * @param enable defines the state to set
  33964. */
  33965. setDepthBuffer(enable: boolean): void;
  33966. /**
  33967. * Gets a boolean indicating if depth writing is enabled
  33968. * @returns the current depth writing state
  33969. */
  33970. getDepthWrite(): boolean;
  33971. /**
  33972. * Enable or disable depth writing
  33973. * @param enable defines the state to set
  33974. */
  33975. setDepthWrite(enable: boolean): void;
  33976. /**
  33977. * Gets a boolean indicating if stencil buffer is enabled
  33978. * @returns the current stencil buffer state
  33979. */
  33980. getStencilBuffer(): boolean;
  33981. /**
  33982. * Enable or disable the stencil buffer
  33983. * @param enable defines if the stencil buffer must be enabled or disabled
  33984. */
  33985. setStencilBuffer(enable: boolean): void;
  33986. /**
  33987. * Gets the current stencil mask
  33988. * @returns a number defining the new stencil mask to use
  33989. */
  33990. getStencilMask(): number;
  33991. /**
  33992. * Sets the current stencil mask
  33993. * @param mask defines the new stencil mask to use
  33994. */
  33995. setStencilMask(mask: number): void;
  33996. /**
  33997. * Gets the current stencil function
  33998. * @returns a number defining the stencil function to use
  33999. */
  34000. getStencilFunction(): number;
  34001. /**
  34002. * Gets the current stencil reference value
  34003. * @returns a number defining the stencil reference value to use
  34004. */
  34005. getStencilFunctionReference(): number;
  34006. /**
  34007. * Gets the current stencil mask
  34008. * @returns a number defining the stencil mask to use
  34009. */
  34010. getStencilFunctionMask(): number;
  34011. /**
  34012. * Sets the current stencil function
  34013. * @param stencilFunc defines the new stencil function to use
  34014. */
  34015. setStencilFunction(stencilFunc: number): void;
  34016. /**
  34017. * Sets the current stencil reference
  34018. * @param reference defines the new stencil reference to use
  34019. */
  34020. setStencilFunctionReference(reference: number): void;
  34021. /**
  34022. * Sets the current stencil mask
  34023. * @param mask defines the new stencil mask to use
  34024. */
  34025. setStencilFunctionMask(mask: number): void;
  34026. /**
  34027. * Gets the current stencil operation when stencil fails
  34028. * @returns a number defining stencil operation to use when stencil fails
  34029. */
  34030. getStencilOperationFail(): number;
  34031. /**
  34032. * Gets the current stencil operation when depth fails
  34033. * @returns a number defining stencil operation to use when depth fails
  34034. */
  34035. getStencilOperationDepthFail(): number;
  34036. /**
  34037. * Gets the current stencil operation when stencil passes
  34038. * @returns a number defining stencil operation to use when stencil passes
  34039. */
  34040. getStencilOperationPass(): number;
  34041. /**
  34042. * Sets the stencil operation to use when stencil fails
  34043. * @param operation defines the stencil operation to use when stencil fails
  34044. */
  34045. setStencilOperationFail(operation: number): void;
  34046. /**
  34047. * Sets the stencil operation to use when depth fails
  34048. * @param operation defines the stencil operation to use when depth fails
  34049. */
  34050. setStencilOperationDepthFail(operation: number): void;
  34051. /**
  34052. * Sets the stencil operation to use when stencil passes
  34053. * @param operation defines the stencil operation to use when stencil passes
  34054. */
  34055. setStencilOperationPass(operation: number): void;
  34056. /**
  34057. * Sets a boolean indicating if the dithering state is enabled or disabled
  34058. * @param value defines the dithering state
  34059. */
  34060. setDitheringState(value: boolean): void;
  34061. /**
  34062. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34063. * @param value defines the rasterizer state
  34064. */
  34065. setRasterizerState(value: boolean): void;
  34066. /**
  34067. * Gets the current depth function
  34068. * @returns a number defining the depth function
  34069. */
  34070. getDepthFunction(): Nullable<number>;
  34071. /**
  34072. * Sets the current depth function
  34073. * @param depthFunc defines the function to use
  34074. */
  34075. setDepthFunction(depthFunc: number): void;
  34076. /**
  34077. * Sets the current depth function to GREATER
  34078. */
  34079. setDepthFunctionToGreater(): void;
  34080. /**
  34081. * Sets the current depth function to GEQUAL
  34082. */
  34083. setDepthFunctionToGreaterOrEqual(): void;
  34084. /**
  34085. * Sets the current depth function to LESS
  34086. */
  34087. setDepthFunctionToLess(): void;
  34088. /**
  34089. * Sets the current depth function to LEQUAL
  34090. */
  34091. setDepthFunctionToLessOrEqual(): void;
  34092. private _cachedStencilBuffer;
  34093. private _cachedStencilFunction;
  34094. private _cachedStencilMask;
  34095. private _cachedStencilOperationPass;
  34096. private _cachedStencilOperationFail;
  34097. private _cachedStencilOperationDepthFail;
  34098. private _cachedStencilReference;
  34099. /**
  34100. * Caches the the state of the stencil buffer
  34101. */
  34102. cacheStencilState(): void;
  34103. /**
  34104. * Restores the state of the stencil buffer
  34105. */
  34106. restoreStencilState(): void;
  34107. /**
  34108. * Directly set the WebGL Viewport
  34109. * @param x defines the x coordinate of the viewport (in screen space)
  34110. * @param y defines the y coordinate of the viewport (in screen space)
  34111. * @param width defines the width of the viewport (in screen space)
  34112. * @param height defines the height of the viewport (in screen space)
  34113. * @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
  34114. */
  34115. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34116. /**
  34117. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34118. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34119. * @param y defines the y-coordinate of the corner of the clear rectangle
  34120. * @param width defines the width of the clear rectangle
  34121. * @param height defines the height of the clear rectangle
  34122. * @param clearColor defines the clear color
  34123. */
  34124. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34125. /**
  34126. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34127. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34128. * @param y defines the y-coordinate of the corner of the clear rectangle
  34129. * @param width defines the width of the clear rectangle
  34130. * @param height defines the height of the clear rectangle
  34131. */
  34132. enableScissor(x: number, y: number, width: number, height: number): void;
  34133. /**
  34134. * Disable previously set scissor test rectangle
  34135. */
  34136. disableScissor(): void;
  34137. protected _reportDrawCall(): void;
  34138. /**
  34139. * Initializes a webVR display and starts listening to display change events
  34140. * The onVRDisplayChangedObservable will be notified upon these changes
  34141. * @returns The onVRDisplayChangedObservable
  34142. */
  34143. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34144. /** @hidden */
  34145. _prepareVRComponent(): void;
  34146. /** @hidden */
  34147. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34148. /** @hidden */
  34149. _submitVRFrame(): void;
  34150. /**
  34151. * Call this function to leave webVR mode
  34152. * Will do nothing if webVR is not supported or if there is no webVR device
  34153. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34154. */
  34155. disableVR(): void;
  34156. /**
  34157. * Gets a boolean indicating that the system is in VR mode and is presenting
  34158. * @returns true if VR mode is engaged
  34159. */
  34160. isVRPresenting(): boolean;
  34161. /** @hidden */
  34162. _requestVRFrame(): void;
  34163. /** @hidden */
  34164. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34165. /**
  34166. * Gets the source code of the vertex shader associated with a specific webGL program
  34167. * @param program defines the program to use
  34168. * @returns a string containing the source code of the vertex shader associated with the program
  34169. */
  34170. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34171. /**
  34172. * Gets the source code of the fragment shader associated with a specific webGL program
  34173. * @param program defines the program to use
  34174. * @returns a string containing the source code of the fragment shader associated with the program
  34175. */
  34176. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34177. /**
  34178. * Sets a depth stencil texture from a render target to the according uniform.
  34179. * @param channel The texture channel
  34180. * @param uniform The uniform to set
  34181. * @param texture The render target texture containing the depth stencil texture to apply
  34182. */
  34183. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34184. /**
  34185. * Sets a texture to the webGL context from a postprocess
  34186. * @param channel defines the channel to use
  34187. * @param postProcess defines the source postprocess
  34188. */
  34189. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34190. /**
  34191. * Binds the output of the passed in post process to the texture channel specified
  34192. * @param channel The channel the texture should be bound to
  34193. * @param postProcess The post process which's output should be bound
  34194. */
  34195. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34196. protected _rebuildBuffers(): void;
  34197. /** @hidden */
  34198. _renderFrame(): void;
  34199. _renderLoop(): void;
  34200. /** @hidden */
  34201. _renderViews(): boolean;
  34202. /**
  34203. * Toggle full screen mode
  34204. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34205. */
  34206. switchFullscreen(requestPointerLock: boolean): void;
  34207. /**
  34208. * Enters full screen mode
  34209. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34210. */
  34211. enterFullscreen(requestPointerLock: boolean): void;
  34212. /**
  34213. * Exits full screen mode
  34214. */
  34215. exitFullscreen(): void;
  34216. /**
  34217. * Enters Pointerlock mode
  34218. */
  34219. enterPointerlock(): void;
  34220. /**
  34221. * Exits Pointerlock mode
  34222. */
  34223. exitPointerlock(): void;
  34224. /**
  34225. * Begin a new frame
  34226. */
  34227. beginFrame(): void;
  34228. /**
  34229. * Enf the current frame
  34230. */
  34231. endFrame(): void;
  34232. resize(): void;
  34233. /**
  34234. * Force a specific size of the canvas
  34235. * @param width defines the new canvas' width
  34236. * @param height defines the new canvas' height
  34237. */
  34238. setSize(width: number, height: number): void;
  34239. /**
  34240. * Updates a dynamic vertex buffer.
  34241. * @param vertexBuffer the vertex buffer to update
  34242. * @param data the data used to update the vertex buffer
  34243. * @param byteOffset the byte offset of the data
  34244. * @param byteLength the byte length of the data
  34245. */
  34246. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34247. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34248. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34249. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34250. _releaseTexture(texture: InternalTexture): void;
  34251. /**
  34252. * @hidden
  34253. * Rescales a texture
  34254. * @param source input texutre
  34255. * @param destination destination texture
  34256. * @param scene scene to use to render the resize
  34257. * @param internalFormat format to use when resizing
  34258. * @param onComplete callback to be called when resize has completed
  34259. */
  34260. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34261. /**
  34262. * Gets the current framerate
  34263. * @returns a number representing the framerate
  34264. */
  34265. getFps(): number;
  34266. /**
  34267. * Gets the time spent between current and previous frame
  34268. * @returns a number representing the delta time in ms
  34269. */
  34270. getDeltaTime(): number;
  34271. private _measureFps;
  34272. /** @hidden */
  34273. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34274. /**
  34275. * Update a dynamic index buffer
  34276. * @param indexBuffer defines the target index buffer
  34277. * @param indices defines the data to update
  34278. * @param offset defines the offset in the target index buffer where update should start
  34279. */
  34280. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34281. /**
  34282. * Updates the sample count of a render target texture
  34283. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34284. * @param texture defines the texture to update
  34285. * @param samples defines the sample count to set
  34286. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34287. */
  34288. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34289. /**
  34290. * Updates a depth texture Comparison Mode and Function.
  34291. * If the comparison Function is equal to 0, the mode will be set to none.
  34292. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34293. * @param texture The texture to set the comparison function for
  34294. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34295. */
  34296. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34297. /**
  34298. * Creates a webGL buffer to use with instanciation
  34299. * @param capacity defines the size of the buffer
  34300. * @returns the webGL buffer
  34301. */
  34302. createInstancesBuffer(capacity: number): DataBuffer;
  34303. /**
  34304. * Delete a webGL buffer used with instanciation
  34305. * @param buffer defines the webGL buffer to delete
  34306. */
  34307. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34308. private _clientWaitAsync;
  34309. /** @hidden */
  34310. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34311. /** @hidden */
  34312. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34313. dispose(): void;
  34314. private _disableTouchAction;
  34315. /**
  34316. * Display the loading screen
  34317. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34318. */
  34319. displayLoadingUI(): void;
  34320. /**
  34321. * Hide the loading screen
  34322. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34323. */
  34324. hideLoadingUI(): void;
  34325. /**
  34326. * Gets the current loading screen object
  34327. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34328. */
  34329. get loadingScreen(): ILoadingScreen;
  34330. /**
  34331. * Sets the current loading screen object
  34332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34333. */
  34334. set loadingScreen(loadingScreen: ILoadingScreen);
  34335. /**
  34336. * Sets the current loading screen text
  34337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34338. */
  34339. set loadingUIText(text: string);
  34340. /**
  34341. * Sets the current loading screen background color
  34342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34343. */
  34344. set loadingUIBackgroundColor(color: string);
  34345. /** Pointerlock and fullscreen */
  34346. /**
  34347. * Ask the browser to promote the current element to pointerlock mode
  34348. * @param element defines the DOM element to promote
  34349. */
  34350. static _RequestPointerlock(element: HTMLElement): void;
  34351. /**
  34352. * Asks the browser to exit pointerlock mode
  34353. */
  34354. static _ExitPointerlock(): void;
  34355. /**
  34356. * Ask the browser to promote the current element to fullscreen rendering mode
  34357. * @param element defines the DOM element to promote
  34358. */
  34359. static _RequestFullscreen(element: HTMLElement): void;
  34360. /**
  34361. * Asks the browser to exit fullscreen mode
  34362. */
  34363. static _ExitFullscreen(): void;
  34364. }
  34365. }
  34366. declare module BABYLON {
  34367. /**
  34368. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34369. * during the life time of the application.
  34370. */
  34371. export class EngineStore {
  34372. /** Gets the list of created engines */
  34373. static Instances: Engine[];
  34374. /** @hidden */
  34375. static _LastCreatedScene: Nullable<Scene>;
  34376. /**
  34377. * Gets the latest created engine
  34378. */
  34379. static get LastCreatedEngine(): Nullable<Engine>;
  34380. /**
  34381. * Gets the latest created scene
  34382. */
  34383. static get LastCreatedScene(): Nullable<Scene>;
  34384. /**
  34385. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34386. * @ignorenaming
  34387. */
  34388. static UseFallbackTexture: boolean;
  34389. /**
  34390. * Texture content used if a texture cannot loaded
  34391. * @ignorenaming
  34392. */
  34393. static FallbackTexture: string;
  34394. }
  34395. }
  34396. declare module BABYLON {
  34397. /**
  34398. * Helper class that provides a small promise polyfill
  34399. */
  34400. export class PromisePolyfill {
  34401. /**
  34402. * Static function used to check if the polyfill is required
  34403. * If this is the case then the function will inject the polyfill to window.Promise
  34404. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34405. */
  34406. static Apply(force?: boolean): void;
  34407. }
  34408. }
  34409. declare module BABYLON {
  34410. /**
  34411. * Interface for screenshot methods with describe argument called `size` as object with options
  34412. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34413. */
  34414. export interface IScreenshotSize {
  34415. /**
  34416. * number in pixels for canvas height
  34417. */
  34418. height?: number;
  34419. /**
  34420. * multiplier allowing render at a higher or lower resolution
  34421. * If value is defined then height and width will be ignored and taken from camera
  34422. */
  34423. precision?: number;
  34424. /**
  34425. * number in pixels for canvas width
  34426. */
  34427. width?: number;
  34428. }
  34429. }
  34430. declare module BABYLON {
  34431. interface IColor4Like {
  34432. r: float;
  34433. g: float;
  34434. b: float;
  34435. a: float;
  34436. }
  34437. /**
  34438. * Class containing a set of static utilities functions
  34439. */
  34440. export class Tools {
  34441. /**
  34442. * Gets or sets the base URL to use to load assets
  34443. */
  34444. static get BaseUrl(): string;
  34445. static set BaseUrl(value: string);
  34446. /**
  34447. * Enable/Disable Custom HTTP Request Headers globally.
  34448. * default = false
  34449. * @see CustomRequestHeaders
  34450. */
  34451. static UseCustomRequestHeaders: boolean;
  34452. /**
  34453. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34454. * i.e. when loading files, where the server/service expects an Authorization header
  34455. */
  34456. static CustomRequestHeaders: {
  34457. [key: string]: string;
  34458. };
  34459. /**
  34460. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34461. */
  34462. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34463. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34464. /**
  34465. * Default behaviour for cors in the application.
  34466. * It can be a string if the expected behavior is identical in the entire app.
  34467. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34468. */
  34469. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34470. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34471. /**
  34472. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34473. * @ignorenaming
  34474. */
  34475. static get UseFallbackTexture(): boolean;
  34476. static set UseFallbackTexture(value: boolean);
  34477. /**
  34478. * Use this object to register external classes like custom textures or material
  34479. * to allow the laoders to instantiate them
  34480. */
  34481. static get RegisteredExternalClasses(): {
  34482. [key: string]: Object;
  34483. };
  34484. static set RegisteredExternalClasses(classes: {
  34485. [key: string]: Object;
  34486. });
  34487. /**
  34488. * Texture content used if a texture cannot loaded
  34489. * @ignorenaming
  34490. */
  34491. static get fallbackTexture(): string;
  34492. static set fallbackTexture(value: string);
  34493. /**
  34494. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34495. * @param u defines the coordinate on X axis
  34496. * @param v defines the coordinate on Y axis
  34497. * @param width defines the width of the source data
  34498. * @param height defines the height of the source data
  34499. * @param pixels defines the source byte array
  34500. * @param color defines the output color
  34501. */
  34502. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34503. /**
  34504. * Interpolates between a and b via alpha
  34505. * @param a The lower value (returned when alpha = 0)
  34506. * @param b The upper value (returned when alpha = 1)
  34507. * @param alpha The interpolation-factor
  34508. * @return The mixed value
  34509. */
  34510. static Mix(a: number, b: number, alpha: number): number;
  34511. /**
  34512. * Tries to instantiate a new object from a given class name
  34513. * @param className defines the class name to instantiate
  34514. * @returns the new object or null if the system was not able to do the instantiation
  34515. */
  34516. static Instantiate(className: string): any;
  34517. /**
  34518. * Provides a slice function that will work even on IE
  34519. * @param data defines the array to slice
  34520. * @param start defines the start of the data (optional)
  34521. * @param end defines the end of the data (optional)
  34522. * @returns the new sliced array
  34523. */
  34524. static Slice<T>(data: T, start?: number, end?: number): T;
  34525. /**
  34526. * Polyfill for setImmediate
  34527. * @param action defines the action to execute after the current execution block
  34528. */
  34529. static SetImmediate(action: () => void): void;
  34530. /**
  34531. * Function indicating if a number is an exponent of 2
  34532. * @param value defines the value to test
  34533. * @returns true if the value is an exponent of 2
  34534. */
  34535. static IsExponentOfTwo(value: number): boolean;
  34536. private static _tmpFloatArray;
  34537. /**
  34538. * Returns the nearest 32-bit single precision float representation of a Number
  34539. * @param value A Number. If the parameter is of a different type, it will get converted
  34540. * to a number or to NaN if it cannot be converted
  34541. * @returns number
  34542. */
  34543. static FloatRound(value: number): number;
  34544. /**
  34545. * Extracts the filename from a path
  34546. * @param path defines the path to use
  34547. * @returns the filename
  34548. */
  34549. static GetFilename(path: string): string;
  34550. /**
  34551. * Extracts the "folder" part of a path (everything before the filename).
  34552. * @param uri The URI to extract the info from
  34553. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34554. * @returns The "folder" part of the path
  34555. */
  34556. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34557. /**
  34558. * Extracts text content from a DOM element hierarchy
  34559. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34560. */
  34561. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34562. /**
  34563. * Convert an angle in radians to degrees
  34564. * @param angle defines the angle to convert
  34565. * @returns the angle in degrees
  34566. */
  34567. static ToDegrees(angle: number): number;
  34568. /**
  34569. * Convert an angle in degrees to radians
  34570. * @param angle defines the angle to convert
  34571. * @returns the angle in radians
  34572. */
  34573. static ToRadians(angle: number): number;
  34574. /**
  34575. * Returns an array if obj is not an array
  34576. * @param obj defines the object to evaluate as an array
  34577. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34578. * @returns either obj directly if obj is an array or a new array containing obj
  34579. */
  34580. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34581. /**
  34582. * Gets the pointer prefix to use
  34583. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34584. */
  34585. static GetPointerPrefix(): string;
  34586. /**
  34587. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34588. * @param url define the url we are trying
  34589. * @param element define the dom element where to configure the cors policy
  34590. */
  34591. static SetCorsBehavior(url: string | string[], element: {
  34592. crossOrigin: string | null;
  34593. }): void;
  34594. /**
  34595. * Removes unwanted characters from an url
  34596. * @param url defines the url to clean
  34597. * @returns the cleaned url
  34598. */
  34599. static CleanUrl(url: string): string;
  34600. /**
  34601. * Gets or sets a function used to pre-process url before using them to load assets
  34602. */
  34603. static get PreprocessUrl(): (url: string) => string;
  34604. static set PreprocessUrl(processor: (url: string) => string);
  34605. /**
  34606. * Loads an image as an HTMLImageElement.
  34607. * @param input url string, ArrayBuffer, or Blob to load
  34608. * @param onLoad callback called when the image successfully loads
  34609. * @param onError callback called when the image fails to load
  34610. * @param offlineProvider offline provider for caching
  34611. * @param mimeType optional mime type
  34612. * @returns the HTMLImageElement of the loaded image
  34613. */
  34614. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34615. /**
  34616. * Loads a file from a url
  34617. * @param url url string, ArrayBuffer, or Blob to load
  34618. * @param onSuccess callback called when the file successfully loads
  34619. * @param onProgress callback called while file is loading (if the server supports this mode)
  34620. * @param offlineProvider defines the offline provider for caching
  34621. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34622. * @param onError callback called when the file fails to load
  34623. * @returns a file request object
  34624. */
  34625. 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;
  34626. /**
  34627. * Loads a file from a url
  34628. * @param url the file url to load
  34629. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34630. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34631. */
  34632. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34633. /**
  34634. * Load a script (identified by an url). When the url returns, the
  34635. * content of this file is added into a new script element, attached to the DOM (body element)
  34636. * @param scriptUrl defines the url of the script to laod
  34637. * @param onSuccess defines the callback called when the script is loaded
  34638. * @param onError defines the callback to call if an error occurs
  34639. * @param scriptId defines the id of the script element
  34640. */
  34641. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34642. /**
  34643. * Load an asynchronous script (identified by an url). When the url returns, the
  34644. * content of this file is added into a new script element, attached to the DOM (body element)
  34645. * @param scriptUrl defines the url of the script to laod
  34646. * @param scriptId defines the id of the script element
  34647. * @returns a promise request object
  34648. */
  34649. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34650. /**
  34651. * Loads a file from a blob
  34652. * @param fileToLoad defines the blob to use
  34653. * @param callback defines the callback to call when data is loaded
  34654. * @param progressCallback defines the callback to call during loading process
  34655. * @returns a file request object
  34656. */
  34657. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34658. /**
  34659. * Reads a file from a File object
  34660. * @param file defines the file to load
  34661. * @param onSuccess defines the callback to call when data is loaded
  34662. * @param onProgress defines the callback to call during loading process
  34663. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34664. * @param onError defines the callback to call when an error occurs
  34665. * @returns a file request object
  34666. */
  34667. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34668. /**
  34669. * Creates a data url from a given string content
  34670. * @param content defines the content to convert
  34671. * @returns the new data url link
  34672. */
  34673. static FileAsURL(content: string): string;
  34674. /**
  34675. * Format the given number to a specific decimal format
  34676. * @param value defines the number to format
  34677. * @param decimals defines the number of decimals to use
  34678. * @returns the formatted string
  34679. */
  34680. static Format(value: number, decimals?: number): string;
  34681. /**
  34682. * Tries to copy an object by duplicating every property
  34683. * @param source defines the source object
  34684. * @param destination defines the target object
  34685. * @param doNotCopyList defines a list of properties to avoid
  34686. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34687. */
  34688. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34689. /**
  34690. * Gets a boolean indicating if the given object has no own property
  34691. * @param obj defines the object to test
  34692. * @returns true if object has no own property
  34693. */
  34694. static IsEmpty(obj: any): boolean;
  34695. /**
  34696. * Function used to register events at window level
  34697. * @param windowElement defines the Window object to use
  34698. * @param events defines the events to register
  34699. */
  34700. static RegisterTopRootEvents(windowElement: Window, events: {
  34701. name: string;
  34702. handler: Nullable<(e: FocusEvent) => any>;
  34703. }[]): void;
  34704. /**
  34705. * Function used to unregister events from window level
  34706. * @param windowElement defines the Window object to use
  34707. * @param events defines the events to unregister
  34708. */
  34709. static UnregisterTopRootEvents(windowElement: Window, events: {
  34710. name: string;
  34711. handler: Nullable<(e: FocusEvent) => any>;
  34712. }[]): void;
  34713. /**
  34714. * @ignore
  34715. */
  34716. static _ScreenshotCanvas: HTMLCanvasElement;
  34717. /**
  34718. * Dumps the current bound framebuffer
  34719. * @param width defines the rendering width
  34720. * @param height defines the rendering height
  34721. * @param engine defines the hosting engine
  34722. * @param successCallback defines the callback triggered once the data are available
  34723. * @param mimeType defines the mime type of the result
  34724. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34725. */
  34726. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34727. /**
  34728. * Converts the canvas data to blob.
  34729. * This acts as a polyfill for browsers not supporting the to blob function.
  34730. * @param canvas Defines the canvas to extract the data from
  34731. * @param successCallback Defines the callback triggered once the data are available
  34732. * @param mimeType Defines the mime type of the result
  34733. */
  34734. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34735. /**
  34736. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34737. * @param successCallback defines the callback triggered once the data are available
  34738. * @param mimeType defines the mime type of the result
  34739. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34740. */
  34741. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34742. /**
  34743. * Downloads a blob in the browser
  34744. * @param blob defines the blob to download
  34745. * @param fileName defines the name of the downloaded file
  34746. */
  34747. static Download(blob: Blob, fileName: string): void;
  34748. /**
  34749. * Captures a screenshot of the current rendering
  34750. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34751. * @param engine defines the rendering engine
  34752. * @param camera defines the source camera
  34753. * @param size This parameter can be set to a single number or to an object with the
  34754. * following (optional) properties: precision, width, height. If a single number is passed,
  34755. * it will be used for both width and height. If an object is passed, the screenshot size
  34756. * will be derived from the parameters. The precision property is a multiplier allowing
  34757. * rendering at a higher or lower resolution
  34758. * @param successCallback defines the callback receives a single parameter which contains the
  34759. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34760. * src parameter of an <img> to display it
  34761. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34762. * Check your browser for supported MIME types
  34763. */
  34764. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34765. /**
  34766. * Captures a screenshot of the current rendering
  34767. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34768. * @param engine defines the rendering engine
  34769. * @param camera defines the source camera
  34770. * @param size This parameter can be set to a single number or to an object with the
  34771. * following (optional) properties: precision, width, height. If a single number is passed,
  34772. * it will be used for both width and height. If an object is passed, the screenshot size
  34773. * will be derived from the parameters. The precision property is a multiplier allowing
  34774. * rendering at a higher or lower resolution
  34775. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34776. * Check your browser for supported MIME types
  34777. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34778. * to the src parameter of an <img> to display it
  34779. */
  34780. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34781. /**
  34782. * Generates an image screenshot from the specified camera.
  34783. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34784. * @param engine The engine to use for rendering
  34785. * @param camera The camera to use for rendering
  34786. * @param size This parameter can be set to a single number or to an object with the
  34787. * following (optional) properties: precision, width, height. If a single number is passed,
  34788. * it will be used for both width and height. If an object is passed, the screenshot size
  34789. * will be derived from the parameters. The precision property is a multiplier allowing
  34790. * rendering at a higher or lower resolution
  34791. * @param successCallback The callback receives a single parameter which contains the
  34792. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34793. * src parameter of an <img> to display it
  34794. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34795. * Check your browser for supported MIME types
  34796. * @param samples Texture samples (default: 1)
  34797. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34798. * @param fileName A name for for the downloaded file.
  34799. */
  34800. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34801. /**
  34802. * Generates an image screenshot from the specified camera.
  34803. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34804. * @param engine The engine to use for rendering
  34805. * @param camera The camera to use for rendering
  34806. * @param size This parameter can be set to a single number or to an object with the
  34807. * following (optional) properties: precision, width, height. If a single number is passed,
  34808. * it will be used for both width and height. If an object is passed, the screenshot size
  34809. * will be derived from the parameters. The precision property is a multiplier allowing
  34810. * rendering at a higher or lower resolution
  34811. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34812. * Check your browser for supported MIME types
  34813. * @param samples Texture samples (default: 1)
  34814. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34815. * @param fileName A name for for the downloaded file.
  34816. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34817. * to the src parameter of an <img> to display it
  34818. */
  34819. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34820. /**
  34821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34822. * Be aware Math.random() could cause collisions, but:
  34823. * "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"
  34824. * @returns a pseudo random id
  34825. */
  34826. static RandomId(): string;
  34827. /**
  34828. * Test if the given uri is a base64 string
  34829. * @param uri The uri to test
  34830. * @return True if the uri is a base64 string or false otherwise
  34831. */
  34832. static IsBase64(uri: string): boolean;
  34833. /**
  34834. * Decode the given base64 uri.
  34835. * @param uri The uri to decode
  34836. * @return The decoded base64 data.
  34837. */
  34838. static DecodeBase64(uri: string): ArrayBuffer;
  34839. /**
  34840. * Gets the absolute url.
  34841. * @param url the input url
  34842. * @return the absolute url
  34843. */
  34844. static GetAbsoluteUrl(url: string): string;
  34845. /**
  34846. * No log
  34847. */
  34848. static readonly NoneLogLevel: number;
  34849. /**
  34850. * Only message logs
  34851. */
  34852. static readonly MessageLogLevel: number;
  34853. /**
  34854. * Only warning logs
  34855. */
  34856. static readonly WarningLogLevel: number;
  34857. /**
  34858. * Only error logs
  34859. */
  34860. static readonly ErrorLogLevel: number;
  34861. /**
  34862. * All logs
  34863. */
  34864. static readonly AllLogLevel: number;
  34865. /**
  34866. * Gets a value indicating the number of loading errors
  34867. * @ignorenaming
  34868. */
  34869. static get errorsCount(): number;
  34870. /**
  34871. * Callback called when a new log is added
  34872. */
  34873. static OnNewCacheEntry: (entry: string) => void;
  34874. /**
  34875. * Log a message to the console
  34876. * @param message defines the message to log
  34877. */
  34878. static Log(message: string): void;
  34879. /**
  34880. * Write a warning message to the console
  34881. * @param message defines the message to log
  34882. */
  34883. static Warn(message: string): void;
  34884. /**
  34885. * Write an error message to the console
  34886. * @param message defines the message to log
  34887. */
  34888. static Error(message: string): void;
  34889. /**
  34890. * Gets current log cache (list of logs)
  34891. */
  34892. static get LogCache(): string;
  34893. /**
  34894. * Clears the log cache
  34895. */
  34896. static ClearLogCache(): void;
  34897. /**
  34898. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34899. */
  34900. static set LogLevels(level: number);
  34901. /**
  34902. * Checks if the window object exists
  34903. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34904. */
  34905. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34906. /**
  34907. * No performance log
  34908. */
  34909. static readonly PerformanceNoneLogLevel: number;
  34910. /**
  34911. * Use user marks to log performance
  34912. */
  34913. static readonly PerformanceUserMarkLogLevel: number;
  34914. /**
  34915. * Log performance to the console
  34916. */
  34917. static readonly PerformanceConsoleLogLevel: number;
  34918. private static _performance;
  34919. /**
  34920. * Sets the current performance log level
  34921. */
  34922. static set PerformanceLogLevel(level: number);
  34923. private static _StartPerformanceCounterDisabled;
  34924. private static _EndPerformanceCounterDisabled;
  34925. private static _StartUserMark;
  34926. private static _EndUserMark;
  34927. private static _StartPerformanceConsole;
  34928. private static _EndPerformanceConsole;
  34929. /**
  34930. * Starts a performance counter
  34931. */
  34932. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34933. /**
  34934. * Ends a specific performance coutner
  34935. */
  34936. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34937. /**
  34938. * Gets either window.performance.now() if supported or Date.now() else
  34939. */
  34940. static get Now(): number;
  34941. /**
  34942. * This method will return the name of the class used to create the instance of the given object.
  34943. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34944. * @param object the object to get the class name from
  34945. * @param isType defines if the object is actually a type
  34946. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34947. */
  34948. static GetClassName(object: any, isType?: boolean): string;
  34949. /**
  34950. * Gets the first element of an array satisfying a given predicate
  34951. * @param array defines the array to browse
  34952. * @param predicate defines the predicate to use
  34953. * @returns null if not found or the element
  34954. */
  34955. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34956. /**
  34957. * This method will return the name of the full name of the class, including its owning module (if any).
  34958. * 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).
  34959. * @param object the object to get the class name from
  34960. * @param isType defines if the object is actually a type
  34961. * @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.
  34962. * @ignorenaming
  34963. */
  34964. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34965. /**
  34966. * Returns a promise that resolves after the given amount of time.
  34967. * @param delay Number of milliseconds to delay
  34968. * @returns Promise that resolves after the given amount of time
  34969. */
  34970. static DelayAsync(delay: number): Promise<void>;
  34971. /**
  34972. * Utility function to detect if the current user agent is Safari
  34973. * @returns whether or not the current user agent is safari
  34974. */
  34975. static IsSafari(): boolean;
  34976. }
  34977. /**
  34978. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34979. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34980. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34981. * @param name The name of the class, case should be preserved
  34982. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34983. */
  34984. export function className(name: string, module?: string): (target: Object) => void;
  34985. /**
  34986. * An implementation of a loop for asynchronous functions.
  34987. */
  34988. export class AsyncLoop {
  34989. /**
  34990. * Defines the number of iterations for the loop
  34991. */
  34992. iterations: number;
  34993. /**
  34994. * Defines the current index of the loop.
  34995. */
  34996. index: number;
  34997. private _done;
  34998. private _fn;
  34999. private _successCallback;
  35000. /**
  35001. * Constructor.
  35002. * @param iterations the number of iterations.
  35003. * @param func the function to run each iteration
  35004. * @param successCallback the callback that will be called upon succesful execution
  35005. * @param offset starting offset.
  35006. */
  35007. constructor(
  35008. /**
  35009. * Defines the number of iterations for the loop
  35010. */
  35011. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35012. /**
  35013. * Execute the next iteration. Must be called after the last iteration was finished.
  35014. */
  35015. executeNext(): void;
  35016. /**
  35017. * Break the loop and run the success callback.
  35018. */
  35019. breakLoop(): void;
  35020. /**
  35021. * Create and run an async loop.
  35022. * @param iterations the number of iterations.
  35023. * @param fn the function to run each iteration
  35024. * @param successCallback the callback that will be called upon succesful execution
  35025. * @param offset starting offset.
  35026. * @returns the created async loop object
  35027. */
  35028. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35029. /**
  35030. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35031. * @param iterations total number of iterations
  35032. * @param syncedIterations number of synchronous iterations in each async iteration.
  35033. * @param fn the function to call each iteration.
  35034. * @param callback a success call back that will be called when iterating stops.
  35035. * @param breakFunction a break condition (optional)
  35036. * @param timeout timeout settings for the setTimeout function. default - 0.
  35037. * @returns the created async loop object
  35038. */
  35039. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35040. }
  35041. }
  35042. declare module BABYLON {
  35043. /**
  35044. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35045. * The underlying implementation relies on an associative array to ensure the best performances.
  35046. * The value can be anything including 'null' but except 'undefined'
  35047. */
  35048. export class StringDictionary<T> {
  35049. /**
  35050. * This will clear this dictionary and copy the content from the 'source' one.
  35051. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35052. * @param source the dictionary to take the content from and copy to this dictionary
  35053. */
  35054. copyFrom(source: StringDictionary<T>): void;
  35055. /**
  35056. * Get a value based from its key
  35057. * @param key the given key to get the matching value from
  35058. * @return the value if found, otherwise undefined is returned
  35059. */
  35060. get(key: string): T | undefined;
  35061. /**
  35062. * Get a value from its key or add it if it doesn't exist.
  35063. * This method will ensure you that a given key/data will be present in the dictionary.
  35064. * @param key the given key to get the matching value from
  35065. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35066. * The factory will only be invoked if there's no data for the given key.
  35067. * @return the value corresponding to the key.
  35068. */
  35069. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35070. /**
  35071. * Get a value from its key if present in the dictionary otherwise add it
  35072. * @param key the key to get the value from
  35073. * @param val if there's no such key/value pair in the dictionary add it with this value
  35074. * @return the value corresponding to the key
  35075. */
  35076. getOrAdd(key: string, val: T): T;
  35077. /**
  35078. * Check if there's a given key in the dictionary
  35079. * @param key the key to check for
  35080. * @return true if the key is present, false otherwise
  35081. */
  35082. contains(key: string): boolean;
  35083. /**
  35084. * Add a new key and its corresponding value
  35085. * @param key the key to add
  35086. * @param value the value corresponding to the key
  35087. * @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
  35088. */
  35089. add(key: string, value: T): boolean;
  35090. /**
  35091. * Update a specific value associated to a key
  35092. * @param key defines the key to use
  35093. * @param value defines the value to store
  35094. * @returns true if the value was updated (or false if the key was not found)
  35095. */
  35096. set(key: string, value: T): boolean;
  35097. /**
  35098. * Get the element of the given key and remove it from the dictionary
  35099. * @param key defines the key to search
  35100. * @returns the value associated with the key or null if not found
  35101. */
  35102. getAndRemove(key: string): Nullable<T>;
  35103. /**
  35104. * Remove a key/value from the dictionary.
  35105. * @param key the key to remove
  35106. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35107. */
  35108. remove(key: string): boolean;
  35109. /**
  35110. * Clear the whole content of the dictionary
  35111. */
  35112. clear(): void;
  35113. /**
  35114. * Gets the current count
  35115. */
  35116. get count(): number;
  35117. /**
  35118. * Execute a callback on each key/val of the dictionary.
  35119. * Note that you can remove any element in this dictionary in the callback implementation
  35120. * @param callback the callback to execute on a given key/value pair
  35121. */
  35122. forEach(callback: (key: string, val: T) => void): void;
  35123. /**
  35124. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35125. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35126. * Note that you can remove any element in this dictionary in the callback implementation
  35127. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35128. * @returns the first item
  35129. */
  35130. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35131. private _count;
  35132. private _data;
  35133. }
  35134. }
  35135. declare module BABYLON {
  35136. /** @hidden */
  35137. export interface ICollisionCoordinator {
  35138. createCollider(): Collider;
  35139. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35140. init(scene: Scene): void;
  35141. }
  35142. /** @hidden */
  35143. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35144. private _scene;
  35145. private _scaledPosition;
  35146. private _scaledVelocity;
  35147. private _finalPosition;
  35148. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35149. createCollider(): Collider;
  35150. init(scene: Scene): void;
  35151. private _collideWithWorld;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. /**
  35156. * Class used to manage all inputs for the scene.
  35157. */
  35158. export class InputManager {
  35159. /** The distance in pixel that you have to move to prevent some events */
  35160. static DragMovementThreshold: number;
  35161. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35162. static LongPressDelay: number;
  35163. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35164. static DoubleClickDelay: number;
  35165. /** If you need to check double click without raising a single click at first click, enable this flag */
  35166. static ExclusiveDoubleClickMode: boolean;
  35167. private _wheelEventName;
  35168. private _onPointerMove;
  35169. private _onPointerDown;
  35170. private _onPointerUp;
  35171. private _initClickEvent;
  35172. private _initActionManager;
  35173. private _delayedSimpleClick;
  35174. private _delayedSimpleClickTimeout;
  35175. private _previousDelayedSimpleClickTimeout;
  35176. private _meshPickProceed;
  35177. private _previousButtonPressed;
  35178. private _currentPickResult;
  35179. private _previousPickResult;
  35180. private _totalPointersPressed;
  35181. private _doubleClickOccured;
  35182. private _pointerOverMesh;
  35183. private _pickedDownMesh;
  35184. private _pickedUpMesh;
  35185. private _pointerX;
  35186. private _pointerY;
  35187. private _unTranslatedPointerX;
  35188. private _unTranslatedPointerY;
  35189. private _startingPointerPosition;
  35190. private _previousStartingPointerPosition;
  35191. private _startingPointerTime;
  35192. private _previousStartingPointerTime;
  35193. private _pointerCaptures;
  35194. private _onKeyDown;
  35195. private _onKeyUp;
  35196. private _onCanvasFocusObserver;
  35197. private _onCanvasBlurObserver;
  35198. private _scene;
  35199. /**
  35200. * Creates a new InputManager
  35201. * @param scene defines the hosting scene
  35202. */
  35203. constructor(scene: Scene);
  35204. /**
  35205. * Gets the mesh that is currently under the pointer
  35206. */
  35207. get meshUnderPointer(): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35210. */
  35211. get unTranslatedPointer(): Vector2;
  35212. /**
  35213. * Gets or sets the current on-screen X position of the pointer
  35214. */
  35215. get pointerX(): number;
  35216. set pointerX(value: number);
  35217. /**
  35218. * Gets or sets the current on-screen Y position of the pointer
  35219. */
  35220. get pointerY(): number;
  35221. set pointerY(value: number);
  35222. private _updatePointerPosition;
  35223. private _processPointerMove;
  35224. private _setRayOnPointerInfo;
  35225. private _checkPrePointerObservable;
  35226. /**
  35227. * Use this method to simulate a pointer move on a mesh
  35228. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35229. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35230. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35231. */
  35232. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35233. /**
  35234. * Use this method to simulate a pointer down on a mesh
  35235. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35236. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35237. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35238. */
  35239. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35240. private _processPointerDown;
  35241. /** @hidden */
  35242. _isPointerSwiping(): boolean;
  35243. /**
  35244. * Use this method to simulate a pointer up on a mesh
  35245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35248. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35249. */
  35250. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35251. private _processPointerUp;
  35252. /**
  35253. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35254. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35255. * @returns true if the pointer was captured
  35256. */
  35257. isPointerCaptured(pointerId?: number): boolean;
  35258. /**
  35259. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35260. * @param attachUp defines if you want to attach events to pointerup
  35261. * @param attachDown defines if you want to attach events to pointerdown
  35262. * @param attachMove defines if you want to attach events to pointermove
  35263. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35264. */
  35265. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35266. /**
  35267. * Detaches all event handlers
  35268. */
  35269. detachControl(): void;
  35270. /**
  35271. * Force the value of meshUnderPointer
  35272. * @param mesh defines the mesh to use
  35273. */
  35274. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35275. /**
  35276. * Gets the mesh under the pointer
  35277. * @returns a Mesh or null if no mesh is under the pointer
  35278. */
  35279. getPointerOverMesh(): Nullable<AbstractMesh>;
  35280. }
  35281. }
  35282. declare module BABYLON {
  35283. /**
  35284. * Helper class used to generate session unique ID
  35285. */
  35286. export class UniqueIdGenerator {
  35287. private static _UniqueIdCounter;
  35288. /**
  35289. * Gets an unique (relatively to the current scene) Id
  35290. */
  35291. static get UniqueId(): number;
  35292. }
  35293. }
  35294. declare module BABYLON {
  35295. /**
  35296. * This class defines the direct association between an animation and a target
  35297. */
  35298. export class TargetedAnimation {
  35299. /**
  35300. * Animation to perform
  35301. */
  35302. animation: Animation;
  35303. /**
  35304. * Target to animate
  35305. */
  35306. target: any;
  35307. /**
  35308. * Serialize the object
  35309. * @returns the JSON object representing the current entity
  35310. */
  35311. serialize(): any;
  35312. }
  35313. /**
  35314. * Use this class to create coordinated animations on multiple targets
  35315. */
  35316. export class AnimationGroup implements IDisposable {
  35317. /** The name of the animation group */
  35318. name: string;
  35319. private _scene;
  35320. private _targetedAnimations;
  35321. private _animatables;
  35322. private _from;
  35323. private _to;
  35324. private _isStarted;
  35325. private _isPaused;
  35326. private _speedRatio;
  35327. private _loopAnimation;
  35328. private _isAdditive;
  35329. /**
  35330. * Gets or sets the unique id of the node
  35331. */
  35332. uniqueId: number;
  35333. /**
  35334. * This observable will notify when one animation have ended
  35335. */
  35336. onAnimationEndObservable: Observable<TargetedAnimation>;
  35337. /**
  35338. * Observer raised when one animation loops
  35339. */
  35340. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35341. /**
  35342. * Observer raised when all animations have looped
  35343. */
  35344. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35345. /**
  35346. * This observable will notify when all animations have ended.
  35347. */
  35348. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35349. /**
  35350. * This observable will notify when all animations have paused.
  35351. */
  35352. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35353. /**
  35354. * This observable will notify when all animations are playing.
  35355. */
  35356. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35357. /**
  35358. * Gets the first frame
  35359. */
  35360. get from(): number;
  35361. /**
  35362. * Gets the last frame
  35363. */
  35364. get to(): number;
  35365. /**
  35366. * Define if the animations are started
  35367. */
  35368. get isStarted(): boolean;
  35369. /**
  35370. * Gets a value indicating that the current group is playing
  35371. */
  35372. get isPlaying(): boolean;
  35373. /**
  35374. * Gets or sets the speed ratio to use for all animations
  35375. */
  35376. get speedRatio(): number;
  35377. /**
  35378. * Gets or sets the speed ratio to use for all animations
  35379. */
  35380. set speedRatio(value: number);
  35381. /**
  35382. * Gets or sets if all animations should loop or not
  35383. */
  35384. get loopAnimation(): boolean;
  35385. set loopAnimation(value: boolean);
  35386. /**
  35387. * Gets or sets if all animations should be evaluated additively
  35388. */
  35389. get isAdditive(): boolean;
  35390. set isAdditive(value: boolean);
  35391. /**
  35392. * Gets the targeted animations for this animation group
  35393. */
  35394. get targetedAnimations(): Array<TargetedAnimation>;
  35395. /**
  35396. * returning the list of animatables controlled by this animation group.
  35397. */
  35398. get animatables(): Array<Animatable>;
  35399. /**
  35400. * Instantiates a new Animation Group.
  35401. * This helps managing several animations at once.
  35402. * @see http://doc.babylonjs.com/how_to/group
  35403. * @param name Defines the name of the group
  35404. * @param scene Defines the scene the group belongs to
  35405. */
  35406. constructor(
  35407. /** The name of the animation group */
  35408. name: string, scene?: Nullable<Scene>);
  35409. /**
  35410. * Add an animation (with its target) in the group
  35411. * @param animation defines the animation we want to add
  35412. * @param target defines the target of the animation
  35413. * @returns the TargetedAnimation object
  35414. */
  35415. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35416. /**
  35417. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35418. * It can add constant keys at begin or end
  35419. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35420. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35421. * @returns the animation group
  35422. */
  35423. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35424. private _animationLoopCount;
  35425. private _animationLoopFlags;
  35426. private _processLoop;
  35427. /**
  35428. * Start all animations on given targets
  35429. * @param loop defines if animations must loop
  35430. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35431. * @param from defines the from key (optional)
  35432. * @param to defines the to key (optional)
  35433. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35434. * @returns the current animation group
  35435. */
  35436. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35437. /**
  35438. * Pause all animations
  35439. * @returns the animation group
  35440. */
  35441. pause(): AnimationGroup;
  35442. /**
  35443. * Play all animations to initial state
  35444. * This function will start() the animations if they were not started or will restart() them if they were paused
  35445. * @param loop defines if animations must loop
  35446. * @returns the animation group
  35447. */
  35448. play(loop?: boolean): AnimationGroup;
  35449. /**
  35450. * Reset all animations to initial state
  35451. * @returns the animation group
  35452. */
  35453. reset(): AnimationGroup;
  35454. /**
  35455. * Restart animations from key 0
  35456. * @returns the animation group
  35457. */
  35458. restart(): AnimationGroup;
  35459. /**
  35460. * Stop all animations
  35461. * @returns the animation group
  35462. */
  35463. stop(): AnimationGroup;
  35464. /**
  35465. * Set animation weight for all animatables
  35466. * @param weight defines the weight to use
  35467. * @return the animationGroup
  35468. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35469. */
  35470. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35471. /**
  35472. * Synchronize and normalize all animatables with a source animatable
  35473. * @param root defines the root animatable to synchronize with
  35474. * @return the animationGroup
  35475. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35476. */
  35477. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35478. /**
  35479. * Goes to a specific frame in this animation group
  35480. * @param frame the frame number to go to
  35481. * @return the animationGroup
  35482. */
  35483. goToFrame(frame: number): AnimationGroup;
  35484. /**
  35485. * Dispose all associated resources
  35486. */
  35487. dispose(): void;
  35488. private _checkAnimationGroupEnded;
  35489. /**
  35490. * Clone the current animation group and returns a copy
  35491. * @param newName defines the name of the new group
  35492. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35493. * @returns the new aniamtion group
  35494. */
  35495. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35496. /**
  35497. * Serializes the animationGroup to an object
  35498. * @returns Serialized object
  35499. */
  35500. serialize(): any;
  35501. /**
  35502. * Returns a new AnimationGroup object parsed from the source provided.
  35503. * @param parsedAnimationGroup defines the source
  35504. * @param scene defines the scene that will receive the animationGroup
  35505. * @returns a new AnimationGroup
  35506. */
  35507. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35508. /**
  35509. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35510. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35511. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35512. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35513. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35514. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35515. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35516. */
  35517. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35518. /**
  35519. * Returns the string "AnimationGroup"
  35520. * @returns "AnimationGroup"
  35521. */
  35522. getClassName(): string;
  35523. /**
  35524. * Creates a detailled string about the object
  35525. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35526. * @returns a string representing the object
  35527. */
  35528. toString(fullDetails?: boolean): string;
  35529. }
  35530. }
  35531. declare module BABYLON {
  35532. /**
  35533. * Define an interface for all classes that will hold resources
  35534. */
  35535. export interface IDisposable {
  35536. /**
  35537. * Releases all held resources
  35538. */
  35539. dispose(): void;
  35540. }
  35541. /** Interface defining initialization parameters for Scene class */
  35542. export interface SceneOptions {
  35543. /**
  35544. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35545. * It will improve performance when the number of geometries becomes important.
  35546. */
  35547. useGeometryUniqueIdsMap?: boolean;
  35548. /**
  35549. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35550. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35551. */
  35552. useMaterialMeshMap?: boolean;
  35553. /**
  35554. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35555. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35556. */
  35557. useClonedMeshMap?: boolean;
  35558. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35559. virtual?: boolean;
  35560. }
  35561. /**
  35562. * Represents a scene to be rendered by the engine.
  35563. * @see http://doc.babylonjs.com/features/scene
  35564. */
  35565. export class Scene extends AbstractScene implements IAnimatable {
  35566. /** The fog is deactivated */
  35567. static readonly FOGMODE_NONE: number;
  35568. /** The fog density is following an exponential function */
  35569. static readonly FOGMODE_EXP: number;
  35570. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35571. static readonly FOGMODE_EXP2: number;
  35572. /** The fog density is following a linear function. */
  35573. static readonly FOGMODE_LINEAR: number;
  35574. /**
  35575. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35576. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35577. */
  35578. static MinDeltaTime: number;
  35579. /**
  35580. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35582. */
  35583. static MaxDeltaTime: number;
  35584. /**
  35585. * Factory used to create the default material.
  35586. * @param name The name of the material to create
  35587. * @param scene The scene to create the material for
  35588. * @returns The default material
  35589. */
  35590. static DefaultMaterialFactory(scene: Scene): Material;
  35591. /**
  35592. * Factory used to create the a collision coordinator.
  35593. * @returns The collision coordinator
  35594. */
  35595. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35596. /** @hidden */
  35597. _inputManager: InputManager;
  35598. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35599. cameraToUseForPointers: Nullable<Camera>;
  35600. /** @hidden */
  35601. readonly _isScene: boolean;
  35602. /** @hidden */
  35603. _blockEntityCollection: boolean;
  35604. /**
  35605. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35606. */
  35607. autoClear: boolean;
  35608. /**
  35609. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35610. */
  35611. autoClearDepthAndStencil: boolean;
  35612. /**
  35613. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35614. */
  35615. clearColor: Color4;
  35616. /**
  35617. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35618. */
  35619. ambientColor: Color3;
  35620. /**
  35621. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35622. * It should only be one of the following (if not the default embedded one):
  35623. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35624. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35625. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35626. * The material properties need to be setup according to the type of texture in use.
  35627. */
  35628. environmentBRDFTexture: BaseTexture;
  35629. /** @hidden */
  35630. protected _environmentTexture: Nullable<BaseTexture>;
  35631. /**
  35632. * Texture used in all pbr material as the reflection texture.
  35633. * As in the majority of the scene they are the same (exception for multi room and so on),
  35634. * this is easier to reference from here than from all the materials.
  35635. */
  35636. get environmentTexture(): Nullable<BaseTexture>;
  35637. /**
  35638. * Texture used in all pbr material as the reflection texture.
  35639. * As in the majority of the scene they are the same (exception for multi room and so on),
  35640. * this is easier to set here than in all the materials.
  35641. */
  35642. set environmentTexture(value: Nullable<BaseTexture>);
  35643. /** @hidden */
  35644. protected _environmentIntensity: number;
  35645. /**
  35646. * Intensity of the environment in all pbr material.
  35647. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35648. * As in the majority of the scene they are the same (exception for multi room and so on),
  35649. * this is easier to reference from here than from all the materials.
  35650. */
  35651. get environmentIntensity(): number;
  35652. /**
  35653. * Intensity of the environment in all pbr material.
  35654. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35655. * As in the majority of the scene they are the same (exception for multi room and so on),
  35656. * this is easier to set here than in all the materials.
  35657. */
  35658. set environmentIntensity(value: number);
  35659. /** @hidden */
  35660. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35661. /**
  35662. * Default image processing configuration used either in the rendering
  35663. * Forward main pass or through the imageProcessingPostProcess if present.
  35664. * As in the majority of the scene they are the same (exception for multi camera),
  35665. * this is easier to reference from here than from all the materials and post process.
  35666. *
  35667. * No setter as we it is a shared configuration, you can set the values instead.
  35668. */
  35669. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35670. private _forceWireframe;
  35671. /**
  35672. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35673. */
  35674. set forceWireframe(value: boolean);
  35675. get forceWireframe(): boolean;
  35676. private _skipFrustumClipping;
  35677. /**
  35678. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35679. */
  35680. set skipFrustumClipping(value: boolean);
  35681. get skipFrustumClipping(): boolean;
  35682. private _forcePointsCloud;
  35683. /**
  35684. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35685. */
  35686. set forcePointsCloud(value: boolean);
  35687. get forcePointsCloud(): boolean;
  35688. /**
  35689. * Gets or sets the active clipplane 1
  35690. */
  35691. clipPlane: Nullable<Plane>;
  35692. /**
  35693. * Gets or sets the active clipplane 2
  35694. */
  35695. clipPlane2: Nullable<Plane>;
  35696. /**
  35697. * Gets or sets the active clipplane 3
  35698. */
  35699. clipPlane3: Nullable<Plane>;
  35700. /**
  35701. * Gets or sets the active clipplane 4
  35702. */
  35703. clipPlane4: Nullable<Plane>;
  35704. /**
  35705. * Gets or sets the active clipplane 5
  35706. */
  35707. clipPlane5: Nullable<Plane>;
  35708. /**
  35709. * Gets or sets the active clipplane 6
  35710. */
  35711. clipPlane6: Nullable<Plane>;
  35712. /**
  35713. * Gets or sets a boolean indicating if animations are enabled
  35714. */
  35715. animationsEnabled: boolean;
  35716. private _animationPropertiesOverride;
  35717. /**
  35718. * Gets or sets the animation properties override
  35719. */
  35720. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35721. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35722. /**
  35723. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35724. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35725. */
  35726. useConstantAnimationDeltaTime: boolean;
  35727. /**
  35728. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35729. * Please note that it requires to run a ray cast through the scene on every frame
  35730. */
  35731. constantlyUpdateMeshUnderPointer: boolean;
  35732. /**
  35733. * Defines the HTML cursor to use when hovering over interactive elements
  35734. */
  35735. hoverCursor: string;
  35736. /**
  35737. * Defines the HTML default cursor to use (empty by default)
  35738. */
  35739. defaultCursor: string;
  35740. /**
  35741. * Defines whether cursors are handled by the scene.
  35742. */
  35743. doNotHandleCursors: boolean;
  35744. /**
  35745. * This is used to call preventDefault() on pointer down
  35746. * in order to block unwanted artifacts like system double clicks
  35747. */
  35748. preventDefaultOnPointerDown: boolean;
  35749. /**
  35750. * This is used to call preventDefault() on pointer up
  35751. * in order to block unwanted artifacts like system double clicks
  35752. */
  35753. preventDefaultOnPointerUp: boolean;
  35754. /**
  35755. * Gets or sets user defined metadata
  35756. */
  35757. metadata: any;
  35758. /**
  35759. * For internal use only. Please do not use.
  35760. */
  35761. reservedDataStore: any;
  35762. /**
  35763. * Gets the name of the plugin used to load this scene (null by default)
  35764. */
  35765. loadingPluginName: string;
  35766. /**
  35767. * Use this array to add regular expressions used to disable offline support for specific urls
  35768. */
  35769. disableOfflineSupportExceptionRules: RegExp[];
  35770. /**
  35771. * An event triggered when the scene is disposed.
  35772. */
  35773. onDisposeObservable: Observable<Scene>;
  35774. private _onDisposeObserver;
  35775. /** Sets a function to be executed when this scene is disposed. */
  35776. set onDispose(callback: () => void);
  35777. /**
  35778. * An event triggered before rendering the scene (right after animations and physics)
  35779. */
  35780. onBeforeRenderObservable: Observable<Scene>;
  35781. private _onBeforeRenderObserver;
  35782. /** Sets a function to be executed before rendering this scene */
  35783. set beforeRender(callback: Nullable<() => void>);
  35784. /**
  35785. * An event triggered after rendering the scene
  35786. */
  35787. onAfterRenderObservable: Observable<Scene>;
  35788. /**
  35789. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35790. */
  35791. onAfterRenderCameraObservable: Observable<Camera>;
  35792. private _onAfterRenderObserver;
  35793. /** Sets a function to be executed after rendering this scene */
  35794. set afterRender(callback: Nullable<() => void>);
  35795. /**
  35796. * An event triggered before animating the scene
  35797. */
  35798. onBeforeAnimationsObservable: Observable<Scene>;
  35799. /**
  35800. * An event triggered after animations processing
  35801. */
  35802. onAfterAnimationsObservable: Observable<Scene>;
  35803. /**
  35804. * An event triggered before draw calls are ready to be sent
  35805. */
  35806. onBeforeDrawPhaseObservable: Observable<Scene>;
  35807. /**
  35808. * An event triggered after draw calls have been sent
  35809. */
  35810. onAfterDrawPhaseObservable: Observable<Scene>;
  35811. /**
  35812. * An event triggered when the scene is ready
  35813. */
  35814. onReadyObservable: Observable<Scene>;
  35815. /**
  35816. * An event triggered before rendering a camera
  35817. */
  35818. onBeforeCameraRenderObservable: Observable<Camera>;
  35819. private _onBeforeCameraRenderObserver;
  35820. /** Sets a function to be executed before rendering a camera*/
  35821. set beforeCameraRender(callback: () => void);
  35822. /**
  35823. * An event triggered after rendering a camera
  35824. */
  35825. onAfterCameraRenderObservable: Observable<Camera>;
  35826. private _onAfterCameraRenderObserver;
  35827. /** Sets a function to be executed after rendering a camera*/
  35828. set afterCameraRender(callback: () => void);
  35829. /**
  35830. * An event triggered when active meshes evaluation is about to start
  35831. */
  35832. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35833. /**
  35834. * An event triggered when active meshes evaluation is done
  35835. */
  35836. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35837. /**
  35838. * An event triggered when particles rendering is about to start
  35839. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35840. */
  35841. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35842. /**
  35843. * An event triggered when particles rendering is done
  35844. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35845. */
  35846. onAfterParticlesRenderingObservable: Observable<Scene>;
  35847. /**
  35848. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35849. */
  35850. onDataLoadedObservable: Observable<Scene>;
  35851. /**
  35852. * An event triggered when a camera is created
  35853. */
  35854. onNewCameraAddedObservable: Observable<Camera>;
  35855. /**
  35856. * An event triggered when a camera is removed
  35857. */
  35858. onCameraRemovedObservable: Observable<Camera>;
  35859. /**
  35860. * An event triggered when a light is created
  35861. */
  35862. onNewLightAddedObservable: Observable<Light>;
  35863. /**
  35864. * An event triggered when a light is removed
  35865. */
  35866. onLightRemovedObservable: Observable<Light>;
  35867. /**
  35868. * An event triggered when a geometry is created
  35869. */
  35870. onNewGeometryAddedObservable: Observable<Geometry>;
  35871. /**
  35872. * An event triggered when a geometry is removed
  35873. */
  35874. onGeometryRemovedObservable: Observable<Geometry>;
  35875. /**
  35876. * An event triggered when a transform node is created
  35877. */
  35878. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35879. /**
  35880. * An event triggered when a transform node is removed
  35881. */
  35882. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35883. /**
  35884. * An event triggered when a mesh is created
  35885. */
  35886. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35887. /**
  35888. * An event triggered when a mesh is removed
  35889. */
  35890. onMeshRemovedObservable: Observable<AbstractMesh>;
  35891. /**
  35892. * An event triggered when a skeleton is created
  35893. */
  35894. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35895. /**
  35896. * An event triggered when a skeleton is removed
  35897. */
  35898. onSkeletonRemovedObservable: Observable<Skeleton>;
  35899. /**
  35900. * An event triggered when a material is created
  35901. */
  35902. onNewMaterialAddedObservable: Observable<Material>;
  35903. /**
  35904. * An event triggered when a material is removed
  35905. */
  35906. onMaterialRemovedObservable: Observable<Material>;
  35907. /**
  35908. * An event triggered when a texture is created
  35909. */
  35910. onNewTextureAddedObservable: Observable<BaseTexture>;
  35911. /**
  35912. * An event triggered when a texture is removed
  35913. */
  35914. onTextureRemovedObservable: Observable<BaseTexture>;
  35915. /**
  35916. * An event triggered when render targets are about to be rendered
  35917. * Can happen multiple times per frame.
  35918. */
  35919. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35920. /**
  35921. * An event triggered when render targets were rendered.
  35922. * Can happen multiple times per frame.
  35923. */
  35924. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35925. /**
  35926. * An event triggered before calculating deterministic simulation step
  35927. */
  35928. onBeforeStepObservable: Observable<Scene>;
  35929. /**
  35930. * An event triggered after calculating deterministic simulation step
  35931. */
  35932. onAfterStepObservable: Observable<Scene>;
  35933. /**
  35934. * An event triggered when the activeCamera property is updated
  35935. */
  35936. onActiveCameraChanged: Observable<Scene>;
  35937. /**
  35938. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35939. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35940. * 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)
  35941. */
  35942. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35943. /**
  35944. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35945. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35946. * 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)
  35947. */
  35948. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35949. /**
  35950. * This Observable will when a mesh has been imported into the scene.
  35951. */
  35952. onMeshImportedObservable: Observable<AbstractMesh>;
  35953. /**
  35954. * This Observable will when an animation file has been imported into the scene.
  35955. */
  35956. onAnimationFileImportedObservable: Observable<Scene>;
  35957. /**
  35958. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35959. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35960. */
  35961. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35962. /** @hidden */
  35963. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35964. /**
  35965. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35966. */
  35967. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35968. /**
  35969. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35970. */
  35971. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35972. /**
  35973. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35974. */
  35975. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35976. /** Callback called when a pointer move is detected */
  35977. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35978. /** Callback called when a pointer down is detected */
  35979. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35980. /** Callback called when a pointer up is detected */
  35981. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35982. /** Callback called when a pointer pick is detected */
  35983. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35984. /**
  35985. * 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).
  35986. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35987. */
  35988. onPrePointerObservable: Observable<PointerInfoPre>;
  35989. /**
  35990. * Observable event triggered each time an input event is received from the rendering canvas
  35991. */
  35992. onPointerObservable: Observable<PointerInfo>;
  35993. /**
  35994. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35995. */
  35996. get unTranslatedPointer(): Vector2;
  35997. /**
  35998. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35999. */
  36000. static get DragMovementThreshold(): number;
  36001. static set DragMovementThreshold(value: number);
  36002. /**
  36003. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36004. */
  36005. static get LongPressDelay(): number;
  36006. static set LongPressDelay(value: number);
  36007. /**
  36008. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36009. */
  36010. static get DoubleClickDelay(): number;
  36011. static set DoubleClickDelay(value: number);
  36012. /** If you need to check double click without raising a single click at first click, enable this flag */
  36013. static get ExclusiveDoubleClickMode(): boolean;
  36014. static set ExclusiveDoubleClickMode(value: boolean);
  36015. /** @hidden */
  36016. _mirroredCameraPosition: Nullable<Vector3>;
  36017. /**
  36018. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36019. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36020. */
  36021. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36022. /**
  36023. * Observable event triggered each time an keyboard event is received from the hosting window
  36024. */
  36025. onKeyboardObservable: Observable<KeyboardInfo>;
  36026. private _useRightHandedSystem;
  36027. /**
  36028. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36029. */
  36030. set useRightHandedSystem(value: boolean);
  36031. get useRightHandedSystem(): boolean;
  36032. private _timeAccumulator;
  36033. private _currentStepId;
  36034. private _currentInternalStep;
  36035. /**
  36036. * Sets the step Id used by deterministic lock step
  36037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36038. * @param newStepId defines the step Id
  36039. */
  36040. setStepId(newStepId: number): void;
  36041. /**
  36042. * Gets the step Id used by deterministic lock step
  36043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36044. * @returns the step Id
  36045. */
  36046. getStepId(): number;
  36047. /**
  36048. * Gets the internal step used by deterministic lock step
  36049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36050. * @returns the internal step
  36051. */
  36052. getInternalStep(): number;
  36053. private _fogEnabled;
  36054. /**
  36055. * Gets or sets a boolean indicating if fog is enabled on this scene
  36056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36057. * (Default is true)
  36058. */
  36059. set fogEnabled(value: boolean);
  36060. get fogEnabled(): boolean;
  36061. private _fogMode;
  36062. /**
  36063. * Gets or sets the fog mode to use
  36064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36065. * | mode | value |
  36066. * | --- | --- |
  36067. * | FOGMODE_NONE | 0 |
  36068. * | FOGMODE_EXP | 1 |
  36069. * | FOGMODE_EXP2 | 2 |
  36070. * | FOGMODE_LINEAR | 3 |
  36071. */
  36072. set fogMode(value: number);
  36073. get fogMode(): number;
  36074. /**
  36075. * Gets or sets the fog color to use
  36076. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36077. * (Default is Color3(0.2, 0.2, 0.3))
  36078. */
  36079. fogColor: Color3;
  36080. /**
  36081. * Gets or sets the fog density to use
  36082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36083. * (Default is 0.1)
  36084. */
  36085. fogDensity: number;
  36086. /**
  36087. * Gets or sets the fog start distance to use
  36088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36089. * (Default is 0)
  36090. */
  36091. fogStart: number;
  36092. /**
  36093. * Gets or sets the fog end distance to use
  36094. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36095. * (Default is 1000)
  36096. */
  36097. fogEnd: number;
  36098. private _shadowsEnabled;
  36099. /**
  36100. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36101. */
  36102. set shadowsEnabled(value: boolean);
  36103. get shadowsEnabled(): boolean;
  36104. private _lightsEnabled;
  36105. /**
  36106. * Gets or sets a boolean indicating if lights are enabled on this scene
  36107. */
  36108. set lightsEnabled(value: boolean);
  36109. get lightsEnabled(): boolean;
  36110. /** All of the active cameras added to this scene. */
  36111. activeCameras: Camera[];
  36112. /** @hidden */
  36113. _activeCamera: Nullable<Camera>;
  36114. /** Gets or sets the current active camera */
  36115. get activeCamera(): Nullable<Camera>;
  36116. set activeCamera(value: Nullable<Camera>);
  36117. private _defaultMaterial;
  36118. /** The default material used on meshes when no material is affected */
  36119. get defaultMaterial(): Material;
  36120. /** The default material used on meshes when no material is affected */
  36121. set defaultMaterial(value: Material);
  36122. private _texturesEnabled;
  36123. /**
  36124. * Gets or sets a boolean indicating if textures are enabled on this scene
  36125. */
  36126. set texturesEnabled(value: boolean);
  36127. get texturesEnabled(): boolean;
  36128. /**
  36129. * Gets or sets a boolean indicating if particles are enabled on this scene
  36130. */
  36131. particlesEnabled: boolean;
  36132. /**
  36133. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36134. */
  36135. spritesEnabled: boolean;
  36136. private _skeletonsEnabled;
  36137. /**
  36138. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36139. */
  36140. set skeletonsEnabled(value: boolean);
  36141. get skeletonsEnabled(): boolean;
  36142. /**
  36143. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36144. */
  36145. lensFlaresEnabled: boolean;
  36146. /**
  36147. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36149. */
  36150. collisionsEnabled: boolean;
  36151. private _collisionCoordinator;
  36152. /** @hidden */
  36153. get collisionCoordinator(): ICollisionCoordinator;
  36154. /**
  36155. * Defines the gravity applied to this scene (used only for collisions)
  36156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36157. */
  36158. gravity: Vector3;
  36159. /**
  36160. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36161. */
  36162. postProcessesEnabled: boolean;
  36163. /**
  36164. * The list of postprocesses added to the scene
  36165. */
  36166. postProcesses: PostProcess[];
  36167. /**
  36168. * Gets the current postprocess manager
  36169. */
  36170. postProcessManager: PostProcessManager;
  36171. /**
  36172. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36173. */
  36174. renderTargetsEnabled: boolean;
  36175. /**
  36176. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36177. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36178. */
  36179. dumpNextRenderTargets: boolean;
  36180. /**
  36181. * The list of user defined render targets added to the scene
  36182. */
  36183. customRenderTargets: RenderTargetTexture[];
  36184. /**
  36185. * Defines if texture loading must be delayed
  36186. * If true, textures will only be loaded when they need to be rendered
  36187. */
  36188. useDelayedTextureLoading: boolean;
  36189. /**
  36190. * Gets the list of meshes imported to the scene through SceneLoader
  36191. */
  36192. importedMeshesFiles: String[];
  36193. /**
  36194. * Gets or sets a boolean indicating if probes are enabled on this scene
  36195. */
  36196. probesEnabled: boolean;
  36197. /**
  36198. * Gets or sets the current offline provider to use to store scene data
  36199. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36200. */
  36201. offlineProvider: IOfflineProvider;
  36202. /**
  36203. * Gets or sets the action manager associated with the scene
  36204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36205. */
  36206. actionManager: AbstractActionManager;
  36207. private _meshesForIntersections;
  36208. /**
  36209. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36210. */
  36211. proceduralTexturesEnabled: boolean;
  36212. private _engine;
  36213. private _totalVertices;
  36214. /** @hidden */
  36215. _activeIndices: PerfCounter;
  36216. /** @hidden */
  36217. _activeParticles: PerfCounter;
  36218. /** @hidden */
  36219. _activeBones: PerfCounter;
  36220. private _animationRatio;
  36221. /** @hidden */
  36222. _animationTimeLast: number;
  36223. /** @hidden */
  36224. _animationTime: number;
  36225. /**
  36226. * Gets or sets a general scale for animation speed
  36227. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36228. */
  36229. animationTimeScale: number;
  36230. /** @hidden */
  36231. _cachedMaterial: Nullable<Material>;
  36232. /** @hidden */
  36233. _cachedEffect: Nullable<Effect>;
  36234. /** @hidden */
  36235. _cachedVisibility: Nullable<number>;
  36236. private _renderId;
  36237. private _frameId;
  36238. private _executeWhenReadyTimeoutId;
  36239. private _intermediateRendering;
  36240. private _viewUpdateFlag;
  36241. private _projectionUpdateFlag;
  36242. /** @hidden */
  36243. _toBeDisposed: Nullable<IDisposable>[];
  36244. private _activeRequests;
  36245. /** @hidden */
  36246. _pendingData: any[];
  36247. private _isDisposed;
  36248. /**
  36249. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36250. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36251. */
  36252. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36253. private _activeMeshes;
  36254. private _processedMaterials;
  36255. private _renderTargets;
  36256. /** @hidden */
  36257. _activeParticleSystems: SmartArray<IParticleSystem>;
  36258. private _activeSkeletons;
  36259. private _softwareSkinnedMeshes;
  36260. private _renderingManager;
  36261. /** @hidden */
  36262. _activeAnimatables: Animatable[];
  36263. private _transformMatrix;
  36264. private _sceneUbo;
  36265. /** @hidden */
  36266. _viewMatrix: Matrix;
  36267. private _projectionMatrix;
  36268. /** @hidden */
  36269. _forcedViewPosition: Nullable<Vector3>;
  36270. /** @hidden */
  36271. _frustumPlanes: Plane[];
  36272. /**
  36273. * Gets the list of frustum planes (built from the active camera)
  36274. */
  36275. get frustumPlanes(): Plane[];
  36276. /**
  36277. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36278. * This is useful if there are more lights that the maximum simulteanous authorized
  36279. */
  36280. requireLightSorting: boolean;
  36281. /** @hidden */
  36282. readonly useMaterialMeshMap: boolean;
  36283. /** @hidden */
  36284. readonly useClonedMeshMap: boolean;
  36285. private _externalData;
  36286. private _uid;
  36287. /**
  36288. * @hidden
  36289. * Backing store of defined scene components.
  36290. */
  36291. _components: ISceneComponent[];
  36292. /**
  36293. * @hidden
  36294. * Backing store of defined scene components.
  36295. */
  36296. _serializableComponents: ISceneSerializableComponent[];
  36297. /**
  36298. * List of components to register on the next registration step.
  36299. */
  36300. private _transientComponents;
  36301. /**
  36302. * Registers the transient components if needed.
  36303. */
  36304. private _registerTransientComponents;
  36305. /**
  36306. * @hidden
  36307. * Add a component to the scene.
  36308. * Note that the ccomponent could be registered on th next frame if this is called after
  36309. * the register component stage.
  36310. * @param component Defines the component to add to the scene
  36311. */
  36312. _addComponent(component: ISceneComponent): void;
  36313. /**
  36314. * @hidden
  36315. * Gets a component from the scene.
  36316. * @param name defines the name of the component to retrieve
  36317. * @returns the component or null if not present
  36318. */
  36319. _getComponent(name: string): Nullable<ISceneComponent>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening before camera updates.
  36323. */
  36324. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening before clear the canvas.
  36328. */
  36329. _beforeClearStage: Stage<SimpleStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions when collecting render targets for the frame.
  36333. */
  36334. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36335. /**
  36336. * @hidden
  36337. * Defines the actions happening for one camera in the frame.
  36338. */
  36339. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36340. /**
  36341. * @hidden
  36342. * Defines the actions happening during the per mesh ready checks.
  36343. */
  36344. _isReadyForMeshStage: Stage<MeshStageAction>;
  36345. /**
  36346. * @hidden
  36347. * Defines the actions happening before evaluate active mesh checks.
  36348. */
  36349. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36350. /**
  36351. * @hidden
  36352. * Defines the actions happening during the evaluate sub mesh checks.
  36353. */
  36354. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36355. /**
  36356. * @hidden
  36357. * Defines the actions happening during the active mesh stage.
  36358. */
  36359. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36360. /**
  36361. * @hidden
  36362. * Defines the actions happening during the per camera render target step.
  36363. */
  36364. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36365. /**
  36366. * @hidden
  36367. * Defines the actions happening just before the active camera is drawing.
  36368. */
  36369. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36370. /**
  36371. * @hidden
  36372. * Defines the actions happening just before a render target is drawing.
  36373. */
  36374. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36375. /**
  36376. * @hidden
  36377. * Defines the actions happening just before a rendering group is drawing.
  36378. */
  36379. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36380. /**
  36381. * @hidden
  36382. * Defines the actions happening just before a mesh is drawing.
  36383. */
  36384. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36385. /**
  36386. * @hidden
  36387. * Defines the actions happening just after a mesh has been drawn.
  36388. */
  36389. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36390. /**
  36391. * @hidden
  36392. * Defines the actions happening just after a rendering group has been drawn.
  36393. */
  36394. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36395. /**
  36396. * @hidden
  36397. * Defines the actions happening just after the active camera has been drawn.
  36398. */
  36399. _afterCameraDrawStage: Stage<CameraStageAction>;
  36400. /**
  36401. * @hidden
  36402. * Defines the actions happening just after a render target has been drawn.
  36403. */
  36404. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36405. /**
  36406. * @hidden
  36407. * Defines the actions happening just after rendering all cameras and computing intersections.
  36408. */
  36409. _afterRenderStage: Stage<SimpleStageAction>;
  36410. /**
  36411. * @hidden
  36412. * Defines the actions happening when a pointer move event happens.
  36413. */
  36414. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36415. /**
  36416. * @hidden
  36417. * Defines the actions happening when a pointer down event happens.
  36418. */
  36419. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36420. /**
  36421. * @hidden
  36422. * Defines the actions happening when a pointer up event happens.
  36423. */
  36424. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36425. /**
  36426. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36427. */
  36428. private geometriesByUniqueId;
  36429. /**
  36430. * Creates a new Scene
  36431. * @param engine defines the engine to use to render this scene
  36432. * @param options defines the scene options
  36433. */
  36434. constructor(engine: Engine, options?: SceneOptions);
  36435. /**
  36436. * Gets a string idenfifying the name of the class
  36437. * @returns "Scene" string
  36438. */
  36439. getClassName(): string;
  36440. private _defaultMeshCandidates;
  36441. /**
  36442. * @hidden
  36443. */
  36444. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36445. private _defaultSubMeshCandidates;
  36446. /**
  36447. * @hidden
  36448. */
  36449. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36450. /**
  36451. * Sets the default candidate providers for the scene.
  36452. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36453. * and getCollidingSubMeshCandidates to their default function
  36454. */
  36455. setDefaultCandidateProviders(): void;
  36456. /**
  36457. * Gets the mesh that is currently under the pointer
  36458. */
  36459. get meshUnderPointer(): Nullable<AbstractMesh>;
  36460. /**
  36461. * Gets or sets the current on-screen X position of the pointer
  36462. */
  36463. get pointerX(): number;
  36464. set pointerX(value: number);
  36465. /**
  36466. * Gets or sets the current on-screen Y position of the pointer
  36467. */
  36468. get pointerY(): number;
  36469. set pointerY(value: number);
  36470. /**
  36471. * Gets the cached material (ie. the latest rendered one)
  36472. * @returns the cached material
  36473. */
  36474. getCachedMaterial(): Nullable<Material>;
  36475. /**
  36476. * Gets the cached effect (ie. the latest rendered one)
  36477. * @returns the cached effect
  36478. */
  36479. getCachedEffect(): Nullable<Effect>;
  36480. /**
  36481. * Gets the cached visibility state (ie. the latest rendered one)
  36482. * @returns the cached visibility state
  36483. */
  36484. getCachedVisibility(): Nullable<number>;
  36485. /**
  36486. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36487. * @param material defines the current material
  36488. * @param effect defines the current effect
  36489. * @param visibility defines the current visibility state
  36490. * @returns true if one parameter is not cached
  36491. */
  36492. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36493. /**
  36494. * Gets the engine associated with the scene
  36495. * @returns an Engine
  36496. */
  36497. getEngine(): Engine;
  36498. /**
  36499. * Gets the total number of vertices rendered per frame
  36500. * @returns the total number of vertices rendered per frame
  36501. */
  36502. getTotalVertices(): number;
  36503. /**
  36504. * Gets the performance counter for total vertices
  36505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36506. */
  36507. get totalVerticesPerfCounter(): PerfCounter;
  36508. /**
  36509. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36510. * @returns the total number of active indices rendered per frame
  36511. */
  36512. getActiveIndices(): number;
  36513. /**
  36514. * Gets the performance counter for active indices
  36515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36516. */
  36517. get totalActiveIndicesPerfCounter(): PerfCounter;
  36518. /**
  36519. * Gets the total number of active particles rendered per frame
  36520. * @returns the total number of active particles rendered per frame
  36521. */
  36522. getActiveParticles(): number;
  36523. /**
  36524. * Gets the performance counter for active particles
  36525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36526. */
  36527. get activeParticlesPerfCounter(): PerfCounter;
  36528. /**
  36529. * Gets the total number of active bones rendered per frame
  36530. * @returns the total number of active bones rendered per frame
  36531. */
  36532. getActiveBones(): number;
  36533. /**
  36534. * Gets the performance counter for active bones
  36535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36536. */
  36537. get activeBonesPerfCounter(): PerfCounter;
  36538. /**
  36539. * Gets the array of active meshes
  36540. * @returns an array of AbstractMesh
  36541. */
  36542. getActiveMeshes(): SmartArray<AbstractMesh>;
  36543. /**
  36544. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36545. * @returns a number
  36546. */
  36547. getAnimationRatio(): number;
  36548. /**
  36549. * Gets an unique Id for the current render phase
  36550. * @returns a number
  36551. */
  36552. getRenderId(): number;
  36553. /**
  36554. * Gets an unique Id for the current frame
  36555. * @returns a number
  36556. */
  36557. getFrameId(): number;
  36558. /** Call this function if you want to manually increment the render Id*/
  36559. incrementRenderId(): void;
  36560. private _createUbo;
  36561. /**
  36562. * Use this method to simulate a pointer move on a mesh
  36563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36566. * @returns the current scene
  36567. */
  36568. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36569. /**
  36570. * Use this method to simulate a pointer down on a mesh
  36571. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36572. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36573. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36574. * @returns the current scene
  36575. */
  36576. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36577. /**
  36578. * Use this method to simulate a pointer up on a mesh
  36579. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36580. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36581. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36582. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36583. * @returns the current scene
  36584. */
  36585. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36586. /**
  36587. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36588. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36589. * @returns true if the pointer was captured
  36590. */
  36591. isPointerCaptured(pointerId?: number): boolean;
  36592. /**
  36593. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36594. * @param attachUp defines if you want to attach events to pointerup
  36595. * @param attachDown defines if you want to attach events to pointerdown
  36596. * @param attachMove defines if you want to attach events to pointermove
  36597. */
  36598. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36599. /** Detaches all event handlers*/
  36600. detachControl(): void;
  36601. /**
  36602. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36603. * Delay loaded resources are not taking in account
  36604. * @return true if all required resources are ready
  36605. */
  36606. isReady(): boolean;
  36607. /** Resets all cached information relative to material (including effect and visibility) */
  36608. resetCachedMaterial(): void;
  36609. /**
  36610. * Registers a function to be called before every frame render
  36611. * @param func defines the function to register
  36612. */
  36613. registerBeforeRender(func: () => void): void;
  36614. /**
  36615. * Unregisters a function called before every frame render
  36616. * @param func defines the function to unregister
  36617. */
  36618. unregisterBeforeRender(func: () => void): void;
  36619. /**
  36620. * Registers a function to be called after every frame render
  36621. * @param func defines the function to register
  36622. */
  36623. registerAfterRender(func: () => void): void;
  36624. /**
  36625. * Unregisters a function called after every frame render
  36626. * @param func defines the function to unregister
  36627. */
  36628. unregisterAfterRender(func: () => void): void;
  36629. private _executeOnceBeforeRender;
  36630. /**
  36631. * The provided function will run before render once and will be disposed afterwards.
  36632. * A timeout delay can be provided so that the function will be executed in N ms.
  36633. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36634. * @param func The function to be executed.
  36635. * @param timeout optional delay in ms
  36636. */
  36637. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36638. /** @hidden */
  36639. _addPendingData(data: any): void;
  36640. /** @hidden */
  36641. _removePendingData(data: any): void;
  36642. /**
  36643. * Returns the number of items waiting to be loaded
  36644. * @returns the number of items waiting to be loaded
  36645. */
  36646. getWaitingItemsCount(): number;
  36647. /**
  36648. * Returns a boolean indicating if the scene is still loading data
  36649. */
  36650. get isLoading(): boolean;
  36651. /**
  36652. * Registers a function to be executed when the scene is ready
  36653. * @param {Function} func - the function to be executed
  36654. */
  36655. executeWhenReady(func: () => void): void;
  36656. /**
  36657. * Returns a promise that resolves when the scene is ready
  36658. * @returns A promise that resolves when the scene is ready
  36659. */
  36660. whenReadyAsync(): Promise<void>;
  36661. /** @hidden */
  36662. _checkIsReady(): void;
  36663. /**
  36664. * Gets all animatable attached to the scene
  36665. */
  36666. get animatables(): Animatable[];
  36667. /**
  36668. * Resets the last animation time frame.
  36669. * Useful to override when animations start running when loading a scene for the first time.
  36670. */
  36671. resetLastAnimationTimeFrame(): void;
  36672. /**
  36673. * Gets the current view matrix
  36674. * @returns a Matrix
  36675. */
  36676. getViewMatrix(): Matrix;
  36677. /**
  36678. * Gets the current projection matrix
  36679. * @returns a Matrix
  36680. */
  36681. getProjectionMatrix(): Matrix;
  36682. /**
  36683. * Gets the current transform matrix
  36684. * @returns a Matrix made of View * Projection
  36685. */
  36686. getTransformMatrix(): Matrix;
  36687. /**
  36688. * Sets the current transform matrix
  36689. * @param viewL defines the View matrix to use
  36690. * @param projectionL defines the Projection matrix to use
  36691. * @param viewR defines the right View matrix to use (if provided)
  36692. * @param projectionR defines the right Projection matrix to use (if provided)
  36693. */
  36694. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36695. /**
  36696. * Gets the uniform buffer used to store scene data
  36697. * @returns a UniformBuffer
  36698. */
  36699. getSceneUniformBuffer(): UniformBuffer;
  36700. /**
  36701. * Gets an unique (relatively to the current scene) Id
  36702. * @returns an unique number for the scene
  36703. */
  36704. getUniqueId(): number;
  36705. /**
  36706. * Add a mesh to the list of scene's meshes
  36707. * @param newMesh defines the mesh to add
  36708. * @param recursive if all child meshes should also be added to the scene
  36709. */
  36710. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36711. /**
  36712. * Remove a mesh for the list of scene's meshes
  36713. * @param toRemove defines the mesh to remove
  36714. * @param recursive if all child meshes should also be removed from the scene
  36715. * @returns the index where the mesh was in the mesh list
  36716. */
  36717. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36718. /**
  36719. * Add a transform node to the list of scene's transform nodes
  36720. * @param newTransformNode defines the transform node to add
  36721. */
  36722. addTransformNode(newTransformNode: TransformNode): void;
  36723. /**
  36724. * Remove a transform node for the list of scene's transform nodes
  36725. * @param toRemove defines the transform node to remove
  36726. * @returns the index where the transform node was in the transform node list
  36727. */
  36728. removeTransformNode(toRemove: TransformNode): number;
  36729. /**
  36730. * Remove a skeleton for the list of scene's skeletons
  36731. * @param toRemove defines the skeleton to remove
  36732. * @returns the index where the skeleton was in the skeleton list
  36733. */
  36734. removeSkeleton(toRemove: Skeleton): number;
  36735. /**
  36736. * Remove a morph target for the list of scene's morph targets
  36737. * @param toRemove defines the morph target to remove
  36738. * @returns the index where the morph target was in the morph target list
  36739. */
  36740. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36741. /**
  36742. * Remove a light for the list of scene's lights
  36743. * @param toRemove defines the light to remove
  36744. * @returns the index where the light was in the light list
  36745. */
  36746. removeLight(toRemove: Light): number;
  36747. /**
  36748. * Remove a camera for the list of scene's cameras
  36749. * @param toRemove defines the camera to remove
  36750. * @returns the index where the camera was in the camera list
  36751. */
  36752. removeCamera(toRemove: Camera): number;
  36753. /**
  36754. * Remove a particle system for the list of scene's particle systems
  36755. * @param toRemove defines the particle system to remove
  36756. * @returns the index where the particle system was in the particle system list
  36757. */
  36758. removeParticleSystem(toRemove: IParticleSystem): number;
  36759. /**
  36760. * Remove a animation for the list of scene's animations
  36761. * @param toRemove defines the animation to remove
  36762. * @returns the index where the animation was in the animation list
  36763. */
  36764. removeAnimation(toRemove: Animation): number;
  36765. /**
  36766. * Will stop the animation of the given target
  36767. * @param target - the target
  36768. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36769. * @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)
  36770. */
  36771. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36772. /**
  36773. * Removes the given animation group from this scene.
  36774. * @param toRemove The animation group to remove
  36775. * @returns The index of the removed animation group
  36776. */
  36777. removeAnimationGroup(toRemove: AnimationGroup): number;
  36778. /**
  36779. * Removes the given multi-material from this scene.
  36780. * @param toRemove The multi-material to remove
  36781. * @returns The index of the removed multi-material
  36782. */
  36783. removeMultiMaterial(toRemove: MultiMaterial): number;
  36784. /**
  36785. * Removes the given material from this scene.
  36786. * @param toRemove The material to remove
  36787. * @returns The index of the removed material
  36788. */
  36789. removeMaterial(toRemove: Material): number;
  36790. /**
  36791. * Removes the given action manager from this scene.
  36792. * @param toRemove The action manager to remove
  36793. * @returns The index of the removed action manager
  36794. */
  36795. removeActionManager(toRemove: AbstractActionManager): number;
  36796. /**
  36797. * Removes the given texture from this scene.
  36798. * @param toRemove The texture to remove
  36799. * @returns The index of the removed texture
  36800. */
  36801. removeTexture(toRemove: BaseTexture): number;
  36802. /**
  36803. * Adds the given light to this scene
  36804. * @param newLight The light to add
  36805. */
  36806. addLight(newLight: Light): void;
  36807. /**
  36808. * Sorts the list list based on light priorities
  36809. */
  36810. sortLightsByPriority(): void;
  36811. /**
  36812. * Adds the given camera to this scene
  36813. * @param newCamera The camera to add
  36814. */
  36815. addCamera(newCamera: Camera): void;
  36816. /**
  36817. * Adds the given skeleton to this scene
  36818. * @param newSkeleton The skeleton to add
  36819. */
  36820. addSkeleton(newSkeleton: Skeleton): void;
  36821. /**
  36822. * Adds the given particle system to this scene
  36823. * @param newParticleSystem The particle system to add
  36824. */
  36825. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36826. /**
  36827. * Adds the given animation to this scene
  36828. * @param newAnimation The animation to add
  36829. */
  36830. addAnimation(newAnimation: Animation): void;
  36831. /**
  36832. * Adds the given animation group to this scene.
  36833. * @param newAnimationGroup The animation group to add
  36834. */
  36835. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36836. /**
  36837. * Adds the given multi-material to this scene
  36838. * @param newMultiMaterial The multi-material to add
  36839. */
  36840. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36841. /**
  36842. * Adds the given material to this scene
  36843. * @param newMaterial The material to add
  36844. */
  36845. addMaterial(newMaterial: Material): void;
  36846. /**
  36847. * Adds the given morph target to this scene
  36848. * @param newMorphTargetManager The morph target to add
  36849. */
  36850. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36851. /**
  36852. * Adds the given geometry to this scene
  36853. * @param newGeometry The geometry to add
  36854. */
  36855. addGeometry(newGeometry: Geometry): void;
  36856. /**
  36857. * Adds the given action manager to this scene
  36858. * @param newActionManager The action manager to add
  36859. */
  36860. addActionManager(newActionManager: AbstractActionManager): void;
  36861. /**
  36862. * Adds the given texture to this scene.
  36863. * @param newTexture The texture to add
  36864. */
  36865. addTexture(newTexture: BaseTexture): void;
  36866. /**
  36867. * Switch active camera
  36868. * @param newCamera defines the new active camera
  36869. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36870. */
  36871. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36872. /**
  36873. * sets the active camera of the scene using its ID
  36874. * @param id defines the camera's ID
  36875. * @return the new active camera or null if none found.
  36876. */
  36877. setActiveCameraByID(id: string): Nullable<Camera>;
  36878. /**
  36879. * sets the active camera of the scene using its name
  36880. * @param name defines the camera's name
  36881. * @returns the new active camera or null if none found.
  36882. */
  36883. setActiveCameraByName(name: string): Nullable<Camera>;
  36884. /**
  36885. * get an animation group using its name
  36886. * @param name defines the material's name
  36887. * @return the animation group or null if none found.
  36888. */
  36889. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36890. /**
  36891. * Get a material using its unique id
  36892. * @param uniqueId defines the material's unique id
  36893. * @return the material or null if none found.
  36894. */
  36895. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36896. /**
  36897. * get a material using its id
  36898. * @param id defines the material's ID
  36899. * @return the material or null if none found.
  36900. */
  36901. getMaterialByID(id: string): Nullable<Material>;
  36902. /**
  36903. * Gets a the last added material using a given id
  36904. * @param id defines the material's ID
  36905. * @return the last material with the given id or null if none found.
  36906. */
  36907. getLastMaterialByID(id: string): Nullable<Material>;
  36908. /**
  36909. * Gets a material using its name
  36910. * @param name defines the material's name
  36911. * @return the material or null if none found.
  36912. */
  36913. getMaterialByName(name: string): Nullable<Material>;
  36914. /**
  36915. * Get a texture using its unique id
  36916. * @param uniqueId defines the texture's unique id
  36917. * @return the texture or null if none found.
  36918. */
  36919. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36920. /**
  36921. * Gets a camera using its id
  36922. * @param id defines the id to look for
  36923. * @returns the camera or null if not found
  36924. */
  36925. getCameraByID(id: string): Nullable<Camera>;
  36926. /**
  36927. * Gets a camera using its unique id
  36928. * @param uniqueId defines the unique id to look for
  36929. * @returns the camera or null if not found
  36930. */
  36931. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36932. /**
  36933. * Gets a camera using its name
  36934. * @param name defines the camera's name
  36935. * @return the camera or null if none found.
  36936. */
  36937. getCameraByName(name: string): Nullable<Camera>;
  36938. /**
  36939. * Gets a bone using its id
  36940. * @param id defines the bone's id
  36941. * @return the bone or null if not found
  36942. */
  36943. getBoneByID(id: string): Nullable<Bone>;
  36944. /**
  36945. * Gets a bone using its id
  36946. * @param name defines the bone's name
  36947. * @return the bone or null if not found
  36948. */
  36949. getBoneByName(name: string): Nullable<Bone>;
  36950. /**
  36951. * Gets a light node using its name
  36952. * @param name defines the the light's name
  36953. * @return the light or null if none found.
  36954. */
  36955. getLightByName(name: string): Nullable<Light>;
  36956. /**
  36957. * Gets a light node using its id
  36958. * @param id defines the light's id
  36959. * @return the light or null if none found.
  36960. */
  36961. getLightByID(id: string): Nullable<Light>;
  36962. /**
  36963. * Gets a light node using its scene-generated unique ID
  36964. * @param uniqueId defines the light's unique id
  36965. * @return the light or null if none found.
  36966. */
  36967. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36968. /**
  36969. * Gets a particle system by id
  36970. * @param id defines the particle system id
  36971. * @return the corresponding system or null if none found
  36972. */
  36973. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36974. /**
  36975. * Gets a geometry using its ID
  36976. * @param id defines the geometry's id
  36977. * @return the geometry or null if none found.
  36978. */
  36979. getGeometryByID(id: string): Nullable<Geometry>;
  36980. private _getGeometryByUniqueID;
  36981. /**
  36982. * Add a new geometry to this scene
  36983. * @param geometry defines the geometry to be added to the scene.
  36984. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36985. * @return a boolean defining if the geometry was added or not
  36986. */
  36987. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36988. /**
  36989. * Removes an existing geometry
  36990. * @param geometry defines the geometry to be removed from the scene
  36991. * @return a boolean defining if the geometry was removed or not
  36992. */
  36993. removeGeometry(geometry: Geometry): boolean;
  36994. /**
  36995. * Gets the list of geometries attached to the scene
  36996. * @returns an array of Geometry
  36997. */
  36998. getGeometries(): Geometry[];
  36999. /**
  37000. * Gets the first added mesh found of a given ID
  37001. * @param id defines the id to search for
  37002. * @return the mesh found or null if not found at all
  37003. */
  37004. getMeshByID(id: string): Nullable<AbstractMesh>;
  37005. /**
  37006. * Gets a list of meshes using their id
  37007. * @param id defines the id to search for
  37008. * @returns a list of meshes
  37009. */
  37010. getMeshesByID(id: string): Array<AbstractMesh>;
  37011. /**
  37012. * Gets the first added transform node found of a given ID
  37013. * @param id defines the id to search for
  37014. * @return the found transform node or null if not found at all.
  37015. */
  37016. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37017. /**
  37018. * Gets a transform node with its auto-generated unique id
  37019. * @param uniqueId efines the unique id to search for
  37020. * @return the found transform node or null if not found at all.
  37021. */
  37022. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37023. /**
  37024. * Gets a list of transform nodes using their id
  37025. * @param id defines the id to search for
  37026. * @returns a list of transform nodes
  37027. */
  37028. getTransformNodesByID(id: string): Array<TransformNode>;
  37029. /**
  37030. * Gets a mesh with its auto-generated unique id
  37031. * @param uniqueId defines the unique id to search for
  37032. * @return the found mesh or null if not found at all.
  37033. */
  37034. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37035. /**
  37036. * Gets a the last added mesh using a given id
  37037. * @param id defines the id to search for
  37038. * @return the found mesh or null if not found at all.
  37039. */
  37040. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37041. /**
  37042. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37043. * @param id defines the id to search for
  37044. * @return the found node or null if not found at all
  37045. */
  37046. getLastEntryByID(id: string): Nullable<Node>;
  37047. /**
  37048. * Gets a node (Mesh, Camera, Light) using a given id
  37049. * @param id defines the id to search for
  37050. * @return the found node or null if not found at all
  37051. */
  37052. getNodeByID(id: string): Nullable<Node>;
  37053. /**
  37054. * Gets a node (Mesh, Camera, Light) using a given name
  37055. * @param name defines the name to search for
  37056. * @return the found node or null if not found at all.
  37057. */
  37058. getNodeByName(name: string): Nullable<Node>;
  37059. /**
  37060. * Gets a mesh using a given name
  37061. * @param name defines the name to search for
  37062. * @return the found mesh or null if not found at all.
  37063. */
  37064. getMeshByName(name: string): Nullable<AbstractMesh>;
  37065. /**
  37066. * Gets a transform node using a given name
  37067. * @param name defines the name to search for
  37068. * @return the found transform node or null if not found at all.
  37069. */
  37070. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37071. /**
  37072. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37073. * @param id defines the id to search for
  37074. * @return the found skeleton or null if not found at all.
  37075. */
  37076. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37077. /**
  37078. * Gets a skeleton using a given auto generated unique id
  37079. * @param uniqueId defines the unique id to search for
  37080. * @return the found skeleton or null if not found at all.
  37081. */
  37082. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37083. /**
  37084. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37085. * @param id defines the id to search for
  37086. * @return the found skeleton or null if not found at all.
  37087. */
  37088. getSkeletonById(id: string): Nullable<Skeleton>;
  37089. /**
  37090. * Gets a skeleton using a given name
  37091. * @param name defines the name to search for
  37092. * @return the found skeleton or null if not found at all.
  37093. */
  37094. getSkeletonByName(name: string): Nullable<Skeleton>;
  37095. /**
  37096. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37097. * @param id defines the id to search for
  37098. * @return the found morph target manager or null if not found at all.
  37099. */
  37100. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37101. /**
  37102. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37103. * @param id defines the id to search for
  37104. * @return the found morph target or null if not found at all.
  37105. */
  37106. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37107. /**
  37108. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37109. * @param name defines the name to search for
  37110. * @return the found morph target or null if not found at all.
  37111. */
  37112. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37113. /**
  37114. * Gets a boolean indicating if the given mesh is active
  37115. * @param mesh defines the mesh to look for
  37116. * @returns true if the mesh is in the active list
  37117. */
  37118. isActiveMesh(mesh: AbstractMesh): boolean;
  37119. /**
  37120. * Return a unique id as a string which can serve as an identifier for the scene
  37121. */
  37122. get uid(): string;
  37123. /**
  37124. * Add an externaly attached data from its key.
  37125. * This method call will fail and return false, if such key already exists.
  37126. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37127. * @param key the unique key that identifies the data
  37128. * @param data the data object to associate to the key for this Engine instance
  37129. * @return true if no such key were already present and the data was added successfully, false otherwise
  37130. */
  37131. addExternalData<T>(key: string, data: T): boolean;
  37132. /**
  37133. * Get an externaly attached data from its key
  37134. * @param key the unique key that identifies the data
  37135. * @return the associated data, if present (can be null), or undefined if not present
  37136. */
  37137. getExternalData<T>(key: string): Nullable<T>;
  37138. /**
  37139. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37140. * @param key the unique key that identifies the data
  37141. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37142. * @return the associated data, can be null if the factory returned null.
  37143. */
  37144. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37145. /**
  37146. * Remove an externaly attached data from the Engine instance
  37147. * @param key the unique key that identifies the data
  37148. * @return true if the data was successfully removed, false if it doesn't exist
  37149. */
  37150. removeExternalData(key: string): boolean;
  37151. private _evaluateSubMesh;
  37152. /**
  37153. * Clear the processed materials smart array preventing retention point in material dispose.
  37154. */
  37155. freeProcessedMaterials(): void;
  37156. private _preventFreeActiveMeshesAndRenderingGroups;
  37157. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37158. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37159. * when disposing several meshes in a row or a hierarchy of meshes.
  37160. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37161. */
  37162. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37163. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37164. /**
  37165. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37166. */
  37167. freeActiveMeshes(): void;
  37168. /**
  37169. * Clear the info related to rendering groups preventing retention points during dispose.
  37170. */
  37171. freeRenderingGroups(): void;
  37172. /** @hidden */
  37173. _isInIntermediateRendering(): boolean;
  37174. /**
  37175. * Lambda returning the list of potentially active meshes.
  37176. */
  37177. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37178. /**
  37179. * Lambda returning the list of potentially active sub meshes.
  37180. */
  37181. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37182. /**
  37183. * Lambda returning the list of potentially intersecting sub meshes.
  37184. */
  37185. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37186. /**
  37187. * Lambda returning the list of potentially colliding sub meshes.
  37188. */
  37189. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37190. private _activeMeshesFrozen;
  37191. private _skipEvaluateActiveMeshesCompletely;
  37192. /**
  37193. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37194. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37195. * @returns the current scene
  37196. */
  37197. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37198. /**
  37199. * Use this function to restart evaluating active meshes on every frame
  37200. * @returns the current scene
  37201. */
  37202. unfreezeActiveMeshes(): Scene;
  37203. private _evaluateActiveMeshes;
  37204. private _activeMesh;
  37205. /**
  37206. * Update the transform matrix to update from the current active camera
  37207. * @param force defines a boolean used to force the update even if cache is up to date
  37208. */
  37209. updateTransformMatrix(force?: boolean): void;
  37210. private _bindFrameBuffer;
  37211. /** @hidden */
  37212. _allowPostProcessClearColor: boolean;
  37213. /** @hidden */
  37214. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37215. private _processSubCameras;
  37216. private _checkIntersections;
  37217. /** @hidden */
  37218. _advancePhysicsEngineStep(step: number): void;
  37219. /**
  37220. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37221. */
  37222. getDeterministicFrameTime: () => number;
  37223. /** @hidden */
  37224. _animate(): void;
  37225. /** Execute all animations (for a frame) */
  37226. animate(): void;
  37227. /**
  37228. * Render the scene
  37229. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37230. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37231. */
  37232. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37233. /**
  37234. * Freeze all materials
  37235. * A frozen material will not be updatable but should be faster to render
  37236. */
  37237. freezeMaterials(): void;
  37238. /**
  37239. * Unfreeze all materials
  37240. * A frozen material will not be updatable but should be faster to render
  37241. */
  37242. unfreezeMaterials(): void;
  37243. /**
  37244. * Releases all held ressources
  37245. */
  37246. dispose(): void;
  37247. /**
  37248. * Gets if the scene is already disposed
  37249. */
  37250. get isDisposed(): boolean;
  37251. /**
  37252. * Call this function to reduce memory footprint of the scene.
  37253. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37254. */
  37255. clearCachedVertexData(): void;
  37256. /**
  37257. * This function will remove the local cached buffer data from texture.
  37258. * It will save memory but will prevent the texture from being rebuilt
  37259. */
  37260. cleanCachedTextureBuffer(): void;
  37261. /**
  37262. * Get the world extend vectors with an optional filter
  37263. *
  37264. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37265. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37266. */
  37267. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37268. min: Vector3;
  37269. max: Vector3;
  37270. };
  37271. /**
  37272. * Creates a ray that can be used to pick in the scene
  37273. * @param x defines the x coordinate of the origin (on-screen)
  37274. * @param y defines the y coordinate of the origin (on-screen)
  37275. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37276. * @param camera defines the camera to use for the picking
  37277. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37278. * @returns a Ray
  37279. */
  37280. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37281. /**
  37282. * Creates a ray that can be used to pick in the scene
  37283. * @param x defines the x coordinate of the origin (on-screen)
  37284. * @param y defines the y coordinate of the origin (on-screen)
  37285. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37286. * @param result defines the ray where to store the picking ray
  37287. * @param camera defines the camera to use for the picking
  37288. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37289. * @returns the current scene
  37290. */
  37291. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37292. /**
  37293. * Creates a ray that can be used to pick in the scene
  37294. * @param x defines the x coordinate of the origin (on-screen)
  37295. * @param y defines the y coordinate of the origin (on-screen)
  37296. * @param camera defines the camera to use for the picking
  37297. * @returns a Ray
  37298. */
  37299. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37300. /**
  37301. * Creates a ray that can be used to pick in the scene
  37302. * @param x defines the x coordinate of the origin (on-screen)
  37303. * @param y defines the y coordinate of the origin (on-screen)
  37304. * @param result defines the ray where to store the picking ray
  37305. * @param camera defines the camera to use for the picking
  37306. * @returns the current scene
  37307. */
  37308. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37309. /** Launch a ray to try to pick a mesh in the scene
  37310. * @param x position on screen
  37311. * @param y position on screen
  37312. * @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
  37313. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37314. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37315. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37316. * @returns a PickingInfo
  37317. */
  37318. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37319. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37320. * @param x position on screen
  37321. * @param y position on screen
  37322. * @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
  37323. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37324. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37325. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37326. */
  37327. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37328. /** Use the given ray to pick a mesh in the scene
  37329. * @param ray The ray to use to pick meshes
  37330. * @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
  37331. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37332. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37333. * @returns a PickingInfo
  37334. */
  37335. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37336. /**
  37337. * Launch a ray to try to pick a mesh in the scene
  37338. * @param x X position on screen
  37339. * @param y Y position on screen
  37340. * @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
  37341. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37342. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37343. * @returns an array of PickingInfo
  37344. */
  37345. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37346. /**
  37347. * Launch a ray to try to pick a mesh in the scene
  37348. * @param ray Ray to use
  37349. * @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
  37350. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37351. * @returns an array of PickingInfo
  37352. */
  37353. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37354. /**
  37355. * Force the value of meshUnderPointer
  37356. * @param mesh defines the mesh to use
  37357. */
  37358. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37359. /**
  37360. * Gets the mesh under the pointer
  37361. * @returns a Mesh or null if no mesh is under the pointer
  37362. */
  37363. getPointerOverMesh(): Nullable<AbstractMesh>;
  37364. /** @hidden */
  37365. _rebuildGeometries(): void;
  37366. /** @hidden */
  37367. _rebuildTextures(): void;
  37368. private _getByTags;
  37369. /**
  37370. * Get a list of meshes by tags
  37371. * @param tagsQuery defines the tags query to use
  37372. * @param forEach defines a predicate used to filter results
  37373. * @returns an array of Mesh
  37374. */
  37375. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37376. /**
  37377. * Get a list of cameras by tags
  37378. * @param tagsQuery defines the tags query to use
  37379. * @param forEach defines a predicate used to filter results
  37380. * @returns an array of Camera
  37381. */
  37382. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37383. /**
  37384. * Get a list of lights by tags
  37385. * @param tagsQuery defines the tags query to use
  37386. * @param forEach defines a predicate used to filter results
  37387. * @returns an array of Light
  37388. */
  37389. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37390. /**
  37391. * Get a list of materials by tags
  37392. * @param tagsQuery defines the tags query to use
  37393. * @param forEach defines a predicate used to filter results
  37394. * @returns an array of Material
  37395. */
  37396. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37397. /**
  37398. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37399. * This allowed control for front to back rendering or reversly depending of the special needs.
  37400. *
  37401. * @param renderingGroupId The rendering group id corresponding to its index
  37402. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37403. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37404. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37405. */
  37406. 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;
  37407. /**
  37408. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37409. *
  37410. * @param renderingGroupId The rendering group id corresponding to its index
  37411. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37412. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37413. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37414. */
  37415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37416. /**
  37417. * Gets the current auto clear configuration for one rendering group of the rendering
  37418. * manager.
  37419. * @param index the rendering group index to get the information for
  37420. * @returns The auto clear setup for the requested rendering group
  37421. */
  37422. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37423. private _blockMaterialDirtyMechanism;
  37424. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37425. get blockMaterialDirtyMechanism(): boolean;
  37426. set blockMaterialDirtyMechanism(value: boolean);
  37427. /**
  37428. * Will flag all materials as dirty to trigger new shader compilation
  37429. * @param flag defines the flag used to specify which material part must be marked as dirty
  37430. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37431. */
  37432. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37433. /** @hidden */
  37434. _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;
  37435. /** @hidden */
  37436. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37437. /** @hidden */
  37438. _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;
  37439. /** @hidden */
  37440. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37441. /** @hidden */
  37442. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37443. /** @hidden */
  37444. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37445. }
  37446. }
  37447. declare module BABYLON {
  37448. /**
  37449. * Set of assets to keep when moving a scene into an asset container.
  37450. */
  37451. export class KeepAssets extends AbstractScene {
  37452. }
  37453. /**
  37454. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37455. */
  37456. export class InstantiatedEntries {
  37457. /**
  37458. * List of new root nodes (eg. nodes with no parent)
  37459. */
  37460. rootNodes: TransformNode[];
  37461. /**
  37462. * List of new skeletons
  37463. */
  37464. skeletons: Skeleton[];
  37465. /**
  37466. * List of new animation groups
  37467. */
  37468. animationGroups: AnimationGroup[];
  37469. }
  37470. /**
  37471. * Container with a set of assets that can be added or removed from a scene.
  37472. */
  37473. export class AssetContainer extends AbstractScene {
  37474. private _wasAddedToScene;
  37475. /**
  37476. * The scene the AssetContainer belongs to.
  37477. */
  37478. scene: Scene;
  37479. /**
  37480. * Instantiates an AssetContainer.
  37481. * @param scene The scene the AssetContainer belongs to.
  37482. */
  37483. constructor(scene: Scene);
  37484. /**
  37485. * Instantiate or clone all meshes and add the new ones to the scene.
  37486. * Skeletons and animation groups will all be cloned
  37487. * @param nameFunction defines an optional function used to get new names for clones
  37488. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37489. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37490. */
  37491. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37492. /**
  37493. * Adds all the assets from the container to the scene.
  37494. */
  37495. addAllToScene(): void;
  37496. /**
  37497. * Removes all the assets in the container from the scene
  37498. */
  37499. removeAllFromScene(): void;
  37500. /**
  37501. * Disposes all the assets in the container
  37502. */
  37503. dispose(): void;
  37504. private _moveAssets;
  37505. /**
  37506. * Removes all the assets contained in the scene and adds them to the container.
  37507. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37508. */
  37509. moveAllFromScene(keepAssets?: KeepAssets): void;
  37510. /**
  37511. * 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.
  37512. * @returns the root mesh
  37513. */
  37514. createRootMesh(): Mesh;
  37515. /**
  37516. * Merge animations from this asset container into a scene
  37517. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37518. * @param animatables set of animatables to retarget to a node from the scene
  37519. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37520. */
  37521. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37522. }
  37523. }
  37524. declare module BABYLON {
  37525. /**
  37526. * Defines how the parser contract is defined.
  37527. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37528. */
  37529. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37530. /**
  37531. * Defines how the individual parser contract is defined.
  37532. * These parser can parse an individual asset
  37533. */
  37534. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37535. /**
  37536. * Base class of the scene acting as a container for the different elements composing a scene.
  37537. * This class is dynamically extended by the different components of the scene increasing
  37538. * flexibility and reducing coupling
  37539. */
  37540. export abstract class AbstractScene {
  37541. /**
  37542. * Stores the list of available parsers in the application.
  37543. */
  37544. private static _BabylonFileParsers;
  37545. /**
  37546. * Stores the list of available individual parsers in the application.
  37547. */
  37548. private static _IndividualBabylonFileParsers;
  37549. /**
  37550. * Adds a parser in the list of available ones
  37551. * @param name Defines the name of the parser
  37552. * @param parser Defines the parser to add
  37553. */
  37554. static AddParser(name: string, parser: BabylonFileParser): void;
  37555. /**
  37556. * Gets a general parser from the list of avaialble ones
  37557. * @param name Defines the name of the parser
  37558. * @returns the requested parser or null
  37559. */
  37560. static GetParser(name: string): Nullable<BabylonFileParser>;
  37561. /**
  37562. * Adds n individual parser in the list of available ones
  37563. * @param name Defines the name of the parser
  37564. * @param parser Defines the parser to add
  37565. */
  37566. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37567. /**
  37568. * Gets an individual parser from the list of avaialble ones
  37569. * @param name Defines the name of the parser
  37570. * @returns the requested parser or null
  37571. */
  37572. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37573. /**
  37574. * Parser json data and populate both a scene and its associated container object
  37575. * @param jsonData Defines the data to parse
  37576. * @param scene Defines the scene to parse the data for
  37577. * @param container Defines the container attached to the parsing sequence
  37578. * @param rootUrl Defines the root url of the data
  37579. */
  37580. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37581. /**
  37582. * Gets the list of root nodes (ie. nodes with no parent)
  37583. */
  37584. rootNodes: Node[];
  37585. /** All of the cameras added to this scene
  37586. * @see http://doc.babylonjs.com/babylon101/cameras
  37587. */
  37588. cameras: Camera[];
  37589. /**
  37590. * All of the lights added to this scene
  37591. * @see http://doc.babylonjs.com/babylon101/lights
  37592. */
  37593. lights: Light[];
  37594. /**
  37595. * All of the (abstract) meshes added to this scene
  37596. */
  37597. meshes: AbstractMesh[];
  37598. /**
  37599. * The list of skeletons added to the scene
  37600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37601. */
  37602. skeletons: Skeleton[];
  37603. /**
  37604. * All of the particle systems added to this scene
  37605. * @see http://doc.babylonjs.com/babylon101/particles
  37606. */
  37607. particleSystems: IParticleSystem[];
  37608. /**
  37609. * Gets a list of Animations associated with the scene
  37610. */
  37611. animations: Animation[];
  37612. /**
  37613. * All of the animation groups added to this scene
  37614. * @see http://doc.babylonjs.com/how_to/group
  37615. */
  37616. animationGroups: AnimationGroup[];
  37617. /**
  37618. * All of the multi-materials added to this scene
  37619. * @see http://doc.babylonjs.com/how_to/multi_materials
  37620. */
  37621. multiMaterials: MultiMaterial[];
  37622. /**
  37623. * All of the materials added to this scene
  37624. * In the context of a Scene, it is not supposed to be modified manually.
  37625. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37626. * Note also that the order of the Material within the array is not significant and might change.
  37627. * @see http://doc.babylonjs.com/babylon101/materials
  37628. */
  37629. materials: Material[];
  37630. /**
  37631. * The list of morph target managers added to the scene
  37632. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37633. */
  37634. morphTargetManagers: MorphTargetManager[];
  37635. /**
  37636. * The list of geometries used in the scene.
  37637. */
  37638. geometries: Geometry[];
  37639. /**
  37640. * All of the tranform nodes added to this scene
  37641. * In the context of a Scene, it is not supposed to be modified manually.
  37642. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37643. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37644. * @see http://doc.babylonjs.com/how_to/transformnode
  37645. */
  37646. transformNodes: TransformNode[];
  37647. /**
  37648. * ActionManagers available on the scene.
  37649. */
  37650. actionManagers: AbstractActionManager[];
  37651. /**
  37652. * Textures to keep.
  37653. */
  37654. textures: BaseTexture[];
  37655. /**
  37656. * Environment texture for the scene
  37657. */
  37658. environmentTexture: Nullable<BaseTexture>;
  37659. /**
  37660. * @returns all meshes, lights, cameras, transformNodes and bones
  37661. */
  37662. getNodes(): Array<Node>;
  37663. }
  37664. }
  37665. declare module BABYLON {
  37666. /**
  37667. * Interface used to define options for Sound class
  37668. */
  37669. export interface ISoundOptions {
  37670. /**
  37671. * Does the sound autoplay once loaded.
  37672. */
  37673. autoplay?: boolean;
  37674. /**
  37675. * Does the sound loop after it finishes playing once.
  37676. */
  37677. loop?: boolean;
  37678. /**
  37679. * Sound's volume
  37680. */
  37681. volume?: number;
  37682. /**
  37683. * Is it a spatial sound?
  37684. */
  37685. spatialSound?: boolean;
  37686. /**
  37687. * Maximum distance to hear that sound
  37688. */
  37689. maxDistance?: number;
  37690. /**
  37691. * Uses user defined attenuation function
  37692. */
  37693. useCustomAttenuation?: boolean;
  37694. /**
  37695. * Define the roll off factor of spatial sounds.
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37697. */
  37698. rolloffFactor?: number;
  37699. /**
  37700. * Define the reference distance the sound should be heard perfectly.
  37701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37702. */
  37703. refDistance?: number;
  37704. /**
  37705. * Define the distance attenuation model the sound will follow.
  37706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37707. */
  37708. distanceModel?: string;
  37709. /**
  37710. * Defines the playback speed (1 by default)
  37711. */
  37712. playbackRate?: number;
  37713. /**
  37714. * Defines if the sound is from a streaming source
  37715. */
  37716. streaming?: boolean;
  37717. /**
  37718. * Defines an optional length (in seconds) inside the sound file
  37719. */
  37720. length?: number;
  37721. /**
  37722. * Defines an optional offset (in seconds) inside the sound file
  37723. */
  37724. offset?: number;
  37725. /**
  37726. * If true, URLs will not be required to state the audio file codec to use.
  37727. */
  37728. skipCodecCheck?: boolean;
  37729. }
  37730. /**
  37731. * Defines a sound that can be played in the application.
  37732. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37734. */
  37735. export class Sound {
  37736. /**
  37737. * The name of the sound in the scene.
  37738. */
  37739. name: string;
  37740. /**
  37741. * Does the sound autoplay once loaded.
  37742. */
  37743. autoplay: boolean;
  37744. /**
  37745. * Does the sound loop after it finishes playing once.
  37746. */
  37747. loop: boolean;
  37748. /**
  37749. * Does the sound use a custom attenuation curve to simulate the falloff
  37750. * happening when the source gets further away from the camera.
  37751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37752. */
  37753. useCustomAttenuation: boolean;
  37754. /**
  37755. * The sound track id this sound belongs to.
  37756. */
  37757. soundTrackId: number;
  37758. /**
  37759. * Is this sound currently played.
  37760. */
  37761. isPlaying: boolean;
  37762. /**
  37763. * Is this sound currently paused.
  37764. */
  37765. isPaused: boolean;
  37766. /**
  37767. * Does this sound enables spatial sound.
  37768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37769. */
  37770. spatialSound: boolean;
  37771. /**
  37772. * Define the reference distance the sound should be heard perfectly.
  37773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37774. */
  37775. refDistance: number;
  37776. /**
  37777. * Define the roll off factor of spatial sounds.
  37778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37779. */
  37780. rolloffFactor: number;
  37781. /**
  37782. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37784. */
  37785. maxDistance: number;
  37786. /**
  37787. * Define the distance attenuation model the sound will follow.
  37788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37789. */
  37790. distanceModel: string;
  37791. /**
  37792. * @hidden
  37793. * Back Compat
  37794. **/
  37795. onended: () => any;
  37796. /**
  37797. * Observable event when the current playing sound finishes.
  37798. */
  37799. onEndedObservable: Observable<Sound>;
  37800. private _panningModel;
  37801. private _playbackRate;
  37802. private _streaming;
  37803. private _startTime;
  37804. private _startOffset;
  37805. private _position;
  37806. /** @hidden */
  37807. _positionInEmitterSpace: boolean;
  37808. private _localDirection;
  37809. private _volume;
  37810. private _isReadyToPlay;
  37811. private _isDirectional;
  37812. private _readyToPlayCallback;
  37813. private _audioBuffer;
  37814. private _soundSource;
  37815. private _streamingSource;
  37816. private _soundPanner;
  37817. private _soundGain;
  37818. private _inputAudioNode;
  37819. private _outputAudioNode;
  37820. private _coneInnerAngle;
  37821. private _coneOuterAngle;
  37822. private _coneOuterGain;
  37823. private _scene;
  37824. private _connectedTransformNode;
  37825. private _customAttenuationFunction;
  37826. private _registerFunc;
  37827. private _isOutputConnected;
  37828. private _htmlAudioElement;
  37829. private _urlType;
  37830. private _length?;
  37831. private _offset?;
  37832. /** @hidden */
  37833. static _SceneComponentInitialization: (scene: Scene) => void;
  37834. /**
  37835. * Create a sound and attach it to a scene
  37836. * @param name Name of your sound
  37837. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37838. * @param scene defines the scene the sound belongs to
  37839. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37840. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37841. */
  37842. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37843. /**
  37844. * Release the sound and its associated resources
  37845. */
  37846. dispose(): void;
  37847. /**
  37848. * Gets if the sounds is ready to be played or not.
  37849. * @returns true if ready, otherwise false
  37850. */
  37851. isReady(): boolean;
  37852. private _soundLoaded;
  37853. /**
  37854. * Sets the data of the sound from an audiobuffer
  37855. * @param audioBuffer The audioBuffer containing the data
  37856. */
  37857. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37858. /**
  37859. * Updates the current sounds options such as maxdistance, loop...
  37860. * @param options A JSON object containing values named as the object properties
  37861. */
  37862. updateOptions(options: ISoundOptions): void;
  37863. private _createSpatialParameters;
  37864. private _updateSpatialParameters;
  37865. /**
  37866. * Switch the panning model to HRTF:
  37867. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37869. */
  37870. switchPanningModelToHRTF(): void;
  37871. /**
  37872. * Switch the panning model to Equal Power:
  37873. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37875. */
  37876. switchPanningModelToEqualPower(): void;
  37877. private _switchPanningModel;
  37878. /**
  37879. * Connect this sound to a sound track audio node like gain...
  37880. * @param soundTrackAudioNode the sound track audio node to connect to
  37881. */
  37882. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37883. /**
  37884. * Transform this sound into a directional source
  37885. * @param coneInnerAngle Size of the inner cone in degree
  37886. * @param coneOuterAngle Size of the outer cone in degree
  37887. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37888. */
  37889. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37890. /**
  37891. * Gets or sets the inner angle for the directional cone.
  37892. */
  37893. get directionalConeInnerAngle(): number;
  37894. /**
  37895. * Gets or sets the inner angle for the directional cone.
  37896. */
  37897. set directionalConeInnerAngle(value: number);
  37898. /**
  37899. * Gets or sets the outer angle for the directional cone.
  37900. */
  37901. get directionalConeOuterAngle(): number;
  37902. /**
  37903. * Gets or sets the outer angle for the directional cone.
  37904. */
  37905. set directionalConeOuterAngle(value: number);
  37906. /**
  37907. * Sets the position of the emitter if spatial sound is enabled
  37908. * @param newPosition Defines the new posisiton
  37909. */
  37910. setPosition(newPosition: Vector3): void;
  37911. /**
  37912. * Sets the local direction of the emitter if spatial sound is enabled
  37913. * @param newLocalDirection Defines the new local direction
  37914. */
  37915. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37916. private _updateDirection;
  37917. /** @hidden */
  37918. updateDistanceFromListener(): void;
  37919. /**
  37920. * Sets a new custom attenuation function for the sound.
  37921. * @param callback Defines the function used for the attenuation
  37922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37923. */
  37924. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37925. /**
  37926. * Play the sound
  37927. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37928. * @param offset (optional) Start the sound at a specific time in seconds
  37929. * @param length (optional) Sound duration (in seconds)
  37930. */
  37931. play(time?: number, offset?: number, length?: number): void;
  37932. private _onended;
  37933. /**
  37934. * Stop the sound
  37935. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37936. */
  37937. stop(time?: number): void;
  37938. /**
  37939. * Put the sound in pause
  37940. */
  37941. pause(): void;
  37942. /**
  37943. * Sets a dedicated volume for this sounds
  37944. * @param newVolume Define the new volume of the sound
  37945. * @param time Define time for gradual change to new volume
  37946. */
  37947. setVolume(newVolume: number, time?: number): void;
  37948. /**
  37949. * Set the sound play back rate
  37950. * @param newPlaybackRate Define the playback rate the sound should be played at
  37951. */
  37952. setPlaybackRate(newPlaybackRate: number): void;
  37953. /**
  37954. * Gets the volume of the sound.
  37955. * @returns the volume of the sound
  37956. */
  37957. getVolume(): number;
  37958. /**
  37959. * Attach the sound to a dedicated mesh
  37960. * @param transformNode The transform node to connect the sound with
  37961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37962. */
  37963. attachToMesh(transformNode: TransformNode): void;
  37964. /**
  37965. * Detach the sound from the previously attached mesh
  37966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37967. */
  37968. detachFromMesh(): void;
  37969. private _onRegisterAfterWorldMatrixUpdate;
  37970. /**
  37971. * Clone the current sound in the scene.
  37972. * @returns the new sound clone
  37973. */
  37974. clone(): Nullable<Sound>;
  37975. /**
  37976. * Gets the current underlying audio buffer containing the data
  37977. * @returns the audio buffer
  37978. */
  37979. getAudioBuffer(): Nullable<AudioBuffer>;
  37980. /**
  37981. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37982. * @returns the source node
  37983. */
  37984. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37985. /**
  37986. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37987. * @returns the gain node
  37988. */
  37989. getSoundGain(): Nullable<GainNode>;
  37990. /**
  37991. * Serializes the Sound in a JSON representation
  37992. * @returns the JSON representation of the sound
  37993. */
  37994. serialize(): any;
  37995. /**
  37996. * Parse a JSON representation of a sound to innstantiate in a given scene
  37997. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37998. * @param scene Define the scene the new parsed sound should be created in
  37999. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38000. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38001. * @returns the newly parsed sound
  38002. */
  38003. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38004. }
  38005. }
  38006. declare module BABYLON {
  38007. /**
  38008. * This defines an action helpful to play a defined sound on a triggered action.
  38009. */
  38010. export class PlaySoundAction extends Action {
  38011. private _sound;
  38012. /**
  38013. * Instantiate the action
  38014. * @param triggerOptions defines the trigger options
  38015. * @param sound defines the sound to play
  38016. * @param condition defines the trigger related conditions
  38017. */
  38018. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38019. /** @hidden */
  38020. _prepare(): void;
  38021. /**
  38022. * Execute the action and play the sound.
  38023. */
  38024. execute(): void;
  38025. /**
  38026. * Serializes the actions and its related information.
  38027. * @param parent defines the object to serialize in
  38028. * @returns the serialized object
  38029. */
  38030. serialize(parent: any): any;
  38031. }
  38032. /**
  38033. * This defines an action helpful to stop a defined sound on a triggered action.
  38034. */
  38035. export class StopSoundAction extends Action {
  38036. private _sound;
  38037. /**
  38038. * Instantiate the action
  38039. * @param triggerOptions defines the trigger options
  38040. * @param sound defines the sound to stop
  38041. * @param condition defines the trigger related conditions
  38042. */
  38043. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38044. /** @hidden */
  38045. _prepare(): void;
  38046. /**
  38047. * Execute the action and stop the sound.
  38048. */
  38049. execute(): void;
  38050. /**
  38051. * Serializes the actions and its related information.
  38052. * @param parent defines the object to serialize in
  38053. * @returns the serialized object
  38054. */
  38055. serialize(parent: any): any;
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. /**
  38060. * This defines an action responsible to change the value of a property
  38061. * by interpolating between its current value and the newly set one once triggered.
  38062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38063. */
  38064. export class InterpolateValueAction extends Action {
  38065. /**
  38066. * Defines the path of the property where the value should be interpolated
  38067. */
  38068. propertyPath: string;
  38069. /**
  38070. * Defines the target value at the end of the interpolation.
  38071. */
  38072. value: any;
  38073. /**
  38074. * Defines the time it will take for the property to interpolate to the value.
  38075. */
  38076. duration: number;
  38077. /**
  38078. * Defines if the other scene animations should be stopped when the action has been triggered
  38079. */
  38080. stopOtherAnimations?: boolean;
  38081. /**
  38082. * Defines a callback raised once the interpolation animation has been done.
  38083. */
  38084. onInterpolationDone?: () => void;
  38085. /**
  38086. * Observable triggered once the interpolation animation has been done.
  38087. */
  38088. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38089. private _target;
  38090. private _effectiveTarget;
  38091. private _property;
  38092. /**
  38093. * Instantiate the action
  38094. * @param triggerOptions defines the trigger options
  38095. * @param target defines the object containing the value to interpolate
  38096. * @param propertyPath defines the path to the property in the target object
  38097. * @param value defines the target value at the end of the interpolation
  38098. * @param duration deines the time it will take for the property to interpolate to the value.
  38099. * @param condition defines the trigger related conditions
  38100. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38101. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38102. */
  38103. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38104. /** @hidden */
  38105. _prepare(): void;
  38106. /**
  38107. * Execute the action starts the value interpolation.
  38108. */
  38109. execute(): void;
  38110. /**
  38111. * Serializes the actions and its related information.
  38112. * @param parent defines the object to serialize in
  38113. * @returns the serialized object
  38114. */
  38115. serialize(parent: any): any;
  38116. }
  38117. }
  38118. declare module BABYLON {
  38119. /**
  38120. * Options allowed during the creation of a sound track.
  38121. */
  38122. export interface ISoundTrackOptions {
  38123. /**
  38124. * The volume the sound track should take during creation
  38125. */
  38126. volume?: number;
  38127. /**
  38128. * Define if the sound track is the main sound track of the scene
  38129. */
  38130. mainTrack?: boolean;
  38131. }
  38132. /**
  38133. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38134. * It will be also used in a future release to apply effects on a specific track.
  38135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38136. */
  38137. export class SoundTrack {
  38138. /**
  38139. * The unique identifier of the sound track in the scene.
  38140. */
  38141. id: number;
  38142. /**
  38143. * The list of sounds included in the sound track.
  38144. */
  38145. soundCollection: Array<Sound>;
  38146. private _outputAudioNode;
  38147. private _scene;
  38148. private _connectedAnalyser;
  38149. private _options;
  38150. private _isInitialized;
  38151. /**
  38152. * Creates a new sound track.
  38153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38154. * @param scene Define the scene the sound track belongs to
  38155. * @param options
  38156. */
  38157. constructor(scene: Scene, options?: ISoundTrackOptions);
  38158. private _initializeSoundTrackAudioGraph;
  38159. /**
  38160. * Release the sound track and its associated resources
  38161. */
  38162. dispose(): void;
  38163. /**
  38164. * Adds a sound to this sound track
  38165. * @param sound define the cound to add
  38166. * @ignoreNaming
  38167. */
  38168. AddSound(sound: Sound): void;
  38169. /**
  38170. * Removes a sound to this sound track
  38171. * @param sound define the cound to remove
  38172. * @ignoreNaming
  38173. */
  38174. RemoveSound(sound: Sound): void;
  38175. /**
  38176. * Set a global volume for the full sound track.
  38177. * @param newVolume Define the new volume of the sound track
  38178. */
  38179. setVolume(newVolume: number): void;
  38180. /**
  38181. * Switch the panning model to HRTF:
  38182. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38184. */
  38185. switchPanningModelToHRTF(): void;
  38186. /**
  38187. * Switch the panning model to Equal Power:
  38188. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38190. */
  38191. switchPanningModelToEqualPower(): void;
  38192. /**
  38193. * Connect the sound track to an audio analyser allowing some amazing
  38194. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38196. * @param analyser The analyser to connect to the engine
  38197. */
  38198. connectToAnalyser(analyser: Analyser): void;
  38199. }
  38200. }
  38201. declare module BABYLON {
  38202. interface AbstractScene {
  38203. /**
  38204. * The list of sounds used in the scene.
  38205. */
  38206. sounds: Nullable<Array<Sound>>;
  38207. }
  38208. interface Scene {
  38209. /**
  38210. * @hidden
  38211. * Backing field
  38212. */
  38213. _mainSoundTrack: SoundTrack;
  38214. /**
  38215. * The main sound track played by the scene.
  38216. * It cotains your primary collection of sounds.
  38217. */
  38218. mainSoundTrack: SoundTrack;
  38219. /**
  38220. * The list of sound tracks added to the scene
  38221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38222. */
  38223. soundTracks: Nullable<Array<SoundTrack>>;
  38224. /**
  38225. * Gets a sound using a given name
  38226. * @param name defines the name to search for
  38227. * @return the found sound or null if not found at all.
  38228. */
  38229. getSoundByName(name: string): Nullable<Sound>;
  38230. /**
  38231. * Gets or sets if audio support is enabled
  38232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38233. */
  38234. audioEnabled: boolean;
  38235. /**
  38236. * Gets or sets if audio will be output to headphones
  38237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38238. */
  38239. headphone: boolean;
  38240. /**
  38241. * Gets or sets custom audio listener position provider
  38242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38243. */
  38244. audioListenerPositionProvider: Nullable<() => Vector3>;
  38245. /**
  38246. * Gets or sets a refresh rate when using 3D audio positioning
  38247. */
  38248. audioPositioningRefreshRate: number;
  38249. }
  38250. /**
  38251. * Defines the sound scene component responsible to manage any sounds
  38252. * in a given scene.
  38253. */
  38254. export class AudioSceneComponent implements ISceneSerializableComponent {
  38255. /**
  38256. * The component name helpfull to identify the component in the list of scene components.
  38257. */
  38258. readonly name: string;
  38259. /**
  38260. * The scene the component belongs to.
  38261. */
  38262. scene: Scene;
  38263. private _audioEnabled;
  38264. /**
  38265. * Gets whether audio is enabled or not.
  38266. * Please use related enable/disable method to switch state.
  38267. */
  38268. get audioEnabled(): boolean;
  38269. private _headphone;
  38270. /**
  38271. * Gets whether audio is outputing to headphone or not.
  38272. * Please use the according Switch methods to change output.
  38273. */
  38274. get headphone(): boolean;
  38275. /**
  38276. * Gets or sets a refresh rate when using 3D audio positioning
  38277. */
  38278. audioPositioningRefreshRate: number;
  38279. private _audioListenerPositionProvider;
  38280. /**
  38281. * Gets the current audio listener position provider
  38282. */
  38283. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38284. /**
  38285. * Sets a custom listener position for all sounds in the scene
  38286. * By default, this is the position of the first active camera
  38287. */
  38288. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38289. /**
  38290. * Creates a new instance of the component for the given scene
  38291. * @param scene Defines the scene to register the component in
  38292. */
  38293. constructor(scene: Scene);
  38294. /**
  38295. * Registers the component in a given scene
  38296. */
  38297. register(): void;
  38298. /**
  38299. * Rebuilds the elements related to this component in case of
  38300. * context lost for instance.
  38301. */
  38302. rebuild(): void;
  38303. /**
  38304. * Serializes the component data to the specified json object
  38305. * @param serializationObject The object to serialize to
  38306. */
  38307. serialize(serializationObject: any): void;
  38308. /**
  38309. * Adds all the elements from the container to the scene
  38310. * @param container the container holding the elements
  38311. */
  38312. addFromContainer(container: AbstractScene): void;
  38313. /**
  38314. * Removes all the elements in the container from the scene
  38315. * @param container contains the elements to remove
  38316. * @param dispose if the removed element should be disposed (default: false)
  38317. */
  38318. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38319. /**
  38320. * Disposes the component and the associated ressources.
  38321. */
  38322. dispose(): void;
  38323. /**
  38324. * Disables audio in the associated scene.
  38325. */
  38326. disableAudio(): void;
  38327. /**
  38328. * Enables audio in the associated scene.
  38329. */
  38330. enableAudio(): void;
  38331. /**
  38332. * Switch audio to headphone output.
  38333. */
  38334. switchAudioModeForHeadphones(): void;
  38335. /**
  38336. * Switch audio to normal speakers.
  38337. */
  38338. switchAudioModeForNormalSpeakers(): void;
  38339. private _cachedCameraDirection;
  38340. private _cachedCameraPosition;
  38341. private _lastCheck;
  38342. private _afterRender;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * Wraps one or more Sound objects and selects one with random weight for playback.
  38348. */
  38349. export class WeightedSound {
  38350. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38351. loop: boolean;
  38352. private _coneInnerAngle;
  38353. private _coneOuterAngle;
  38354. private _volume;
  38355. /** A Sound is currently playing. */
  38356. isPlaying: boolean;
  38357. /** A Sound is currently paused. */
  38358. isPaused: boolean;
  38359. private _sounds;
  38360. private _weights;
  38361. private _currentIndex?;
  38362. /**
  38363. * Creates a new WeightedSound from the list of sounds given.
  38364. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38365. * @param sounds Array of Sounds that will be selected from.
  38366. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38367. */
  38368. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38369. /**
  38370. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38371. */
  38372. get directionalConeInnerAngle(): number;
  38373. /**
  38374. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38375. */
  38376. set directionalConeInnerAngle(value: number);
  38377. /**
  38378. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38379. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38380. */
  38381. get directionalConeOuterAngle(): number;
  38382. /**
  38383. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38384. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38385. */
  38386. set directionalConeOuterAngle(value: number);
  38387. /**
  38388. * Playback volume.
  38389. */
  38390. get volume(): number;
  38391. /**
  38392. * Playback volume.
  38393. */
  38394. set volume(value: number);
  38395. private _onended;
  38396. /**
  38397. * Suspend playback
  38398. */
  38399. pause(): void;
  38400. /**
  38401. * Stop playback
  38402. */
  38403. stop(): void;
  38404. /**
  38405. * Start playback.
  38406. * @param startOffset Position the clip head at a specific time in seconds.
  38407. */
  38408. play(startOffset?: number): void;
  38409. }
  38410. }
  38411. declare module BABYLON {
  38412. /**
  38413. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38415. */
  38416. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38417. /**
  38418. * Gets the name of the behavior.
  38419. */
  38420. get name(): string;
  38421. /**
  38422. * The easing function used by animations
  38423. */
  38424. static EasingFunction: BackEase;
  38425. /**
  38426. * The easing mode used by animations
  38427. */
  38428. static EasingMode: number;
  38429. /**
  38430. * The duration of the animation, in milliseconds
  38431. */
  38432. transitionDuration: number;
  38433. /**
  38434. * Length of the distance animated by the transition when lower radius is reached
  38435. */
  38436. lowerRadiusTransitionRange: number;
  38437. /**
  38438. * Length of the distance animated by the transition when upper radius is reached
  38439. */
  38440. upperRadiusTransitionRange: number;
  38441. private _autoTransitionRange;
  38442. /**
  38443. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38444. */
  38445. get autoTransitionRange(): boolean;
  38446. /**
  38447. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38448. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38449. */
  38450. set autoTransitionRange(value: boolean);
  38451. private _attachedCamera;
  38452. private _onAfterCheckInputsObserver;
  38453. private _onMeshTargetChangedObserver;
  38454. /**
  38455. * Initializes the behavior.
  38456. */
  38457. init(): void;
  38458. /**
  38459. * Attaches the behavior to its arc rotate camera.
  38460. * @param camera Defines the camera to attach the behavior to
  38461. */
  38462. attach(camera: ArcRotateCamera): void;
  38463. /**
  38464. * Detaches the behavior from its current arc rotate camera.
  38465. */
  38466. detach(): void;
  38467. private _radiusIsAnimating;
  38468. private _radiusBounceTransition;
  38469. private _animatables;
  38470. private _cachedWheelPrecision;
  38471. /**
  38472. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38473. * @param radiusLimit The limit to check against.
  38474. * @return Bool to indicate if at limit.
  38475. */
  38476. private _isRadiusAtLimit;
  38477. /**
  38478. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38479. * @param radiusDelta The delta by which to animate to. Can be negative.
  38480. */
  38481. private _applyBoundRadiusAnimation;
  38482. /**
  38483. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38484. */
  38485. protected _clearAnimationLocks(): void;
  38486. /**
  38487. * Stops and removes all animations that have been applied to the camera
  38488. */
  38489. stopAllAnimations(): void;
  38490. }
  38491. }
  38492. declare module BABYLON {
  38493. /**
  38494. * 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.
  38495. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38496. */
  38497. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38498. /**
  38499. * Gets the name of the behavior.
  38500. */
  38501. get name(): string;
  38502. private _mode;
  38503. private _radiusScale;
  38504. private _positionScale;
  38505. private _defaultElevation;
  38506. private _elevationReturnTime;
  38507. private _elevationReturnWaitTime;
  38508. private _zoomStopsAnimation;
  38509. private _framingTime;
  38510. /**
  38511. * The easing function used by animations
  38512. */
  38513. static EasingFunction: ExponentialEase;
  38514. /**
  38515. * The easing mode used by animations
  38516. */
  38517. static EasingMode: number;
  38518. /**
  38519. * Sets the current mode used by the behavior
  38520. */
  38521. set mode(mode: number);
  38522. /**
  38523. * Gets current mode used by the behavior.
  38524. */
  38525. get mode(): number;
  38526. /**
  38527. * Sets the scale applied to the radius (1 by default)
  38528. */
  38529. set radiusScale(radius: number);
  38530. /**
  38531. * Gets the scale applied to the radius
  38532. */
  38533. get radiusScale(): number;
  38534. /**
  38535. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38536. */
  38537. set positionScale(scale: number);
  38538. /**
  38539. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38540. */
  38541. get positionScale(): number;
  38542. /**
  38543. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38544. * behaviour is triggered, in radians.
  38545. */
  38546. set defaultElevation(elevation: number);
  38547. /**
  38548. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38549. * behaviour is triggered, in radians.
  38550. */
  38551. get defaultElevation(): number;
  38552. /**
  38553. * Sets the time (in milliseconds) taken to return to the default beta position.
  38554. * Negative value indicates camera should not return to default.
  38555. */
  38556. set elevationReturnTime(speed: number);
  38557. /**
  38558. * Gets the time (in milliseconds) taken to return to the default beta position.
  38559. * Negative value indicates camera should not return to default.
  38560. */
  38561. get elevationReturnTime(): number;
  38562. /**
  38563. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38564. */
  38565. set elevationReturnWaitTime(time: number);
  38566. /**
  38567. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38568. */
  38569. get elevationReturnWaitTime(): number;
  38570. /**
  38571. * Sets the flag that indicates if user zooming should stop animation.
  38572. */
  38573. set zoomStopsAnimation(flag: boolean);
  38574. /**
  38575. * Gets the flag that indicates if user zooming should stop animation.
  38576. */
  38577. get zoomStopsAnimation(): boolean;
  38578. /**
  38579. * Sets the transition time when framing the mesh, in milliseconds
  38580. */
  38581. set framingTime(time: number);
  38582. /**
  38583. * Gets the transition time when framing the mesh, in milliseconds
  38584. */
  38585. get framingTime(): number;
  38586. /**
  38587. * Define if the behavior should automatically change the configured
  38588. * camera limits and sensibilities.
  38589. */
  38590. autoCorrectCameraLimitsAndSensibility: boolean;
  38591. private _onPrePointerObservableObserver;
  38592. private _onAfterCheckInputsObserver;
  38593. private _onMeshTargetChangedObserver;
  38594. private _attachedCamera;
  38595. private _isPointerDown;
  38596. private _lastInteractionTime;
  38597. /**
  38598. * Initializes the behavior.
  38599. */
  38600. init(): void;
  38601. /**
  38602. * Attaches the behavior to its arc rotate camera.
  38603. * @param camera Defines the camera to attach the behavior to
  38604. */
  38605. attach(camera: ArcRotateCamera): void;
  38606. /**
  38607. * Detaches the behavior from its current arc rotate camera.
  38608. */
  38609. detach(): void;
  38610. private _animatables;
  38611. private _betaIsAnimating;
  38612. private _betaTransition;
  38613. private _radiusTransition;
  38614. private _vectorTransition;
  38615. /**
  38616. * Targets the given mesh and updates zoom level accordingly.
  38617. * @param mesh The mesh to target.
  38618. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38619. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38620. */
  38621. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38622. /**
  38623. * Targets the given mesh with its children and updates zoom level accordingly.
  38624. * @param mesh The mesh to target.
  38625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38627. */
  38628. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38629. /**
  38630. * Targets the given meshes with their children and updates zoom level accordingly.
  38631. * @param meshes The mesh to target.
  38632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38634. */
  38635. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38636. /**
  38637. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38638. * @param minimumWorld Determines the smaller position of the bounding box extend
  38639. * @param maximumWorld Determines the bigger position of the bounding box extend
  38640. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38641. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38642. */
  38643. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38644. /**
  38645. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38646. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38647. * frustum width.
  38648. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38649. * to fully enclose the mesh in the viewing frustum.
  38650. */
  38651. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38652. /**
  38653. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38654. * is automatically returned to its default position (expected to be above ground plane).
  38655. */
  38656. private _maintainCameraAboveGround;
  38657. /**
  38658. * Returns the frustum slope based on the canvas ratio and camera FOV
  38659. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38660. */
  38661. private _getFrustumSlope;
  38662. /**
  38663. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38664. */
  38665. private _clearAnimationLocks;
  38666. /**
  38667. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38668. */
  38669. private _applyUserInteraction;
  38670. /**
  38671. * Stops and removes all animations that have been applied to the camera
  38672. */
  38673. stopAllAnimations(): void;
  38674. /**
  38675. * Gets a value indicating if the user is moving the camera
  38676. */
  38677. get isUserIsMoving(): boolean;
  38678. /**
  38679. * The camera can move all the way towards the mesh.
  38680. */
  38681. static IgnoreBoundsSizeMode: number;
  38682. /**
  38683. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38684. */
  38685. static FitFrustumSidesMode: number;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * Base class for Camera Pointer Inputs.
  38691. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38692. * for example usage.
  38693. */
  38694. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38695. /**
  38696. * Defines the camera the input is attached to.
  38697. */
  38698. abstract camera: Camera;
  38699. /**
  38700. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38701. */
  38702. protected _altKey: boolean;
  38703. protected _ctrlKey: boolean;
  38704. protected _metaKey: boolean;
  38705. protected _shiftKey: boolean;
  38706. /**
  38707. * Which mouse buttons were pressed at time of last mouse event.
  38708. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38709. */
  38710. protected _buttonsPressed: number;
  38711. /**
  38712. * Defines the buttons associated with the input to handle camera move.
  38713. */
  38714. buttons: number[];
  38715. /**
  38716. * Attach the input controls to a specific dom element to get the input from.
  38717. * @param element Defines the element the controls should be listened from
  38718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38719. */
  38720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38721. /**
  38722. * Detach the current controls from the specified dom element.
  38723. * @param element Defines the element to stop listening the inputs from
  38724. */
  38725. detachControl(element: Nullable<HTMLElement>): void;
  38726. /**
  38727. * Gets the class name of the current input.
  38728. * @returns the class name
  38729. */
  38730. getClassName(): string;
  38731. /**
  38732. * Get the friendly name associated with the input class.
  38733. * @returns the input friendly name
  38734. */
  38735. getSimpleName(): string;
  38736. /**
  38737. * Called on pointer POINTERDOUBLETAP event.
  38738. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38739. */
  38740. protected onDoubleTap(type: string): void;
  38741. /**
  38742. * Called on pointer POINTERMOVE event if only a single touch is active.
  38743. * Override this method to provide functionality.
  38744. */
  38745. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38746. /**
  38747. * Called on pointer POINTERMOVE event if multiple touches are active.
  38748. * Override this method to provide functionality.
  38749. */
  38750. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38751. /**
  38752. * Called on JS contextmenu event.
  38753. * Override this method to provide functionality.
  38754. */
  38755. protected onContextMenu(evt: PointerEvent): void;
  38756. /**
  38757. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38758. * press.
  38759. * Override this method to provide functionality.
  38760. */
  38761. protected onButtonDown(evt: PointerEvent): void;
  38762. /**
  38763. * Called each time a new POINTERUP event occurs. Ie, for each button
  38764. * release.
  38765. * Override this method to provide functionality.
  38766. */
  38767. protected onButtonUp(evt: PointerEvent): void;
  38768. /**
  38769. * Called when window becomes inactive.
  38770. * Override this method to provide functionality.
  38771. */
  38772. protected onLostFocus(): void;
  38773. private _pointerInput;
  38774. private _observer;
  38775. private _onLostFocus;
  38776. private pointA;
  38777. private pointB;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Manage the pointers inputs to control an arc rotate camera.
  38783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38784. */
  38785. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38786. /**
  38787. * Defines the camera the input is attached to.
  38788. */
  38789. camera: ArcRotateCamera;
  38790. /**
  38791. * Gets the class name of the current input.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /**
  38796. * Defines the buttons associated with the input to handle camera move.
  38797. */
  38798. buttons: number[];
  38799. /**
  38800. * Defines the pointer angular sensibility along the X axis or how fast is
  38801. * the camera rotating.
  38802. */
  38803. angularSensibilityX: number;
  38804. /**
  38805. * Defines the pointer angular sensibility along the Y axis or how fast is
  38806. * the camera rotating.
  38807. */
  38808. angularSensibilityY: number;
  38809. /**
  38810. * Defines the pointer pinch precision or how fast is the camera zooming.
  38811. */
  38812. pinchPrecision: number;
  38813. /**
  38814. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38815. * from 0.
  38816. * It defines the percentage of current camera.radius to use as delta when
  38817. * pinch zoom is used.
  38818. */
  38819. pinchDeltaPercentage: number;
  38820. /**
  38821. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38822. * that any object in the plane at the camera's target point will scale
  38823. * perfectly with finger motion.
  38824. * Overrides pinchDeltaPercentage and pinchPrecision.
  38825. */
  38826. useNaturalPinchZoom: boolean;
  38827. /**
  38828. * Defines the pointer panning sensibility or how fast is the camera moving.
  38829. */
  38830. panningSensibility: number;
  38831. /**
  38832. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38833. */
  38834. multiTouchPanning: boolean;
  38835. /**
  38836. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38837. * zoom (pinch) through multitouch.
  38838. */
  38839. multiTouchPanAndZoom: boolean;
  38840. /**
  38841. * Revers pinch action direction.
  38842. */
  38843. pinchInwards: boolean;
  38844. private _isPanClick;
  38845. private _twoFingerActivityCount;
  38846. private _isPinching;
  38847. /**
  38848. * Called on pointer POINTERMOVE event if only a single touch is active.
  38849. */
  38850. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38851. /**
  38852. * Called on pointer POINTERDOUBLETAP event.
  38853. */
  38854. protected onDoubleTap(type: string): void;
  38855. /**
  38856. * Called on pointer POINTERMOVE event if multiple touches are active.
  38857. */
  38858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38859. /**
  38860. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38861. * press.
  38862. */
  38863. protected onButtonDown(evt: PointerEvent): void;
  38864. /**
  38865. * Called each time a new POINTERUP event occurs. Ie, for each button
  38866. * release.
  38867. */
  38868. protected onButtonUp(evt: PointerEvent): void;
  38869. /**
  38870. * Called when window becomes inactive.
  38871. */
  38872. protected onLostFocus(): void;
  38873. }
  38874. }
  38875. declare module BABYLON {
  38876. /**
  38877. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38879. */
  38880. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38881. /**
  38882. * Defines the camera the input is attached to.
  38883. */
  38884. camera: ArcRotateCamera;
  38885. /**
  38886. * Defines the list of key codes associated with the up action (increase alpha)
  38887. */
  38888. keysUp: number[];
  38889. /**
  38890. * Defines the list of key codes associated with the down action (decrease alpha)
  38891. */
  38892. keysDown: number[];
  38893. /**
  38894. * Defines the list of key codes associated with the left action (increase beta)
  38895. */
  38896. keysLeft: number[];
  38897. /**
  38898. * Defines the list of key codes associated with the right action (decrease beta)
  38899. */
  38900. keysRight: number[];
  38901. /**
  38902. * Defines the list of key codes associated with the reset action.
  38903. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38904. */
  38905. keysReset: number[];
  38906. /**
  38907. * Defines the panning sensibility of the inputs.
  38908. * (How fast is the camera panning)
  38909. */
  38910. panningSensibility: number;
  38911. /**
  38912. * Defines the zooming sensibility of the inputs.
  38913. * (How fast is the camera zooming)
  38914. */
  38915. zoomingSensibility: number;
  38916. /**
  38917. * Defines whether maintaining the alt key down switch the movement mode from
  38918. * orientation to zoom.
  38919. */
  38920. useAltToZoom: boolean;
  38921. /**
  38922. * Rotation speed of the camera
  38923. */
  38924. angularSpeed: number;
  38925. private _keys;
  38926. private _ctrlPressed;
  38927. private _altPressed;
  38928. private _onCanvasBlurObserver;
  38929. private _onKeyboardObserver;
  38930. private _engine;
  38931. private _scene;
  38932. /**
  38933. * Attach the input controls to a specific dom element to get the input from.
  38934. * @param element Defines the element the controls should be listened from
  38935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38936. */
  38937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38938. /**
  38939. * Detach the current controls from the specified dom element.
  38940. * @param element Defines the element to stop listening the inputs from
  38941. */
  38942. detachControl(element: Nullable<HTMLElement>): void;
  38943. /**
  38944. * Update the current camera state depending on the inputs that have been used this frame.
  38945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38946. */
  38947. checkInputs(): void;
  38948. /**
  38949. * Gets the class name of the current intput.
  38950. * @returns the class name
  38951. */
  38952. getClassName(): string;
  38953. /**
  38954. * Get the friendly name associated with the input class.
  38955. * @returns the input friendly name
  38956. */
  38957. getSimpleName(): string;
  38958. }
  38959. }
  38960. declare module BABYLON {
  38961. /**
  38962. * Manage the mouse wheel inputs to control an arc rotate camera.
  38963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38964. */
  38965. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38966. /**
  38967. * Defines the camera the input is attached to.
  38968. */
  38969. camera: ArcRotateCamera;
  38970. /**
  38971. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38972. */
  38973. wheelPrecision: number;
  38974. /**
  38975. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38976. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38977. */
  38978. wheelDeltaPercentage: number;
  38979. private _wheel;
  38980. private _observer;
  38981. private computeDeltaFromMouseWheelLegacyEvent;
  38982. /**
  38983. * Attach the input controls to a specific dom element to get the input from.
  38984. * @param element Defines the element the controls should be listened from
  38985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38986. */
  38987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38988. /**
  38989. * Detach the current controls from the specified dom element.
  38990. * @param element Defines the element to stop listening the inputs from
  38991. */
  38992. detachControl(element: Nullable<HTMLElement>): void;
  38993. /**
  38994. * Gets the class name of the current intput.
  38995. * @returns the class name
  38996. */
  38997. getClassName(): string;
  38998. /**
  38999. * Get the friendly name associated with the input class.
  39000. * @returns the input friendly name
  39001. */
  39002. getSimpleName(): string;
  39003. }
  39004. }
  39005. declare module BABYLON {
  39006. /**
  39007. * Default Inputs manager for the ArcRotateCamera.
  39008. * It groups all the default supported inputs for ease of use.
  39009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39010. */
  39011. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39012. /**
  39013. * Instantiates a new ArcRotateCameraInputsManager.
  39014. * @param camera Defines the camera the inputs belong to
  39015. */
  39016. constructor(camera: ArcRotateCamera);
  39017. /**
  39018. * Add mouse wheel input support to the input manager.
  39019. * @returns the current input manager
  39020. */
  39021. addMouseWheel(): ArcRotateCameraInputsManager;
  39022. /**
  39023. * Add pointers input support to the input manager.
  39024. * @returns the current input manager
  39025. */
  39026. addPointers(): ArcRotateCameraInputsManager;
  39027. /**
  39028. * Add keyboard input support to the input manager.
  39029. * @returns the current input manager
  39030. */
  39031. addKeyboard(): ArcRotateCameraInputsManager;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * This represents an orbital type of camera.
  39037. *
  39038. * 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.
  39039. * 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.
  39040. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39041. */
  39042. export class ArcRotateCamera extends TargetCamera {
  39043. /**
  39044. * Defines the rotation angle of the camera along the longitudinal axis.
  39045. */
  39046. alpha: number;
  39047. /**
  39048. * Defines the rotation angle of the camera along the latitudinal axis.
  39049. */
  39050. beta: number;
  39051. /**
  39052. * Defines the radius of the camera from it s target point.
  39053. */
  39054. radius: number;
  39055. protected _target: Vector3;
  39056. protected _targetHost: Nullable<AbstractMesh>;
  39057. /**
  39058. * Defines the target point of the camera.
  39059. * The camera looks towards it form the radius distance.
  39060. */
  39061. get target(): Vector3;
  39062. set target(value: Vector3);
  39063. /**
  39064. * Define the current local position of the camera in the scene
  39065. */
  39066. get position(): Vector3;
  39067. set position(newPosition: Vector3);
  39068. protected _upVector: Vector3;
  39069. protected _upToYMatrix: Matrix;
  39070. protected _YToUpMatrix: Matrix;
  39071. /**
  39072. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39073. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39074. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39075. */
  39076. set upVector(vec: Vector3);
  39077. get upVector(): Vector3;
  39078. /**
  39079. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39080. */
  39081. setMatUp(): void;
  39082. /**
  39083. * Current inertia value on the longitudinal axis.
  39084. * The bigger this number the longer it will take for the camera to stop.
  39085. */
  39086. inertialAlphaOffset: number;
  39087. /**
  39088. * Current inertia value on the latitudinal axis.
  39089. * The bigger this number the longer it will take for the camera to stop.
  39090. */
  39091. inertialBetaOffset: number;
  39092. /**
  39093. * Current inertia value on the radius axis.
  39094. * The bigger this number the longer it will take for the camera to stop.
  39095. */
  39096. inertialRadiusOffset: number;
  39097. /**
  39098. * Minimum allowed angle on the longitudinal axis.
  39099. * This can help limiting how the Camera is able to move in the scene.
  39100. */
  39101. lowerAlphaLimit: Nullable<number>;
  39102. /**
  39103. * Maximum allowed angle on the longitudinal axis.
  39104. * This can help limiting how the Camera is able to move in the scene.
  39105. */
  39106. upperAlphaLimit: Nullable<number>;
  39107. /**
  39108. * Minimum allowed angle on the latitudinal axis.
  39109. * This can help limiting how the Camera is able to move in the scene.
  39110. */
  39111. lowerBetaLimit: number;
  39112. /**
  39113. * Maximum allowed angle on the latitudinal axis.
  39114. * This can help limiting how the Camera is able to move in the scene.
  39115. */
  39116. upperBetaLimit: number;
  39117. /**
  39118. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39119. * This can help limiting how the Camera is able to move in the scene.
  39120. */
  39121. lowerRadiusLimit: Nullable<number>;
  39122. /**
  39123. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39124. * This can help limiting how the Camera is able to move in the scene.
  39125. */
  39126. upperRadiusLimit: Nullable<number>;
  39127. /**
  39128. * Defines the current inertia value used during panning of the camera along the X axis.
  39129. */
  39130. inertialPanningX: number;
  39131. /**
  39132. * Defines the current inertia value used during panning of the camera along the Y axis.
  39133. */
  39134. inertialPanningY: number;
  39135. /**
  39136. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39137. * Basically if your fingers moves away from more than this distance you will be considered
  39138. * in pinch mode.
  39139. */
  39140. pinchToPanMaxDistance: number;
  39141. /**
  39142. * Defines the maximum distance the camera can pan.
  39143. * This could help keeping the cammera always in your scene.
  39144. */
  39145. panningDistanceLimit: Nullable<number>;
  39146. /**
  39147. * Defines the target of the camera before paning.
  39148. */
  39149. panningOriginTarget: Vector3;
  39150. /**
  39151. * Defines the value of the inertia used during panning.
  39152. * 0 would mean stop inertia and one would mean no decelleration at all.
  39153. */
  39154. panningInertia: number;
  39155. /**
  39156. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39157. */
  39158. get angularSensibilityX(): number;
  39159. set angularSensibilityX(value: number);
  39160. /**
  39161. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39162. */
  39163. get angularSensibilityY(): number;
  39164. set angularSensibilityY(value: number);
  39165. /**
  39166. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39167. */
  39168. get pinchPrecision(): number;
  39169. set pinchPrecision(value: number);
  39170. /**
  39171. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39172. * It will be used instead of pinchDeltaPrecision if different from 0.
  39173. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39174. */
  39175. get pinchDeltaPercentage(): number;
  39176. set pinchDeltaPercentage(value: number);
  39177. /**
  39178. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39179. * and pinch delta percentage.
  39180. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39181. * that any object in the plane at the camera's target point will scale
  39182. * perfectly with finger motion.
  39183. */
  39184. get useNaturalPinchZoom(): boolean;
  39185. set useNaturalPinchZoom(value: boolean);
  39186. /**
  39187. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39188. */
  39189. get panningSensibility(): number;
  39190. set panningSensibility(value: number);
  39191. /**
  39192. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39193. */
  39194. get keysUp(): number[];
  39195. set keysUp(value: number[]);
  39196. /**
  39197. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39198. */
  39199. get keysDown(): number[];
  39200. set keysDown(value: number[]);
  39201. /**
  39202. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39203. */
  39204. get keysLeft(): number[];
  39205. set keysLeft(value: number[]);
  39206. /**
  39207. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39208. */
  39209. get keysRight(): number[];
  39210. set keysRight(value: number[]);
  39211. /**
  39212. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39213. */
  39214. get wheelPrecision(): number;
  39215. set wheelPrecision(value: number);
  39216. /**
  39217. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39218. * It will be used instead of pinchDeltaPrecision if different from 0.
  39219. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39220. */
  39221. get wheelDeltaPercentage(): number;
  39222. set wheelDeltaPercentage(value: number);
  39223. /**
  39224. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39225. */
  39226. zoomOnFactor: number;
  39227. /**
  39228. * Defines a screen offset for the camera position.
  39229. */
  39230. targetScreenOffset: Vector2;
  39231. /**
  39232. * Allows the camera to be completely reversed.
  39233. * If false the camera can not arrive upside down.
  39234. */
  39235. allowUpsideDown: boolean;
  39236. /**
  39237. * Define if double tap/click is used to restore the previously saved state of the camera.
  39238. */
  39239. useInputToRestoreState: boolean;
  39240. /** @hidden */
  39241. _viewMatrix: Matrix;
  39242. /** @hidden */
  39243. _useCtrlForPanning: boolean;
  39244. /** @hidden */
  39245. _panningMouseButton: number;
  39246. /**
  39247. * Defines the input associated to the camera.
  39248. */
  39249. inputs: ArcRotateCameraInputsManager;
  39250. /** @hidden */
  39251. _reset: () => void;
  39252. /**
  39253. * Defines the allowed panning axis.
  39254. */
  39255. panningAxis: Vector3;
  39256. protected _localDirection: Vector3;
  39257. protected _transformedDirection: Vector3;
  39258. private _bouncingBehavior;
  39259. /**
  39260. * Gets the bouncing behavior of the camera if it has been enabled.
  39261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39262. */
  39263. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39264. /**
  39265. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39267. */
  39268. get useBouncingBehavior(): boolean;
  39269. set useBouncingBehavior(value: boolean);
  39270. private _framingBehavior;
  39271. /**
  39272. * Gets the framing behavior of the camera if it has been enabled.
  39273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39274. */
  39275. get framingBehavior(): Nullable<FramingBehavior>;
  39276. /**
  39277. * Defines if the framing behavior of the camera is enabled on the camera.
  39278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39279. */
  39280. get useFramingBehavior(): boolean;
  39281. set useFramingBehavior(value: boolean);
  39282. private _autoRotationBehavior;
  39283. /**
  39284. * Gets the auto rotation behavior of the camera if it has been enabled.
  39285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39286. */
  39287. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39288. /**
  39289. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39291. */
  39292. get useAutoRotationBehavior(): boolean;
  39293. set useAutoRotationBehavior(value: boolean);
  39294. /**
  39295. * Observable triggered when the mesh target has been changed on the camera.
  39296. */
  39297. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39298. /**
  39299. * Event raised when the camera is colliding with a mesh.
  39300. */
  39301. onCollide: (collidedMesh: AbstractMesh) => void;
  39302. /**
  39303. * Defines whether the camera should check collision with the objects oh the scene.
  39304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39305. */
  39306. checkCollisions: boolean;
  39307. /**
  39308. * Defines the collision radius of the camera.
  39309. * This simulates a sphere around the camera.
  39310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39311. */
  39312. collisionRadius: Vector3;
  39313. protected _collider: Collider;
  39314. protected _previousPosition: Vector3;
  39315. protected _collisionVelocity: Vector3;
  39316. protected _newPosition: Vector3;
  39317. protected _previousAlpha: number;
  39318. protected _previousBeta: number;
  39319. protected _previousRadius: number;
  39320. protected _collisionTriggered: boolean;
  39321. protected _targetBoundingCenter: Nullable<Vector3>;
  39322. private _computationVector;
  39323. /**
  39324. * Instantiates a new ArcRotateCamera in a given scene
  39325. * @param name Defines the name of the camera
  39326. * @param alpha Defines the camera rotation along the logitudinal axis
  39327. * @param beta Defines the camera rotation along the latitudinal axis
  39328. * @param radius Defines the camera distance from its target
  39329. * @param target Defines the camera target
  39330. * @param scene Defines the scene the camera belongs to
  39331. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39332. */
  39333. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39334. /** @hidden */
  39335. _initCache(): void;
  39336. /** @hidden */
  39337. _updateCache(ignoreParentClass?: boolean): void;
  39338. protected _getTargetPosition(): Vector3;
  39339. private _storedAlpha;
  39340. private _storedBeta;
  39341. private _storedRadius;
  39342. private _storedTarget;
  39343. private _storedTargetScreenOffset;
  39344. /**
  39345. * Stores the current state of the camera (alpha, beta, radius and target)
  39346. * @returns the camera itself
  39347. */
  39348. storeState(): Camera;
  39349. /**
  39350. * @hidden
  39351. * Restored camera state. You must call storeState() first
  39352. */
  39353. _restoreStateValues(): boolean;
  39354. /** @hidden */
  39355. _isSynchronizedViewMatrix(): boolean;
  39356. /**
  39357. * Attached controls to the current camera.
  39358. * @param element Defines the element the controls should be listened from
  39359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39360. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39361. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39362. */
  39363. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39364. /**
  39365. * Detach the current controls from the camera.
  39366. * The camera will stop reacting to inputs.
  39367. * @param element Defines the element to stop listening the inputs from
  39368. */
  39369. detachControl(element: HTMLElement): void;
  39370. /** @hidden */
  39371. _checkInputs(): void;
  39372. protected _checkLimits(): void;
  39373. /**
  39374. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39375. */
  39376. rebuildAnglesAndRadius(): void;
  39377. /**
  39378. * Use a position to define the current camera related information like alpha, beta and radius
  39379. * @param position Defines the position to set the camera at
  39380. */
  39381. setPosition(position: Vector3): void;
  39382. /**
  39383. * Defines the target the camera should look at.
  39384. * This will automatically adapt alpha beta and radius to fit within the new target.
  39385. * @param target Defines the new target as a Vector or a mesh
  39386. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39387. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39388. */
  39389. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39390. /** @hidden */
  39391. _getViewMatrix(): Matrix;
  39392. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39393. /**
  39394. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39395. * @param meshes Defines the mesh to zoom on
  39396. * @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)
  39397. */
  39398. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39399. /**
  39400. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39401. * The target will be changed but the radius
  39402. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39403. * @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)
  39404. */
  39405. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39406. min: Vector3;
  39407. max: Vector3;
  39408. distance: number;
  39409. }, doNotUpdateMaxZ?: boolean): void;
  39410. /**
  39411. * @override
  39412. * Override Camera.createRigCamera
  39413. */
  39414. createRigCamera(name: string, cameraIndex: number): Camera;
  39415. /**
  39416. * @hidden
  39417. * @override
  39418. * Override Camera._updateRigCameras
  39419. */
  39420. _updateRigCameras(): void;
  39421. /**
  39422. * Destroy the camera and release the current resources hold by it.
  39423. */
  39424. dispose(): void;
  39425. /**
  39426. * Gets the current object class name.
  39427. * @return the class name
  39428. */
  39429. getClassName(): string;
  39430. }
  39431. }
  39432. declare module BABYLON {
  39433. /**
  39434. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39436. */
  39437. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39438. /**
  39439. * Gets the name of the behavior.
  39440. */
  39441. get name(): string;
  39442. private _zoomStopsAnimation;
  39443. private _idleRotationSpeed;
  39444. private _idleRotationWaitTime;
  39445. private _idleRotationSpinupTime;
  39446. /**
  39447. * Sets the flag that indicates if user zooming should stop animation.
  39448. */
  39449. set zoomStopsAnimation(flag: boolean);
  39450. /**
  39451. * Gets the flag that indicates if user zooming should stop animation.
  39452. */
  39453. get zoomStopsAnimation(): boolean;
  39454. /**
  39455. * Sets the default speed at which the camera rotates around the model.
  39456. */
  39457. set idleRotationSpeed(speed: number);
  39458. /**
  39459. * Gets the default speed at which the camera rotates around the model.
  39460. */
  39461. get idleRotationSpeed(): number;
  39462. /**
  39463. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39464. */
  39465. set idleRotationWaitTime(time: number);
  39466. /**
  39467. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39468. */
  39469. get idleRotationWaitTime(): number;
  39470. /**
  39471. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39472. */
  39473. set idleRotationSpinupTime(time: number);
  39474. /**
  39475. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39476. */
  39477. get idleRotationSpinupTime(): number;
  39478. /**
  39479. * Gets a value indicating if the camera is currently rotating because of this behavior
  39480. */
  39481. get rotationInProgress(): boolean;
  39482. private _onPrePointerObservableObserver;
  39483. private _onAfterCheckInputsObserver;
  39484. private _attachedCamera;
  39485. private _isPointerDown;
  39486. private _lastFrameTime;
  39487. private _lastInteractionTime;
  39488. private _cameraRotationSpeed;
  39489. /**
  39490. * Initializes the behavior.
  39491. */
  39492. init(): void;
  39493. /**
  39494. * Attaches the behavior to its arc rotate camera.
  39495. * @param camera Defines the camera to attach the behavior to
  39496. */
  39497. attach(camera: ArcRotateCamera): void;
  39498. /**
  39499. * Detaches the behavior from its current arc rotate camera.
  39500. */
  39501. detach(): void;
  39502. /**
  39503. * Returns true if user is scrolling.
  39504. * @return true if user is scrolling.
  39505. */
  39506. private _userIsZooming;
  39507. private _lastFrameRadius;
  39508. private _shouldAnimationStopForInteraction;
  39509. /**
  39510. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39511. */
  39512. private _applyUserInteraction;
  39513. private _userIsMoving;
  39514. }
  39515. }
  39516. declare module BABYLON {
  39517. /**
  39518. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39519. */
  39520. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39521. private ui;
  39522. /**
  39523. * The name of the behavior
  39524. */
  39525. name: string;
  39526. /**
  39527. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39528. */
  39529. distanceAwayFromFace: number;
  39530. /**
  39531. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39532. */
  39533. distanceAwayFromBottomOfFace: number;
  39534. private _faceVectors;
  39535. private _target;
  39536. private _scene;
  39537. private _onRenderObserver;
  39538. private _tmpMatrix;
  39539. private _tmpVector;
  39540. /**
  39541. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39542. * @param ui The transform node that should be attched to the mesh
  39543. */
  39544. constructor(ui: TransformNode);
  39545. /**
  39546. * Initializes the behavior
  39547. */
  39548. init(): void;
  39549. private _closestFace;
  39550. private _zeroVector;
  39551. private _lookAtTmpMatrix;
  39552. private _lookAtToRef;
  39553. /**
  39554. * Attaches the AttachToBoxBehavior to the passed in mesh
  39555. * @param target The mesh that the specified node will be attached to
  39556. */
  39557. attach(target: Mesh): void;
  39558. /**
  39559. * Detaches the behavior from the mesh
  39560. */
  39561. detach(): void;
  39562. }
  39563. }
  39564. declare module BABYLON {
  39565. /**
  39566. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39567. */
  39568. export class FadeInOutBehavior implements Behavior<Mesh> {
  39569. /**
  39570. * Time in milliseconds to delay before fading in (Default: 0)
  39571. */
  39572. delay: number;
  39573. /**
  39574. * Time in milliseconds for the mesh to fade in (Default: 300)
  39575. */
  39576. fadeInTime: number;
  39577. private _millisecondsPerFrame;
  39578. private _hovered;
  39579. private _hoverValue;
  39580. private _ownerNode;
  39581. /**
  39582. * Instatiates the FadeInOutBehavior
  39583. */
  39584. constructor();
  39585. /**
  39586. * The name of the behavior
  39587. */
  39588. get name(): string;
  39589. /**
  39590. * Initializes the behavior
  39591. */
  39592. init(): void;
  39593. /**
  39594. * Attaches the fade behavior on the passed in mesh
  39595. * @param ownerNode The mesh that will be faded in/out once attached
  39596. */
  39597. attach(ownerNode: Mesh): void;
  39598. /**
  39599. * Detaches the behavior from the mesh
  39600. */
  39601. detach(): void;
  39602. /**
  39603. * Triggers the mesh to begin fading in or out
  39604. * @param value if the object should fade in or out (true to fade in)
  39605. */
  39606. fadeIn(value: boolean): void;
  39607. private _update;
  39608. private _setAllVisibility;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. /**
  39613. * Class containing a set of static utilities functions for managing Pivots
  39614. * @hidden
  39615. */
  39616. export class PivotTools {
  39617. private static _PivotCached;
  39618. private static _OldPivotPoint;
  39619. private static _PivotTranslation;
  39620. private static _PivotTmpVector;
  39621. /** @hidden */
  39622. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39623. /** @hidden */
  39624. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39625. }
  39626. }
  39627. declare module BABYLON {
  39628. /**
  39629. * Class containing static functions to help procedurally build meshes
  39630. */
  39631. export class PlaneBuilder {
  39632. /**
  39633. * Creates a plane mesh
  39634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39638. * * 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
  39639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39640. * @param name defines the name of the mesh
  39641. * @param options defines the options used to create the mesh
  39642. * @param scene defines the hosting scene
  39643. * @returns the plane mesh
  39644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39645. */
  39646. static CreatePlane(name: string, options: {
  39647. size?: number;
  39648. width?: number;
  39649. height?: number;
  39650. sideOrientation?: number;
  39651. frontUVs?: Vector4;
  39652. backUVs?: Vector4;
  39653. updatable?: boolean;
  39654. sourcePlane?: Plane;
  39655. }, scene?: Nullable<Scene>): Mesh;
  39656. }
  39657. }
  39658. declare module BABYLON {
  39659. /**
  39660. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39661. */
  39662. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39663. private static _AnyMouseID;
  39664. /**
  39665. * Abstract mesh the behavior is set on
  39666. */
  39667. attachedNode: AbstractMesh;
  39668. private _dragPlane;
  39669. private _scene;
  39670. private _pointerObserver;
  39671. private _beforeRenderObserver;
  39672. private static _planeScene;
  39673. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39674. /**
  39675. * 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)
  39676. */
  39677. maxDragAngle: number;
  39678. /**
  39679. * @hidden
  39680. */
  39681. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39682. /**
  39683. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39684. */
  39685. currentDraggingPointerID: number;
  39686. /**
  39687. * The last position where the pointer hit the drag plane in world space
  39688. */
  39689. lastDragPosition: Vector3;
  39690. /**
  39691. * If the behavior is currently in a dragging state
  39692. */
  39693. dragging: boolean;
  39694. /**
  39695. * 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)
  39696. */
  39697. dragDeltaRatio: number;
  39698. /**
  39699. * If the drag plane orientation should be updated during the dragging (Default: true)
  39700. */
  39701. updateDragPlane: boolean;
  39702. private _debugMode;
  39703. private _moving;
  39704. /**
  39705. * Fires each time the attached mesh is dragged with the pointer
  39706. * * delta between last drag position and current drag position in world space
  39707. * * dragDistance along the drag axis
  39708. * * dragPlaneNormal normal of the current drag plane used during the drag
  39709. * * dragPlanePoint in world space where the drag intersects the drag plane
  39710. */
  39711. onDragObservable: Observable<{
  39712. delta: Vector3;
  39713. dragPlanePoint: Vector3;
  39714. dragPlaneNormal: Vector3;
  39715. dragDistance: number;
  39716. pointerId: number;
  39717. }>;
  39718. /**
  39719. * Fires each time a drag begins (eg. mouse down on mesh)
  39720. */
  39721. onDragStartObservable: Observable<{
  39722. dragPlanePoint: Vector3;
  39723. pointerId: number;
  39724. }>;
  39725. /**
  39726. * Fires each time a drag ends (eg. mouse release after drag)
  39727. */
  39728. onDragEndObservable: Observable<{
  39729. dragPlanePoint: Vector3;
  39730. pointerId: number;
  39731. }>;
  39732. /**
  39733. * If the attached mesh should be moved when dragged
  39734. */
  39735. moveAttached: boolean;
  39736. /**
  39737. * If the drag behavior will react to drag events (Default: true)
  39738. */
  39739. enabled: boolean;
  39740. /**
  39741. * If pointer events should start and release the drag (Default: true)
  39742. */
  39743. startAndReleaseDragOnPointerEvents: boolean;
  39744. /**
  39745. * If camera controls should be detached during the drag
  39746. */
  39747. detachCameraControls: boolean;
  39748. /**
  39749. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39750. */
  39751. useObjectOrientationForDragging: boolean;
  39752. private _options;
  39753. /**
  39754. * Gets the options used by the behavior
  39755. */
  39756. get options(): {
  39757. dragAxis?: Vector3;
  39758. dragPlaneNormal?: Vector3;
  39759. };
  39760. /**
  39761. * Sets the options used by the behavior
  39762. */
  39763. set options(options: {
  39764. dragAxis?: Vector3;
  39765. dragPlaneNormal?: Vector3;
  39766. });
  39767. /**
  39768. * Creates a pointer drag behavior that can be attached to a mesh
  39769. * @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)
  39770. */
  39771. constructor(options?: {
  39772. dragAxis?: Vector3;
  39773. dragPlaneNormal?: Vector3;
  39774. });
  39775. /**
  39776. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39777. */
  39778. validateDrag: (targetPosition: Vector3) => boolean;
  39779. /**
  39780. * The name of the behavior
  39781. */
  39782. get name(): string;
  39783. /**
  39784. * Initializes the behavior
  39785. */
  39786. init(): void;
  39787. private _tmpVector;
  39788. private _alternatePickedPoint;
  39789. private _worldDragAxis;
  39790. private _targetPosition;
  39791. private _attachedElement;
  39792. /**
  39793. * Attaches the drag behavior the passed in mesh
  39794. * @param ownerNode The mesh that will be dragged around once attached
  39795. * @param predicate Predicate to use for pick filtering
  39796. */
  39797. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39798. /**
  39799. * Force relase the drag action by code.
  39800. */
  39801. releaseDrag(): void;
  39802. private _startDragRay;
  39803. private _lastPointerRay;
  39804. /**
  39805. * Simulates the start of a pointer drag event on the behavior
  39806. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39807. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39808. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39809. */
  39810. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39811. private _startDrag;
  39812. private _dragDelta;
  39813. private _moveDrag;
  39814. private _pickWithRayOnDragPlane;
  39815. private _pointA;
  39816. private _pointB;
  39817. private _pointC;
  39818. private _lineA;
  39819. private _lineB;
  39820. private _localAxis;
  39821. private _lookAt;
  39822. private _updateDragPlanePosition;
  39823. /**
  39824. * Detaches the behavior from the mesh
  39825. */
  39826. detach(): void;
  39827. }
  39828. }
  39829. declare module BABYLON {
  39830. /**
  39831. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39832. */
  39833. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39834. private _dragBehaviorA;
  39835. private _dragBehaviorB;
  39836. private _startDistance;
  39837. private _initialScale;
  39838. private _targetScale;
  39839. private _ownerNode;
  39840. private _sceneRenderObserver;
  39841. /**
  39842. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39843. */
  39844. constructor();
  39845. /**
  39846. * The name of the behavior
  39847. */
  39848. get name(): string;
  39849. /**
  39850. * Initializes the behavior
  39851. */
  39852. init(): void;
  39853. private _getCurrentDistance;
  39854. /**
  39855. * Attaches the scale behavior the passed in mesh
  39856. * @param ownerNode The mesh that will be scaled around once attached
  39857. */
  39858. attach(ownerNode: Mesh): void;
  39859. /**
  39860. * Detaches the behavior from the mesh
  39861. */
  39862. detach(): void;
  39863. }
  39864. }
  39865. declare module BABYLON {
  39866. /**
  39867. * 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
  39868. */
  39869. export class SixDofDragBehavior implements Behavior<Mesh> {
  39870. private static _virtualScene;
  39871. private _ownerNode;
  39872. private _sceneRenderObserver;
  39873. private _scene;
  39874. private _targetPosition;
  39875. private _virtualOriginMesh;
  39876. private _virtualDragMesh;
  39877. private _pointerObserver;
  39878. private _moving;
  39879. private _startingOrientation;
  39880. private _attachedElement;
  39881. /**
  39882. * 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)
  39883. */
  39884. private zDragFactor;
  39885. /**
  39886. * If the object should rotate to face the drag origin
  39887. */
  39888. rotateDraggedObject: boolean;
  39889. /**
  39890. * If the behavior is currently in a dragging state
  39891. */
  39892. dragging: boolean;
  39893. /**
  39894. * 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)
  39895. */
  39896. dragDeltaRatio: number;
  39897. /**
  39898. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39899. */
  39900. currentDraggingPointerID: number;
  39901. /**
  39902. * If camera controls should be detached during the drag
  39903. */
  39904. detachCameraControls: boolean;
  39905. /**
  39906. * Fires each time a drag starts
  39907. */
  39908. onDragStartObservable: Observable<{}>;
  39909. /**
  39910. * Fires each time a drag ends (eg. mouse release after drag)
  39911. */
  39912. onDragEndObservable: Observable<{}>;
  39913. /**
  39914. * 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
  39915. */
  39916. constructor();
  39917. /**
  39918. * The name of the behavior
  39919. */
  39920. get name(): string;
  39921. /**
  39922. * Initializes the behavior
  39923. */
  39924. init(): void;
  39925. /**
  39926. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39927. */
  39928. private get _pointerCamera();
  39929. /**
  39930. * Attaches the scale behavior the passed in mesh
  39931. * @param ownerNode The mesh that will be scaled around once attached
  39932. */
  39933. attach(ownerNode: Mesh): void;
  39934. /**
  39935. * Detaches the behavior from the mesh
  39936. */
  39937. detach(): void;
  39938. }
  39939. }
  39940. declare module BABYLON {
  39941. /**
  39942. * Class used to apply inverse kinematics to bones
  39943. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39944. */
  39945. export class BoneIKController {
  39946. private static _tmpVecs;
  39947. private static _tmpQuat;
  39948. private static _tmpMats;
  39949. /**
  39950. * Gets or sets the target mesh
  39951. */
  39952. targetMesh: AbstractMesh;
  39953. /** Gets or sets the mesh used as pole */
  39954. poleTargetMesh: AbstractMesh;
  39955. /**
  39956. * Gets or sets the bone used as pole
  39957. */
  39958. poleTargetBone: Nullable<Bone>;
  39959. /**
  39960. * Gets or sets the target position
  39961. */
  39962. targetPosition: Vector3;
  39963. /**
  39964. * Gets or sets the pole target position
  39965. */
  39966. poleTargetPosition: Vector3;
  39967. /**
  39968. * Gets or sets the pole target local offset
  39969. */
  39970. poleTargetLocalOffset: Vector3;
  39971. /**
  39972. * Gets or sets the pole angle
  39973. */
  39974. poleAngle: number;
  39975. /**
  39976. * Gets or sets the mesh associated with the controller
  39977. */
  39978. mesh: AbstractMesh;
  39979. /**
  39980. * 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)
  39981. */
  39982. slerpAmount: number;
  39983. private _bone1Quat;
  39984. private _bone1Mat;
  39985. private _bone2Ang;
  39986. private _bone1;
  39987. private _bone2;
  39988. private _bone1Length;
  39989. private _bone2Length;
  39990. private _maxAngle;
  39991. private _maxReach;
  39992. private _rightHandedSystem;
  39993. private _bendAxis;
  39994. private _slerping;
  39995. private _adjustRoll;
  39996. /**
  39997. * Gets or sets maximum allowed angle
  39998. */
  39999. get maxAngle(): number;
  40000. set maxAngle(value: number);
  40001. /**
  40002. * Creates a new BoneIKController
  40003. * @param mesh defines the mesh to control
  40004. * @param bone defines the bone to control
  40005. * @param options defines options to set up the controller
  40006. */
  40007. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40008. targetMesh?: AbstractMesh;
  40009. poleTargetMesh?: AbstractMesh;
  40010. poleTargetBone?: Bone;
  40011. poleTargetLocalOffset?: Vector3;
  40012. poleAngle?: number;
  40013. bendAxis?: Vector3;
  40014. maxAngle?: number;
  40015. slerpAmount?: number;
  40016. });
  40017. private _setMaxAngle;
  40018. /**
  40019. * Force the controller to update the bones
  40020. */
  40021. update(): void;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. /**
  40026. * Class used to make a bone look toward a point in space
  40027. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40028. */
  40029. export class BoneLookController {
  40030. private static _tmpVecs;
  40031. private static _tmpQuat;
  40032. private static _tmpMats;
  40033. /**
  40034. * The target Vector3 that the bone will look at
  40035. */
  40036. target: Vector3;
  40037. /**
  40038. * The mesh that the bone is attached to
  40039. */
  40040. mesh: AbstractMesh;
  40041. /**
  40042. * The bone that will be looking to the target
  40043. */
  40044. bone: Bone;
  40045. /**
  40046. * The up axis of the coordinate system that is used when the bone is rotated
  40047. */
  40048. upAxis: Vector3;
  40049. /**
  40050. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40051. */
  40052. upAxisSpace: Space;
  40053. /**
  40054. * Used to make an adjustment to the yaw of the bone
  40055. */
  40056. adjustYaw: number;
  40057. /**
  40058. * Used to make an adjustment to the pitch of the bone
  40059. */
  40060. adjustPitch: number;
  40061. /**
  40062. * Used to make an adjustment to the roll of the bone
  40063. */
  40064. adjustRoll: number;
  40065. /**
  40066. * 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)
  40067. */
  40068. slerpAmount: number;
  40069. private _minYaw;
  40070. private _maxYaw;
  40071. private _minPitch;
  40072. private _maxPitch;
  40073. private _minYawSin;
  40074. private _minYawCos;
  40075. private _maxYawSin;
  40076. private _maxYawCos;
  40077. private _midYawConstraint;
  40078. private _minPitchTan;
  40079. private _maxPitchTan;
  40080. private _boneQuat;
  40081. private _slerping;
  40082. private _transformYawPitch;
  40083. private _transformYawPitchInv;
  40084. private _firstFrameSkipped;
  40085. private _yawRange;
  40086. private _fowardAxis;
  40087. /**
  40088. * Gets or sets the minimum yaw angle that the bone can look to
  40089. */
  40090. get minYaw(): number;
  40091. set minYaw(value: number);
  40092. /**
  40093. * Gets or sets the maximum yaw angle that the bone can look to
  40094. */
  40095. get maxYaw(): number;
  40096. set maxYaw(value: number);
  40097. /**
  40098. * Gets or sets the minimum pitch angle that the bone can look to
  40099. */
  40100. get minPitch(): number;
  40101. set minPitch(value: number);
  40102. /**
  40103. * Gets or sets the maximum pitch angle that the bone can look to
  40104. */
  40105. get maxPitch(): number;
  40106. set maxPitch(value: number);
  40107. /**
  40108. * Create a BoneLookController
  40109. * @param mesh the mesh that the bone belongs to
  40110. * @param bone the bone that will be looking to the target
  40111. * @param target the target Vector3 to look at
  40112. * @param options optional settings:
  40113. * * maxYaw: the maximum angle the bone will yaw to
  40114. * * minYaw: the minimum angle the bone will yaw to
  40115. * * maxPitch: the maximum angle the bone will pitch to
  40116. * * minPitch: the minimum angle the bone will yaw to
  40117. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40118. * * upAxis: the up axis of the coordinate system
  40119. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40120. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40121. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40122. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40123. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40124. * * adjustRoll: used to make an adjustment to the roll of the bone
  40125. **/
  40126. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40127. maxYaw?: number;
  40128. minYaw?: number;
  40129. maxPitch?: number;
  40130. minPitch?: number;
  40131. slerpAmount?: number;
  40132. upAxis?: Vector3;
  40133. upAxisSpace?: Space;
  40134. yawAxis?: Vector3;
  40135. pitchAxis?: Vector3;
  40136. adjustYaw?: number;
  40137. adjustPitch?: number;
  40138. adjustRoll?: number;
  40139. });
  40140. /**
  40141. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40142. */
  40143. update(): void;
  40144. private _getAngleDiff;
  40145. private _getAngleBetween;
  40146. private _isAngleBetween;
  40147. }
  40148. }
  40149. declare module BABYLON {
  40150. /**
  40151. * Manage the gamepad inputs to control an arc rotate camera.
  40152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40153. */
  40154. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40155. /**
  40156. * Defines the camera the input is attached to.
  40157. */
  40158. camera: ArcRotateCamera;
  40159. /**
  40160. * Defines the gamepad the input is gathering event from.
  40161. */
  40162. gamepad: Nullable<Gamepad>;
  40163. /**
  40164. * Defines the gamepad rotation sensiblity.
  40165. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40166. */
  40167. gamepadRotationSensibility: number;
  40168. /**
  40169. * Defines the gamepad move sensiblity.
  40170. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40171. */
  40172. gamepadMoveSensibility: number;
  40173. private _yAxisScale;
  40174. /**
  40175. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40176. */
  40177. get invertYAxis(): boolean;
  40178. set invertYAxis(value: boolean);
  40179. private _onGamepadConnectedObserver;
  40180. private _onGamepadDisconnectedObserver;
  40181. /**
  40182. * Attach the input controls to a specific dom element to get the input from.
  40183. * @param element Defines the element the controls should be listened from
  40184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40185. */
  40186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40187. /**
  40188. * Detach the current controls from the specified dom element.
  40189. * @param element Defines the element to stop listening the inputs from
  40190. */
  40191. detachControl(element: Nullable<HTMLElement>): void;
  40192. /**
  40193. * Update the current camera state depending on the inputs that have been used this frame.
  40194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40195. */
  40196. checkInputs(): void;
  40197. /**
  40198. * Gets the class name of the current intput.
  40199. * @returns the class name
  40200. */
  40201. getClassName(): string;
  40202. /**
  40203. * Get the friendly name associated with the input class.
  40204. * @returns the input friendly name
  40205. */
  40206. getSimpleName(): string;
  40207. }
  40208. }
  40209. declare module BABYLON {
  40210. interface ArcRotateCameraInputsManager {
  40211. /**
  40212. * Add orientation input support to the input manager.
  40213. * @returns the current input manager
  40214. */
  40215. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40216. }
  40217. /**
  40218. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40220. */
  40221. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40222. /**
  40223. * Defines the camera the input is attached to.
  40224. */
  40225. camera: ArcRotateCamera;
  40226. /**
  40227. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40228. */
  40229. alphaCorrection: number;
  40230. /**
  40231. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40232. */
  40233. gammaCorrection: number;
  40234. private _alpha;
  40235. private _gamma;
  40236. private _dirty;
  40237. private _deviceOrientationHandler;
  40238. /**
  40239. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40240. */
  40241. constructor();
  40242. /**
  40243. * Attach the input controls to a specific dom element to get the input from.
  40244. * @param element Defines the element the controls should be listened from
  40245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40246. */
  40247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40248. /** @hidden */
  40249. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40250. /**
  40251. * Update the current camera state depending on the inputs that have been used this frame.
  40252. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40253. */
  40254. checkInputs(): void;
  40255. /**
  40256. * Detach the current controls from the specified dom element.
  40257. * @param element Defines the element to stop listening the inputs from
  40258. */
  40259. detachControl(element: Nullable<HTMLElement>): void;
  40260. /**
  40261. * Gets the class name of the current intput.
  40262. * @returns the class name
  40263. */
  40264. getClassName(): string;
  40265. /**
  40266. * Get the friendly name associated with the input class.
  40267. * @returns the input friendly name
  40268. */
  40269. getSimpleName(): string;
  40270. }
  40271. }
  40272. declare module BABYLON {
  40273. /**
  40274. * Listen to mouse events to control the camera.
  40275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40276. */
  40277. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40278. /**
  40279. * Defines the camera the input is attached to.
  40280. */
  40281. camera: FlyCamera;
  40282. /**
  40283. * Defines if touch is enabled. (Default is true.)
  40284. */
  40285. touchEnabled: boolean;
  40286. /**
  40287. * Defines the buttons associated with the input to handle camera rotation.
  40288. */
  40289. buttons: number[];
  40290. /**
  40291. * Assign buttons for Yaw control.
  40292. */
  40293. buttonsYaw: number[];
  40294. /**
  40295. * Assign buttons for Pitch control.
  40296. */
  40297. buttonsPitch: number[];
  40298. /**
  40299. * Assign buttons for Roll control.
  40300. */
  40301. buttonsRoll: number[];
  40302. /**
  40303. * Detect if any button is being pressed while mouse is moved.
  40304. * -1 = Mouse locked.
  40305. * 0 = Left button.
  40306. * 1 = Middle Button.
  40307. * 2 = Right Button.
  40308. */
  40309. activeButton: number;
  40310. /**
  40311. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40312. * Higher values reduce its sensitivity.
  40313. */
  40314. angularSensibility: number;
  40315. private _mousemoveCallback;
  40316. private _observer;
  40317. private _rollObserver;
  40318. private previousPosition;
  40319. private noPreventDefault;
  40320. private element;
  40321. /**
  40322. * Listen to mouse events to control the camera.
  40323. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40325. */
  40326. constructor(touchEnabled?: boolean);
  40327. /**
  40328. * Attach the mouse control to the HTML DOM element.
  40329. * @param element Defines the element that listens to the input events.
  40330. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40331. */
  40332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40333. /**
  40334. * Detach the current controls from the specified dom element.
  40335. * @param element Defines the element to stop listening the inputs from
  40336. */
  40337. detachControl(element: Nullable<HTMLElement>): void;
  40338. /**
  40339. * Gets the class name of the current input.
  40340. * @returns the class name.
  40341. */
  40342. getClassName(): string;
  40343. /**
  40344. * Get the friendly name associated with the input class.
  40345. * @returns the input's friendly name.
  40346. */
  40347. getSimpleName(): string;
  40348. private _pointerInput;
  40349. private _onMouseMove;
  40350. /**
  40351. * Rotate camera by mouse offset.
  40352. */
  40353. private rotateCamera;
  40354. }
  40355. }
  40356. declare module BABYLON {
  40357. /**
  40358. * Default Inputs manager for the FlyCamera.
  40359. * It groups all the default supported inputs for ease of use.
  40360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40361. */
  40362. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40363. /**
  40364. * Instantiates a new FlyCameraInputsManager.
  40365. * @param camera Defines the camera the inputs belong to.
  40366. */
  40367. constructor(camera: FlyCamera);
  40368. /**
  40369. * Add keyboard input support to the input manager.
  40370. * @returns the new FlyCameraKeyboardMoveInput().
  40371. */
  40372. addKeyboard(): FlyCameraInputsManager;
  40373. /**
  40374. * Add mouse input support to the input manager.
  40375. * @param touchEnabled Enable touch screen support.
  40376. * @returns the new FlyCameraMouseInput().
  40377. */
  40378. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40379. }
  40380. }
  40381. declare module BABYLON {
  40382. /**
  40383. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40384. * such as in a 3D Space Shooter or a Flight Simulator.
  40385. */
  40386. export class FlyCamera extends TargetCamera {
  40387. /**
  40388. * Define the collision ellipsoid of the camera.
  40389. * This is helpful for simulating a camera body, like a player's body.
  40390. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40391. */
  40392. ellipsoid: Vector3;
  40393. /**
  40394. * Define an offset for the position of the ellipsoid around the camera.
  40395. * This can be helpful if the camera is attached away from the player's body center,
  40396. * such as at its head.
  40397. */
  40398. ellipsoidOffset: Vector3;
  40399. /**
  40400. * Enable or disable collisions of the camera with the rest of the scene objects.
  40401. */
  40402. checkCollisions: boolean;
  40403. /**
  40404. * Enable or disable gravity on the camera.
  40405. */
  40406. applyGravity: boolean;
  40407. /**
  40408. * Define the current direction the camera is moving to.
  40409. */
  40410. cameraDirection: Vector3;
  40411. /**
  40412. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40413. * This overrides and empties cameraRotation.
  40414. */
  40415. rotationQuaternion: Quaternion;
  40416. /**
  40417. * Track Roll to maintain the wanted Rolling when looking around.
  40418. */
  40419. _trackRoll: number;
  40420. /**
  40421. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40422. */
  40423. rollCorrect: number;
  40424. /**
  40425. * Mimic a banked turn, Rolling the camera when Yawing.
  40426. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40427. */
  40428. bankedTurn: boolean;
  40429. /**
  40430. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40431. */
  40432. bankedTurnLimit: number;
  40433. /**
  40434. * Value of 0 disables the banked Roll.
  40435. * Value of 1 is equal to the Yaw angle in radians.
  40436. */
  40437. bankedTurnMultiplier: number;
  40438. /**
  40439. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40440. */
  40441. inputs: FlyCameraInputsManager;
  40442. /**
  40443. * Gets the input sensibility for mouse input.
  40444. * Higher values reduce sensitivity.
  40445. */
  40446. get angularSensibility(): number;
  40447. /**
  40448. * Sets the input sensibility for a mouse input.
  40449. * Higher values reduce sensitivity.
  40450. */
  40451. set angularSensibility(value: number);
  40452. /**
  40453. * Get the keys for camera movement forward.
  40454. */
  40455. get keysForward(): number[];
  40456. /**
  40457. * Set the keys for camera movement forward.
  40458. */
  40459. set keysForward(value: number[]);
  40460. /**
  40461. * Get the keys for camera movement backward.
  40462. */
  40463. get keysBackward(): number[];
  40464. set keysBackward(value: number[]);
  40465. /**
  40466. * Get the keys for camera movement up.
  40467. */
  40468. get keysUp(): number[];
  40469. /**
  40470. * Set the keys for camera movement up.
  40471. */
  40472. set keysUp(value: number[]);
  40473. /**
  40474. * Get the keys for camera movement down.
  40475. */
  40476. get keysDown(): number[];
  40477. /**
  40478. * Set the keys for camera movement down.
  40479. */
  40480. set keysDown(value: number[]);
  40481. /**
  40482. * Get the keys for camera movement left.
  40483. */
  40484. get keysLeft(): number[];
  40485. /**
  40486. * Set the keys for camera movement left.
  40487. */
  40488. set keysLeft(value: number[]);
  40489. /**
  40490. * Set the keys for camera movement right.
  40491. */
  40492. get keysRight(): number[];
  40493. /**
  40494. * Set the keys for camera movement right.
  40495. */
  40496. set keysRight(value: number[]);
  40497. /**
  40498. * Event raised when the camera collides with a mesh in the scene.
  40499. */
  40500. onCollide: (collidedMesh: AbstractMesh) => void;
  40501. private _collider;
  40502. private _needMoveForGravity;
  40503. private _oldPosition;
  40504. private _diffPosition;
  40505. private _newPosition;
  40506. /** @hidden */
  40507. _localDirection: Vector3;
  40508. /** @hidden */
  40509. _transformedDirection: Vector3;
  40510. /**
  40511. * Instantiates a FlyCamera.
  40512. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40513. * such as in a 3D Space Shooter or a Flight Simulator.
  40514. * @param name Define the name of the camera in the scene.
  40515. * @param position Define the starting position of the camera in the scene.
  40516. * @param scene Define the scene the camera belongs to.
  40517. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40518. */
  40519. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40520. /**
  40521. * Attach a control to the HTML DOM element.
  40522. * @param element Defines the element that listens to the input events.
  40523. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40524. */
  40525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40526. /**
  40527. * Detach a control from the HTML DOM element.
  40528. * The camera will stop reacting to that input.
  40529. * @param element Defines the element that listens to the input events.
  40530. */
  40531. detachControl(element: HTMLElement): void;
  40532. private _collisionMask;
  40533. /**
  40534. * Get the mask that the camera ignores in collision events.
  40535. */
  40536. get collisionMask(): number;
  40537. /**
  40538. * Set the mask that the camera ignores in collision events.
  40539. */
  40540. set collisionMask(mask: number);
  40541. /** @hidden */
  40542. _collideWithWorld(displacement: Vector3): void;
  40543. /** @hidden */
  40544. private _onCollisionPositionChange;
  40545. /** @hidden */
  40546. _checkInputs(): void;
  40547. /** @hidden */
  40548. _decideIfNeedsToMove(): boolean;
  40549. /** @hidden */
  40550. _updatePosition(): void;
  40551. /**
  40552. * Restore the Roll to its target value at the rate specified.
  40553. * @param rate - Higher means slower restoring.
  40554. * @hidden
  40555. */
  40556. restoreRoll(rate: number): void;
  40557. /**
  40558. * Destroy the camera and release the current resources held by it.
  40559. */
  40560. dispose(): void;
  40561. /**
  40562. * Get the current object class name.
  40563. * @returns the class name.
  40564. */
  40565. getClassName(): string;
  40566. }
  40567. }
  40568. declare module BABYLON {
  40569. /**
  40570. * Listen to keyboard events to control the camera.
  40571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40572. */
  40573. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40574. /**
  40575. * Defines the camera the input is attached to.
  40576. */
  40577. camera: FlyCamera;
  40578. /**
  40579. * The list of keyboard keys used to control the forward move of the camera.
  40580. */
  40581. keysForward: number[];
  40582. /**
  40583. * The list of keyboard keys used to control the backward move of the camera.
  40584. */
  40585. keysBackward: number[];
  40586. /**
  40587. * The list of keyboard keys used to control the forward move of the camera.
  40588. */
  40589. keysUp: number[];
  40590. /**
  40591. * The list of keyboard keys used to control the backward move of the camera.
  40592. */
  40593. keysDown: number[];
  40594. /**
  40595. * The list of keyboard keys used to control the right strafe move of the camera.
  40596. */
  40597. keysRight: number[];
  40598. /**
  40599. * The list of keyboard keys used to control the left strafe move of the camera.
  40600. */
  40601. keysLeft: number[];
  40602. private _keys;
  40603. private _onCanvasBlurObserver;
  40604. private _onKeyboardObserver;
  40605. private _engine;
  40606. private _scene;
  40607. /**
  40608. * Attach the input controls to a specific dom element to get the input from.
  40609. * @param element Defines the element the controls should be listened from
  40610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40611. */
  40612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40613. /**
  40614. * Detach the current controls from the specified dom element.
  40615. * @param element Defines the element to stop listening the inputs from
  40616. */
  40617. detachControl(element: Nullable<HTMLElement>): void;
  40618. /**
  40619. * Gets the class name of the current intput.
  40620. * @returns the class name
  40621. */
  40622. getClassName(): string;
  40623. /** @hidden */
  40624. _onLostFocus(e: FocusEvent): void;
  40625. /**
  40626. * Get the friendly name associated with the input class.
  40627. * @returns the input friendly name
  40628. */
  40629. getSimpleName(): string;
  40630. /**
  40631. * Update the current camera state depending on the inputs that have been used this frame.
  40632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40633. */
  40634. checkInputs(): void;
  40635. }
  40636. }
  40637. declare module BABYLON {
  40638. /**
  40639. * Manage the mouse wheel inputs to control a follow camera.
  40640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40641. */
  40642. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40643. /**
  40644. * Defines the camera the input is attached to.
  40645. */
  40646. camera: FollowCamera;
  40647. /**
  40648. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40649. */
  40650. axisControlRadius: boolean;
  40651. /**
  40652. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40653. */
  40654. axisControlHeight: boolean;
  40655. /**
  40656. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40657. */
  40658. axisControlRotation: boolean;
  40659. /**
  40660. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40661. * relation to mouseWheel events.
  40662. */
  40663. wheelPrecision: number;
  40664. /**
  40665. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40666. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40667. */
  40668. wheelDeltaPercentage: number;
  40669. private _wheel;
  40670. private _observer;
  40671. /**
  40672. * Attach the input controls to a specific dom element to get the input from.
  40673. * @param element Defines the element the controls should be listened from
  40674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40675. */
  40676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40677. /**
  40678. * Detach the current controls from the specified dom element.
  40679. * @param element Defines the element to stop listening the inputs from
  40680. */
  40681. detachControl(element: Nullable<HTMLElement>): void;
  40682. /**
  40683. * Gets the class name of the current intput.
  40684. * @returns the class name
  40685. */
  40686. getClassName(): string;
  40687. /**
  40688. * Get the friendly name associated with the input class.
  40689. * @returns the input friendly name
  40690. */
  40691. getSimpleName(): string;
  40692. }
  40693. }
  40694. declare module BABYLON {
  40695. /**
  40696. * Manage the pointers inputs to control an follow camera.
  40697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40698. */
  40699. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40700. /**
  40701. * Defines the camera the input is attached to.
  40702. */
  40703. camera: FollowCamera;
  40704. /**
  40705. * Gets the class name of the current input.
  40706. * @returns the class name
  40707. */
  40708. getClassName(): string;
  40709. /**
  40710. * Defines the pointer angular sensibility along the X axis or how fast is
  40711. * the camera rotating.
  40712. * A negative number will reverse the axis direction.
  40713. */
  40714. angularSensibilityX: number;
  40715. /**
  40716. * Defines the pointer angular sensibility along the Y axis or how fast is
  40717. * the camera rotating.
  40718. * A negative number will reverse the axis direction.
  40719. */
  40720. angularSensibilityY: number;
  40721. /**
  40722. * Defines the pointer pinch precision or how fast is the camera zooming.
  40723. * A negative number will reverse the axis direction.
  40724. */
  40725. pinchPrecision: number;
  40726. /**
  40727. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40728. * from 0.
  40729. * It defines the percentage of current camera.radius to use as delta when
  40730. * pinch zoom is used.
  40731. */
  40732. pinchDeltaPercentage: number;
  40733. /**
  40734. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40735. */
  40736. axisXControlRadius: boolean;
  40737. /**
  40738. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40739. */
  40740. axisXControlHeight: boolean;
  40741. /**
  40742. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40743. */
  40744. axisXControlRotation: boolean;
  40745. /**
  40746. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40747. */
  40748. axisYControlRadius: boolean;
  40749. /**
  40750. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40751. */
  40752. axisYControlHeight: boolean;
  40753. /**
  40754. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40755. */
  40756. axisYControlRotation: boolean;
  40757. /**
  40758. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40759. */
  40760. axisPinchControlRadius: boolean;
  40761. /**
  40762. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40763. */
  40764. axisPinchControlHeight: boolean;
  40765. /**
  40766. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40767. */
  40768. axisPinchControlRotation: boolean;
  40769. /**
  40770. * Log error messages if basic misconfiguration has occurred.
  40771. */
  40772. warningEnable: boolean;
  40773. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40774. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40775. private _warningCounter;
  40776. private _warning;
  40777. }
  40778. }
  40779. declare module BABYLON {
  40780. /**
  40781. * Default Inputs manager for the FollowCamera.
  40782. * It groups all the default supported inputs for ease of use.
  40783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40784. */
  40785. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40786. /**
  40787. * Instantiates a new FollowCameraInputsManager.
  40788. * @param camera Defines the camera the inputs belong to
  40789. */
  40790. constructor(camera: FollowCamera);
  40791. /**
  40792. * Add keyboard input support to the input manager.
  40793. * @returns the current input manager
  40794. */
  40795. addKeyboard(): FollowCameraInputsManager;
  40796. /**
  40797. * Add mouse wheel input support to the input manager.
  40798. * @returns the current input manager
  40799. */
  40800. addMouseWheel(): FollowCameraInputsManager;
  40801. /**
  40802. * Add pointers input support to the input manager.
  40803. * @returns the current input manager
  40804. */
  40805. addPointers(): FollowCameraInputsManager;
  40806. /**
  40807. * Add orientation input support to the input manager.
  40808. * @returns the current input manager
  40809. */
  40810. addVRDeviceOrientation(): FollowCameraInputsManager;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40816. * an arc rotate version arcFollowCamera are available.
  40817. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40818. */
  40819. export class FollowCamera extends TargetCamera {
  40820. /**
  40821. * Distance the follow camera should follow an object at
  40822. */
  40823. radius: number;
  40824. /**
  40825. * Minimum allowed distance of the camera to the axis of rotation
  40826. * (The camera can not get closer).
  40827. * This can help limiting how the Camera is able to move in the scene.
  40828. */
  40829. lowerRadiusLimit: Nullable<number>;
  40830. /**
  40831. * Maximum allowed distance of the camera to the axis of rotation
  40832. * (The camera can not get further).
  40833. * This can help limiting how the Camera is able to move in the scene.
  40834. */
  40835. upperRadiusLimit: Nullable<number>;
  40836. /**
  40837. * Define a rotation offset between the camera and the object it follows
  40838. */
  40839. rotationOffset: number;
  40840. /**
  40841. * Minimum allowed angle to camera position relative to target object.
  40842. * This can help limiting how the Camera is able to move in the scene.
  40843. */
  40844. lowerRotationOffsetLimit: Nullable<number>;
  40845. /**
  40846. * Maximum allowed angle to camera position relative to target object.
  40847. * This can help limiting how the Camera is able to move in the scene.
  40848. */
  40849. upperRotationOffsetLimit: Nullable<number>;
  40850. /**
  40851. * Define a height offset between the camera and the object it follows.
  40852. * It can help following an object from the top (like a car chaing a plane)
  40853. */
  40854. heightOffset: number;
  40855. /**
  40856. * Minimum allowed height of camera position relative to target object.
  40857. * This can help limiting how the Camera is able to move in the scene.
  40858. */
  40859. lowerHeightOffsetLimit: Nullable<number>;
  40860. /**
  40861. * Maximum allowed height of camera position relative to target object.
  40862. * This can help limiting how the Camera is able to move in the scene.
  40863. */
  40864. upperHeightOffsetLimit: Nullable<number>;
  40865. /**
  40866. * Define how fast the camera can accelerate to follow it s target.
  40867. */
  40868. cameraAcceleration: number;
  40869. /**
  40870. * Define the speed limit of the camera following an object.
  40871. */
  40872. maxCameraSpeed: number;
  40873. /**
  40874. * Define the target of the camera.
  40875. */
  40876. lockedTarget: Nullable<AbstractMesh>;
  40877. /**
  40878. * Defines the input associated with the camera.
  40879. */
  40880. inputs: FollowCameraInputsManager;
  40881. /**
  40882. * Instantiates the follow camera.
  40883. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40884. * @param name Define the name of the camera in the scene
  40885. * @param position Define the position of the camera
  40886. * @param scene Define the scene the camera belong to
  40887. * @param lockedTarget Define the target of the camera
  40888. */
  40889. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40890. private _follow;
  40891. /**
  40892. * Attached controls to the current camera.
  40893. * @param element Defines the element the controls should be listened from
  40894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40895. */
  40896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40897. /**
  40898. * Detach the current controls from the camera.
  40899. * The camera will stop reacting to inputs.
  40900. * @param element Defines the element to stop listening the inputs from
  40901. */
  40902. detachControl(element: HTMLElement): void;
  40903. /** @hidden */
  40904. _checkInputs(): void;
  40905. private _checkLimits;
  40906. /**
  40907. * Gets the camera class name.
  40908. * @returns the class name
  40909. */
  40910. getClassName(): string;
  40911. }
  40912. /**
  40913. * Arc Rotate version of the follow camera.
  40914. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40915. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40916. */
  40917. export class ArcFollowCamera extends TargetCamera {
  40918. /** The longitudinal angle of the camera */
  40919. alpha: number;
  40920. /** The latitudinal angle of the camera */
  40921. beta: number;
  40922. /** The radius of the camera from its target */
  40923. radius: number;
  40924. /** Define the camera target (the messh it should follow) */
  40925. target: Nullable<AbstractMesh>;
  40926. private _cartesianCoordinates;
  40927. /**
  40928. * Instantiates a new ArcFollowCamera
  40929. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40930. * @param name Define the name of the camera
  40931. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40932. * @param beta Define the rotation angle of the camera around the elevation axis
  40933. * @param radius Define the radius of the camera from its target point
  40934. * @param target Define the target of the camera
  40935. * @param scene Define the scene the camera belongs to
  40936. */
  40937. constructor(name: string,
  40938. /** The longitudinal angle of the camera */
  40939. alpha: number,
  40940. /** The latitudinal angle of the camera */
  40941. beta: number,
  40942. /** The radius of the camera from its target */
  40943. radius: number,
  40944. /** Define the camera target (the messh it should follow) */
  40945. target: Nullable<AbstractMesh>, scene: Scene);
  40946. private _follow;
  40947. /** @hidden */
  40948. _checkInputs(): void;
  40949. /**
  40950. * Returns the class name of the object.
  40951. * It is mostly used internally for serialization purposes.
  40952. */
  40953. getClassName(): string;
  40954. }
  40955. }
  40956. declare module BABYLON {
  40957. /**
  40958. * Manage the keyboard inputs to control the movement of a follow camera.
  40959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40960. */
  40961. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40962. /**
  40963. * Defines the camera the input is attached to.
  40964. */
  40965. camera: FollowCamera;
  40966. /**
  40967. * Defines the list of key codes associated with the up action (increase heightOffset)
  40968. */
  40969. keysHeightOffsetIncr: number[];
  40970. /**
  40971. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40972. */
  40973. keysHeightOffsetDecr: number[];
  40974. /**
  40975. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40976. */
  40977. keysHeightOffsetModifierAlt: boolean;
  40978. /**
  40979. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40980. */
  40981. keysHeightOffsetModifierCtrl: boolean;
  40982. /**
  40983. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40984. */
  40985. keysHeightOffsetModifierShift: boolean;
  40986. /**
  40987. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40988. */
  40989. keysRotationOffsetIncr: number[];
  40990. /**
  40991. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40992. */
  40993. keysRotationOffsetDecr: number[];
  40994. /**
  40995. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40996. */
  40997. keysRotationOffsetModifierAlt: boolean;
  40998. /**
  40999. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41000. */
  41001. keysRotationOffsetModifierCtrl: boolean;
  41002. /**
  41003. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41004. */
  41005. keysRotationOffsetModifierShift: boolean;
  41006. /**
  41007. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41008. */
  41009. keysRadiusIncr: number[];
  41010. /**
  41011. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41012. */
  41013. keysRadiusDecr: number[];
  41014. /**
  41015. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41016. */
  41017. keysRadiusModifierAlt: boolean;
  41018. /**
  41019. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41020. */
  41021. keysRadiusModifierCtrl: boolean;
  41022. /**
  41023. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41024. */
  41025. keysRadiusModifierShift: boolean;
  41026. /**
  41027. * Defines the rate of change of heightOffset.
  41028. */
  41029. heightSensibility: number;
  41030. /**
  41031. * Defines the rate of change of rotationOffset.
  41032. */
  41033. rotationSensibility: number;
  41034. /**
  41035. * Defines the rate of change of radius.
  41036. */
  41037. radiusSensibility: number;
  41038. private _keys;
  41039. private _ctrlPressed;
  41040. private _altPressed;
  41041. private _shiftPressed;
  41042. private _onCanvasBlurObserver;
  41043. private _onKeyboardObserver;
  41044. private _engine;
  41045. private _scene;
  41046. /**
  41047. * Attach the input controls to a specific dom element to get the input from.
  41048. * @param element Defines the element the controls should be listened from
  41049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41050. */
  41051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41052. /**
  41053. * Detach the current controls from the specified dom element.
  41054. * @param element Defines the element to stop listening the inputs from
  41055. */
  41056. detachControl(element: Nullable<HTMLElement>): void;
  41057. /**
  41058. * Update the current camera state depending on the inputs that have been used this frame.
  41059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41060. */
  41061. checkInputs(): void;
  41062. /**
  41063. * Gets the class name of the current input.
  41064. * @returns the class name
  41065. */
  41066. getClassName(): string;
  41067. /**
  41068. * Get the friendly name associated with the input class.
  41069. * @returns the input friendly name
  41070. */
  41071. getSimpleName(): string;
  41072. /**
  41073. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41074. * allow modification of the heightOffset value.
  41075. */
  41076. private _modifierHeightOffset;
  41077. /**
  41078. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41079. * allow modification of the rotationOffset value.
  41080. */
  41081. private _modifierRotationOffset;
  41082. /**
  41083. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41084. * allow modification of the radius value.
  41085. */
  41086. private _modifierRadius;
  41087. }
  41088. }
  41089. declare module BABYLON {
  41090. interface FreeCameraInputsManager {
  41091. /**
  41092. * @hidden
  41093. */
  41094. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41095. /**
  41096. * Add orientation input support to the input manager.
  41097. * @returns the current input manager
  41098. */
  41099. addDeviceOrientation(): FreeCameraInputsManager;
  41100. }
  41101. /**
  41102. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41103. * Screen rotation is taken into account.
  41104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41105. */
  41106. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41107. private _camera;
  41108. private _screenOrientationAngle;
  41109. private _constantTranform;
  41110. private _screenQuaternion;
  41111. private _alpha;
  41112. private _beta;
  41113. private _gamma;
  41114. /**
  41115. * Can be used to detect if a device orientation sensor is available on a device
  41116. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41117. * @returns a promise that will resolve on orientation change
  41118. */
  41119. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41120. /**
  41121. * @hidden
  41122. */
  41123. _onDeviceOrientationChangedObservable: Observable<void>;
  41124. /**
  41125. * Instantiates a new input
  41126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41127. */
  41128. constructor();
  41129. /**
  41130. * Define the camera controlled by the input.
  41131. */
  41132. get camera(): FreeCamera;
  41133. set camera(camera: FreeCamera);
  41134. /**
  41135. * Attach the input controls to a specific dom element to get the input from.
  41136. * @param element Defines the element the controls should be listened from
  41137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41138. */
  41139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41140. private _orientationChanged;
  41141. private _deviceOrientation;
  41142. /**
  41143. * Detach the current controls from the specified dom element.
  41144. * @param element Defines the element to stop listening the inputs from
  41145. */
  41146. detachControl(element: Nullable<HTMLElement>): void;
  41147. /**
  41148. * Update the current camera state depending on the inputs that have been used this frame.
  41149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41150. */
  41151. checkInputs(): void;
  41152. /**
  41153. * Gets the class name of the current intput.
  41154. * @returns the class name
  41155. */
  41156. getClassName(): string;
  41157. /**
  41158. * Get the friendly name associated with the input class.
  41159. * @returns the input friendly name
  41160. */
  41161. getSimpleName(): string;
  41162. }
  41163. }
  41164. declare module BABYLON {
  41165. /**
  41166. * Manage the gamepad inputs to control a free camera.
  41167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41168. */
  41169. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41170. /**
  41171. * Define the camera the input is attached to.
  41172. */
  41173. camera: FreeCamera;
  41174. /**
  41175. * Define the Gamepad controlling the input
  41176. */
  41177. gamepad: Nullable<Gamepad>;
  41178. /**
  41179. * Defines the gamepad rotation sensiblity.
  41180. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41181. */
  41182. gamepadAngularSensibility: number;
  41183. /**
  41184. * Defines the gamepad move sensiblity.
  41185. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41186. */
  41187. gamepadMoveSensibility: number;
  41188. private _yAxisScale;
  41189. /**
  41190. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41191. */
  41192. get invertYAxis(): boolean;
  41193. set invertYAxis(value: boolean);
  41194. private _onGamepadConnectedObserver;
  41195. private _onGamepadDisconnectedObserver;
  41196. private _cameraTransform;
  41197. private _deltaTransform;
  41198. private _vector3;
  41199. private _vector2;
  41200. /**
  41201. * Attach the input controls to a specific dom element to get the input from.
  41202. * @param element Defines the element the controls should be listened from
  41203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41204. */
  41205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41206. /**
  41207. * Detach the current controls from the specified dom element.
  41208. * @param element Defines the element to stop listening the inputs from
  41209. */
  41210. detachControl(element: Nullable<HTMLElement>): void;
  41211. /**
  41212. * Update the current camera state depending on the inputs that have been used this frame.
  41213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41214. */
  41215. checkInputs(): void;
  41216. /**
  41217. * Gets the class name of the current intput.
  41218. * @returns the class name
  41219. */
  41220. getClassName(): string;
  41221. /**
  41222. * Get the friendly name associated with the input class.
  41223. * @returns the input friendly name
  41224. */
  41225. getSimpleName(): string;
  41226. }
  41227. }
  41228. declare module BABYLON {
  41229. /**
  41230. * Defines the potential axis of a Joystick
  41231. */
  41232. export enum JoystickAxis {
  41233. /** X axis */
  41234. X = 0,
  41235. /** Y axis */
  41236. Y = 1,
  41237. /** Z axis */
  41238. Z = 2
  41239. }
  41240. /**
  41241. * Class used to define virtual joystick (used in touch mode)
  41242. */
  41243. export class VirtualJoystick {
  41244. /**
  41245. * Gets or sets a boolean indicating that left and right values must be inverted
  41246. */
  41247. reverseLeftRight: boolean;
  41248. /**
  41249. * Gets or sets a boolean indicating that up and down values must be inverted
  41250. */
  41251. reverseUpDown: boolean;
  41252. /**
  41253. * Gets the offset value for the position (ie. the change of the position value)
  41254. */
  41255. deltaPosition: Vector3;
  41256. /**
  41257. * Gets a boolean indicating if the virtual joystick was pressed
  41258. */
  41259. pressed: boolean;
  41260. /**
  41261. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41262. */
  41263. static Canvas: Nullable<HTMLCanvasElement>;
  41264. private static _globalJoystickIndex;
  41265. private static vjCanvasContext;
  41266. private static vjCanvasWidth;
  41267. private static vjCanvasHeight;
  41268. private static halfWidth;
  41269. private _action;
  41270. private _axisTargetedByLeftAndRight;
  41271. private _axisTargetedByUpAndDown;
  41272. private _joystickSensibility;
  41273. private _inversedSensibility;
  41274. private _joystickPointerID;
  41275. private _joystickColor;
  41276. private _joystickPointerPos;
  41277. private _joystickPreviousPointerPos;
  41278. private _joystickPointerStartPos;
  41279. private _deltaJoystickVector;
  41280. private _leftJoystick;
  41281. private _touches;
  41282. private _onPointerDownHandlerRef;
  41283. private _onPointerMoveHandlerRef;
  41284. private _onPointerUpHandlerRef;
  41285. private _onResize;
  41286. /**
  41287. * Creates a new virtual joystick
  41288. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41289. */
  41290. constructor(leftJoystick?: boolean);
  41291. /**
  41292. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41293. * @param newJoystickSensibility defines the new sensibility
  41294. */
  41295. setJoystickSensibility(newJoystickSensibility: number): void;
  41296. private _onPointerDown;
  41297. private _onPointerMove;
  41298. private _onPointerUp;
  41299. /**
  41300. * Change the color of the virtual joystick
  41301. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41302. */
  41303. setJoystickColor(newColor: string): void;
  41304. /**
  41305. * Defines a callback to call when the joystick is touched
  41306. * @param action defines the callback
  41307. */
  41308. setActionOnTouch(action: () => any): void;
  41309. /**
  41310. * Defines which axis you'd like to control for left & right
  41311. * @param axis defines the axis to use
  41312. */
  41313. setAxisForLeftRight(axis: JoystickAxis): void;
  41314. /**
  41315. * Defines which axis you'd like to control for up & down
  41316. * @param axis defines the axis to use
  41317. */
  41318. setAxisForUpDown(axis: JoystickAxis): void;
  41319. private _drawVirtualJoystick;
  41320. /**
  41321. * Release internal HTML canvas
  41322. */
  41323. releaseCanvas(): void;
  41324. }
  41325. }
  41326. declare module BABYLON {
  41327. interface FreeCameraInputsManager {
  41328. /**
  41329. * Add virtual joystick input support to the input manager.
  41330. * @returns the current input manager
  41331. */
  41332. addVirtualJoystick(): FreeCameraInputsManager;
  41333. }
  41334. /**
  41335. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41337. */
  41338. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41339. /**
  41340. * Defines the camera the input is attached to.
  41341. */
  41342. camera: FreeCamera;
  41343. private _leftjoystick;
  41344. private _rightjoystick;
  41345. /**
  41346. * Gets the left stick of the virtual joystick.
  41347. * @returns The virtual Joystick
  41348. */
  41349. getLeftJoystick(): VirtualJoystick;
  41350. /**
  41351. * Gets the right stick of the virtual joystick.
  41352. * @returns The virtual Joystick
  41353. */
  41354. getRightJoystick(): VirtualJoystick;
  41355. /**
  41356. * Update the current camera state depending on the inputs that have been used this frame.
  41357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41358. */
  41359. checkInputs(): void;
  41360. /**
  41361. * Attach the input controls to a specific dom element to get the input from.
  41362. * @param element Defines the element the controls should be listened from
  41363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41364. */
  41365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41366. /**
  41367. * Detach the current controls from the specified dom element.
  41368. * @param element Defines the element to stop listening the inputs from
  41369. */
  41370. detachControl(element: Nullable<HTMLElement>): void;
  41371. /**
  41372. * Gets the class name of the current intput.
  41373. * @returns the class name
  41374. */
  41375. getClassName(): string;
  41376. /**
  41377. * Get the friendly name associated with the input class.
  41378. * @returns the input friendly name
  41379. */
  41380. getSimpleName(): string;
  41381. }
  41382. }
  41383. declare module BABYLON {
  41384. /**
  41385. * This represents a FPS type of camera controlled by touch.
  41386. * This is like a universal camera minus the Gamepad controls.
  41387. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41388. */
  41389. export class TouchCamera extends FreeCamera {
  41390. /**
  41391. * Defines the touch sensibility for rotation.
  41392. * The higher the faster.
  41393. */
  41394. get touchAngularSensibility(): number;
  41395. set touchAngularSensibility(value: number);
  41396. /**
  41397. * Defines the touch sensibility for move.
  41398. * The higher the faster.
  41399. */
  41400. get touchMoveSensibility(): number;
  41401. set touchMoveSensibility(value: number);
  41402. /**
  41403. * Instantiates a new touch camera.
  41404. * This represents a FPS type of camera controlled by touch.
  41405. * This is like a universal camera minus the Gamepad controls.
  41406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41407. * @param name Define the name of the camera in the scene
  41408. * @param position Define the start position of the camera in the scene
  41409. * @param scene Define the scene the camera belongs to
  41410. */
  41411. constructor(name: string, position: Vector3, scene: Scene);
  41412. /**
  41413. * Gets the current object class name.
  41414. * @return the class name
  41415. */
  41416. getClassName(): string;
  41417. /** @hidden */
  41418. _setupInputs(): void;
  41419. }
  41420. }
  41421. declare module BABYLON {
  41422. /**
  41423. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41424. * being tilted forward or back and left or right.
  41425. */
  41426. export class DeviceOrientationCamera extends FreeCamera {
  41427. private _initialQuaternion;
  41428. private _quaternionCache;
  41429. private _tmpDragQuaternion;
  41430. private _disablePointerInputWhenUsingDeviceOrientation;
  41431. /**
  41432. * Creates a new device orientation camera
  41433. * @param name The name of the camera
  41434. * @param position The start position camera
  41435. * @param scene The scene the camera belongs to
  41436. */
  41437. constructor(name: string, position: Vector3, scene: Scene);
  41438. /**
  41439. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41440. */
  41441. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41442. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41443. private _dragFactor;
  41444. /**
  41445. * Enabled turning on the y axis when the orientation sensor is active
  41446. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41447. */
  41448. enableHorizontalDragging(dragFactor?: number): void;
  41449. /**
  41450. * Gets the current instance class name ("DeviceOrientationCamera").
  41451. * This helps avoiding instanceof at run time.
  41452. * @returns the class name
  41453. */
  41454. getClassName(): string;
  41455. /**
  41456. * @hidden
  41457. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41458. */
  41459. _checkInputs(): void;
  41460. /**
  41461. * Reset the camera to its default orientation on the specified axis only.
  41462. * @param axis The axis to reset
  41463. */
  41464. resetToCurrentRotation(axis?: Axis): void;
  41465. }
  41466. }
  41467. declare module BABYLON {
  41468. /**
  41469. * Defines supported buttons for XBox360 compatible gamepads
  41470. */
  41471. export enum Xbox360Button {
  41472. /** A */
  41473. A = 0,
  41474. /** B */
  41475. B = 1,
  41476. /** X */
  41477. X = 2,
  41478. /** Y */
  41479. Y = 3,
  41480. /** Left button */
  41481. LB = 4,
  41482. /** Right button */
  41483. RB = 5,
  41484. /** Back */
  41485. Back = 8,
  41486. /** Start */
  41487. Start = 9,
  41488. /** Left stick */
  41489. LeftStick = 10,
  41490. /** Right stick */
  41491. RightStick = 11
  41492. }
  41493. /** Defines values for XBox360 DPad */
  41494. export enum Xbox360Dpad {
  41495. /** Up */
  41496. Up = 12,
  41497. /** Down */
  41498. Down = 13,
  41499. /** Left */
  41500. Left = 14,
  41501. /** Right */
  41502. Right = 15
  41503. }
  41504. /**
  41505. * Defines a XBox360 gamepad
  41506. */
  41507. export class Xbox360Pad extends Gamepad {
  41508. private _leftTrigger;
  41509. private _rightTrigger;
  41510. private _onlefttriggerchanged;
  41511. private _onrighttriggerchanged;
  41512. private _onbuttondown;
  41513. private _onbuttonup;
  41514. private _ondpaddown;
  41515. private _ondpadup;
  41516. /** Observable raised when a button is pressed */
  41517. onButtonDownObservable: Observable<Xbox360Button>;
  41518. /** Observable raised when a button is released */
  41519. onButtonUpObservable: Observable<Xbox360Button>;
  41520. /** Observable raised when a pad is pressed */
  41521. onPadDownObservable: Observable<Xbox360Dpad>;
  41522. /** Observable raised when a pad is released */
  41523. onPadUpObservable: Observable<Xbox360Dpad>;
  41524. private _buttonA;
  41525. private _buttonB;
  41526. private _buttonX;
  41527. private _buttonY;
  41528. private _buttonBack;
  41529. private _buttonStart;
  41530. private _buttonLB;
  41531. private _buttonRB;
  41532. private _buttonLeftStick;
  41533. private _buttonRightStick;
  41534. private _dPadUp;
  41535. private _dPadDown;
  41536. private _dPadLeft;
  41537. private _dPadRight;
  41538. private _isXboxOnePad;
  41539. /**
  41540. * Creates a new XBox360 gamepad object
  41541. * @param id defines the id of this gamepad
  41542. * @param index defines its index
  41543. * @param gamepad defines the internal HTML gamepad object
  41544. * @param xboxOne defines if it is a XBox One gamepad
  41545. */
  41546. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41547. /**
  41548. * Defines the callback to call when left trigger is pressed
  41549. * @param callback defines the callback to use
  41550. */
  41551. onlefttriggerchanged(callback: (value: number) => void): void;
  41552. /**
  41553. * Defines the callback to call when right trigger is pressed
  41554. * @param callback defines the callback to use
  41555. */
  41556. onrighttriggerchanged(callback: (value: number) => void): void;
  41557. /**
  41558. * Gets the left trigger value
  41559. */
  41560. get leftTrigger(): number;
  41561. /**
  41562. * Sets the left trigger value
  41563. */
  41564. set leftTrigger(newValue: number);
  41565. /**
  41566. * Gets the right trigger value
  41567. */
  41568. get rightTrigger(): number;
  41569. /**
  41570. * Sets the right trigger value
  41571. */
  41572. set rightTrigger(newValue: number);
  41573. /**
  41574. * Defines the callback to call when a button is pressed
  41575. * @param callback defines the callback to use
  41576. */
  41577. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41578. /**
  41579. * Defines the callback to call when a button is released
  41580. * @param callback defines the callback to use
  41581. */
  41582. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41583. /**
  41584. * Defines the callback to call when a pad is pressed
  41585. * @param callback defines the callback to use
  41586. */
  41587. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41588. /**
  41589. * Defines the callback to call when a pad is released
  41590. * @param callback defines the callback to use
  41591. */
  41592. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41593. private _setButtonValue;
  41594. private _setDPadValue;
  41595. /**
  41596. * Gets the value of the `A` button
  41597. */
  41598. get buttonA(): number;
  41599. /**
  41600. * Sets the value of the `A` button
  41601. */
  41602. set buttonA(value: number);
  41603. /**
  41604. * Gets the value of the `B` button
  41605. */
  41606. get buttonB(): number;
  41607. /**
  41608. * Sets the value of the `B` button
  41609. */
  41610. set buttonB(value: number);
  41611. /**
  41612. * Gets the value of the `X` button
  41613. */
  41614. get buttonX(): number;
  41615. /**
  41616. * Sets the value of the `X` button
  41617. */
  41618. set buttonX(value: number);
  41619. /**
  41620. * Gets the value of the `Y` button
  41621. */
  41622. get buttonY(): number;
  41623. /**
  41624. * Sets the value of the `Y` button
  41625. */
  41626. set buttonY(value: number);
  41627. /**
  41628. * Gets the value of the `Start` button
  41629. */
  41630. get buttonStart(): number;
  41631. /**
  41632. * Sets the value of the `Start` button
  41633. */
  41634. set buttonStart(value: number);
  41635. /**
  41636. * Gets the value of the `Back` button
  41637. */
  41638. get buttonBack(): number;
  41639. /**
  41640. * Sets the value of the `Back` button
  41641. */
  41642. set buttonBack(value: number);
  41643. /**
  41644. * Gets the value of the `Left` button
  41645. */
  41646. get buttonLB(): number;
  41647. /**
  41648. * Sets the value of the `Left` button
  41649. */
  41650. set buttonLB(value: number);
  41651. /**
  41652. * Gets the value of the `Right` button
  41653. */
  41654. get buttonRB(): number;
  41655. /**
  41656. * Sets the value of the `Right` button
  41657. */
  41658. set buttonRB(value: number);
  41659. /**
  41660. * Gets the value of the Left joystick
  41661. */
  41662. get buttonLeftStick(): number;
  41663. /**
  41664. * Sets the value of the Left joystick
  41665. */
  41666. set buttonLeftStick(value: number);
  41667. /**
  41668. * Gets the value of the Right joystick
  41669. */
  41670. get buttonRightStick(): number;
  41671. /**
  41672. * Sets the value of the Right joystick
  41673. */
  41674. set buttonRightStick(value: number);
  41675. /**
  41676. * Gets the value of D-pad up
  41677. */
  41678. get dPadUp(): number;
  41679. /**
  41680. * Sets the value of D-pad up
  41681. */
  41682. set dPadUp(value: number);
  41683. /**
  41684. * Gets the value of D-pad down
  41685. */
  41686. get dPadDown(): number;
  41687. /**
  41688. * Sets the value of D-pad down
  41689. */
  41690. set dPadDown(value: number);
  41691. /**
  41692. * Gets the value of D-pad left
  41693. */
  41694. get dPadLeft(): number;
  41695. /**
  41696. * Sets the value of D-pad left
  41697. */
  41698. set dPadLeft(value: number);
  41699. /**
  41700. * Gets the value of D-pad right
  41701. */
  41702. get dPadRight(): number;
  41703. /**
  41704. * Sets the value of D-pad right
  41705. */
  41706. set dPadRight(value: number);
  41707. /**
  41708. * Force the gamepad to synchronize with device values
  41709. */
  41710. update(): void;
  41711. /**
  41712. * Disposes the gamepad
  41713. */
  41714. dispose(): void;
  41715. }
  41716. }
  41717. declare module BABYLON {
  41718. /**
  41719. * Defines supported buttons for DualShock compatible gamepads
  41720. */
  41721. export enum DualShockButton {
  41722. /** Cross */
  41723. Cross = 0,
  41724. /** Circle */
  41725. Circle = 1,
  41726. /** Square */
  41727. Square = 2,
  41728. /** Triangle */
  41729. Triangle = 3,
  41730. /** L1 */
  41731. L1 = 4,
  41732. /** R1 */
  41733. R1 = 5,
  41734. /** Share */
  41735. Share = 8,
  41736. /** Options */
  41737. Options = 9,
  41738. /** Left stick */
  41739. LeftStick = 10,
  41740. /** Right stick */
  41741. RightStick = 11
  41742. }
  41743. /** Defines values for DualShock DPad */
  41744. export enum DualShockDpad {
  41745. /** Up */
  41746. Up = 12,
  41747. /** Down */
  41748. Down = 13,
  41749. /** Left */
  41750. Left = 14,
  41751. /** Right */
  41752. Right = 15
  41753. }
  41754. /**
  41755. * Defines a DualShock gamepad
  41756. */
  41757. export class DualShockPad extends Gamepad {
  41758. private _leftTrigger;
  41759. private _rightTrigger;
  41760. private _onlefttriggerchanged;
  41761. private _onrighttriggerchanged;
  41762. private _onbuttondown;
  41763. private _onbuttonup;
  41764. private _ondpaddown;
  41765. private _ondpadup;
  41766. /** Observable raised when a button is pressed */
  41767. onButtonDownObservable: Observable<DualShockButton>;
  41768. /** Observable raised when a button is released */
  41769. onButtonUpObservable: Observable<DualShockButton>;
  41770. /** Observable raised when a pad is pressed */
  41771. onPadDownObservable: Observable<DualShockDpad>;
  41772. /** Observable raised when a pad is released */
  41773. onPadUpObservable: Observable<DualShockDpad>;
  41774. private _buttonCross;
  41775. private _buttonCircle;
  41776. private _buttonSquare;
  41777. private _buttonTriangle;
  41778. private _buttonShare;
  41779. private _buttonOptions;
  41780. private _buttonL1;
  41781. private _buttonR1;
  41782. private _buttonLeftStick;
  41783. private _buttonRightStick;
  41784. private _dPadUp;
  41785. private _dPadDown;
  41786. private _dPadLeft;
  41787. private _dPadRight;
  41788. /**
  41789. * Creates a new DualShock gamepad object
  41790. * @param id defines the id of this gamepad
  41791. * @param index defines its index
  41792. * @param gamepad defines the internal HTML gamepad object
  41793. */
  41794. constructor(id: string, index: number, gamepad: any);
  41795. /**
  41796. * Defines the callback to call when left trigger is pressed
  41797. * @param callback defines the callback to use
  41798. */
  41799. onlefttriggerchanged(callback: (value: number) => void): void;
  41800. /**
  41801. * Defines the callback to call when right trigger is pressed
  41802. * @param callback defines the callback to use
  41803. */
  41804. onrighttriggerchanged(callback: (value: number) => void): void;
  41805. /**
  41806. * Gets the left trigger value
  41807. */
  41808. get leftTrigger(): number;
  41809. /**
  41810. * Sets the left trigger value
  41811. */
  41812. set leftTrigger(newValue: number);
  41813. /**
  41814. * Gets the right trigger value
  41815. */
  41816. get rightTrigger(): number;
  41817. /**
  41818. * Sets the right trigger value
  41819. */
  41820. set rightTrigger(newValue: number);
  41821. /**
  41822. * Defines the callback to call when a button is pressed
  41823. * @param callback defines the callback to use
  41824. */
  41825. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41826. /**
  41827. * Defines the callback to call when a button is released
  41828. * @param callback defines the callback to use
  41829. */
  41830. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41831. /**
  41832. * Defines the callback to call when a pad is pressed
  41833. * @param callback defines the callback to use
  41834. */
  41835. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41836. /**
  41837. * Defines the callback to call when a pad is released
  41838. * @param callback defines the callback to use
  41839. */
  41840. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41841. private _setButtonValue;
  41842. private _setDPadValue;
  41843. /**
  41844. * Gets the value of the `Cross` button
  41845. */
  41846. get buttonCross(): number;
  41847. /**
  41848. * Sets the value of the `Cross` button
  41849. */
  41850. set buttonCross(value: number);
  41851. /**
  41852. * Gets the value of the `Circle` button
  41853. */
  41854. get buttonCircle(): number;
  41855. /**
  41856. * Sets the value of the `Circle` button
  41857. */
  41858. set buttonCircle(value: number);
  41859. /**
  41860. * Gets the value of the `Square` button
  41861. */
  41862. get buttonSquare(): number;
  41863. /**
  41864. * Sets the value of the `Square` button
  41865. */
  41866. set buttonSquare(value: number);
  41867. /**
  41868. * Gets the value of the `Triangle` button
  41869. */
  41870. get buttonTriangle(): number;
  41871. /**
  41872. * Sets the value of the `Triangle` button
  41873. */
  41874. set buttonTriangle(value: number);
  41875. /**
  41876. * Gets the value of the `Options` button
  41877. */
  41878. get buttonOptions(): number;
  41879. /**
  41880. * Sets the value of the `Options` button
  41881. */
  41882. set buttonOptions(value: number);
  41883. /**
  41884. * Gets the value of the `Share` button
  41885. */
  41886. get buttonShare(): number;
  41887. /**
  41888. * Sets the value of the `Share` button
  41889. */
  41890. set buttonShare(value: number);
  41891. /**
  41892. * Gets the value of the `L1` button
  41893. */
  41894. get buttonL1(): number;
  41895. /**
  41896. * Sets the value of the `L1` button
  41897. */
  41898. set buttonL1(value: number);
  41899. /**
  41900. * Gets the value of the `R1` button
  41901. */
  41902. get buttonR1(): number;
  41903. /**
  41904. * Sets the value of the `R1` button
  41905. */
  41906. set buttonR1(value: number);
  41907. /**
  41908. * Gets the value of the Left joystick
  41909. */
  41910. get buttonLeftStick(): number;
  41911. /**
  41912. * Sets the value of the Left joystick
  41913. */
  41914. set buttonLeftStick(value: number);
  41915. /**
  41916. * Gets the value of the Right joystick
  41917. */
  41918. get buttonRightStick(): number;
  41919. /**
  41920. * Sets the value of the Right joystick
  41921. */
  41922. set buttonRightStick(value: number);
  41923. /**
  41924. * Gets the value of D-pad up
  41925. */
  41926. get dPadUp(): number;
  41927. /**
  41928. * Sets the value of D-pad up
  41929. */
  41930. set dPadUp(value: number);
  41931. /**
  41932. * Gets the value of D-pad down
  41933. */
  41934. get dPadDown(): number;
  41935. /**
  41936. * Sets the value of D-pad down
  41937. */
  41938. set dPadDown(value: number);
  41939. /**
  41940. * Gets the value of D-pad left
  41941. */
  41942. get dPadLeft(): number;
  41943. /**
  41944. * Sets the value of D-pad left
  41945. */
  41946. set dPadLeft(value: number);
  41947. /**
  41948. * Gets the value of D-pad right
  41949. */
  41950. get dPadRight(): number;
  41951. /**
  41952. * Sets the value of D-pad right
  41953. */
  41954. set dPadRight(value: number);
  41955. /**
  41956. * Force the gamepad to synchronize with device values
  41957. */
  41958. update(): void;
  41959. /**
  41960. * Disposes the gamepad
  41961. */
  41962. dispose(): void;
  41963. }
  41964. }
  41965. declare module BABYLON {
  41966. /**
  41967. * Manager for handling gamepads
  41968. */
  41969. export class GamepadManager {
  41970. private _scene?;
  41971. private _babylonGamepads;
  41972. private _oneGamepadConnected;
  41973. /** @hidden */
  41974. _isMonitoring: boolean;
  41975. private _gamepadEventSupported;
  41976. private _gamepadSupport?;
  41977. /**
  41978. * observable to be triggered when the gamepad controller has been connected
  41979. */
  41980. onGamepadConnectedObservable: Observable<Gamepad>;
  41981. /**
  41982. * observable to be triggered when the gamepad controller has been disconnected
  41983. */
  41984. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41985. private _onGamepadConnectedEvent;
  41986. private _onGamepadDisconnectedEvent;
  41987. /**
  41988. * Initializes the gamepad manager
  41989. * @param _scene BabylonJS scene
  41990. */
  41991. constructor(_scene?: Scene | undefined);
  41992. /**
  41993. * The gamepads in the game pad manager
  41994. */
  41995. get gamepads(): Gamepad[];
  41996. /**
  41997. * Get the gamepad controllers based on type
  41998. * @param type The type of gamepad controller
  41999. * @returns Nullable gamepad
  42000. */
  42001. getGamepadByType(type?: number): Nullable<Gamepad>;
  42002. /**
  42003. * Disposes the gamepad manager
  42004. */
  42005. dispose(): void;
  42006. private _addNewGamepad;
  42007. private _startMonitoringGamepads;
  42008. private _stopMonitoringGamepads;
  42009. /** @hidden */
  42010. _checkGamepadsStatus(): void;
  42011. private _updateGamepadObjects;
  42012. }
  42013. }
  42014. declare module BABYLON {
  42015. interface Scene {
  42016. /** @hidden */
  42017. _gamepadManager: Nullable<GamepadManager>;
  42018. /**
  42019. * Gets the gamepad manager associated with the scene
  42020. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42021. */
  42022. gamepadManager: GamepadManager;
  42023. }
  42024. /**
  42025. * Interface representing a free camera inputs manager
  42026. */
  42027. interface FreeCameraInputsManager {
  42028. /**
  42029. * Adds gamepad input support to the FreeCameraInputsManager.
  42030. * @returns the FreeCameraInputsManager
  42031. */
  42032. addGamepad(): FreeCameraInputsManager;
  42033. }
  42034. /**
  42035. * Interface representing an arc rotate camera inputs manager
  42036. */
  42037. interface ArcRotateCameraInputsManager {
  42038. /**
  42039. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42040. * @returns the camera inputs manager
  42041. */
  42042. addGamepad(): ArcRotateCameraInputsManager;
  42043. }
  42044. /**
  42045. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42046. */
  42047. export class GamepadSystemSceneComponent implements ISceneComponent {
  42048. /**
  42049. * The component name helpfull to identify the component in the list of scene components.
  42050. */
  42051. readonly name: string;
  42052. /**
  42053. * The scene the component belongs to.
  42054. */
  42055. scene: Scene;
  42056. /**
  42057. * Creates a new instance of the component for the given scene
  42058. * @param scene Defines the scene to register the component in
  42059. */
  42060. constructor(scene: Scene);
  42061. /**
  42062. * Registers the component in a given scene
  42063. */
  42064. register(): void;
  42065. /**
  42066. * Rebuilds the elements related to this component in case of
  42067. * context lost for instance.
  42068. */
  42069. rebuild(): void;
  42070. /**
  42071. * Disposes the component and the associated ressources
  42072. */
  42073. dispose(): void;
  42074. private _beforeCameraUpdate;
  42075. }
  42076. }
  42077. declare module BABYLON {
  42078. /**
  42079. * 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,
  42080. * which still works and will still be found in many Playgrounds.
  42081. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42082. */
  42083. export class UniversalCamera extends TouchCamera {
  42084. /**
  42085. * Defines the gamepad rotation sensiblity.
  42086. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42087. */
  42088. get gamepadAngularSensibility(): number;
  42089. set gamepadAngularSensibility(value: number);
  42090. /**
  42091. * Defines the gamepad move sensiblity.
  42092. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42093. */
  42094. get gamepadMoveSensibility(): number;
  42095. set gamepadMoveSensibility(value: number);
  42096. /**
  42097. * 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,
  42098. * which still works and will still be found in many Playgrounds.
  42099. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42100. * @param name Define the name of the camera in the scene
  42101. * @param position Define the start position of the camera in the scene
  42102. * @param scene Define the scene the camera belongs to
  42103. */
  42104. constructor(name: string, position: Vector3, scene: Scene);
  42105. /**
  42106. * Gets the current object class name.
  42107. * @return the class name
  42108. */
  42109. getClassName(): string;
  42110. }
  42111. }
  42112. declare module BABYLON {
  42113. /**
  42114. * This represents a FPS type of camera. This is only here for back compat purpose.
  42115. * Please use the UniversalCamera instead as both are identical.
  42116. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42117. */
  42118. export class GamepadCamera extends UniversalCamera {
  42119. /**
  42120. * Instantiates a new Gamepad Camera
  42121. * This represents a FPS type of camera. This is only here for back compat purpose.
  42122. * Please use the UniversalCamera instead as both are identical.
  42123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42124. * @param name Define the name of the camera in the scene
  42125. * @param position Define the start position of the camera in the scene
  42126. * @param scene Define the scene the camera belongs to
  42127. */
  42128. constructor(name: string, position: Vector3, scene: Scene);
  42129. /**
  42130. * Gets the current object class name.
  42131. * @return the class name
  42132. */
  42133. getClassName(): string;
  42134. }
  42135. }
  42136. declare module BABYLON {
  42137. /** @hidden */
  42138. export var passPixelShader: {
  42139. name: string;
  42140. shader: string;
  42141. };
  42142. }
  42143. declare module BABYLON {
  42144. /** @hidden */
  42145. export var passCubePixelShader: {
  42146. name: string;
  42147. shader: string;
  42148. };
  42149. }
  42150. declare module BABYLON {
  42151. /**
  42152. * PassPostProcess which produces an output the same as it's input
  42153. */
  42154. export class PassPostProcess extends PostProcess {
  42155. /**
  42156. * Creates the PassPostProcess
  42157. * @param name The name of the effect.
  42158. * @param options The required width/height ratio to downsize to before computing the render pass.
  42159. * @param camera The camera to apply the render pass to.
  42160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42161. * @param engine The engine which the post process will be applied. (default: current engine)
  42162. * @param reusable If the post process can be reused on the same frame. (default: false)
  42163. * @param textureType The type of texture to be used when performing the post processing.
  42164. * @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)
  42165. */
  42166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42167. }
  42168. /**
  42169. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42170. */
  42171. export class PassCubePostProcess extends PostProcess {
  42172. private _face;
  42173. /**
  42174. * Gets or sets the cube face to display.
  42175. * * 0 is +X
  42176. * * 1 is -X
  42177. * * 2 is +Y
  42178. * * 3 is -Y
  42179. * * 4 is +Z
  42180. * * 5 is -Z
  42181. */
  42182. get face(): number;
  42183. set face(value: number);
  42184. /**
  42185. * Creates the PassCubePostProcess
  42186. * @param name The name of the effect.
  42187. * @param options The required width/height ratio to downsize to before computing the render pass.
  42188. * @param camera The camera to apply the render pass to.
  42189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42190. * @param engine The engine which the post process will be applied. (default: current engine)
  42191. * @param reusable If the post process can be reused on the same frame. (default: false)
  42192. * @param textureType The type of texture to be used when performing the post processing.
  42193. * @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)
  42194. */
  42195. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42196. }
  42197. }
  42198. declare module BABYLON {
  42199. /** @hidden */
  42200. export var anaglyphPixelShader: {
  42201. name: string;
  42202. shader: string;
  42203. };
  42204. }
  42205. declare module BABYLON {
  42206. /**
  42207. * Postprocess used to generate anaglyphic rendering
  42208. */
  42209. export class AnaglyphPostProcess extends PostProcess {
  42210. private _passedProcess;
  42211. /**
  42212. * Creates a new AnaglyphPostProcess
  42213. * @param name defines postprocess name
  42214. * @param options defines creation options or target ratio scale
  42215. * @param rigCameras defines cameras using this postprocess
  42216. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42217. * @param engine defines hosting engine
  42218. * @param reusable defines if the postprocess will be reused multiple times per frame
  42219. */
  42220. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42221. }
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42226. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42227. */
  42228. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42229. /**
  42230. * Creates a new AnaglyphArcRotateCamera
  42231. * @param name defines camera name
  42232. * @param alpha defines alpha angle (in radians)
  42233. * @param beta defines beta angle (in radians)
  42234. * @param radius defines radius
  42235. * @param target defines camera target
  42236. * @param interaxialDistance defines distance between each color axis
  42237. * @param scene defines the hosting scene
  42238. */
  42239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42240. /**
  42241. * Gets camera class name
  42242. * @returns AnaglyphArcRotateCamera
  42243. */
  42244. getClassName(): string;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42251. */
  42252. export class AnaglyphFreeCamera extends FreeCamera {
  42253. /**
  42254. * Creates a new AnaglyphFreeCamera
  42255. * @param name defines camera name
  42256. * @param position defines initial position
  42257. * @param interaxialDistance defines distance between each color axis
  42258. * @param scene defines the hosting scene
  42259. */
  42260. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42261. /**
  42262. * Gets camera class name
  42263. * @returns AnaglyphFreeCamera
  42264. */
  42265. getClassName(): string;
  42266. }
  42267. }
  42268. declare module BABYLON {
  42269. /**
  42270. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42271. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42272. */
  42273. export class AnaglyphGamepadCamera extends GamepadCamera {
  42274. /**
  42275. * Creates a new AnaglyphGamepadCamera
  42276. * @param name defines camera name
  42277. * @param position defines initial position
  42278. * @param interaxialDistance defines distance between each color axis
  42279. * @param scene defines the hosting scene
  42280. */
  42281. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42282. /**
  42283. * Gets camera class name
  42284. * @returns AnaglyphGamepadCamera
  42285. */
  42286. getClassName(): string;
  42287. }
  42288. }
  42289. declare module BABYLON {
  42290. /**
  42291. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42292. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42293. */
  42294. export class AnaglyphUniversalCamera extends UniversalCamera {
  42295. /**
  42296. * Creates a new AnaglyphUniversalCamera
  42297. * @param name defines camera name
  42298. * @param position defines initial position
  42299. * @param interaxialDistance defines distance between each color axis
  42300. * @param scene defines the hosting scene
  42301. */
  42302. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42303. /**
  42304. * Gets camera class name
  42305. * @returns AnaglyphUniversalCamera
  42306. */
  42307. getClassName(): string;
  42308. }
  42309. }
  42310. declare module BABYLON {
  42311. /**
  42312. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42313. * @see http://doc.babylonjs.com/features/cameras
  42314. */
  42315. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42316. /**
  42317. * Creates a new StereoscopicArcRotateCamera
  42318. * @param name defines camera name
  42319. * @param alpha defines alpha angle (in radians)
  42320. * @param beta defines beta angle (in radians)
  42321. * @param radius defines radius
  42322. * @param target defines camera target
  42323. * @param interaxialDistance defines distance between each color axis
  42324. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42325. * @param scene defines the hosting scene
  42326. */
  42327. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42328. /**
  42329. * Gets camera class name
  42330. * @returns StereoscopicArcRotateCamera
  42331. */
  42332. getClassName(): string;
  42333. }
  42334. }
  42335. declare module BABYLON {
  42336. /**
  42337. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42338. * @see http://doc.babylonjs.com/features/cameras
  42339. */
  42340. export class StereoscopicFreeCamera extends FreeCamera {
  42341. /**
  42342. * Creates a new StereoscopicFreeCamera
  42343. * @param name defines camera name
  42344. * @param position defines initial position
  42345. * @param interaxialDistance defines distance between each color axis
  42346. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42347. * @param scene defines the hosting scene
  42348. */
  42349. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42350. /**
  42351. * Gets camera class name
  42352. * @returns StereoscopicFreeCamera
  42353. */
  42354. getClassName(): string;
  42355. }
  42356. }
  42357. declare module BABYLON {
  42358. /**
  42359. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42360. * @see http://doc.babylonjs.com/features/cameras
  42361. */
  42362. export class StereoscopicGamepadCamera extends GamepadCamera {
  42363. /**
  42364. * Creates a new StereoscopicGamepadCamera
  42365. * @param name defines camera name
  42366. * @param position defines initial position
  42367. * @param interaxialDistance defines distance between each color axis
  42368. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42369. * @param scene defines the hosting scene
  42370. */
  42371. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42372. /**
  42373. * Gets camera class name
  42374. * @returns StereoscopicGamepadCamera
  42375. */
  42376. getClassName(): string;
  42377. }
  42378. }
  42379. declare module BABYLON {
  42380. /**
  42381. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42382. * @see http://doc.babylonjs.com/features/cameras
  42383. */
  42384. export class StereoscopicUniversalCamera extends UniversalCamera {
  42385. /**
  42386. * Creates a new StereoscopicUniversalCamera
  42387. * @param name defines camera name
  42388. * @param position defines initial position
  42389. * @param interaxialDistance defines distance between each color axis
  42390. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42391. * @param scene defines the hosting scene
  42392. */
  42393. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42394. /**
  42395. * Gets camera class name
  42396. * @returns StereoscopicUniversalCamera
  42397. */
  42398. getClassName(): string;
  42399. }
  42400. }
  42401. declare module BABYLON {
  42402. /**
  42403. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42404. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42405. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42406. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42407. */
  42408. export class VirtualJoysticksCamera extends FreeCamera {
  42409. /**
  42410. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42411. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42412. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42413. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42414. * @param name Define the name of the camera in the scene
  42415. * @param position Define the start position of the camera in the scene
  42416. * @param scene Define the scene the camera belongs to
  42417. */
  42418. constructor(name: string, position: Vector3, scene: Scene);
  42419. /**
  42420. * Gets the current object class name.
  42421. * @return the class name
  42422. */
  42423. getClassName(): string;
  42424. }
  42425. }
  42426. declare module BABYLON {
  42427. /**
  42428. * This represents all the required metrics to create a VR camera.
  42429. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42430. */
  42431. export class VRCameraMetrics {
  42432. /**
  42433. * Define the horizontal resolution off the screen.
  42434. */
  42435. hResolution: number;
  42436. /**
  42437. * Define the vertical resolution off the screen.
  42438. */
  42439. vResolution: number;
  42440. /**
  42441. * Define the horizontal screen size.
  42442. */
  42443. hScreenSize: number;
  42444. /**
  42445. * Define the vertical screen size.
  42446. */
  42447. vScreenSize: number;
  42448. /**
  42449. * Define the vertical screen center position.
  42450. */
  42451. vScreenCenter: number;
  42452. /**
  42453. * Define the distance of the eyes to the screen.
  42454. */
  42455. eyeToScreenDistance: number;
  42456. /**
  42457. * Define the distance between both lenses
  42458. */
  42459. lensSeparationDistance: number;
  42460. /**
  42461. * Define the distance between both viewer's eyes.
  42462. */
  42463. interpupillaryDistance: number;
  42464. /**
  42465. * Define the distortion factor of the VR postprocess.
  42466. * Please, touch with care.
  42467. */
  42468. distortionK: number[];
  42469. /**
  42470. * Define the chromatic aberration correction factors for the VR post process.
  42471. */
  42472. chromaAbCorrection: number[];
  42473. /**
  42474. * Define the scale factor of the post process.
  42475. * The smaller the better but the slower.
  42476. */
  42477. postProcessScaleFactor: number;
  42478. /**
  42479. * Define an offset for the lens center.
  42480. */
  42481. lensCenterOffset: number;
  42482. /**
  42483. * Define if the current vr camera should compensate the distortion of the lense or not.
  42484. */
  42485. compensateDistortion: boolean;
  42486. /**
  42487. * Defines if multiview should be enabled when rendering (Default: false)
  42488. */
  42489. multiviewEnabled: boolean;
  42490. /**
  42491. * Gets the rendering aspect ratio based on the provided resolutions.
  42492. */
  42493. get aspectRatio(): number;
  42494. /**
  42495. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42496. */
  42497. get aspectRatioFov(): number;
  42498. /**
  42499. * @hidden
  42500. */
  42501. get leftHMatrix(): Matrix;
  42502. /**
  42503. * @hidden
  42504. */
  42505. get rightHMatrix(): Matrix;
  42506. /**
  42507. * @hidden
  42508. */
  42509. get leftPreViewMatrix(): Matrix;
  42510. /**
  42511. * @hidden
  42512. */
  42513. get rightPreViewMatrix(): Matrix;
  42514. /**
  42515. * Get the default VRMetrics based on the most generic setup.
  42516. * @returns the default vr metrics
  42517. */
  42518. static GetDefault(): VRCameraMetrics;
  42519. }
  42520. }
  42521. declare module BABYLON {
  42522. /** @hidden */
  42523. export var vrDistortionCorrectionPixelShader: {
  42524. name: string;
  42525. shader: string;
  42526. };
  42527. }
  42528. declare module BABYLON {
  42529. /**
  42530. * VRDistortionCorrectionPostProcess used for mobile VR
  42531. */
  42532. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42533. private _isRightEye;
  42534. private _distortionFactors;
  42535. private _postProcessScaleFactor;
  42536. private _lensCenterOffset;
  42537. private _scaleIn;
  42538. private _scaleFactor;
  42539. private _lensCenter;
  42540. /**
  42541. * Initializes the VRDistortionCorrectionPostProcess
  42542. * @param name The name of the effect.
  42543. * @param camera The camera to apply the render pass to.
  42544. * @param isRightEye If this is for the right eye distortion
  42545. * @param vrMetrics All the required metrics for the VR camera
  42546. */
  42547. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42548. }
  42549. }
  42550. declare module BABYLON {
  42551. /**
  42552. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42553. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42554. */
  42555. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42556. /**
  42557. * Creates a new VRDeviceOrientationArcRotateCamera
  42558. * @param name defines camera name
  42559. * @param alpha defines the camera rotation along the logitudinal axis
  42560. * @param beta defines the camera rotation along the latitudinal axis
  42561. * @param radius defines the camera distance from its target
  42562. * @param target defines the camera target
  42563. * @param scene defines the scene the camera belongs to
  42564. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42565. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42566. */
  42567. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42568. /**
  42569. * Gets camera class name
  42570. * @returns VRDeviceOrientationArcRotateCamera
  42571. */
  42572. getClassName(): string;
  42573. }
  42574. }
  42575. declare module BABYLON {
  42576. /**
  42577. * Camera used to simulate VR rendering (based on FreeCamera)
  42578. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42579. */
  42580. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42581. /**
  42582. * Creates a new VRDeviceOrientationFreeCamera
  42583. * @param name defines camera name
  42584. * @param position defines the start position of the camera
  42585. * @param scene defines the scene the camera belongs to
  42586. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42587. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42588. */
  42589. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42590. /**
  42591. * Gets camera class name
  42592. * @returns VRDeviceOrientationFreeCamera
  42593. */
  42594. getClassName(): string;
  42595. }
  42596. }
  42597. declare module BABYLON {
  42598. /**
  42599. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42600. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42601. */
  42602. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42603. /**
  42604. * Creates a new VRDeviceOrientationGamepadCamera
  42605. * @param name defines camera name
  42606. * @param position defines the start position of the camera
  42607. * @param scene defines the scene the camera belongs to
  42608. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42609. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42610. */
  42611. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42612. /**
  42613. * Gets camera class name
  42614. * @returns VRDeviceOrientationGamepadCamera
  42615. */
  42616. getClassName(): string;
  42617. }
  42618. }
  42619. declare module BABYLON {
  42620. /** @hidden */
  42621. export var imageProcessingPixelShader: {
  42622. name: string;
  42623. shader: string;
  42624. };
  42625. }
  42626. declare module BABYLON {
  42627. /**
  42628. * ImageProcessingPostProcess
  42629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42630. */
  42631. export class ImageProcessingPostProcess extends PostProcess {
  42632. /**
  42633. * Default configuration related to image processing available in the PBR Material.
  42634. */
  42635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42636. /**
  42637. * Gets the image processing configuration used either in this material.
  42638. */
  42639. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42640. /**
  42641. * Sets the Default image processing configuration used either in the this material.
  42642. *
  42643. * If sets to null, the scene one is in use.
  42644. */
  42645. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42646. /**
  42647. * Keep track of the image processing observer to allow dispose and replace.
  42648. */
  42649. private _imageProcessingObserver;
  42650. /**
  42651. * Attaches a new image processing configuration to the PBR Material.
  42652. * @param configuration
  42653. */
  42654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42655. /**
  42656. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42657. */
  42658. get colorCurves(): Nullable<ColorCurves>;
  42659. /**
  42660. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42661. */
  42662. set colorCurves(value: Nullable<ColorCurves>);
  42663. /**
  42664. * Gets wether the color curves effect is enabled.
  42665. */
  42666. get colorCurvesEnabled(): boolean;
  42667. /**
  42668. * Sets wether the color curves effect is enabled.
  42669. */
  42670. set colorCurvesEnabled(value: boolean);
  42671. /**
  42672. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42673. */
  42674. get colorGradingTexture(): Nullable<BaseTexture>;
  42675. /**
  42676. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42677. */
  42678. set colorGradingTexture(value: Nullable<BaseTexture>);
  42679. /**
  42680. * Gets wether the color grading effect is enabled.
  42681. */
  42682. get colorGradingEnabled(): boolean;
  42683. /**
  42684. * Gets wether the color grading effect is enabled.
  42685. */
  42686. set colorGradingEnabled(value: boolean);
  42687. /**
  42688. * Gets exposure used in the effect.
  42689. */
  42690. get exposure(): number;
  42691. /**
  42692. * Sets exposure used in the effect.
  42693. */
  42694. set exposure(value: number);
  42695. /**
  42696. * Gets wether tonemapping is enabled or not.
  42697. */
  42698. get toneMappingEnabled(): boolean;
  42699. /**
  42700. * Sets wether tonemapping is enabled or not
  42701. */
  42702. set toneMappingEnabled(value: boolean);
  42703. /**
  42704. * Gets the type of tone mapping effect.
  42705. */
  42706. get toneMappingType(): number;
  42707. /**
  42708. * Sets the type of tone mapping effect.
  42709. */
  42710. set toneMappingType(value: number);
  42711. /**
  42712. * Gets contrast used in the effect.
  42713. */
  42714. get contrast(): number;
  42715. /**
  42716. * Sets contrast used in the effect.
  42717. */
  42718. set contrast(value: number);
  42719. /**
  42720. * Gets Vignette stretch size.
  42721. */
  42722. get vignetteStretch(): number;
  42723. /**
  42724. * Sets Vignette stretch size.
  42725. */
  42726. set vignetteStretch(value: number);
  42727. /**
  42728. * Gets Vignette centre X Offset.
  42729. */
  42730. get vignetteCentreX(): number;
  42731. /**
  42732. * Sets Vignette centre X Offset.
  42733. */
  42734. set vignetteCentreX(value: number);
  42735. /**
  42736. * Gets Vignette centre Y Offset.
  42737. */
  42738. get vignetteCentreY(): number;
  42739. /**
  42740. * Sets Vignette centre Y Offset.
  42741. */
  42742. set vignetteCentreY(value: number);
  42743. /**
  42744. * Gets Vignette weight or intensity of the vignette effect.
  42745. */
  42746. get vignetteWeight(): number;
  42747. /**
  42748. * Sets Vignette weight or intensity of the vignette effect.
  42749. */
  42750. set vignetteWeight(value: number);
  42751. /**
  42752. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42753. * if vignetteEnabled is set to true.
  42754. */
  42755. get vignetteColor(): Color4;
  42756. /**
  42757. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42758. * if vignetteEnabled is set to true.
  42759. */
  42760. set vignetteColor(value: Color4);
  42761. /**
  42762. * Gets Camera field of view used by the Vignette effect.
  42763. */
  42764. get vignetteCameraFov(): number;
  42765. /**
  42766. * Sets Camera field of view used by the Vignette effect.
  42767. */
  42768. set vignetteCameraFov(value: number);
  42769. /**
  42770. * Gets the vignette blend mode allowing different kind of effect.
  42771. */
  42772. get vignetteBlendMode(): number;
  42773. /**
  42774. * Sets the vignette blend mode allowing different kind of effect.
  42775. */
  42776. set vignetteBlendMode(value: number);
  42777. /**
  42778. * Gets wether the vignette effect is enabled.
  42779. */
  42780. get vignetteEnabled(): boolean;
  42781. /**
  42782. * Sets wether the vignette effect is enabled.
  42783. */
  42784. set vignetteEnabled(value: boolean);
  42785. private _fromLinearSpace;
  42786. /**
  42787. * Gets wether the input of the processing is in Gamma or Linear Space.
  42788. */
  42789. get fromLinearSpace(): boolean;
  42790. /**
  42791. * Sets wether the input of the processing is in Gamma or Linear Space.
  42792. */
  42793. set fromLinearSpace(value: boolean);
  42794. /**
  42795. * Defines cache preventing GC.
  42796. */
  42797. private _defines;
  42798. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42799. /**
  42800. * "ImageProcessingPostProcess"
  42801. * @returns "ImageProcessingPostProcess"
  42802. */
  42803. getClassName(): string;
  42804. protected _updateParameters(): void;
  42805. dispose(camera?: Camera): void;
  42806. }
  42807. }
  42808. declare module BABYLON {
  42809. /**
  42810. * Class containing static functions to help procedurally build meshes
  42811. */
  42812. export class GroundBuilder {
  42813. /**
  42814. * Creates a ground mesh
  42815. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42816. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42818. * @param name defines the name of the mesh
  42819. * @param options defines the options used to create the mesh
  42820. * @param scene defines the hosting scene
  42821. * @returns the ground mesh
  42822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42823. */
  42824. static CreateGround(name: string, options: {
  42825. width?: number;
  42826. height?: number;
  42827. subdivisions?: number;
  42828. subdivisionsX?: number;
  42829. subdivisionsY?: number;
  42830. updatable?: boolean;
  42831. }, scene: any): Mesh;
  42832. /**
  42833. * Creates a tiled ground mesh
  42834. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42835. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42836. * * 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
  42837. * * 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
  42838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42839. * @param name defines the name of the mesh
  42840. * @param options defines the options used to create the mesh
  42841. * @param scene defines the hosting scene
  42842. * @returns the tiled ground mesh
  42843. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42844. */
  42845. static CreateTiledGround(name: string, options: {
  42846. xmin: number;
  42847. zmin: number;
  42848. xmax: number;
  42849. zmax: number;
  42850. subdivisions?: {
  42851. w: number;
  42852. h: number;
  42853. };
  42854. precision?: {
  42855. w: number;
  42856. h: number;
  42857. };
  42858. updatable?: boolean;
  42859. }, scene?: Nullable<Scene>): Mesh;
  42860. /**
  42861. * Creates a ground mesh from a height map
  42862. * * The parameter `url` sets the URL of the height map image resource.
  42863. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42864. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42865. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42866. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42867. * * 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.
  42868. * * 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).
  42869. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42871. * @param name defines the name of the mesh
  42872. * @param url defines the url to the height map
  42873. * @param options defines the options used to create the mesh
  42874. * @param scene defines the hosting scene
  42875. * @returns the ground mesh
  42876. * @see https://doc.babylonjs.com/babylon101/height_map
  42877. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42878. */
  42879. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42880. width?: number;
  42881. height?: number;
  42882. subdivisions?: number;
  42883. minHeight?: number;
  42884. maxHeight?: number;
  42885. colorFilter?: Color3;
  42886. alphaFilter?: number;
  42887. updatable?: boolean;
  42888. onReady?: (mesh: GroundMesh) => void;
  42889. }, scene?: Nullable<Scene>): GroundMesh;
  42890. }
  42891. }
  42892. declare module BABYLON {
  42893. /**
  42894. * Class containing static functions to help procedurally build meshes
  42895. */
  42896. export class TorusBuilder {
  42897. /**
  42898. * Creates a torus mesh
  42899. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42900. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42901. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42903. * * 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
  42904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42905. * @param name defines the name of the mesh
  42906. * @param options defines the options used to create the mesh
  42907. * @param scene defines the hosting scene
  42908. * @returns the torus mesh
  42909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42910. */
  42911. static CreateTorus(name: string, options: {
  42912. diameter?: number;
  42913. thickness?: number;
  42914. tessellation?: number;
  42915. updatable?: boolean;
  42916. sideOrientation?: number;
  42917. frontUVs?: Vector4;
  42918. backUVs?: Vector4;
  42919. }, scene: any): Mesh;
  42920. }
  42921. }
  42922. declare module BABYLON {
  42923. /**
  42924. * Class containing static functions to help procedurally build meshes
  42925. */
  42926. export class CylinderBuilder {
  42927. /**
  42928. * Creates a cylinder or a cone mesh
  42929. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42930. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42931. * * 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.
  42932. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42933. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42934. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42935. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42936. * * 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).
  42937. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42938. * * 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).
  42939. * * 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
  42940. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42941. * * 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
  42942. * * 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.
  42943. * * If `enclose` is false, a ring surface is one element.
  42944. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42945. * * 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
  42946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42947. * * 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
  42948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42949. * @param name defines the name of the mesh
  42950. * @param options defines the options used to create the mesh
  42951. * @param scene defines the hosting scene
  42952. * @returns the cylinder mesh
  42953. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42954. */
  42955. static CreateCylinder(name: string, options: {
  42956. height?: number;
  42957. diameterTop?: number;
  42958. diameterBottom?: number;
  42959. diameter?: number;
  42960. tessellation?: number;
  42961. subdivisions?: number;
  42962. arc?: number;
  42963. faceColors?: Color4[];
  42964. faceUV?: Vector4[];
  42965. updatable?: boolean;
  42966. hasRings?: boolean;
  42967. enclose?: boolean;
  42968. cap?: number;
  42969. sideOrientation?: number;
  42970. frontUVs?: Vector4;
  42971. backUVs?: Vector4;
  42972. }, scene: any): Mesh;
  42973. }
  42974. }
  42975. declare module BABYLON {
  42976. /**
  42977. * States of the webXR experience
  42978. */
  42979. export enum WebXRState {
  42980. /**
  42981. * Transitioning to being in XR mode
  42982. */
  42983. ENTERING_XR = 0,
  42984. /**
  42985. * Transitioning to non XR mode
  42986. */
  42987. EXITING_XR = 1,
  42988. /**
  42989. * In XR mode and presenting
  42990. */
  42991. IN_XR = 2,
  42992. /**
  42993. * Not entered XR mode
  42994. */
  42995. NOT_IN_XR = 3
  42996. }
  42997. /**
  42998. * Abstraction of the XR render target
  42999. */
  43000. export interface WebXRRenderTarget extends IDisposable {
  43001. /**
  43002. * xrpresent context of the canvas which can be used to display/mirror xr content
  43003. */
  43004. canvasContext: WebGLRenderingContext;
  43005. /**
  43006. * xr layer for the canvas
  43007. */
  43008. xrLayer: Nullable<XRWebGLLayer>;
  43009. /**
  43010. * Initializes the xr layer for the session
  43011. * @param xrSession xr session
  43012. * @returns a promise that will resolve once the XR Layer has been created
  43013. */
  43014. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43015. }
  43016. }
  43017. declare module BABYLON {
  43018. /**
  43019. * COnfiguration object for WebXR output canvas
  43020. */
  43021. export class WebXRManagedOutputCanvasOptions {
  43022. /**
  43023. * An optional canvas in case you wish to create it yourself and provide it here.
  43024. * If not provided, a new canvas will be created
  43025. */
  43026. canvasElement?: HTMLCanvasElement;
  43027. /**
  43028. * Options for this XR Layer output
  43029. */
  43030. canvasOptions?: XRWebGLLayerOptions;
  43031. /**
  43032. * CSS styling for a newly created canvas (if not provided)
  43033. */
  43034. newCanvasCssStyle?: string;
  43035. /**
  43036. * Get the default values of the configuration object
  43037. * @returns default values of this configuration object
  43038. */
  43039. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43040. }
  43041. /**
  43042. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43043. */
  43044. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43045. private _options;
  43046. private _canvas;
  43047. private _engine;
  43048. /**
  43049. * Rendering context of the canvas which can be used to display/mirror xr content
  43050. */
  43051. canvasContext: WebGLRenderingContext;
  43052. /**
  43053. * xr layer for the canvas
  43054. */
  43055. xrLayer: Nullable<XRWebGLLayer>;
  43056. /**
  43057. * Initializes the canvas to be added/removed upon entering/exiting xr
  43058. * @param _xrSessionManager The XR Session manager
  43059. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43060. */
  43061. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43062. /**
  43063. * Disposes of the object
  43064. */
  43065. dispose(): void;
  43066. /**
  43067. * Initializes the xr layer for the session
  43068. * @param xrSession xr session
  43069. * @returns a promise that will resolve once the XR Layer has been created
  43070. */
  43071. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43072. private _addCanvas;
  43073. private _removeCanvas;
  43074. private _setManagedOutputCanvas;
  43075. }
  43076. }
  43077. declare module BABYLON {
  43078. /**
  43079. * Manages an XRSession to work with Babylon's engine
  43080. * @see https://doc.babylonjs.com/how_to/webxr
  43081. */
  43082. export class WebXRSessionManager implements IDisposable {
  43083. /** The scene which the session should be created for */
  43084. scene: Scene;
  43085. private _referenceSpace;
  43086. private _rttProvider;
  43087. private _sessionEnded;
  43088. private _xrNavigator;
  43089. private baseLayer;
  43090. /**
  43091. * The base reference space from which the session started. good if you want to reset your
  43092. * reference space
  43093. */
  43094. baseReferenceSpace: XRReferenceSpace;
  43095. /**
  43096. * Current XR frame
  43097. */
  43098. currentFrame: Nullable<XRFrame>;
  43099. /** WebXR timestamp updated every frame */
  43100. currentTimestamp: number;
  43101. /**
  43102. * Used just in case of a failure to initialize an immersive session.
  43103. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43104. */
  43105. defaultHeightCompensation: number;
  43106. /**
  43107. * Fires every time a new xrFrame arrives which can be used to update the camera
  43108. */
  43109. onXRFrameObservable: Observable<XRFrame>;
  43110. /**
  43111. * Fires when the reference space changed
  43112. */
  43113. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43114. /**
  43115. * Fires when the xr session is ended either by the device or manually done
  43116. */
  43117. onXRSessionEnded: Observable<any>;
  43118. /**
  43119. * Fires when the xr session is ended either by the device or manually done
  43120. */
  43121. onXRSessionInit: Observable<XRSession>;
  43122. /**
  43123. * Underlying xr session
  43124. */
  43125. session: XRSession;
  43126. /**
  43127. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43128. * or get the offset the player is currently at.
  43129. */
  43130. viewerReferenceSpace: XRReferenceSpace;
  43131. /**
  43132. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43133. * @param scene The scene which the session should be created for
  43134. */
  43135. constructor(
  43136. /** The scene which the session should be created for */
  43137. scene: Scene);
  43138. /**
  43139. * The current reference space used in this session. This reference space can constantly change!
  43140. * It is mainly used to offset the camera's position.
  43141. */
  43142. get referenceSpace(): XRReferenceSpace;
  43143. /**
  43144. * Set a new reference space and triggers the observable
  43145. */
  43146. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43147. /**
  43148. * Disposes of the session manager
  43149. */
  43150. dispose(): void;
  43151. /**
  43152. * Stops the xrSession and restores the render loop
  43153. * @returns Promise which resolves after it exits XR
  43154. */
  43155. exitXRAsync(): Promise<void>;
  43156. /**
  43157. * Gets the correct render target texture to be rendered this frame for this eye
  43158. * @param eye the eye for which to get the render target
  43159. * @returns the render target for the specified eye
  43160. */
  43161. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43162. /**
  43163. * Creates a WebXRRenderTarget object for the XR session
  43164. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43165. * @param options optional options to provide when creating a new render target
  43166. * @returns a WebXR render target to which the session can render
  43167. */
  43168. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43169. /**
  43170. * Initializes the manager
  43171. * After initialization enterXR can be called to start an XR session
  43172. * @returns Promise which resolves after it is initialized
  43173. */
  43174. initializeAsync(): Promise<void>;
  43175. /**
  43176. * Initializes an xr session
  43177. * @param xrSessionMode mode to initialize
  43178. * @param xrSessionInit defines optional and required values to pass to the session builder
  43179. * @returns a promise which will resolve once the session has been initialized
  43180. */
  43181. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43182. /**
  43183. * Checks if a session would be supported for the creation options specified
  43184. * @param sessionMode session mode to check if supported eg. immersive-vr
  43185. * @returns A Promise that resolves to true if supported and false if not
  43186. */
  43187. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43188. /**
  43189. * Resets the reference space to the one started the session
  43190. */
  43191. resetReferenceSpace(): void;
  43192. /**
  43193. * Starts rendering to the xr layer
  43194. */
  43195. runXRRenderLoop(): void;
  43196. /**
  43197. * Sets the reference space on the xr session
  43198. * @param referenceSpaceType space to set
  43199. * @returns a promise that will resolve once the reference space has been set
  43200. */
  43201. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43202. /**
  43203. * Updates the render state of the session
  43204. * @param state state to set
  43205. * @returns a promise that resolves once the render state has been updated
  43206. */
  43207. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43208. /**
  43209. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43210. * @param sessionMode defines the session to test
  43211. * @returns a promise with boolean as final value
  43212. */
  43213. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43214. private _createRenderTargetTexture;
  43215. }
  43216. }
  43217. declare module BABYLON {
  43218. /**
  43219. * WebXR Camera which holds the views for the xrSession
  43220. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43221. */
  43222. export class WebXRCamera extends FreeCamera {
  43223. private _xrSessionManager;
  43224. private _firstFrame;
  43225. private _referenceQuaternion;
  43226. private _referencedPosition;
  43227. private _xrInvPositionCache;
  43228. private _xrInvQuaternionCache;
  43229. /**
  43230. * Should position compensation execute on first frame.
  43231. * This is used when copying the position from a native (non XR) camera
  43232. */
  43233. compensateOnFirstFrame: boolean;
  43234. /**
  43235. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43236. * @param name the name of the camera
  43237. * @param scene the scene to add the camera to
  43238. * @param _xrSessionManager a constructed xr session manager
  43239. */
  43240. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43241. /**
  43242. * Return the user's height, unrelated to the current ground.
  43243. * This will be the y position of this camera, when ground level is 0.
  43244. */
  43245. get realWorldHeight(): number;
  43246. /** @hidden */
  43247. _updateForDualEyeDebugging(): void;
  43248. /**
  43249. * Sets this camera's transformation based on a non-vr camera
  43250. * @param otherCamera the non-vr camera to copy the transformation from
  43251. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43252. */
  43253. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43254. /**
  43255. * Gets the current instance class name ("WebXRCamera").
  43256. * @returns the class name
  43257. */
  43258. getClassName(): string;
  43259. private _updateFromXRSession;
  43260. private _updateNumberOfRigCameras;
  43261. private _updateReferenceSpace;
  43262. private _updateReferenceSpaceOffset;
  43263. }
  43264. }
  43265. declare module BABYLON {
  43266. /**
  43267. * Defining the interface required for a (webxr) feature
  43268. */
  43269. export interface IWebXRFeature extends IDisposable {
  43270. /**
  43271. * Is this feature attached
  43272. */
  43273. attached: boolean;
  43274. /**
  43275. * Should auto-attach be disabled?
  43276. */
  43277. disableAutoAttach: boolean;
  43278. /**
  43279. * Attach the feature to the session
  43280. * Will usually be called by the features manager
  43281. *
  43282. * @param force should attachment be forced (even when already attached)
  43283. * @returns true if successful.
  43284. */
  43285. attach(force?: boolean): boolean;
  43286. /**
  43287. * Detach the feature from the session
  43288. * Will usually be called by the features manager
  43289. *
  43290. * @returns true if successful.
  43291. */
  43292. detach(): boolean;
  43293. }
  43294. /**
  43295. * A list of the currently available features without referencing them
  43296. */
  43297. export class WebXRFeatureName {
  43298. /**
  43299. * The name of the anchor system feature
  43300. */
  43301. static ANCHOR_SYSTEM: string;
  43302. /**
  43303. * The name of the background remover feature
  43304. */
  43305. static BACKGROUND_REMOVER: string;
  43306. /**
  43307. * The name of the hit test feature
  43308. */
  43309. static HIT_TEST: string;
  43310. /**
  43311. * physics impostors for xr controllers feature
  43312. */
  43313. static PHYSICS_CONTROLLERS: string;
  43314. /**
  43315. * The name of the plane detection feature
  43316. */
  43317. static PLANE_DETECTION: string;
  43318. /**
  43319. * The name of the pointer selection feature
  43320. */
  43321. static POINTER_SELECTION: string;
  43322. /**
  43323. * The name of the teleportation feature
  43324. */
  43325. static TELEPORTATION: string;
  43326. }
  43327. /**
  43328. * Defining the constructor of a feature. Used to register the modules.
  43329. */
  43330. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43331. /**
  43332. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43333. * It is mainly used in AR sessions.
  43334. *
  43335. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43336. */
  43337. export class WebXRFeaturesManager implements IDisposable {
  43338. private _xrSessionManager;
  43339. private static readonly _AvailableFeatures;
  43340. private _features;
  43341. /**
  43342. * constructs a new features manages.
  43343. *
  43344. * @param _xrSessionManager an instance of WebXRSessionManager
  43345. */
  43346. constructor(_xrSessionManager: WebXRSessionManager);
  43347. /**
  43348. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43349. * Mainly used internally.
  43350. *
  43351. * @param featureName the name of the feature to register
  43352. * @param constructorFunction the function used to construct the module
  43353. * @param version the (babylon) version of the module
  43354. * @param stable is that a stable version of this module
  43355. */
  43356. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43357. /**
  43358. * Returns a constructor of a specific feature.
  43359. *
  43360. * @param featureName the name of the feature to construct
  43361. * @param version the version of the feature to load
  43362. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43363. * @param options optional options provided to the module.
  43364. * @returns a function that, when called, will return a new instance of this feature
  43365. */
  43366. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43367. /**
  43368. * Can be used to return the list of features currently registered
  43369. *
  43370. * @returns an Array of available features
  43371. */
  43372. static GetAvailableFeatures(): string[];
  43373. /**
  43374. * Gets the versions available for a specific feature
  43375. * @param featureName the name of the feature
  43376. * @returns an array with the available versions
  43377. */
  43378. static GetAvailableVersions(featureName: string): string[];
  43379. /**
  43380. * Return the latest unstable version of this feature
  43381. * @param featureName the name of the feature to search
  43382. * @returns the version number. if not found will return -1
  43383. */
  43384. static GetLatestVersionOfFeature(featureName: string): number;
  43385. /**
  43386. * Return the latest stable version of this feature
  43387. * @param featureName the name of the feature to search
  43388. * @returns the version number. if not found will return -1
  43389. */
  43390. static GetStableVersionOfFeature(featureName: string): number;
  43391. /**
  43392. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43393. * Can be used during a session to start a feature
  43394. * @param featureName the name of feature to attach
  43395. */
  43396. attachFeature(featureName: string): void;
  43397. /**
  43398. * Can be used inside a session or when the session ends to detach a specific feature
  43399. * @param featureName the name of the feature to detach
  43400. */
  43401. detachFeature(featureName: string): void;
  43402. /**
  43403. * Used to disable an already-enabled feature
  43404. * The feature will be disposed and will be recreated once enabled.
  43405. * @param featureName the feature to disable
  43406. * @returns true if disable was successful
  43407. */
  43408. disableFeature(featureName: string | {
  43409. Name: string;
  43410. }): boolean;
  43411. /**
  43412. * dispose this features manager
  43413. */
  43414. dispose(): void;
  43415. /**
  43416. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43417. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  43418. *
  43419. * @param featureName the name of the feature to load or the class of the feature
  43420. * @param version optional version to load. if not provided the latest version will be enabled
  43421. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43422. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43423. * @returns a new constructed feature or throws an error if feature not found.
  43424. */
  43425. enableFeature(featureName: string | {
  43426. Name: string;
  43427. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43428. /**
  43429. * get the implementation of an enabled feature.
  43430. * @param featureName the name of the feature to load
  43431. * @returns the feature class, if found
  43432. */
  43433. getEnabledFeature(featureName: string): IWebXRFeature;
  43434. /**
  43435. * Get the list of enabled features
  43436. * @returns an array of enabled features
  43437. */
  43438. getEnabledFeatures(): string[];
  43439. }
  43440. }
  43441. declare module BABYLON {
  43442. /**
  43443. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43444. * @see https://doc.babylonjs.com/how_to/webxr
  43445. */
  43446. export class WebXRExperienceHelper implements IDisposable {
  43447. private scene;
  43448. private _nonVRCamera;
  43449. private _originalSceneAutoClear;
  43450. private _supported;
  43451. /**
  43452. * Camera used to render xr content
  43453. */
  43454. camera: WebXRCamera;
  43455. /** A features manager for this xr session */
  43456. featuresManager: WebXRFeaturesManager;
  43457. /**
  43458. * Observers registered here will be triggered after the camera's initial transformation is set
  43459. * This can be used to set a different ground level or an extra rotation.
  43460. *
  43461. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43462. * to the position set after this observable is done executing.
  43463. */
  43464. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43465. /**
  43466. * Fires when the state of the experience helper has changed
  43467. */
  43468. onStateChangedObservable: Observable<WebXRState>;
  43469. /** Session manager used to keep track of xr session */
  43470. sessionManager: WebXRSessionManager;
  43471. /**
  43472. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43473. */
  43474. state: WebXRState;
  43475. /**
  43476. * Creates a WebXRExperienceHelper
  43477. * @param scene The scene the helper should be created in
  43478. */
  43479. private constructor();
  43480. /**
  43481. * Creates the experience helper
  43482. * @param scene the scene to attach the experience helper to
  43483. * @returns a promise for the experience helper
  43484. */
  43485. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43486. /**
  43487. * Disposes of the experience helper
  43488. */
  43489. dispose(): void;
  43490. /**
  43491. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43492. * @param sessionMode options for the XR session
  43493. * @param referenceSpaceType frame of reference of the XR session
  43494. * @param renderTarget the output canvas that will be used to enter XR mode
  43495. * @returns promise that resolves after xr mode has entered
  43496. */
  43497. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43498. /**
  43499. * Exits XR mode and returns the scene to its original state
  43500. * @returns promise that resolves after xr mode has exited
  43501. */
  43502. exitXRAsync(): Promise<void>;
  43503. private _nonXRToXRCamera;
  43504. private _setState;
  43505. }
  43506. }
  43507. declare module BABYLON {
  43508. /**
  43509. * X-Y values for axes in WebXR
  43510. */
  43511. export interface IWebXRMotionControllerAxesValue {
  43512. /**
  43513. * The value of the x axis
  43514. */
  43515. x: number;
  43516. /**
  43517. * The value of the y-axis
  43518. */
  43519. y: number;
  43520. }
  43521. /**
  43522. * changed / previous values for the values of this component
  43523. */
  43524. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43525. /**
  43526. * current (this frame) value
  43527. */
  43528. current: T;
  43529. /**
  43530. * previous (last change) value
  43531. */
  43532. previous: T;
  43533. }
  43534. /**
  43535. * Represents changes in the component between current frame and last values recorded
  43536. */
  43537. export interface IWebXRMotionControllerComponentChanges {
  43538. /**
  43539. * will be populated with previous and current values if axes changed
  43540. */
  43541. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43542. /**
  43543. * will be populated with previous and current values if pressed changed
  43544. */
  43545. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43546. /**
  43547. * will be populated with previous and current values if touched changed
  43548. */
  43549. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43550. /**
  43551. * will be populated with previous and current values if value changed
  43552. */
  43553. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43554. }
  43555. /**
  43556. * This class represents a single component (for example button or thumbstick) of a motion controller
  43557. */
  43558. export class WebXRControllerComponent implements IDisposable {
  43559. /**
  43560. * the id of this component
  43561. */
  43562. id: string;
  43563. /**
  43564. * the type of the component
  43565. */
  43566. type: MotionControllerComponentType;
  43567. private _buttonIndex;
  43568. private _axesIndices;
  43569. private _axes;
  43570. private _changes;
  43571. private _currentValue;
  43572. private _hasChanges;
  43573. private _pressed;
  43574. private _touched;
  43575. /**
  43576. * button component type
  43577. */
  43578. static BUTTON_TYPE: MotionControllerComponentType;
  43579. /**
  43580. * squeeze component type
  43581. */
  43582. static SQUEEZE_TYPE: MotionControllerComponentType;
  43583. /**
  43584. * Thumbstick component type
  43585. */
  43586. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43587. /**
  43588. * Touchpad component type
  43589. */
  43590. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43591. /**
  43592. * trigger component type
  43593. */
  43594. static TRIGGER_TYPE: MotionControllerComponentType;
  43595. /**
  43596. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43597. * the axes data changes
  43598. */
  43599. onAxisValueChangedObservable: Observable<{
  43600. x: number;
  43601. y: number;
  43602. }>;
  43603. /**
  43604. * Observers registered here will be triggered when the state of a button changes
  43605. * State change is either pressed / touched / value
  43606. */
  43607. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43608. /**
  43609. * Creates a new component for a motion controller.
  43610. * It is created by the motion controller itself
  43611. *
  43612. * @param id the id of this component
  43613. * @param type the type of the component
  43614. * @param _buttonIndex index in the buttons array of the gamepad
  43615. * @param _axesIndices indices of the values in the axes array of the gamepad
  43616. */
  43617. constructor(
  43618. /**
  43619. * the id of this component
  43620. */
  43621. id: string,
  43622. /**
  43623. * the type of the component
  43624. */
  43625. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43626. /**
  43627. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43628. */
  43629. get axes(): IWebXRMotionControllerAxesValue;
  43630. /**
  43631. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43632. */
  43633. get changes(): IWebXRMotionControllerComponentChanges;
  43634. /**
  43635. * Return whether or not the component changed the last frame
  43636. */
  43637. get hasChanges(): boolean;
  43638. /**
  43639. * is the button currently pressed
  43640. */
  43641. get pressed(): boolean;
  43642. /**
  43643. * is the button currently touched
  43644. */
  43645. get touched(): boolean;
  43646. /**
  43647. * Get the current value of this component
  43648. */
  43649. get value(): number;
  43650. /**
  43651. * Dispose this component
  43652. */
  43653. dispose(): void;
  43654. /**
  43655. * Are there axes correlating to this component
  43656. * @return true is axes data is available
  43657. */
  43658. isAxes(): boolean;
  43659. /**
  43660. * Is this component a button (hence - pressable)
  43661. * @returns true if can be pressed
  43662. */
  43663. isButton(): boolean;
  43664. /**
  43665. * update this component using the gamepad object it is in. Called on every frame
  43666. * @param nativeController the native gamepad controller object
  43667. */
  43668. update(nativeController: IMinimalMotionControllerObject): void;
  43669. }
  43670. }
  43671. declare module BABYLON {
  43672. /**
  43673. * Class used to represent data loading progression
  43674. */
  43675. export class SceneLoaderProgressEvent {
  43676. /** defines if data length to load can be evaluated */
  43677. readonly lengthComputable: boolean;
  43678. /** defines the loaded data length */
  43679. readonly loaded: number;
  43680. /** defines the data length to load */
  43681. readonly total: number;
  43682. /**
  43683. * Create a new progress event
  43684. * @param lengthComputable defines if data length to load can be evaluated
  43685. * @param loaded defines the loaded data length
  43686. * @param total defines the data length to load
  43687. */
  43688. constructor(
  43689. /** defines if data length to load can be evaluated */
  43690. lengthComputable: boolean,
  43691. /** defines the loaded data length */
  43692. loaded: number,
  43693. /** defines the data length to load */
  43694. total: number);
  43695. /**
  43696. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43697. * @param event defines the source event
  43698. * @returns a new SceneLoaderProgressEvent
  43699. */
  43700. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43701. }
  43702. /**
  43703. * Interface used by SceneLoader plugins to define supported file extensions
  43704. */
  43705. export interface ISceneLoaderPluginExtensions {
  43706. /**
  43707. * Defines the list of supported extensions
  43708. */
  43709. [extension: string]: {
  43710. isBinary: boolean;
  43711. };
  43712. }
  43713. /**
  43714. * Interface used by SceneLoader plugin factory
  43715. */
  43716. export interface ISceneLoaderPluginFactory {
  43717. /**
  43718. * Defines the name of the factory
  43719. */
  43720. name: string;
  43721. /**
  43722. * Function called to create a new plugin
  43723. * @return the new plugin
  43724. */
  43725. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43726. /**
  43727. * The callback that returns true if the data can be directly loaded.
  43728. * @param data string containing the file data
  43729. * @returns if the data can be loaded directly
  43730. */
  43731. canDirectLoad?(data: string): boolean;
  43732. }
  43733. /**
  43734. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43735. */
  43736. export interface ISceneLoaderPluginBase {
  43737. /**
  43738. * The friendly name of this plugin.
  43739. */
  43740. name: string;
  43741. /**
  43742. * The file extensions supported by this plugin.
  43743. */
  43744. extensions: string | ISceneLoaderPluginExtensions;
  43745. /**
  43746. * The callback called when loading from a url.
  43747. * @param scene scene loading this url
  43748. * @param url url to load
  43749. * @param onSuccess callback called when the file successfully loads
  43750. * @param onProgress callback called while file is loading (if the server supports this mode)
  43751. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43752. * @param onError callback called when the file fails to load
  43753. * @returns a file request object
  43754. */
  43755. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43756. /**
  43757. * The callback called when loading from a file object.
  43758. * @param scene scene loading this file
  43759. * @param file defines the file to load
  43760. * @param onSuccess defines the callback to call when data is loaded
  43761. * @param onProgress defines the callback to call during loading process
  43762. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43763. * @param onError defines the callback to call when an error occurs
  43764. * @returns a file request object
  43765. */
  43766. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43767. /**
  43768. * The callback that returns true if the data can be directly loaded.
  43769. * @param data string containing the file data
  43770. * @returns if the data can be loaded directly
  43771. */
  43772. canDirectLoad?(data: string): boolean;
  43773. /**
  43774. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43775. * @param scene scene loading this data
  43776. * @param data string containing the data
  43777. * @returns data to pass to the plugin
  43778. */
  43779. directLoad?(scene: Scene, data: string): any;
  43780. /**
  43781. * The callback that allows custom handling of the root url based on the response url.
  43782. * @param rootUrl the original root url
  43783. * @param responseURL the response url if available
  43784. * @returns the new root url
  43785. */
  43786. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43787. }
  43788. /**
  43789. * Interface used to define a SceneLoader plugin
  43790. */
  43791. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43792. /**
  43793. * Import meshes into a scene.
  43794. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43795. * @param scene The scene to import into
  43796. * @param data The data to import
  43797. * @param rootUrl The root url for scene and resources
  43798. * @param meshes The meshes array to import into
  43799. * @param particleSystems The particle systems array to import into
  43800. * @param skeletons The skeletons array to import into
  43801. * @param onError The callback when import fails
  43802. * @returns True if successful or false otherwise
  43803. */
  43804. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43805. /**
  43806. * Load into a scene.
  43807. * @param scene The scene to load into
  43808. * @param data The data to import
  43809. * @param rootUrl The root url for scene and resources
  43810. * @param onError The callback when import fails
  43811. * @returns True if successful or false otherwise
  43812. */
  43813. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43814. /**
  43815. * Load into an asset container.
  43816. * @param scene The scene to load into
  43817. * @param data The data to import
  43818. * @param rootUrl The root url for scene and resources
  43819. * @param onError The callback when import fails
  43820. * @returns The loaded asset container
  43821. */
  43822. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43823. }
  43824. /**
  43825. * Interface used to define an async SceneLoader plugin
  43826. */
  43827. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43828. /**
  43829. * Import meshes into a scene.
  43830. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43831. * @param scene The scene to import into
  43832. * @param data The data to import
  43833. * @param rootUrl The root url for scene and resources
  43834. * @param onProgress The callback when the load progresses
  43835. * @param fileName Defines the name of the file to load
  43836. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43837. */
  43838. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43839. meshes: AbstractMesh[];
  43840. particleSystems: IParticleSystem[];
  43841. skeletons: Skeleton[];
  43842. animationGroups: AnimationGroup[];
  43843. }>;
  43844. /**
  43845. * Load into a scene.
  43846. * @param scene The scene to load into
  43847. * @param data The data to import
  43848. * @param rootUrl The root url for scene and resources
  43849. * @param onProgress The callback when the load progresses
  43850. * @param fileName Defines the name of the file to load
  43851. * @returns Nothing
  43852. */
  43853. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43854. /**
  43855. * Load into an asset container.
  43856. * @param scene The scene to load into
  43857. * @param data The data to import
  43858. * @param rootUrl The root url for scene and resources
  43859. * @param onProgress The callback when the load progresses
  43860. * @param fileName Defines the name of the file to load
  43861. * @returns The loaded asset container
  43862. */
  43863. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43864. }
  43865. /**
  43866. * Mode that determines how to handle old animation groups before loading new ones.
  43867. */
  43868. export enum SceneLoaderAnimationGroupLoadingMode {
  43869. /**
  43870. * Reset all old animations to initial state then dispose them.
  43871. */
  43872. Clean = 0,
  43873. /**
  43874. * Stop all old animations.
  43875. */
  43876. Stop = 1,
  43877. /**
  43878. * Restart old animations from first frame.
  43879. */
  43880. Sync = 2,
  43881. /**
  43882. * Old animations remains untouched.
  43883. */
  43884. NoSync = 3
  43885. }
  43886. /**
  43887. * Class used to load scene from various file formats using registered plugins
  43888. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43889. */
  43890. export class SceneLoader {
  43891. /**
  43892. * No logging while loading
  43893. */
  43894. static readonly NO_LOGGING: number;
  43895. /**
  43896. * Minimal logging while loading
  43897. */
  43898. static readonly MINIMAL_LOGGING: number;
  43899. /**
  43900. * Summary logging while loading
  43901. */
  43902. static readonly SUMMARY_LOGGING: number;
  43903. /**
  43904. * Detailled logging while loading
  43905. */
  43906. static readonly DETAILED_LOGGING: number;
  43907. /**
  43908. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43909. */
  43910. static get ForceFullSceneLoadingForIncremental(): boolean;
  43911. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43912. /**
  43913. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43914. */
  43915. static get ShowLoadingScreen(): boolean;
  43916. static set ShowLoadingScreen(value: boolean);
  43917. /**
  43918. * Defines the current logging level (while loading the scene)
  43919. * @ignorenaming
  43920. */
  43921. static get loggingLevel(): number;
  43922. static set loggingLevel(value: number);
  43923. /**
  43924. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43925. */
  43926. static get CleanBoneMatrixWeights(): boolean;
  43927. static set CleanBoneMatrixWeights(value: boolean);
  43928. /**
  43929. * Event raised when a plugin is used to load a scene
  43930. */
  43931. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43932. private static _registeredPlugins;
  43933. private static _getDefaultPlugin;
  43934. private static _getPluginForExtension;
  43935. private static _getPluginForDirectLoad;
  43936. private static _getPluginForFilename;
  43937. private static _getDirectLoad;
  43938. private static _loadData;
  43939. private static _getFileInfo;
  43940. /**
  43941. * Gets a plugin that can load the given extension
  43942. * @param extension defines the extension to load
  43943. * @returns a plugin or null if none works
  43944. */
  43945. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43946. /**
  43947. * Gets a boolean indicating that the given extension can be loaded
  43948. * @param extension defines the extension to load
  43949. * @returns true if the extension is supported
  43950. */
  43951. static IsPluginForExtensionAvailable(extension: string): boolean;
  43952. /**
  43953. * Adds a new plugin to the list of registered plugins
  43954. * @param plugin defines the plugin to add
  43955. */
  43956. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43957. /**
  43958. * Import meshes into a scene
  43959. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43960. * @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)
  43961. * @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)
  43962. * @param scene the instance of BABYLON.Scene to append to
  43963. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43964. * @param onProgress a callback with a progress event for each file being loaded
  43965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43966. * @param pluginExtension the extension used to determine the plugin
  43967. * @returns The loaded plugin
  43968. */
  43969. 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>;
  43970. /**
  43971. * Import meshes into a scene
  43972. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43973. * @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)
  43974. * @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)
  43975. * @param scene the instance of BABYLON.Scene to append to
  43976. * @param onProgress a callback with a progress event for each file being loaded
  43977. * @param pluginExtension the extension used to determine the plugin
  43978. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43979. */
  43980. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43981. meshes: AbstractMesh[];
  43982. particleSystems: IParticleSystem[];
  43983. skeletons: Skeleton[];
  43984. animationGroups: AnimationGroup[];
  43985. }>;
  43986. /**
  43987. * Load a scene
  43988. * @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)
  43989. * @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)
  43990. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43991. * @param onSuccess a callback with the scene when import succeeds
  43992. * @param onProgress a callback with a progress event for each file being loaded
  43993. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43994. * @param pluginExtension the extension used to determine the plugin
  43995. * @returns The loaded plugin
  43996. */
  43997. 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>;
  43998. /**
  43999. * Load a scene
  44000. * @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)
  44001. * @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)
  44002. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44003. * @param onProgress a callback with a progress event for each file being loaded
  44004. * @param pluginExtension the extension used to determine the plugin
  44005. * @returns The loaded scene
  44006. */
  44007. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44008. /**
  44009. * Append a scene
  44010. * @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)
  44011. * @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)
  44012. * @param scene is the instance of BABYLON.Scene to append to
  44013. * @param onSuccess a callback with the scene when import succeeds
  44014. * @param onProgress a callback with a progress event for each file being loaded
  44015. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44016. * @param pluginExtension the extension used to determine the plugin
  44017. * @returns The loaded plugin
  44018. */
  44019. 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>;
  44020. /**
  44021. * Append a scene
  44022. * @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)
  44023. * @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)
  44024. * @param scene is the instance of BABYLON.Scene to append to
  44025. * @param onProgress a callback with a progress event for each file being loaded
  44026. * @param pluginExtension the extension used to determine the plugin
  44027. * @returns The given scene
  44028. */
  44029. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44030. /**
  44031. * Load a scene into an asset container
  44032. * @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)
  44033. * @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)
  44034. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44035. * @param onSuccess a callback with the scene when import succeeds
  44036. * @param onProgress a callback with a progress event for each file being loaded
  44037. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44038. * @param pluginExtension the extension used to determine the plugin
  44039. * @returns The loaded plugin
  44040. */
  44041. 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>;
  44042. /**
  44043. * Load a scene into an asset container
  44044. * @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)
  44045. * @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)
  44046. * @param scene is the instance of Scene to append to
  44047. * @param onProgress a callback with a progress event for each file being loaded
  44048. * @param pluginExtension the extension used to determine the plugin
  44049. * @returns The loaded asset container
  44050. */
  44051. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44052. /**
  44053. * Import animations from a file into a scene
  44054. * @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)
  44055. * @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)
  44056. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44057. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44058. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44059. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44060. * @param onSuccess a callback with the scene when import succeeds
  44061. * @param onProgress a callback with a progress event for each file being loaded
  44062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44063. */
  44064. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44065. /**
  44066. * Import animations from a file into a scene
  44067. * @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)
  44068. * @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)
  44069. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44070. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44071. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44072. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44073. * @param onSuccess a callback with the scene when import succeeds
  44074. * @param onProgress a callback with a progress event for each file being loaded
  44075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44076. * @returns the updated scene with imported animations
  44077. */
  44078. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44079. }
  44080. }
  44081. declare module BABYLON {
  44082. /**
  44083. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44084. */
  44085. export type MotionControllerHandness = "none" | "left" | "right";
  44086. /**
  44087. * The type of components available in motion controllers.
  44088. * This is not the name of the component.
  44089. */
  44090. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44091. /**
  44092. * The state of a controller component
  44093. */
  44094. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44095. /**
  44096. * The schema of motion controller layout.
  44097. * No object will be initialized using this interface
  44098. * This is used just to define the profile.
  44099. */
  44100. export interface IMotionControllerLayout {
  44101. /**
  44102. * Path to load the assets. Usually relative to the base path
  44103. */
  44104. assetPath: string;
  44105. /**
  44106. * Available components (unsorted)
  44107. */
  44108. components: {
  44109. /**
  44110. * A map of component Ids
  44111. */
  44112. [componentId: string]: {
  44113. /**
  44114. * The type of input the component outputs
  44115. */
  44116. type: MotionControllerComponentType;
  44117. /**
  44118. * The indices of this component in the gamepad object
  44119. */
  44120. gamepadIndices: {
  44121. /**
  44122. * Index of button
  44123. */
  44124. button?: number;
  44125. /**
  44126. * If available, index of x-axis
  44127. */
  44128. xAxis?: number;
  44129. /**
  44130. * If available, index of y-axis
  44131. */
  44132. yAxis?: number;
  44133. };
  44134. /**
  44135. * The mesh's root node name
  44136. */
  44137. rootNodeName: string;
  44138. /**
  44139. * Animation definitions for this model
  44140. */
  44141. visualResponses: {
  44142. [stateKey: string]: {
  44143. /**
  44144. * What property will be animated
  44145. */
  44146. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44147. /**
  44148. * What states influence this visual response
  44149. */
  44150. states: MotionControllerComponentStateType[];
  44151. /**
  44152. * Type of animation - movement or visibility
  44153. */
  44154. valueNodeProperty: "transform" | "visibility";
  44155. /**
  44156. * Base node name to move. Its position will be calculated according to the min and max nodes
  44157. */
  44158. valueNodeName?: string;
  44159. /**
  44160. * Minimum movement node
  44161. */
  44162. minNodeName?: string;
  44163. /**
  44164. * Max movement node
  44165. */
  44166. maxNodeName?: string;
  44167. };
  44168. };
  44169. /**
  44170. * If touch enabled, what is the name of node to display user feedback
  44171. */
  44172. touchPointNodeName?: string;
  44173. };
  44174. };
  44175. /**
  44176. * Is it xr standard mapping or not
  44177. */
  44178. gamepadMapping: "" | "xr-standard";
  44179. /**
  44180. * Base root node of this entire model
  44181. */
  44182. rootNodeName: string;
  44183. /**
  44184. * Defines the main button component id
  44185. */
  44186. selectComponentId: string;
  44187. }
  44188. /**
  44189. * A definition for the layout map in the input profile
  44190. */
  44191. export interface IMotionControllerLayoutMap {
  44192. /**
  44193. * Layouts with handness type as a key
  44194. */
  44195. [handness: string]: IMotionControllerLayout;
  44196. }
  44197. /**
  44198. * The XR Input profile schema
  44199. * Profiles can be found here:
  44200. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44201. */
  44202. export interface IMotionControllerProfile {
  44203. /**
  44204. * fallback profiles for this profileId
  44205. */
  44206. fallbackProfileIds: string[];
  44207. /**
  44208. * The layout map, with handness as key
  44209. */
  44210. layouts: IMotionControllerLayoutMap;
  44211. /**
  44212. * The id of this profile
  44213. * correlates to the profile(s) in the xrInput.profiles array
  44214. */
  44215. profileId: string;
  44216. }
  44217. /**
  44218. * A helper-interface for the 3 meshes needed for controller button animation
  44219. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44220. */
  44221. export interface IMotionControllerButtonMeshMap {
  44222. /**
  44223. * the mesh that defines the pressed value mesh position.
  44224. * This is used to find the max-position of this button
  44225. */
  44226. pressedMesh: AbstractMesh;
  44227. /**
  44228. * the mesh that defines the unpressed value mesh position.
  44229. * This is used to find the min (or initial) position of this button
  44230. */
  44231. unpressedMesh: AbstractMesh;
  44232. /**
  44233. * The mesh that will be changed when value changes
  44234. */
  44235. valueMesh: AbstractMesh;
  44236. }
  44237. /**
  44238. * A helper-interface for the 3 meshes needed for controller axis animation.
  44239. * This will be expanded when touchpad animations are fully supported
  44240. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44241. */
  44242. export interface IMotionControllerMeshMap {
  44243. /**
  44244. * the mesh that defines the maximum value mesh position.
  44245. */
  44246. maxMesh?: AbstractMesh;
  44247. /**
  44248. * the mesh that defines the minimum value mesh position.
  44249. */
  44250. minMesh?: AbstractMesh;
  44251. /**
  44252. * The mesh that will be changed when axis value changes
  44253. */
  44254. valueMesh: AbstractMesh;
  44255. }
  44256. /**
  44257. * The elements needed for change-detection of the gamepad objects in motion controllers
  44258. */
  44259. export interface IMinimalMotionControllerObject {
  44260. /**
  44261. * Available axes of this controller
  44262. */
  44263. axes: number[];
  44264. /**
  44265. * An array of available buttons
  44266. */
  44267. buttons: Array<{
  44268. /**
  44269. * Value of the button/trigger
  44270. */
  44271. value: number;
  44272. /**
  44273. * If the button/trigger is currently touched
  44274. */
  44275. touched: boolean;
  44276. /**
  44277. * If the button/trigger is currently pressed
  44278. */
  44279. pressed: boolean;
  44280. }>;
  44281. }
  44282. /**
  44283. * An Abstract Motion controller
  44284. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44285. * Each component has an observable to check for changes in value and state
  44286. */
  44287. export abstract class WebXRAbstractMotionController implements IDisposable {
  44288. protected scene: Scene;
  44289. protected layout: IMotionControllerLayout;
  44290. /**
  44291. * The gamepad object correlating to this controller
  44292. */
  44293. gamepadObject: IMinimalMotionControllerObject;
  44294. /**
  44295. * handness (left/right/none) of this controller
  44296. */
  44297. handness: MotionControllerHandness;
  44298. private _initComponent;
  44299. private _modelReady;
  44300. /**
  44301. * A map of components (WebXRControllerComponent) in this motion controller
  44302. * Components have a ComponentType and can also have both button and axis definitions
  44303. */
  44304. readonly components: {
  44305. [id: string]: WebXRControllerComponent;
  44306. };
  44307. /**
  44308. * Disable the model's animation. Can be set at any time.
  44309. */
  44310. disableAnimation: boolean;
  44311. /**
  44312. * Observers registered here will be triggered when the model of this controller is done loading
  44313. */
  44314. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44315. /**
  44316. * The profile id of this motion controller
  44317. */
  44318. abstract profileId: string;
  44319. /**
  44320. * The root mesh of the model. It is null if the model was not yet initialized
  44321. */
  44322. rootMesh: Nullable<AbstractMesh>;
  44323. /**
  44324. * constructs a new abstract motion controller
  44325. * @param scene the scene to which the model of the controller will be added
  44326. * @param layout The profile layout to load
  44327. * @param gamepadObject The gamepad object correlating to this controller
  44328. * @param handness handness (left/right/none) of this controller
  44329. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44330. */
  44331. constructor(scene: Scene, layout: IMotionControllerLayout,
  44332. /**
  44333. * The gamepad object correlating to this controller
  44334. */
  44335. gamepadObject: IMinimalMotionControllerObject,
  44336. /**
  44337. * handness (left/right/none) of this controller
  44338. */
  44339. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44340. /**
  44341. * Dispose this controller, the model mesh and all its components
  44342. */
  44343. dispose(): void;
  44344. /**
  44345. * Returns all components of specific type
  44346. * @param type the type to search for
  44347. * @return an array of components with this type
  44348. */
  44349. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44350. /**
  44351. * get a component based an its component id as defined in layout.components
  44352. * @param id the id of the component
  44353. * @returns the component correlates to the id or undefined if not found
  44354. */
  44355. getComponent(id: string): WebXRControllerComponent;
  44356. /**
  44357. * Get the list of components available in this motion controller
  44358. * @returns an array of strings correlating to available components
  44359. */
  44360. getComponentIds(): string[];
  44361. /**
  44362. * Get the first component of specific type
  44363. * @param type type of component to find
  44364. * @return a controller component or null if not found
  44365. */
  44366. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44367. /**
  44368. * Get the main (Select) component of this controller as defined in the layout
  44369. * @returns the main component of this controller
  44370. */
  44371. getMainComponent(): WebXRControllerComponent;
  44372. /**
  44373. * Loads the model correlating to this controller
  44374. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44375. * @returns A promise fulfilled with the result of the model loading
  44376. */
  44377. loadModel(): Promise<boolean>;
  44378. /**
  44379. * Update this model using the current XRFrame
  44380. * @param xrFrame the current xr frame to use and update the model
  44381. */
  44382. updateFromXRFrame(xrFrame: XRFrame): void;
  44383. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44384. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44385. /**
  44386. * Moves the axis on the controller mesh based on its current state
  44387. * @param axis the index of the axis
  44388. * @param axisValue the value of the axis which determines the meshes new position
  44389. * @hidden
  44390. */
  44391. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44392. /**
  44393. * Update the model itself with the current frame data
  44394. * @param xrFrame the frame to use for updating the model mesh
  44395. */
  44396. protected updateModel(xrFrame: XRFrame): void;
  44397. /**
  44398. * Get the filename and path for this controller's model
  44399. * @returns a map of filename and path
  44400. */
  44401. protected abstract _getFilenameAndPath(): {
  44402. filename: string;
  44403. path: string;
  44404. };
  44405. /**
  44406. * This function is called before the mesh is loaded. It checks for loading constraints.
  44407. * For example, this function can check if the GLB loader is available
  44408. * If this function returns false, the generic controller will be loaded instead
  44409. * @returns Is the client ready to load the mesh
  44410. */
  44411. protected abstract _getModelLoadingConstraints(): boolean;
  44412. /**
  44413. * This function will be called after the model was successfully loaded and can be used
  44414. * for mesh transformations before it is available for the user
  44415. * @param meshes the loaded meshes
  44416. */
  44417. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44418. /**
  44419. * Set the root mesh for this controller. Important for the WebXR controller class
  44420. * @param meshes the loaded meshes
  44421. */
  44422. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44423. /**
  44424. * A function executed each frame that updates the mesh (if needed)
  44425. * @param xrFrame the current xrFrame
  44426. */
  44427. protected abstract _updateModel(xrFrame: XRFrame): void;
  44428. private _getGenericFilenameAndPath;
  44429. private _getGenericParentMesh;
  44430. }
  44431. }
  44432. declare module BABYLON {
  44433. /**
  44434. * A generic trigger-only motion controller for WebXR
  44435. */
  44436. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44437. /**
  44438. * Static version of the profile id of this controller
  44439. */
  44440. static ProfileId: string;
  44441. profileId: string;
  44442. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44443. protected _getFilenameAndPath(): {
  44444. filename: string;
  44445. path: string;
  44446. };
  44447. protected _getModelLoadingConstraints(): boolean;
  44448. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44449. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44450. protected _updateModel(): void;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * Class containing static functions to help procedurally build meshes
  44456. */
  44457. export class SphereBuilder {
  44458. /**
  44459. * Creates a sphere mesh
  44460. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44461. * * 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`)
  44462. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44463. * * 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
  44464. * * 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)
  44465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44466. * * 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
  44467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44468. * @param name defines the name of the mesh
  44469. * @param options defines the options used to create the mesh
  44470. * @param scene defines the hosting scene
  44471. * @returns the sphere mesh
  44472. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44473. */
  44474. static CreateSphere(name: string, options: {
  44475. segments?: number;
  44476. diameter?: number;
  44477. diameterX?: number;
  44478. diameterY?: number;
  44479. diameterZ?: number;
  44480. arc?: number;
  44481. slice?: number;
  44482. sideOrientation?: number;
  44483. frontUVs?: Vector4;
  44484. backUVs?: Vector4;
  44485. updatable?: boolean;
  44486. }, scene?: Nullable<Scene>): Mesh;
  44487. }
  44488. }
  44489. declare module BABYLON {
  44490. /**
  44491. * A profiled motion controller has its profile loaded from an online repository.
  44492. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44493. */
  44494. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44495. private _repositoryUrl;
  44496. private _buttonMeshMapping;
  44497. private _touchDots;
  44498. /**
  44499. * The profile ID of this controller. Will be populated when the controller initializes.
  44500. */
  44501. profileId: string;
  44502. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44503. dispose(): void;
  44504. protected _getFilenameAndPath(): {
  44505. filename: string;
  44506. path: string;
  44507. };
  44508. protected _getModelLoadingConstraints(): boolean;
  44509. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44510. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44511. protected _updateModel(_xrFrame: XRFrame): void;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * A construction function type to create a new controller based on an xrInput object
  44517. */
  44518. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44519. /**
  44520. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44521. *
  44522. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44523. * it should be replaced with auto-loaded controllers.
  44524. *
  44525. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44526. */
  44527. export class WebXRMotionControllerManager {
  44528. private static _AvailableControllers;
  44529. private static _Fallbacks;
  44530. private static _ProfileLoadingPromises;
  44531. private static _ProfilesList;
  44532. /**
  44533. * The base URL of the online controller repository. Can be changed at any time.
  44534. */
  44535. static BaseRepositoryUrl: string;
  44536. /**
  44537. * Which repository gets priority - local or online
  44538. */
  44539. static PrioritizeOnlineRepository: boolean;
  44540. /**
  44541. * Use the online repository, or use only locally-defined controllers
  44542. */
  44543. static UseOnlineRepository: boolean;
  44544. /**
  44545. * Clear the cache used for profile loading and reload when requested again
  44546. */
  44547. static ClearProfilesCache(): void;
  44548. /**
  44549. * Register the default fallbacks.
  44550. * This function is called automatically when this file is imported.
  44551. */
  44552. static DefaultFallbacks(): void;
  44553. /**
  44554. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44555. * @param profileId the profile to which a fallback needs to be found
  44556. * @return an array with corresponding fallback profiles
  44557. */
  44558. static FindFallbackWithProfileId(profileId: string): string[];
  44559. /**
  44560. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44561. * The order of search:
  44562. *
  44563. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44564. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44565. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44566. * 4) return the generic trigger controller if none were found
  44567. *
  44568. * @param xrInput the xrInput to which a new controller is initialized
  44569. * @param scene the scene to which the model will be added
  44570. * @param forceProfile force a certain profile for this controller
  44571. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44572. */
  44573. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44574. /**
  44575. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44576. *
  44577. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44578. *
  44579. * @param type the profile type to register
  44580. * @param constructFunction the function to be called when loading this profile
  44581. */
  44582. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44583. /**
  44584. * Register a fallback to a specific profile.
  44585. * @param profileId the profileId that will receive the fallbacks
  44586. * @param fallbacks A list of fallback profiles
  44587. */
  44588. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44589. /**
  44590. * Will update the list of profiles available in the repository
  44591. * @return a promise that resolves to a map of profiles available online
  44592. */
  44593. static UpdateProfilesList(): Promise<{
  44594. [profile: string]: string;
  44595. }>;
  44596. private static _LoadProfileFromRepository;
  44597. private static _LoadProfilesFromAvailableControllers;
  44598. }
  44599. }
  44600. declare module BABYLON {
  44601. /**
  44602. * Configuration options for the WebXR controller creation
  44603. */
  44604. export interface IWebXRControllerOptions {
  44605. /**
  44606. * Should the controller mesh be animated when a user interacts with it
  44607. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44608. */
  44609. disableMotionControllerAnimation?: boolean;
  44610. /**
  44611. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44612. */
  44613. doNotLoadControllerMesh?: boolean;
  44614. /**
  44615. * Force a specific controller type for this controller.
  44616. * This can be used when creating your own profile or when testing different controllers
  44617. */
  44618. forceControllerProfile?: string;
  44619. }
  44620. /**
  44621. * Represents an XR controller
  44622. */
  44623. export class WebXRInputSource {
  44624. private _scene;
  44625. /** The underlying input source for the controller */
  44626. inputSource: XRInputSource;
  44627. private _options;
  44628. private _tmpQuaternion;
  44629. private _tmpVector;
  44630. private _uniqueId;
  44631. /**
  44632. * 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
  44633. */
  44634. grip?: AbstractMesh;
  44635. /**
  44636. * If available, this is the gamepad object related to this controller.
  44637. * Using this object it is possible to get click events and trackpad changes of the
  44638. * webxr controller that is currently being used.
  44639. */
  44640. motionController?: WebXRAbstractMotionController;
  44641. /**
  44642. * Event that fires when the controller is removed/disposed.
  44643. * The object provided as event data is this controller, after associated assets were disposed.
  44644. * uniqueId is still available.
  44645. */
  44646. onDisposeObservable: Observable<WebXRInputSource>;
  44647. /**
  44648. * Will be triggered when the mesh associated with the motion controller is done loading.
  44649. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44650. * A shortened version of controller -> motion controller -> on mesh loaded.
  44651. */
  44652. onMeshLoadedObservable: Observable<AbstractMesh>;
  44653. /**
  44654. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44655. */
  44656. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44657. /**
  44658. * Pointer which can be used to select objects or attach a visible laser to
  44659. */
  44660. pointer: AbstractMesh;
  44661. /**
  44662. * Creates the controller
  44663. * @see https://doc.babylonjs.com/how_to/webxr
  44664. * @param _scene the scene which the controller should be associated to
  44665. * @param inputSource the underlying input source for the controller
  44666. * @param _options options for this controller creation
  44667. */
  44668. constructor(_scene: Scene,
  44669. /** The underlying input source for the controller */
  44670. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44671. /**
  44672. * Get this controllers unique id
  44673. */
  44674. get uniqueId(): string;
  44675. /**
  44676. * Disposes of the object
  44677. */
  44678. dispose(): void;
  44679. /**
  44680. * Gets a world space ray coming from the pointer or grip
  44681. * @param result the resulting ray
  44682. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44683. */
  44684. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44685. /**
  44686. * Updates the controller pose based on the given XRFrame
  44687. * @param xrFrame xr frame to update the pose with
  44688. * @param referenceSpace reference space to use
  44689. */
  44690. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44691. }
  44692. }
  44693. declare module BABYLON {
  44694. /**
  44695. * The schema for initialization options of the XR Input class
  44696. */
  44697. export interface IWebXRInputOptions {
  44698. /**
  44699. * If set to true no model will be automatically loaded
  44700. */
  44701. doNotLoadControllerMeshes?: boolean;
  44702. /**
  44703. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44704. * If not found, the xr input profile data will be used.
  44705. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44706. */
  44707. forceInputProfile?: string;
  44708. /**
  44709. * Do not send a request to the controller repository to load the profile.
  44710. *
  44711. * Instead, use the controllers available in babylon itself.
  44712. */
  44713. disableOnlineControllerRepository?: boolean;
  44714. /**
  44715. * A custom URL for the controllers repository
  44716. */
  44717. customControllersRepositoryURL?: string;
  44718. /**
  44719. * Should the controller model's components not move according to the user input
  44720. */
  44721. disableControllerAnimation?: boolean;
  44722. }
  44723. /**
  44724. * XR input used to track XR inputs such as controllers/rays
  44725. */
  44726. export class WebXRInput implements IDisposable {
  44727. /**
  44728. * the xr session manager for this session
  44729. */
  44730. xrSessionManager: WebXRSessionManager;
  44731. /**
  44732. * the WebXR camera for this session. Mainly used for teleportation
  44733. */
  44734. xrCamera: WebXRCamera;
  44735. private readonly options;
  44736. /**
  44737. * XR controllers being tracked
  44738. */
  44739. controllers: Array<WebXRInputSource>;
  44740. private _frameObserver;
  44741. private _sessionEndedObserver;
  44742. private _sessionInitObserver;
  44743. /**
  44744. * Event when a controller has been connected/added
  44745. */
  44746. onControllerAddedObservable: Observable<WebXRInputSource>;
  44747. /**
  44748. * Event when a controller has been removed/disconnected
  44749. */
  44750. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44751. /**
  44752. * Initializes the WebXRInput
  44753. * @param xrSessionManager the xr session manager for this session
  44754. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44755. * @param options = initialization options for this xr input
  44756. */
  44757. constructor(
  44758. /**
  44759. * the xr session manager for this session
  44760. */
  44761. xrSessionManager: WebXRSessionManager,
  44762. /**
  44763. * the WebXR camera for this session. Mainly used for teleportation
  44764. */
  44765. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44766. private _onInputSourcesChange;
  44767. private _addAndRemoveControllers;
  44768. /**
  44769. * Disposes of the object
  44770. */
  44771. dispose(): void;
  44772. }
  44773. }
  44774. declare module BABYLON {
  44775. /**
  44776. * This is the base class for all WebXR features.
  44777. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44778. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44779. */
  44780. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44781. protected _xrSessionManager: WebXRSessionManager;
  44782. private _attached;
  44783. private _removeOnDetach;
  44784. /**
  44785. * Should auto-attach be disabled?
  44786. */
  44787. disableAutoAttach: boolean;
  44788. /**
  44789. * Construct a new (abstract) WebXR feature
  44790. * @param _xrSessionManager the xr session manager for this feature
  44791. */
  44792. constructor(_xrSessionManager: WebXRSessionManager);
  44793. /**
  44794. * Is this feature attached
  44795. */
  44796. get attached(): boolean;
  44797. /**
  44798. * attach this feature
  44799. *
  44800. * @param force should attachment be forced (even when already attached)
  44801. * @returns true if successful, false is failed or already attached
  44802. */
  44803. attach(force?: boolean): boolean;
  44804. /**
  44805. * detach this feature.
  44806. *
  44807. * @returns true if successful, false if failed or already detached
  44808. */
  44809. detach(): boolean;
  44810. /**
  44811. * Dispose this feature and all of the resources attached
  44812. */
  44813. dispose(): void;
  44814. /**
  44815. * This is used to register callbacks that will automatically be removed when detach is called.
  44816. * @param observable the observable to which the observer will be attached
  44817. * @param callback the callback to register
  44818. */
  44819. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44820. /**
  44821. * Code in this function will be executed on each xrFrame received from the browser.
  44822. * This function will not execute after the feature is detached.
  44823. * @param _xrFrame the current frame
  44824. */
  44825. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44826. }
  44827. }
  44828. declare module BABYLON {
  44829. /**
  44830. * Renders a layer on top of an existing scene
  44831. */
  44832. export class UtilityLayerRenderer implements IDisposable {
  44833. /** the original scene that will be rendered on top of */
  44834. originalScene: Scene;
  44835. private _pointerCaptures;
  44836. private _lastPointerEvents;
  44837. private static _DefaultUtilityLayer;
  44838. private static _DefaultKeepDepthUtilityLayer;
  44839. private _sharedGizmoLight;
  44840. private _renderCamera;
  44841. /**
  44842. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44843. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44844. * @returns the camera that is used when rendering the utility layer
  44845. */
  44846. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44847. /**
  44848. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44849. * @param cam the camera that should be used when rendering the utility layer
  44850. */
  44851. setRenderCamera(cam: Nullable<Camera>): void;
  44852. /**
  44853. * @hidden
  44854. * Light which used by gizmos to get light shading
  44855. */
  44856. _getSharedGizmoLight(): HemisphericLight;
  44857. /**
  44858. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44859. */
  44860. pickUtilitySceneFirst: boolean;
  44861. /**
  44862. * 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)
  44863. */
  44864. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44865. /**
  44866. * 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)
  44867. */
  44868. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44869. /**
  44870. * The scene that is rendered on top of the original scene
  44871. */
  44872. utilityLayerScene: Scene;
  44873. /**
  44874. * If the utility layer should automatically be rendered on top of existing scene
  44875. */
  44876. shouldRender: boolean;
  44877. /**
  44878. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44879. */
  44880. onlyCheckPointerDownEvents: boolean;
  44881. /**
  44882. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44883. */
  44884. processAllEvents: boolean;
  44885. /**
  44886. * Observable raised when the pointer move from the utility layer scene to the main scene
  44887. */
  44888. onPointerOutObservable: Observable<number>;
  44889. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44890. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44891. private _afterRenderObserver;
  44892. private _sceneDisposeObserver;
  44893. private _originalPointerObserver;
  44894. /**
  44895. * Instantiates a UtilityLayerRenderer
  44896. * @param originalScene the original scene that will be rendered on top of
  44897. * @param handleEvents boolean indicating if the utility layer should handle events
  44898. */
  44899. constructor(
  44900. /** the original scene that will be rendered on top of */
  44901. originalScene: Scene, handleEvents?: boolean);
  44902. private _notifyObservers;
  44903. /**
  44904. * Renders the utility layers scene on top of the original scene
  44905. */
  44906. render(): void;
  44907. /**
  44908. * Disposes of the renderer
  44909. */
  44910. dispose(): void;
  44911. private _updateCamera;
  44912. }
  44913. }
  44914. declare module BABYLON {
  44915. /**
  44916. * Options interface for the pointer selection module
  44917. */
  44918. export interface IWebXRControllerPointerSelectionOptions {
  44919. /**
  44920. * if provided, this scene will be used to render meshes.
  44921. */
  44922. customUtilityLayerScene?: Scene;
  44923. /**
  44924. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44925. * If not disabled, the last picked point will be used to execute a pointer up event
  44926. * If disabled, pointer up event will be triggered right after the pointer down event.
  44927. * Used in screen and gaze target ray mode only
  44928. */
  44929. disablePointerUpOnTouchOut: boolean;
  44930. /**
  44931. * For gaze mode (time to select instead of press)
  44932. */
  44933. forceGazeMode: boolean;
  44934. /**
  44935. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44936. * to start a new countdown to the pointer down event.
  44937. * Defaults to 1.
  44938. */
  44939. gazeModePointerMovedFactor?: number;
  44940. /**
  44941. * Different button type to use instead of the main component
  44942. */
  44943. overrideButtonId?: string;
  44944. /**
  44945. * use this rendering group id for the meshes (optional)
  44946. */
  44947. renderingGroupId?: number;
  44948. /**
  44949. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44950. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44951. * 3000 means 3 seconds between pointing at something and selecting it
  44952. */
  44953. timeToSelect?: number;
  44954. /**
  44955. * Should meshes created here be added to a utility layer or the main scene
  44956. */
  44957. useUtilityLayer?: boolean;
  44958. /**
  44959. * the xr input to use with this pointer selection
  44960. */
  44961. xrInput: WebXRInput;
  44962. }
  44963. /**
  44964. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44965. */
  44966. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44967. private readonly _options;
  44968. private static _idCounter;
  44969. private _attachController;
  44970. private _controllers;
  44971. private _scene;
  44972. private _tmpVectorForPickCompare;
  44973. /**
  44974. * The module's name
  44975. */
  44976. static readonly Name: string;
  44977. /**
  44978. * The (Babylon) version of this module.
  44979. * This is an integer representing the implementation version.
  44980. * This number does not correspond to the WebXR specs version
  44981. */
  44982. static readonly Version: number;
  44983. /**
  44984. * Disable lighting on the laser pointer (so it will always be visible)
  44985. */
  44986. disablePointerLighting: boolean;
  44987. /**
  44988. * Disable lighting on the selection mesh (so it will always be visible)
  44989. */
  44990. disableSelectionMeshLighting: boolean;
  44991. /**
  44992. * Should the laser pointer be displayed
  44993. */
  44994. displayLaserPointer: boolean;
  44995. /**
  44996. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44997. */
  44998. displaySelectionMesh: boolean;
  44999. /**
  45000. * This color will be set to the laser pointer when selection is triggered
  45001. */
  45002. laserPointerPickedColor: Color3;
  45003. /**
  45004. * Default color of the laser pointer
  45005. */
  45006. lasterPointerDefaultColor: Color3;
  45007. /**
  45008. * default color of the selection ring
  45009. */
  45010. selectionMeshDefaultColor: Color3;
  45011. /**
  45012. * This color will be applied to the selection ring when selection is triggered
  45013. */
  45014. selectionMeshPickedColor: Color3;
  45015. /**
  45016. * Optional filter to be used for ray selection. This predicate shares behavior with
  45017. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45018. */
  45019. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45020. /**
  45021. * constructs a new background remover module
  45022. * @param _xrSessionManager the session manager for this module
  45023. * @param _options read-only options to be used in this module
  45024. */
  45025. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45026. /**
  45027. * attach this feature
  45028. * Will usually be called by the features manager
  45029. *
  45030. * @returns true if successful.
  45031. */
  45032. attach(): boolean;
  45033. /**
  45034. * detach this feature.
  45035. * Will usually be called by the features manager
  45036. *
  45037. * @returns true if successful.
  45038. */
  45039. detach(): boolean;
  45040. /**
  45041. * Will get the mesh under a specific pointer.
  45042. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45043. * @param controllerId the controllerId to check
  45044. * @returns The mesh under pointer or null if no mesh is under the pointer
  45045. */
  45046. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45047. /**
  45048. * Get the xr controller that correlates to the pointer id in the pointer event
  45049. *
  45050. * @param id the pointer id to search for
  45051. * @returns the controller that correlates to this id or null if not found
  45052. */
  45053. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45054. protected _onXRFrame(_xrFrame: XRFrame): void;
  45055. private _attachGazeMode;
  45056. private _attachScreenRayMode;
  45057. private _attachTrackedPointerRayMode;
  45058. private _convertNormalToDirectionOfRay;
  45059. private _detachController;
  45060. private _generateNewMeshPair;
  45061. private _pickingMoved;
  45062. private _updatePointerDistance;
  45063. }
  45064. }
  45065. declare module BABYLON {
  45066. /**
  45067. * Button which can be used to enter a different mode of XR
  45068. */
  45069. export class WebXREnterExitUIButton {
  45070. /** button element */
  45071. element: HTMLElement;
  45072. /** XR initialization options for the button */
  45073. sessionMode: XRSessionMode;
  45074. /** Reference space type */
  45075. referenceSpaceType: XRReferenceSpaceType;
  45076. /**
  45077. * Creates a WebXREnterExitUIButton
  45078. * @param element button element
  45079. * @param sessionMode XR initialization session mode
  45080. * @param referenceSpaceType the type of reference space to be used
  45081. */
  45082. constructor(
  45083. /** button element */
  45084. element: HTMLElement,
  45085. /** XR initialization options for the button */
  45086. sessionMode: XRSessionMode,
  45087. /** Reference space type */
  45088. referenceSpaceType: XRReferenceSpaceType);
  45089. /**
  45090. * Extendable function which can be used to update the button's visuals when the state changes
  45091. * @param activeButton the current active button in the UI
  45092. */
  45093. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45094. }
  45095. /**
  45096. * Options to create the webXR UI
  45097. */
  45098. export class WebXREnterExitUIOptions {
  45099. /**
  45100. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45101. */
  45102. customButtons?: Array<WebXREnterExitUIButton>;
  45103. /**
  45104. * A reference space type to use when creating the default button.
  45105. * Default is local-floor
  45106. */
  45107. referenceSpaceType?: XRReferenceSpaceType;
  45108. /**
  45109. * Context to enter xr with
  45110. */
  45111. renderTarget?: Nullable<WebXRRenderTarget>;
  45112. /**
  45113. * A session mode to use when creating the default button.
  45114. * Default is immersive-vr
  45115. */
  45116. sessionMode?: XRSessionMode;
  45117. }
  45118. /**
  45119. * UI to allow the user to enter/exit XR mode
  45120. */
  45121. export class WebXREnterExitUI implements IDisposable {
  45122. private scene;
  45123. /** version of the options passed to this UI */
  45124. options: WebXREnterExitUIOptions;
  45125. private _activeButton;
  45126. private _buttons;
  45127. private _overlay;
  45128. /**
  45129. * Fired every time the active button is changed.
  45130. *
  45131. * When xr is entered via a button that launches xr that button will be the callback parameter
  45132. *
  45133. * When exiting xr the callback parameter will be null)
  45134. */
  45135. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45136. /**
  45137. *
  45138. * @param scene babylon scene object to use
  45139. * @param options (read-only) version of the options passed to this UI
  45140. */
  45141. private constructor();
  45142. /**
  45143. * Creates UI to allow the user to enter/exit XR mode
  45144. * @param scene the scene to add the ui to
  45145. * @param helper the xr experience helper to enter/exit xr with
  45146. * @param options options to configure the UI
  45147. * @returns the created ui
  45148. */
  45149. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45150. /**
  45151. * Disposes of the XR UI component
  45152. */
  45153. dispose(): void;
  45154. private _updateButtons;
  45155. }
  45156. }
  45157. declare module BABYLON {
  45158. /**
  45159. * Class containing static functions to help procedurally build meshes
  45160. */
  45161. export class LinesBuilder {
  45162. /**
  45163. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45164. * * 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
  45165. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45166. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45167. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45168. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45169. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45170. * * 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
  45171. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45174. * @param name defines the name of the new line system
  45175. * @param options defines the options used to create the line system
  45176. * @param scene defines the hosting scene
  45177. * @returns a new line system mesh
  45178. */
  45179. static CreateLineSystem(name: string, options: {
  45180. lines: Vector3[][];
  45181. updatable?: boolean;
  45182. instance?: Nullable<LinesMesh>;
  45183. colors?: Nullable<Color4[][]>;
  45184. useVertexAlpha?: boolean;
  45185. }, scene: Nullable<Scene>): LinesMesh;
  45186. /**
  45187. * Creates a line mesh
  45188. * 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
  45189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45190. * * The parameter `points` is an array successive Vector3
  45191. * * 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
  45192. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45193. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45194. * * When updating an instance, remember that only point positions can change, not the number of points
  45195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45197. * @param name defines the name of the new line system
  45198. * @param options defines the options used to create the line system
  45199. * @param scene defines the hosting scene
  45200. * @returns a new line mesh
  45201. */
  45202. static CreateLines(name: string, options: {
  45203. points: Vector3[];
  45204. updatable?: boolean;
  45205. instance?: Nullable<LinesMesh>;
  45206. colors?: Color4[];
  45207. useVertexAlpha?: boolean;
  45208. }, scene?: Nullable<Scene>): LinesMesh;
  45209. /**
  45210. * Creates a dashed line mesh
  45211. * * 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
  45212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45213. * * The parameter `points` is an array successive Vector3
  45214. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45215. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45216. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45217. * * 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
  45218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45219. * * When updating an instance, remember that only point positions can change, not the number of points
  45220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45221. * @param name defines the name of the mesh
  45222. * @param options defines the options used to create the mesh
  45223. * @param scene defines the hosting scene
  45224. * @returns the dashed line mesh
  45225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45226. */
  45227. static CreateDashedLines(name: string, options: {
  45228. points: Vector3[];
  45229. dashSize?: number;
  45230. gapSize?: number;
  45231. dashNb?: number;
  45232. updatable?: boolean;
  45233. instance?: LinesMesh;
  45234. useVertexAlpha?: boolean;
  45235. }, scene?: Nullable<Scene>): LinesMesh;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * The options container for the teleportation module
  45241. */
  45242. export interface IWebXRTeleportationOptions {
  45243. /**
  45244. * if provided, this scene will be used to render meshes.
  45245. */
  45246. customUtilityLayerScene?: Scene;
  45247. /**
  45248. * Values to configure the default target mesh
  45249. */
  45250. defaultTargetMeshOptions?: {
  45251. /**
  45252. * Fill color of the teleportation area
  45253. */
  45254. teleportationFillColor?: string;
  45255. /**
  45256. * Border color for the teleportation area
  45257. */
  45258. teleportationBorderColor?: string;
  45259. /**
  45260. * Disable the mesh's animation sequence
  45261. */
  45262. disableAnimation?: boolean;
  45263. /**
  45264. * Disable lighting on the material or the ring and arrow
  45265. */
  45266. disableLighting?: boolean;
  45267. /**
  45268. * Override the default material of the torus and arrow
  45269. */
  45270. torusArrowMaterial?: Material;
  45271. };
  45272. /**
  45273. * A list of meshes to use as floor meshes.
  45274. * Meshes can be added and removed after initializing the feature using the
  45275. * addFloorMesh and removeFloorMesh functions
  45276. * If empty, rotation will still work
  45277. */
  45278. floorMeshes?: AbstractMesh[];
  45279. /**
  45280. * use this rendering group id for the meshes (optional)
  45281. */
  45282. renderingGroupId?: number;
  45283. /**
  45284. * Should teleportation move only to snap points
  45285. */
  45286. snapPointsOnly?: boolean;
  45287. /**
  45288. * An array of points to which the teleportation will snap to.
  45289. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45290. */
  45291. snapPositions?: Vector3[];
  45292. /**
  45293. * How close should the teleportation ray be in order to snap to position.
  45294. * Default to 0.8 units (meters)
  45295. */
  45296. snapToPositionRadius?: number;
  45297. /**
  45298. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45299. * If you want to support rotation, make sure your mesh has a direction indicator.
  45300. *
  45301. * When left untouched, the default mesh will be initialized.
  45302. */
  45303. teleportationTargetMesh?: AbstractMesh;
  45304. /**
  45305. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45306. */
  45307. timeToTeleport?: number;
  45308. /**
  45309. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45310. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45311. */
  45312. useMainComponentOnly?: boolean;
  45313. /**
  45314. * Should meshes created here be added to a utility layer or the main scene
  45315. */
  45316. useUtilityLayer?: boolean;
  45317. /**
  45318. * Babylon XR Input class for controller
  45319. */
  45320. xrInput: WebXRInput;
  45321. }
  45322. /**
  45323. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45324. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45325. * the input of the attached controllers.
  45326. */
  45327. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45328. private _options;
  45329. private _controllers;
  45330. private _currentTeleportationControllerId;
  45331. private _floorMeshes;
  45332. private _quadraticBezierCurve;
  45333. private _selectionFeature;
  45334. private _snapToPositions;
  45335. private _snappedToPoint;
  45336. private _teleportationRingMaterial?;
  45337. private _tmpRay;
  45338. private _tmpVector;
  45339. /**
  45340. * The module's name
  45341. */
  45342. static readonly Name: string;
  45343. /**
  45344. * The (Babylon) version of this module.
  45345. * This is an integer representing the implementation version.
  45346. * This number does not correspond to the webxr specs version
  45347. */
  45348. static readonly Version: number;
  45349. /**
  45350. * Is movement backwards enabled
  45351. */
  45352. backwardsMovementEnabled: boolean;
  45353. /**
  45354. * Distance to travel when moving backwards
  45355. */
  45356. backwardsTeleportationDistance: number;
  45357. /**
  45358. * The distance from the user to the inspection point in the direction of the controller
  45359. * A higher number will allow the user to move further
  45360. * defaults to 5 (meters, in xr units)
  45361. */
  45362. parabolicCheckRadius: number;
  45363. /**
  45364. * Should the module support parabolic ray on top of direct ray
  45365. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45366. * Very helpful when moving between floors / different heights
  45367. */
  45368. parabolicRayEnabled: boolean;
  45369. /**
  45370. * How much rotation should be applied when rotating right and left
  45371. */
  45372. rotationAngle: number;
  45373. /**
  45374. * Is rotation enabled when moving forward?
  45375. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45376. */
  45377. rotationEnabled: boolean;
  45378. /**
  45379. * constructs a new anchor system
  45380. * @param _xrSessionManager an instance of WebXRSessionManager
  45381. * @param _options configuration object for this feature
  45382. */
  45383. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45384. /**
  45385. * Get the snapPointsOnly flag
  45386. */
  45387. get snapPointsOnly(): boolean;
  45388. /**
  45389. * Sets the snapPointsOnly flag
  45390. * @param snapToPoints should teleportation be exclusively to snap points
  45391. */
  45392. set snapPointsOnly(snapToPoints: boolean);
  45393. /**
  45394. * Add a new mesh to the floor meshes array
  45395. * @param mesh the mesh to use as floor mesh
  45396. */
  45397. addFloorMesh(mesh: AbstractMesh): void;
  45398. /**
  45399. * Add a new snap-to point to fix teleportation to this position
  45400. * @param newSnapPoint The new Snap-To point
  45401. */
  45402. addSnapPoint(newSnapPoint: Vector3): void;
  45403. attach(): boolean;
  45404. detach(): boolean;
  45405. dispose(): void;
  45406. /**
  45407. * Remove a mesh from the floor meshes array
  45408. * @param mesh the mesh to remove
  45409. */
  45410. removeFloorMesh(mesh: AbstractMesh): void;
  45411. /**
  45412. * Remove a mesh from the floor meshes array using its name
  45413. * @param name the mesh name to remove
  45414. */
  45415. removeFloorMeshByName(name: string): void;
  45416. /**
  45417. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  45418. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45419. * @returns was the point found and removed or not
  45420. */
  45421. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45422. /**
  45423. * This function sets a selection feature that will be disabled when
  45424. * the forward ray is shown and will be reattached when hidden.
  45425. * This is used to remove the selection rays when moving.
  45426. * @param selectionFeature the feature to disable when forward movement is enabled
  45427. */
  45428. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45429. protected _onXRFrame(_xrFrame: XRFrame): void;
  45430. private _attachController;
  45431. private _createDefaultTargetMesh;
  45432. private _detachController;
  45433. private _findClosestSnapPointWithRadius;
  45434. private _setTargetMeshPosition;
  45435. private _setTargetMeshVisibility;
  45436. private _showParabolicPath;
  45437. private _teleportForward;
  45438. }
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * Options for the default xr helper
  45443. */
  45444. export class WebXRDefaultExperienceOptions {
  45445. /**
  45446. * Enable or disable default UI to enter XR
  45447. */
  45448. disableDefaultUI?: boolean;
  45449. /**
  45450. * Should teleportation not initialize. defaults to false.
  45451. */
  45452. disableTeleportation?: boolean;
  45453. /**
  45454. * Floor meshes that will be used for teleport
  45455. */
  45456. floorMeshes?: Array<AbstractMesh>;
  45457. /**
  45458. * If set to true, the first frame will not be used to reset position
  45459. * The first frame is mainly used when copying transformation from the old camera
  45460. * Mainly used in AR
  45461. */
  45462. ignoreNativeCameraTransformation?: boolean;
  45463. /**
  45464. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45465. */
  45466. inputOptions?: IWebXRInputOptions;
  45467. /**
  45468. * optional configuration for the output canvas
  45469. */
  45470. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45471. /**
  45472. * optional UI options. This can be used among other to change session mode and reference space type
  45473. */
  45474. uiOptions?: WebXREnterExitUIOptions;
  45475. /**
  45476. * When loading teleportation and pointer select, use stable versions instead of latest.
  45477. */
  45478. useStablePlugins?: boolean;
  45479. }
  45480. /**
  45481. * Default experience which provides a similar setup to the previous webVRExperience
  45482. */
  45483. export class WebXRDefaultExperience {
  45484. /**
  45485. * Base experience
  45486. */
  45487. baseExperience: WebXRExperienceHelper;
  45488. /**
  45489. * Enables ui for entering/exiting xr
  45490. */
  45491. enterExitUI: WebXREnterExitUI;
  45492. /**
  45493. * Input experience extension
  45494. */
  45495. input: WebXRInput;
  45496. /**
  45497. * Enables laser pointer and selection
  45498. */
  45499. pointerSelection: WebXRControllerPointerSelection;
  45500. /**
  45501. * Default target xr should render to
  45502. */
  45503. renderTarget: WebXRRenderTarget;
  45504. /**
  45505. * Enables teleportation
  45506. */
  45507. teleportation: WebXRMotionControllerTeleportation;
  45508. private constructor();
  45509. /**
  45510. * Creates the default xr experience
  45511. * @param scene scene
  45512. * @param options options for basic configuration
  45513. * @returns resulting WebXRDefaultExperience
  45514. */
  45515. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45516. /**
  45517. * DIsposes of the experience helper
  45518. */
  45519. dispose(): void;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * Options to modify the vr teleportation behavior.
  45525. */
  45526. export interface VRTeleportationOptions {
  45527. /**
  45528. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45529. */
  45530. floorMeshName?: string;
  45531. /**
  45532. * A list of meshes to be used as the teleportation floor. (default: empty)
  45533. */
  45534. floorMeshes?: Mesh[];
  45535. /**
  45536. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45537. */
  45538. teleportationMode?: number;
  45539. /**
  45540. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45541. */
  45542. teleportationTime?: number;
  45543. /**
  45544. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45545. */
  45546. teleportationSpeed?: number;
  45547. /**
  45548. * The easing function used in the animation or null for Linear. (default CircleEase)
  45549. */
  45550. easingFunction?: EasingFunction;
  45551. }
  45552. /**
  45553. * Options to modify the vr experience helper's behavior.
  45554. */
  45555. export interface VRExperienceHelperOptions extends WebVROptions {
  45556. /**
  45557. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45558. */
  45559. createDeviceOrientationCamera?: boolean;
  45560. /**
  45561. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45562. */
  45563. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45564. /**
  45565. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45566. */
  45567. laserToggle?: boolean;
  45568. /**
  45569. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45570. */
  45571. floorMeshes?: Mesh[];
  45572. /**
  45573. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45574. */
  45575. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45576. /**
  45577. * Defines if WebXR should be used instead of WebVR (if available)
  45578. */
  45579. useXR?: boolean;
  45580. }
  45581. /**
  45582. * Event containing information after VR has been entered
  45583. */
  45584. export class OnAfterEnteringVRObservableEvent {
  45585. /**
  45586. * If entering vr was successful
  45587. */
  45588. success: boolean;
  45589. }
  45590. /**
  45591. * Helps to quickly add VR support to an existing scene.
  45592. * See http://doc.babylonjs.com/how_to/webvr_helper
  45593. */
  45594. export class VRExperienceHelper {
  45595. /** Options to modify the vr experience helper's behavior. */
  45596. webVROptions: VRExperienceHelperOptions;
  45597. private _scene;
  45598. private _position;
  45599. private _btnVR;
  45600. private _btnVRDisplayed;
  45601. private _webVRsupported;
  45602. private _webVRready;
  45603. private _webVRrequesting;
  45604. private _webVRpresenting;
  45605. private _hasEnteredVR;
  45606. private _fullscreenVRpresenting;
  45607. private _inputElement;
  45608. private _webVRCamera;
  45609. private _vrDeviceOrientationCamera;
  45610. private _deviceOrientationCamera;
  45611. private _existingCamera;
  45612. private _onKeyDown;
  45613. private _onVrDisplayPresentChange;
  45614. private _onVRDisplayChanged;
  45615. private _onVRRequestPresentStart;
  45616. private _onVRRequestPresentComplete;
  45617. /**
  45618. * 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)
  45619. */
  45620. enableGazeEvenWhenNoPointerLock: boolean;
  45621. /**
  45622. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45623. */
  45624. exitVROnDoubleTap: boolean;
  45625. /**
  45626. * Observable raised right before entering VR.
  45627. */
  45628. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45629. /**
  45630. * Observable raised when entering VR has completed.
  45631. */
  45632. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45633. /**
  45634. * Observable raised when exiting VR.
  45635. */
  45636. onExitingVRObservable: Observable<VRExperienceHelper>;
  45637. /**
  45638. * Observable raised when controller mesh is loaded.
  45639. */
  45640. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45641. /** Return this.onEnteringVRObservable
  45642. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45643. */
  45644. get onEnteringVR(): Observable<VRExperienceHelper>;
  45645. /** Return this.onExitingVRObservable
  45646. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45647. */
  45648. get onExitingVR(): Observable<VRExperienceHelper>;
  45649. /** Return this.onControllerMeshLoadedObservable
  45650. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45651. */
  45652. get onControllerMeshLoaded(): Observable<WebVRController>;
  45653. private _rayLength;
  45654. private _useCustomVRButton;
  45655. private _teleportationRequested;
  45656. private _teleportActive;
  45657. private _floorMeshName;
  45658. private _floorMeshesCollection;
  45659. private _teleportationMode;
  45660. private _teleportationTime;
  45661. private _teleportationSpeed;
  45662. private _teleportationEasing;
  45663. private _rotationAllowed;
  45664. private _teleportBackwardsVector;
  45665. private _teleportationTarget;
  45666. private _isDefaultTeleportationTarget;
  45667. private _postProcessMove;
  45668. private _teleportationFillColor;
  45669. private _teleportationBorderColor;
  45670. private _rotationAngle;
  45671. private _haloCenter;
  45672. private _cameraGazer;
  45673. private _padSensibilityUp;
  45674. private _padSensibilityDown;
  45675. private _leftController;
  45676. private _rightController;
  45677. private _gazeColor;
  45678. private _laserColor;
  45679. private _pickedLaserColor;
  45680. private _pickedGazeColor;
  45681. /**
  45682. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45683. */
  45684. onNewMeshSelected: Observable<AbstractMesh>;
  45685. /**
  45686. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45687. * This observable will provide the mesh and the controller used to select the mesh
  45688. */
  45689. onMeshSelectedWithController: Observable<{
  45690. mesh: AbstractMesh;
  45691. controller: WebVRController;
  45692. }>;
  45693. /**
  45694. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45695. */
  45696. onNewMeshPicked: Observable<PickingInfo>;
  45697. private _circleEase;
  45698. /**
  45699. * Observable raised before camera teleportation
  45700. */
  45701. onBeforeCameraTeleport: Observable<Vector3>;
  45702. /**
  45703. * Observable raised after camera teleportation
  45704. */
  45705. onAfterCameraTeleport: Observable<Vector3>;
  45706. /**
  45707. * Observable raised when current selected mesh gets unselected
  45708. */
  45709. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45710. private _raySelectionPredicate;
  45711. /**
  45712. * To be optionaly changed by user to define custom ray selection
  45713. */
  45714. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45715. /**
  45716. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45717. */
  45718. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45719. /**
  45720. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45721. */
  45722. teleportationEnabled: boolean;
  45723. private _defaultHeight;
  45724. private _teleportationInitialized;
  45725. private _interactionsEnabled;
  45726. private _interactionsRequested;
  45727. private _displayGaze;
  45728. private _displayLaserPointer;
  45729. /**
  45730. * The mesh used to display where the user is going to teleport.
  45731. */
  45732. get teleportationTarget(): Mesh;
  45733. /**
  45734. * Sets the mesh to be used to display where the user is going to teleport.
  45735. */
  45736. set teleportationTarget(value: Mesh);
  45737. /**
  45738. * 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
  45739. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45740. * See http://doc.babylonjs.com/resources/baking_transformations
  45741. */
  45742. get gazeTrackerMesh(): Mesh;
  45743. set gazeTrackerMesh(value: Mesh);
  45744. /**
  45745. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45746. */
  45747. updateGazeTrackerScale: boolean;
  45748. /**
  45749. * If the gaze trackers color should be updated when selecting meshes
  45750. */
  45751. updateGazeTrackerColor: boolean;
  45752. /**
  45753. * If the controller laser color should be updated when selecting meshes
  45754. */
  45755. updateControllerLaserColor: boolean;
  45756. /**
  45757. * The gaze tracking mesh corresponding to the left controller
  45758. */
  45759. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45760. /**
  45761. * The gaze tracking mesh corresponding to the right controller
  45762. */
  45763. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45764. /**
  45765. * If the ray of the gaze should be displayed.
  45766. */
  45767. get displayGaze(): boolean;
  45768. /**
  45769. * Sets if the ray of the gaze should be displayed.
  45770. */
  45771. set displayGaze(value: boolean);
  45772. /**
  45773. * If the ray of the LaserPointer should be displayed.
  45774. */
  45775. get displayLaserPointer(): boolean;
  45776. /**
  45777. * Sets if the ray of the LaserPointer should be displayed.
  45778. */
  45779. set displayLaserPointer(value: boolean);
  45780. /**
  45781. * The deviceOrientationCamera used as the camera when not in VR.
  45782. */
  45783. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45784. /**
  45785. * Based on the current WebVR support, returns the current VR camera used.
  45786. */
  45787. get currentVRCamera(): Nullable<Camera>;
  45788. /**
  45789. * The webVRCamera which is used when in VR.
  45790. */
  45791. get webVRCamera(): WebVRFreeCamera;
  45792. /**
  45793. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45794. */
  45795. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45796. /**
  45797. * The html button that is used to trigger entering into VR.
  45798. */
  45799. get vrButton(): Nullable<HTMLButtonElement>;
  45800. private get _teleportationRequestInitiated();
  45801. /**
  45802. * Defines whether or not Pointer lock should be requested when switching to
  45803. * full screen.
  45804. */
  45805. requestPointerLockOnFullScreen: boolean;
  45806. /**
  45807. * If asking to force XR, this will be populated with the default xr experience
  45808. */
  45809. xr: WebXRDefaultExperience;
  45810. /**
  45811. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45812. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45813. */
  45814. xrTestDone: boolean;
  45815. /**
  45816. * Instantiates a VRExperienceHelper.
  45817. * Helps to quickly add VR support to an existing scene.
  45818. * @param scene The scene the VRExperienceHelper belongs to.
  45819. * @param webVROptions Options to modify the vr experience helper's behavior.
  45820. */
  45821. constructor(scene: Scene,
  45822. /** Options to modify the vr experience helper's behavior. */
  45823. webVROptions?: VRExperienceHelperOptions);
  45824. private completeVRInit;
  45825. private _onDefaultMeshLoaded;
  45826. private _onResize;
  45827. private _onFullscreenChange;
  45828. /**
  45829. * Gets a value indicating if we are currently in VR mode.
  45830. */
  45831. get isInVRMode(): boolean;
  45832. private onVrDisplayPresentChange;
  45833. private onVRDisplayChanged;
  45834. private moveButtonToBottomRight;
  45835. private displayVRButton;
  45836. private updateButtonVisibility;
  45837. private _cachedAngularSensibility;
  45838. /**
  45839. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45840. * Otherwise, will use the fullscreen API.
  45841. */
  45842. enterVR(): void;
  45843. /**
  45844. * Attempt to exit VR, or fullscreen.
  45845. */
  45846. exitVR(): void;
  45847. /**
  45848. * The position of the vr experience helper.
  45849. */
  45850. get position(): Vector3;
  45851. /**
  45852. * Sets the position of the vr experience helper.
  45853. */
  45854. set position(value: Vector3);
  45855. /**
  45856. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45857. */
  45858. enableInteractions(): void;
  45859. private get _noControllerIsActive();
  45860. private beforeRender;
  45861. private _isTeleportationFloor;
  45862. /**
  45863. * Adds a floor mesh to be used for teleportation.
  45864. * @param floorMesh the mesh to be used for teleportation.
  45865. */
  45866. addFloorMesh(floorMesh: Mesh): void;
  45867. /**
  45868. * Removes a floor mesh from being used for teleportation.
  45869. * @param floorMesh the mesh to be removed.
  45870. */
  45871. removeFloorMesh(floorMesh: Mesh): void;
  45872. /**
  45873. * Enables interactions and teleportation using the VR controllers and gaze.
  45874. * @param vrTeleportationOptions options to modify teleportation behavior.
  45875. */
  45876. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45877. private _onNewGamepadConnected;
  45878. private _tryEnableInteractionOnController;
  45879. private _onNewGamepadDisconnected;
  45880. private _enableInteractionOnController;
  45881. private _checkTeleportWithRay;
  45882. private _checkRotate;
  45883. private _checkTeleportBackwards;
  45884. private _enableTeleportationOnController;
  45885. private _createTeleportationCircles;
  45886. private _displayTeleportationTarget;
  45887. private _hideTeleportationTarget;
  45888. private _rotateCamera;
  45889. private _moveTeleportationSelectorTo;
  45890. private _workingVector;
  45891. private _workingQuaternion;
  45892. private _workingMatrix;
  45893. /**
  45894. * Time Constant Teleportation Mode
  45895. */
  45896. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45897. /**
  45898. * Speed Constant Teleportation Mode
  45899. */
  45900. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45901. /**
  45902. * Teleports the users feet to the desired location
  45903. * @param location The location where the user's feet should be placed
  45904. */
  45905. teleportCamera(location: Vector3): void;
  45906. private _convertNormalToDirectionOfRay;
  45907. private _castRayAndSelectObject;
  45908. private _notifySelectedMeshUnselected;
  45909. /**
  45910. * Permanently set new colors for the laser pointer
  45911. * @param color the new laser color
  45912. * @param pickedColor the new laser color when picked mesh detected
  45913. */
  45914. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45915. /**
  45916. * Set lighting enabled / disabled on the laser pointer of both controllers
  45917. * @param enabled should the lighting be enabled on the laser pointer
  45918. */
  45919. setLaserLightingState(enabled?: boolean): void;
  45920. /**
  45921. * Permanently set new colors for the gaze pointer
  45922. * @param color the new gaze color
  45923. * @param pickedColor the new gaze color when picked mesh detected
  45924. */
  45925. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45926. /**
  45927. * Sets the color of the laser ray from the vr controllers.
  45928. * @param color new color for the ray.
  45929. */
  45930. changeLaserColor(color: Color3): void;
  45931. /**
  45932. * Sets the color of the ray from the vr headsets gaze.
  45933. * @param color new color for the ray.
  45934. */
  45935. changeGazeColor(color: Color3): void;
  45936. /**
  45937. * Exits VR and disposes of the vr experience helper
  45938. */
  45939. dispose(): void;
  45940. /**
  45941. * Gets the name of the VRExperienceHelper class
  45942. * @returns "VRExperienceHelper"
  45943. */
  45944. getClassName(): string;
  45945. }
  45946. }
  45947. declare module BABYLON {
  45948. /**
  45949. * Contains an array of blocks representing the octree
  45950. */
  45951. export interface IOctreeContainer<T> {
  45952. /**
  45953. * Blocks within the octree
  45954. */
  45955. blocks: Array<OctreeBlock<T>>;
  45956. }
  45957. /**
  45958. * Class used to store a cell in an octree
  45959. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45960. */
  45961. export class OctreeBlock<T> {
  45962. /**
  45963. * Gets the content of the current block
  45964. */
  45965. entries: T[];
  45966. /**
  45967. * Gets the list of block children
  45968. */
  45969. blocks: Array<OctreeBlock<T>>;
  45970. private _depth;
  45971. private _maxDepth;
  45972. private _capacity;
  45973. private _minPoint;
  45974. private _maxPoint;
  45975. private _boundingVectors;
  45976. private _creationFunc;
  45977. /**
  45978. * Creates a new block
  45979. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45980. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45981. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45982. * @param depth defines the current depth of this block in the octree
  45983. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45984. * @param creationFunc defines a callback to call when an element is added to the block
  45985. */
  45986. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45987. /**
  45988. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45989. */
  45990. get capacity(): number;
  45991. /**
  45992. * Gets the minimum vector (in world space) of the block's bounding box
  45993. */
  45994. get minPoint(): Vector3;
  45995. /**
  45996. * Gets the maximum vector (in world space) of the block's bounding box
  45997. */
  45998. get maxPoint(): Vector3;
  45999. /**
  46000. * Add a new element to this block
  46001. * @param entry defines the element to add
  46002. */
  46003. addEntry(entry: T): void;
  46004. /**
  46005. * Remove an element from this block
  46006. * @param entry defines the element to remove
  46007. */
  46008. removeEntry(entry: T): void;
  46009. /**
  46010. * Add an array of elements to this block
  46011. * @param entries defines the array of elements to add
  46012. */
  46013. addEntries(entries: T[]): void;
  46014. /**
  46015. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46016. * @param frustumPlanes defines the frustum planes to test
  46017. * @param selection defines the array to store current content if selection is positive
  46018. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46019. */
  46020. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46021. /**
  46022. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46023. * @param sphereCenter defines the bounding sphere center
  46024. * @param sphereRadius defines the bounding sphere radius
  46025. * @param selection defines the array to store current content if selection is positive
  46026. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46027. */
  46028. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46029. /**
  46030. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46031. * @param ray defines the ray to test with
  46032. * @param selection defines the array to store current content if selection is positive
  46033. */
  46034. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46035. /**
  46036. * Subdivide the content into child blocks (this block will then be empty)
  46037. */
  46038. createInnerBlocks(): void;
  46039. /**
  46040. * @hidden
  46041. */
  46042. 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;
  46043. }
  46044. }
  46045. declare module BABYLON {
  46046. /**
  46047. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46049. */
  46050. export class Octree<T> {
  46051. /** 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.) */
  46052. maxDepth: number;
  46053. /**
  46054. * Blocks within the octree containing objects
  46055. */
  46056. blocks: Array<OctreeBlock<T>>;
  46057. /**
  46058. * Content stored in the octree
  46059. */
  46060. dynamicContent: T[];
  46061. private _maxBlockCapacity;
  46062. private _selectionContent;
  46063. private _creationFunc;
  46064. /**
  46065. * Creates a octree
  46066. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46067. * @param creationFunc function to be used to instatiate the octree
  46068. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46069. * @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.)
  46070. */
  46071. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46072. /** 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.) */
  46073. maxDepth?: number);
  46074. /**
  46075. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46076. * @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);
  46077. * @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);
  46078. * @param entries meshes to be added to the octree blocks
  46079. */
  46080. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46081. /**
  46082. * Adds a mesh to the octree
  46083. * @param entry Mesh to add to the octree
  46084. */
  46085. addMesh(entry: T): void;
  46086. /**
  46087. * Remove an element from the octree
  46088. * @param entry defines the element to remove
  46089. */
  46090. removeMesh(entry: T): void;
  46091. /**
  46092. * Selects an array of meshes within the frustum
  46093. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46094. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46095. * @returns array of meshes within the frustum
  46096. */
  46097. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46098. /**
  46099. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46100. * @param sphereCenter defines the bounding sphere center
  46101. * @param sphereRadius defines the bounding sphere radius
  46102. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46103. * @returns an array of objects that intersect the sphere
  46104. */
  46105. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46106. /**
  46107. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46108. * @param ray defines the ray to test with
  46109. * @returns array of intersected objects
  46110. */
  46111. intersectsRay(ray: Ray): SmartArray<T>;
  46112. /**
  46113. * Adds a mesh into the octree block if it intersects the block
  46114. */
  46115. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46116. /**
  46117. * Adds a submesh into the octree block if it intersects the block
  46118. */
  46119. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46120. }
  46121. }
  46122. declare module BABYLON {
  46123. interface Scene {
  46124. /**
  46125. * @hidden
  46126. * Backing Filed
  46127. */
  46128. _selectionOctree: Octree<AbstractMesh>;
  46129. /**
  46130. * Gets the octree used to boost mesh selection (picking)
  46131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46132. */
  46133. selectionOctree: Octree<AbstractMesh>;
  46134. /**
  46135. * Creates or updates the octree used to boost selection (picking)
  46136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46137. * @param maxCapacity defines the maximum capacity per leaf
  46138. * @param maxDepth defines the maximum depth of the octree
  46139. * @returns an octree of AbstractMesh
  46140. */
  46141. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46142. }
  46143. interface AbstractMesh {
  46144. /**
  46145. * @hidden
  46146. * Backing Field
  46147. */
  46148. _submeshesOctree: Octree<SubMesh>;
  46149. /**
  46150. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46151. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46152. * @param maxCapacity defines the maximum size of each block (64 by default)
  46153. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46154. * @returns the new octree
  46155. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46157. */
  46158. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46159. }
  46160. /**
  46161. * Defines the octree scene component responsible to manage any octrees
  46162. * in a given scene.
  46163. */
  46164. export class OctreeSceneComponent {
  46165. /**
  46166. * The component name help to identify the component in the list of scene components.
  46167. */
  46168. readonly name: string;
  46169. /**
  46170. * The scene the component belongs to.
  46171. */
  46172. scene: Scene;
  46173. /**
  46174. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46175. */
  46176. readonly checksIsEnabled: boolean;
  46177. /**
  46178. * Creates a new instance of the component for the given scene
  46179. * @param scene Defines the scene to register the component in
  46180. */
  46181. constructor(scene: Scene);
  46182. /**
  46183. * Registers the component in a given scene
  46184. */
  46185. register(): void;
  46186. /**
  46187. * Return the list of active meshes
  46188. * @returns the list of active meshes
  46189. */
  46190. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46191. /**
  46192. * Return the list of active sub meshes
  46193. * @param mesh The mesh to get the candidates sub meshes from
  46194. * @returns the list of active sub meshes
  46195. */
  46196. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46197. private _tempRay;
  46198. /**
  46199. * Return the list of sub meshes intersecting with a given local ray
  46200. * @param mesh defines the mesh to find the submesh for
  46201. * @param localRay defines the ray in local space
  46202. * @returns the list of intersecting sub meshes
  46203. */
  46204. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46205. /**
  46206. * Return the list of sub meshes colliding with a collider
  46207. * @param mesh defines the mesh to find the submesh for
  46208. * @param collider defines the collider to evaluate the collision against
  46209. * @returns the list of colliding sub meshes
  46210. */
  46211. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46212. /**
  46213. * Rebuilds the elements related to this component in case of
  46214. * context lost for instance.
  46215. */
  46216. rebuild(): void;
  46217. /**
  46218. * Disposes the component and the associated ressources.
  46219. */
  46220. dispose(): void;
  46221. }
  46222. }
  46223. declare module BABYLON {
  46224. /**
  46225. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46226. */
  46227. export class Gizmo implements IDisposable {
  46228. /** The utility layer the gizmo will be added to */
  46229. gizmoLayer: UtilityLayerRenderer;
  46230. /**
  46231. * The root mesh of the gizmo
  46232. */
  46233. _rootMesh: Mesh;
  46234. private _attachedMesh;
  46235. /**
  46236. * Ratio for the scale of the gizmo (Default: 1)
  46237. */
  46238. scaleRatio: number;
  46239. /**
  46240. * If a custom mesh has been set (Default: false)
  46241. */
  46242. protected _customMeshSet: boolean;
  46243. /**
  46244. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46245. * * When set, interactions will be enabled
  46246. */
  46247. get attachedMesh(): Nullable<AbstractMesh>;
  46248. set attachedMesh(value: Nullable<AbstractMesh>);
  46249. /**
  46250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46251. * @param mesh The mesh to replace the default mesh of the gizmo
  46252. */
  46253. setCustomMesh(mesh: Mesh): void;
  46254. /**
  46255. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46256. */
  46257. updateGizmoRotationToMatchAttachedMesh: boolean;
  46258. /**
  46259. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46260. */
  46261. updateGizmoPositionToMatchAttachedMesh: boolean;
  46262. /**
  46263. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46264. */
  46265. updateScale: boolean;
  46266. protected _interactionsEnabled: boolean;
  46267. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46268. private _beforeRenderObserver;
  46269. private _tempVector;
  46270. /**
  46271. * Creates a gizmo
  46272. * @param gizmoLayer The utility layer the gizmo will be added to
  46273. */
  46274. constructor(
  46275. /** The utility layer the gizmo will be added to */
  46276. gizmoLayer?: UtilityLayerRenderer);
  46277. /**
  46278. * Updates the gizmo to match the attached mesh's position/rotation
  46279. */
  46280. protected _update(): void;
  46281. /**
  46282. * Disposes of the gizmo
  46283. */
  46284. dispose(): void;
  46285. }
  46286. }
  46287. declare module BABYLON {
  46288. /**
  46289. * Single plane drag gizmo
  46290. */
  46291. export class PlaneDragGizmo extends Gizmo {
  46292. /**
  46293. * Drag behavior responsible for the gizmos dragging interactions
  46294. */
  46295. dragBehavior: PointerDragBehavior;
  46296. private _pointerObserver;
  46297. /**
  46298. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46299. */
  46300. snapDistance: number;
  46301. /**
  46302. * Event that fires each time the gizmo snaps to a new location.
  46303. * * snapDistance is the the change in distance
  46304. */
  46305. onSnapObservable: Observable<{
  46306. snapDistance: number;
  46307. }>;
  46308. private _plane;
  46309. private _coloredMaterial;
  46310. private _hoverMaterial;
  46311. private _isEnabled;
  46312. private _parent;
  46313. /** @hidden */
  46314. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46315. /** @hidden */
  46316. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46317. /**
  46318. * Creates a PlaneDragGizmo
  46319. * @param gizmoLayer The utility layer the gizmo will be added to
  46320. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46321. * @param color The color of the gizmo
  46322. */
  46323. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46325. /**
  46326. * If the gizmo is enabled
  46327. */
  46328. set isEnabled(value: boolean);
  46329. get isEnabled(): boolean;
  46330. /**
  46331. * Disposes of the gizmo
  46332. */
  46333. dispose(): void;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * Gizmo that enables dragging a mesh along 3 axis
  46339. */
  46340. export class PositionGizmo extends Gizmo {
  46341. /**
  46342. * Internal gizmo used for interactions on the x axis
  46343. */
  46344. xGizmo: AxisDragGizmo;
  46345. /**
  46346. * Internal gizmo used for interactions on the y axis
  46347. */
  46348. yGizmo: AxisDragGizmo;
  46349. /**
  46350. * Internal gizmo used for interactions on the z axis
  46351. */
  46352. zGizmo: AxisDragGizmo;
  46353. /**
  46354. * Internal gizmo used for interactions on the yz plane
  46355. */
  46356. xPlaneGizmo: PlaneDragGizmo;
  46357. /**
  46358. * Internal gizmo used for interactions on the xz plane
  46359. */
  46360. yPlaneGizmo: PlaneDragGizmo;
  46361. /**
  46362. * Internal gizmo used for interactions on the xy plane
  46363. */
  46364. zPlaneGizmo: PlaneDragGizmo;
  46365. /**
  46366. * private variables
  46367. */
  46368. private _meshAttached;
  46369. private _updateGizmoRotationToMatchAttachedMesh;
  46370. private _snapDistance;
  46371. private _scaleRatio;
  46372. /** Fires an event when any of it's sub gizmos are dragged */
  46373. onDragStartObservable: Observable<unknown>;
  46374. /** Fires an event when any of it's sub gizmos are released from dragging */
  46375. onDragEndObservable: Observable<unknown>;
  46376. /**
  46377. * If set to true, planar drag is enabled
  46378. */
  46379. private _planarGizmoEnabled;
  46380. get attachedMesh(): Nullable<AbstractMesh>;
  46381. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46382. /**
  46383. * Creates a PositionGizmo
  46384. * @param gizmoLayer The utility layer the gizmo will be added to
  46385. */
  46386. constructor(gizmoLayer?: UtilityLayerRenderer);
  46387. /**
  46388. * If the planar drag gizmo is enabled
  46389. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46390. */
  46391. set planarGizmoEnabled(value: boolean);
  46392. get planarGizmoEnabled(): boolean;
  46393. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46394. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46395. /**
  46396. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46397. */
  46398. set snapDistance(value: number);
  46399. get snapDistance(): number;
  46400. /**
  46401. * Ratio for the scale of the gizmo (Default: 1)
  46402. */
  46403. set scaleRatio(value: number);
  46404. get scaleRatio(): number;
  46405. /**
  46406. * Disposes of the gizmo
  46407. */
  46408. dispose(): void;
  46409. /**
  46410. * CustomMeshes are not supported by this gizmo
  46411. * @param mesh The mesh to replace the default mesh of the gizmo
  46412. */
  46413. setCustomMesh(mesh: Mesh): void;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * Single axis drag gizmo
  46419. */
  46420. export class AxisDragGizmo extends Gizmo {
  46421. /**
  46422. * Drag behavior responsible for the gizmos dragging interactions
  46423. */
  46424. dragBehavior: PointerDragBehavior;
  46425. private _pointerObserver;
  46426. /**
  46427. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46428. */
  46429. snapDistance: number;
  46430. /**
  46431. * Event that fires each time the gizmo snaps to a new location.
  46432. * * snapDistance is the the change in distance
  46433. */
  46434. onSnapObservable: Observable<{
  46435. snapDistance: number;
  46436. }>;
  46437. private _isEnabled;
  46438. private _parent;
  46439. private _arrow;
  46440. private _coloredMaterial;
  46441. private _hoverMaterial;
  46442. /** @hidden */
  46443. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46444. /** @hidden */
  46445. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46446. /**
  46447. * Creates an AxisDragGizmo
  46448. * @param gizmoLayer The utility layer the gizmo will be added to
  46449. * @param dragAxis The axis which the gizmo will be able to drag on
  46450. * @param color The color of the gizmo
  46451. */
  46452. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46453. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46454. /**
  46455. * If the gizmo is enabled
  46456. */
  46457. set isEnabled(value: boolean);
  46458. get isEnabled(): boolean;
  46459. /**
  46460. * Disposes of the gizmo
  46461. */
  46462. dispose(): void;
  46463. }
  46464. }
  46465. declare module BABYLON.Debug {
  46466. /**
  46467. * The Axes viewer will show 3 axes in a specific point in space
  46468. */
  46469. export class AxesViewer {
  46470. private _xAxis;
  46471. private _yAxis;
  46472. private _zAxis;
  46473. private _scaleLinesFactor;
  46474. private _instanced;
  46475. /**
  46476. * Gets the hosting scene
  46477. */
  46478. scene: Scene;
  46479. /**
  46480. * Gets or sets a number used to scale line length
  46481. */
  46482. scaleLines: number;
  46483. /** Gets the node hierarchy used to render x-axis */
  46484. get xAxis(): TransformNode;
  46485. /** Gets the node hierarchy used to render y-axis */
  46486. get yAxis(): TransformNode;
  46487. /** Gets the node hierarchy used to render z-axis */
  46488. get zAxis(): TransformNode;
  46489. /**
  46490. * Creates a new AxesViewer
  46491. * @param scene defines the hosting scene
  46492. * @param scaleLines defines a number used to scale line length (1 by default)
  46493. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46494. * @param xAxis defines the node hierarchy used to render the x-axis
  46495. * @param yAxis defines the node hierarchy used to render the y-axis
  46496. * @param zAxis defines the node hierarchy used to render the z-axis
  46497. */
  46498. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46499. /**
  46500. * Force the viewer to update
  46501. * @param position defines the position of the viewer
  46502. * @param xaxis defines the x axis of the viewer
  46503. * @param yaxis defines the y axis of the viewer
  46504. * @param zaxis defines the z axis of the viewer
  46505. */
  46506. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46507. /**
  46508. * Creates an instance of this axes viewer.
  46509. * @returns a new axes viewer with instanced meshes
  46510. */
  46511. createInstance(): AxesViewer;
  46512. /** Releases resources */
  46513. dispose(): void;
  46514. private static _SetRenderingGroupId;
  46515. }
  46516. }
  46517. declare module BABYLON.Debug {
  46518. /**
  46519. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46520. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46521. */
  46522. export class BoneAxesViewer extends AxesViewer {
  46523. /**
  46524. * Gets or sets the target mesh where to display the axes viewer
  46525. */
  46526. mesh: Nullable<Mesh>;
  46527. /**
  46528. * Gets or sets the target bone where to display the axes viewer
  46529. */
  46530. bone: Nullable<Bone>;
  46531. /** Gets current position */
  46532. pos: Vector3;
  46533. /** Gets direction of X axis */
  46534. xaxis: Vector3;
  46535. /** Gets direction of Y axis */
  46536. yaxis: Vector3;
  46537. /** Gets direction of Z axis */
  46538. zaxis: Vector3;
  46539. /**
  46540. * Creates a new BoneAxesViewer
  46541. * @param scene defines the hosting scene
  46542. * @param bone defines the target bone
  46543. * @param mesh defines the target mesh
  46544. * @param scaleLines defines a scaling factor for line length (1 by default)
  46545. */
  46546. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46547. /**
  46548. * Force the viewer to update
  46549. */
  46550. update(): void;
  46551. /** Releases resources */
  46552. dispose(): void;
  46553. }
  46554. }
  46555. declare module BABYLON {
  46556. /**
  46557. * Interface used to define scene explorer extensibility option
  46558. */
  46559. export interface IExplorerExtensibilityOption {
  46560. /**
  46561. * Define the option label
  46562. */
  46563. label: string;
  46564. /**
  46565. * Defines the action to execute on click
  46566. */
  46567. action: (entity: any) => void;
  46568. }
  46569. /**
  46570. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46571. */
  46572. export interface IExplorerExtensibilityGroup {
  46573. /**
  46574. * Defines a predicate to test if a given type mut be extended
  46575. */
  46576. predicate: (entity: any) => boolean;
  46577. /**
  46578. * Gets the list of options added to a type
  46579. */
  46580. entries: IExplorerExtensibilityOption[];
  46581. }
  46582. /**
  46583. * Interface used to define the options to use to create the Inspector
  46584. */
  46585. export interface IInspectorOptions {
  46586. /**
  46587. * Display in overlay mode (default: false)
  46588. */
  46589. overlay?: boolean;
  46590. /**
  46591. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46592. */
  46593. globalRoot?: HTMLElement;
  46594. /**
  46595. * Display the Scene explorer
  46596. */
  46597. showExplorer?: boolean;
  46598. /**
  46599. * Display the property inspector
  46600. */
  46601. showInspector?: boolean;
  46602. /**
  46603. * Display in embed mode (both panes on the right)
  46604. */
  46605. embedMode?: boolean;
  46606. /**
  46607. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46608. */
  46609. handleResize?: boolean;
  46610. /**
  46611. * Allow the panes to popup (default: true)
  46612. */
  46613. enablePopup?: boolean;
  46614. /**
  46615. * Allow the panes to be closed by users (default: true)
  46616. */
  46617. enableClose?: boolean;
  46618. /**
  46619. * Optional list of extensibility entries
  46620. */
  46621. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46622. /**
  46623. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46624. */
  46625. inspectorURL?: string;
  46626. /**
  46627. * Optional initial tab (default to DebugLayerTab.Properties)
  46628. */
  46629. initialTab?: DebugLayerTab;
  46630. }
  46631. interface Scene {
  46632. /**
  46633. * @hidden
  46634. * Backing field
  46635. */
  46636. _debugLayer: DebugLayer;
  46637. /**
  46638. * Gets the debug layer (aka Inspector) associated with the scene
  46639. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46640. */
  46641. debugLayer: DebugLayer;
  46642. }
  46643. /**
  46644. * Enum of inspector action tab
  46645. */
  46646. export enum DebugLayerTab {
  46647. /**
  46648. * Properties tag (default)
  46649. */
  46650. Properties = 0,
  46651. /**
  46652. * Debug tab
  46653. */
  46654. Debug = 1,
  46655. /**
  46656. * Statistics tab
  46657. */
  46658. Statistics = 2,
  46659. /**
  46660. * Tools tab
  46661. */
  46662. Tools = 3,
  46663. /**
  46664. * Settings tab
  46665. */
  46666. Settings = 4
  46667. }
  46668. /**
  46669. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46670. * what is happening in your scene
  46671. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46672. */
  46673. export class DebugLayer {
  46674. /**
  46675. * Define the url to get the inspector script from.
  46676. * By default it uses the babylonjs CDN.
  46677. * @ignoreNaming
  46678. */
  46679. static InspectorURL: string;
  46680. private _scene;
  46681. private BJSINSPECTOR;
  46682. private _onPropertyChangedObservable?;
  46683. /**
  46684. * Observable triggered when a property is changed through the inspector.
  46685. */
  46686. get onPropertyChangedObservable(): any;
  46687. /**
  46688. * Instantiates a new debug layer.
  46689. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46690. * what is happening in your scene
  46691. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46692. * @param scene Defines the scene to inspect
  46693. */
  46694. constructor(scene: Scene);
  46695. /** Creates the inspector window. */
  46696. private _createInspector;
  46697. /**
  46698. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46699. * @param entity defines the entity to select
  46700. * @param lineContainerTitle defines the specific block to highlight
  46701. */
  46702. select(entity: any, lineContainerTitle?: string): void;
  46703. /** Get the inspector from bundle or global */
  46704. private _getGlobalInspector;
  46705. /**
  46706. * Get if the inspector is visible or not.
  46707. * @returns true if visible otherwise, false
  46708. */
  46709. isVisible(): boolean;
  46710. /**
  46711. * Hide the inspector and close its window.
  46712. */
  46713. hide(): void;
  46714. /**
  46715. * Launch the debugLayer.
  46716. * @param config Define the configuration of the inspector
  46717. * @return a promise fulfilled when the debug layer is visible
  46718. */
  46719. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * Class containing static functions to help procedurally build meshes
  46725. */
  46726. export class BoxBuilder {
  46727. /**
  46728. * Creates a box mesh
  46729. * * The parameter `size` sets the size (float) of each box side (default 1)
  46730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46731. * * 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)
  46732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46734. * * 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
  46735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46737. * @param name defines the name of the mesh
  46738. * @param options defines the options used to create the mesh
  46739. * @param scene defines the hosting scene
  46740. * @returns the box mesh
  46741. */
  46742. static CreateBox(name: string, options: {
  46743. size?: number;
  46744. width?: number;
  46745. height?: number;
  46746. depth?: number;
  46747. faceUV?: Vector4[];
  46748. faceColors?: Color4[];
  46749. sideOrientation?: number;
  46750. frontUVs?: Vector4;
  46751. backUVs?: Vector4;
  46752. wrap?: boolean;
  46753. topBaseAt?: number;
  46754. bottomBaseAt?: number;
  46755. updatable?: boolean;
  46756. }, scene?: Nullable<Scene>): Mesh;
  46757. }
  46758. }
  46759. declare module BABYLON.Debug {
  46760. /**
  46761. * Used to show the physics impostor around the specific mesh
  46762. */
  46763. export class PhysicsViewer {
  46764. /** @hidden */
  46765. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46766. /** @hidden */
  46767. protected _meshes: Array<Nullable<AbstractMesh>>;
  46768. /** @hidden */
  46769. protected _scene: Nullable<Scene>;
  46770. /** @hidden */
  46771. protected _numMeshes: number;
  46772. /** @hidden */
  46773. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46774. private _renderFunction;
  46775. private _utilityLayer;
  46776. private _debugBoxMesh;
  46777. private _debugSphereMesh;
  46778. private _debugCylinderMesh;
  46779. private _debugMaterial;
  46780. private _debugMeshMeshes;
  46781. /**
  46782. * Creates a new PhysicsViewer
  46783. * @param scene defines the hosting scene
  46784. */
  46785. constructor(scene: Scene);
  46786. /** @hidden */
  46787. protected _updateDebugMeshes(): void;
  46788. /**
  46789. * Renders a specified physic impostor
  46790. * @param impostor defines the impostor to render
  46791. * @param targetMesh defines the mesh represented by the impostor
  46792. * @returns the new debug mesh used to render the impostor
  46793. */
  46794. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46795. /**
  46796. * Hides a specified physic impostor
  46797. * @param impostor defines the impostor to hide
  46798. */
  46799. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46800. private _getDebugMaterial;
  46801. private _getDebugBoxMesh;
  46802. private _getDebugSphereMesh;
  46803. private _getDebugCylinderMesh;
  46804. private _getDebugMeshMesh;
  46805. private _getDebugMesh;
  46806. /** Releases all resources */
  46807. dispose(): void;
  46808. }
  46809. }
  46810. declare module BABYLON {
  46811. /**
  46812. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46813. * in order to better appreciate the issue one might have.
  46814. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46815. */
  46816. export class RayHelper {
  46817. /**
  46818. * Defines the ray we are currently tryin to visualize.
  46819. */
  46820. ray: Nullable<Ray>;
  46821. private _renderPoints;
  46822. private _renderLine;
  46823. private _renderFunction;
  46824. private _scene;
  46825. private _updateToMeshFunction;
  46826. private _attachedToMesh;
  46827. private _meshSpaceDirection;
  46828. private _meshSpaceOrigin;
  46829. /**
  46830. * Helper function to create a colored helper in a scene in one line.
  46831. * @param ray Defines the ray we are currently tryin to visualize
  46832. * @param scene Defines the scene the ray is used in
  46833. * @param color Defines the color we want to see the ray in
  46834. * @returns The newly created ray helper.
  46835. */
  46836. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46837. /**
  46838. * Instantiate a new ray helper.
  46839. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46840. * in order to better appreciate the issue one might have.
  46841. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46842. * @param ray Defines the ray we are currently tryin to visualize
  46843. */
  46844. constructor(ray: Ray);
  46845. /**
  46846. * Shows the ray we are willing to debug.
  46847. * @param scene Defines the scene the ray needs to be rendered in
  46848. * @param color Defines the color the ray needs to be rendered in
  46849. */
  46850. show(scene: Scene, color?: Color3): void;
  46851. /**
  46852. * Hides the ray we are debugging.
  46853. */
  46854. hide(): void;
  46855. private _render;
  46856. /**
  46857. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46858. * @param mesh Defines the mesh we want the helper attached to
  46859. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46860. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46861. * @param length Defines the length of the ray
  46862. */
  46863. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46864. /**
  46865. * Detach the ray helper from the mesh it has previously been attached to.
  46866. */
  46867. detachFromMesh(): void;
  46868. private _updateToMesh;
  46869. /**
  46870. * Dispose the helper and release its associated resources.
  46871. */
  46872. dispose(): void;
  46873. }
  46874. }
  46875. declare module BABYLON.Debug {
  46876. /**
  46877. * Class used to render a debug view of a given skeleton
  46878. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46879. */
  46880. export class SkeletonViewer {
  46881. /** defines the skeleton to render */
  46882. skeleton: Skeleton;
  46883. /** defines the mesh attached to the skeleton */
  46884. mesh: AbstractMesh;
  46885. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46886. autoUpdateBonesMatrices: boolean;
  46887. /** defines the rendering group id to use with the viewer */
  46888. renderingGroupId: number;
  46889. /** Gets or sets the color used to render the skeleton */
  46890. color: Color3;
  46891. private _scene;
  46892. private _debugLines;
  46893. private _debugMesh;
  46894. private _isEnabled;
  46895. private _renderFunction;
  46896. private _utilityLayer;
  46897. /**
  46898. * Returns the mesh used to render the bones
  46899. */
  46900. get debugMesh(): Nullable<LinesMesh>;
  46901. /**
  46902. * Creates a new SkeletonViewer
  46903. * @param skeleton defines the skeleton to render
  46904. * @param mesh defines the mesh attached to the skeleton
  46905. * @param scene defines the hosting scene
  46906. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46907. * @param renderingGroupId defines the rendering group id to use with the viewer
  46908. */
  46909. constructor(
  46910. /** defines the skeleton to render */
  46911. skeleton: Skeleton,
  46912. /** defines the mesh attached to the skeleton */
  46913. mesh: AbstractMesh, scene: Scene,
  46914. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46915. autoUpdateBonesMatrices?: boolean,
  46916. /** defines the rendering group id to use with the viewer */
  46917. renderingGroupId?: number);
  46918. /** Gets or sets a boolean indicating if the viewer is enabled */
  46919. set isEnabled(value: boolean);
  46920. get isEnabled(): boolean;
  46921. private _getBonePosition;
  46922. private _getLinesForBonesWithLength;
  46923. private _getLinesForBonesNoLength;
  46924. /** Update the viewer to sync with current skeleton state */
  46925. update(): void;
  46926. /** Release associated resources */
  46927. dispose(): void;
  46928. }
  46929. }
  46930. declare module BABYLON {
  46931. /**
  46932. * This class will take all inputs from Keyboard, Pointer, and
  46933. * any Gamepads and provide a polling system that all devices
  46934. * will use. This class assumes that there will only be one
  46935. * pointer device and one keyboard.
  46936. */
  46937. export class DeviceInputSystem implements IDisposable {
  46938. /** POINTER_DEVICE */
  46939. static readonly POINTER_DEVICE: string;
  46940. /** KEYBOARD_DEVICE */
  46941. static readonly KEYBOARD_DEVICE: string;
  46942. /**
  46943. * Observable to be triggered when a device is connected
  46944. */
  46945. onDeviceConnectedObservable: Observable<string>;
  46946. /**
  46947. * Observable to be triggered when a device is disconnected
  46948. */
  46949. onDeviceDisconnectedObservable: Observable<string>;
  46950. private _inputs;
  46951. private _gamepads;
  46952. private _keyboardActive;
  46953. private _pointerActive;
  46954. private _elementToAttachTo;
  46955. private _keyboardDownEvent;
  46956. private _keyboardUpEvent;
  46957. private _pointerMoveEvent;
  46958. private _pointerDownEvent;
  46959. private _pointerUpEvent;
  46960. private _gamepadConnectedEvent;
  46961. private _gamepadDisconnectedEvent;
  46962. private static _MAX_KEYCODES;
  46963. private static _MAX_POINTER_INPUTS;
  46964. /**
  46965. * Default Constructor
  46966. * @param engine - engine to pull input element from
  46967. */
  46968. constructor(engine: Engine);
  46969. /**
  46970. * Checks for current device input value, given an id and input index
  46971. * @param deviceName Id of connected device
  46972. * @param inputIndex Index of device input
  46973. * @returns Current value of input
  46974. */
  46975. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  46976. /**
  46977. * Dispose of all the eventlisteners and clears the observables
  46978. */
  46979. dispose(): void;
  46980. /**
  46981. * Add device and inputs to device map
  46982. * @param deviceName Assigned name of device (may be SN)
  46983. * @param numberOfInputs Number of input entries to create for given device
  46984. */
  46985. private _registerDevice;
  46986. /**
  46987. * Given a specific device name, remove that device from the device map
  46988. * @param deviceName Name of device to be removed
  46989. */
  46990. private _unregisterDevice;
  46991. /**
  46992. * Handle all actions that come from keyboard interaction
  46993. */
  46994. private _handleKeyActions;
  46995. /**
  46996. * Handle all actions that come from pointer interaction
  46997. */
  46998. private _handlePointerActions;
  46999. /**
  47000. * Handle all actions that come from gamepad interaction
  47001. */
  47002. private _handleGamepadActions;
  47003. /**
  47004. * Update all non-event based devices with each frame
  47005. */
  47006. private _updateDevice;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /**
  47011. * Options to create the null engine
  47012. */
  47013. export class NullEngineOptions {
  47014. /**
  47015. * Render width (Default: 512)
  47016. */
  47017. renderWidth: number;
  47018. /**
  47019. * Render height (Default: 256)
  47020. */
  47021. renderHeight: number;
  47022. /**
  47023. * Texture size (Default: 512)
  47024. */
  47025. textureSize: number;
  47026. /**
  47027. * If delta time between frames should be constant
  47028. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47029. */
  47030. deterministicLockstep: boolean;
  47031. /**
  47032. * Maximum about of steps between frames (Default: 4)
  47033. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47034. */
  47035. lockstepMaxSteps: number;
  47036. }
  47037. /**
  47038. * The null engine class provides support for headless version of babylon.js.
  47039. * This can be used in server side scenario or for testing purposes
  47040. */
  47041. export class NullEngine extends Engine {
  47042. private _options;
  47043. /**
  47044. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47045. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47046. * @returns true if engine is in deterministic lock step mode
  47047. */
  47048. isDeterministicLockStep(): boolean;
  47049. /**
  47050. * Gets the max steps when engine is running in deterministic lock step
  47051. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47052. * @returns the max steps
  47053. */
  47054. getLockstepMaxSteps(): number;
  47055. /**
  47056. * Gets the current hardware scaling level.
  47057. * By default the hardware scaling level is computed from the window device ratio.
  47058. * 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.
  47059. * @returns a number indicating the current hardware scaling level
  47060. */
  47061. getHardwareScalingLevel(): number;
  47062. constructor(options?: NullEngineOptions);
  47063. /**
  47064. * Creates a vertex buffer
  47065. * @param vertices the data for the vertex buffer
  47066. * @returns the new WebGL static buffer
  47067. */
  47068. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47069. /**
  47070. * Creates a new index buffer
  47071. * @param indices defines the content of the index buffer
  47072. * @param updatable defines if the index buffer must be updatable
  47073. * @returns a new webGL buffer
  47074. */
  47075. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47076. /**
  47077. * Clear the current render buffer or the current render target (if any is set up)
  47078. * @param color defines the color to use
  47079. * @param backBuffer defines if the back buffer must be cleared
  47080. * @param depth defines if the depth buffer must be cleared
  47081. * @param stencil defines if the stencil buffer must be cleared
  47082. */
  47083. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47084. /**
  47085. * Gets the current render width
  47086. * @param useScreen defines if screen size must be used (or the current render target if any)
  47087. * @returns a number defining the current render width
  47088. */
  47089. getRenderWidth(useScreen?: boolean): number;
  47090. /**
  47091. * Gets the current render height
  47092. * @param useScreen defines if screen size must be used (or the current render target if any)
  47093. * @returns a number defining the current render height
  47094. */
  47095. getRenderHeight(useScreen?: boolean): number;
  47096. /**
  47097. * Set the WebGL's viewport
  47098. * @param viewport defines the viewport element to be used
  47099. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47100. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47101. */
  47102. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47103. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47104. /**
  47105. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47106. * @param pipelineContext defines the pipeline context to use
  47107. * @param uniformsNames defines the list of uniform names
  47108. * @returns an array of webGL uniform locations
  47109. */
  47110. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47111. /**
  47112. * Gets the lsit of active attributes for a given webGL program
  47113. * @param pipelineContext defines the pipeline context to use
  47114. * @param attributesNames defines the list of attribute names to get
  47115. * @returns an array of indices indicating the offset of each attribute
  47116. */
  47117. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47118. /**
  47119. * Binds an effect to the webGL context
  47120. * @param effect defines the effect to bind
  47121. */
  47122. bindSamplers(effect: Effect): void;
  47123. /**
  47124. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47125. * @param effect defines the effect to activate
  47126. */
  47127. enableEffect(effect: Effect): void;
  47128. /**
  47129. * Set various states to the webGL context
  47130. * @param culling defines backface culling state
  47131. * @param zOffset defines the value to apply to zOffset (0 by default)
  47132. * @param force defines if states must be applied even if cache is up to date
  47133. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47134. */
  47135. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47136. /**
  47137. * Set the value of an uniform to an array of int32
  47138. * @param uniform defines the webGL uniform location where to store the value
  47139. * @param array defines the array of int32 to store
  47140. */
  47141. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47142. /**
  47143. * Set the value of an uniform to an array of int32 (stored as vec2)
  47144. * @param uniform defines the webGL uniform location where to store the value
  47145. * @param array defines the array of int32 to store
  47146. */
  47147. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47148. /**
  47149. * Set the value of an uniform to an array of int32 (stored as vec3)
  47150. * @param uniform defines the webGL uniform location where to store the value
  47151. * @param array defines the array of int32 to store
  47152. */
  47153. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47154. /**
  47155. * Set the value of an uniform to an array of int32 (stored as vec4)
  47156. * @param uniform defines the webGL uniform location where to store the value
  47157. * @param array defines the array of int32 to store
  47158. */
  47159. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47160. /**
  47161. * Set the value of an uniform to an array of float32
  47162. * @param uniform defines the webGL uniform location where to store the value
  47163. * @param array defines the array of float32 to store
  47164. */
  47165. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47166. /**
  47167. * Set the value of an uniform to an array of float32 (stored as vec2)
  47168. * @param uniform defines the webGL uniform location where to store the value
  47169. * @param array defines the array of float32 to store
  47170. */
  47171. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47172. /**
  47173. * Set the value of an uniform to an array of float32 (stored as vec3)
  47174. * @param uniform defines the webGL uniform location where to store the value
  47175. * @param array defines the array of float32 to store
  47176. */
  47177. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47178. /**
  47179. * Set the value of an uniform to an array of float32 (stored as vec4)
  47180. * @param uniform defines the webGL uniform location where to store the value
  47181. * @param array defines the array of float32 to store
  47182. */
  47183. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47184. /**
  47185. * Set the value of an uniform to an array of number
  47186. * @param uniform defines the webGL uniform location where to store the value
  47187. * @param array defines the array of number to store
  47188. */
  47189. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47190. /**
  47191. * Set the value of an uniform to an array of number (stored as vec2)
  47192. * @param uniform defines the webGL uniform location where to store the value
  47193. * @param array defines the array of number to store
  47194. */
  47195. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47196. /**
  47197. * Set the value of an uniform to an array of number (stored as vec3)
  47198. * @param uniform defines the webGL uniform location where to store the value
  47199. * @param array defines the array of number to store
  47200. */
  47201. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47202. /**
  47203. * Set the value of an uniform to an array of number (stored as vec4)
  47204. * @param uniform defines the webGL uniform location where to store the value
  47205. * @param array defines the array of number to store
  47206. */
  47207. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47208. /**
  47209. * Set the value of an uniform to an array of float32 (stored as matrices)
  47210. * @param uniform defines the webGL uniform location where to store the value
  47211. * @param matrices defines the array of float32 to store
  47212. */
  47213. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47214. /**
  47215. * Set the value of an uniform to a matrix (3x3)
  47216. * @param uniform defines the webGL uniform location where to store the value
  47217. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47218. */
  47219. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47220. /**
  47221. * Set the value of an uniform to a matrix (2x2)
  47222. * @param uniform defines the webGL uniform location where to store the value
  47223. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47224. */
  47225. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47226. /**
  47227. * Set the value of an uniform to a number (float)
  47228. * @param uniform defines the webGL uniform location where to store the value
  47229. * @param value defines the float number to store
  47230. */
  47231. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47232. /**
  47233. * Set the value of an uniform to a vec2
  47234. * @param uniform defines the webGL uniform location where to store the value
  47235. * @param x defines the 1st component of the value
  47236. * @param y defines the 2nd component of the value
  47237. */
  47238. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47239. /**
  47240. * Set the value of an uniform to a vec3
  47241. * @param uniform defines the webGL uniform location where to store the value
  47242. * @param x defines the 1st component of the value
  47243. * @param y defines the 2nd component of the value
  47244. * @param z defines the 3rd component of the value
  47245. */
  47246. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47247. /**
  47248. * Set the value of an uniform to a boolean
  47249. * @param uniform defines the webGL uniform location where to store the value
  47250. * @param bool defines the boolean to store
  47251. */
  47252. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47253. /**
  47254. * Set the value of an uniform to a vec4
  47255. * @param uniform defines the webGL uniform location where to store the value
  47256. * @param x defines the 1st component of the value
  47257. * @param y defines the 2nd component of the value
  47258. * @param z defines the 3rd component of the value
  47259. * @param w defines the 4th component of the value
  47260. */
  47261. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47262. /**
  47263. * Sets the current alpha mode
  47264. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47265. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47267. */
  47268. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47269. /**
  47270. * Bind webGl buffers directly to the webGL context
  47271. * @param vertexBuffers defines the vertex buffer to bind
  47272. * @param indexBuffer defines the index buffer to bind
  47273. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47274. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47275. * @param effect defines the effect associated with the vertex buffer
  47276. */
  47277. bindBuffers(vertexBuffers: {
  47278. [key: string]: VertexBuffer;
  47279. }, indexBuffer: DataBuffer, effect: Effect): void;
  47280. /**
  47281. * Force the entire cache to be cleared
  47282. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47283. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47284. */
  47285. wipeCaches(bruteForce?: boolean): void;
  47286. /**
  47287. * Send a draw order
  47288. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47289. * @param indexStart defines the starting index
  47290. * @param indexCount defines the number of index to draw
  47291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47292. */
  47293. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47294. /**
  47295. * Draw a list of indexed primitives
  47296. * @param fillMode defines the primitive to use
  47297. * @param indexStart defines the starting index
  47298. * @param indexCount defines the number of index to draw
  47299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47300. */
  47301. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47302. /**
  47303. * Draw a list of unindexed primitives
  47304. * @param fillMode defines the primitive to use
  47305. * @param verticesStart defines the index of first vertex to draw
  47306. * @param verticesCount defines the count of vertices to draw
  47307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47308. */
  47309. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47310. /** @hidden */
  47311. _createTexture(): WebGLTexture;
  47312. /** @hidden */
  47313. _releaseTexture(texture: InternalTexture): void;
  47314. /**
  47315. * Usually called from Texture.ts.
  47316. * Passed information to create a WebGLTexture
  47317. * @param urlArg defines a value which contains one of the following:
  47318. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47319. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47320. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47321. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47322. * @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)
  47323. * @param scene needed for loading to the correct scene
  47324. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47325. * @param onLoad optional callback to be called upon successful completion
  47326. * @param onError optional callback to be called upon failure
  47327. * @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
  47328. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47329. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47330. * @param forcedExtension defines the extension to use to pick the right loader
  47331. * @param mimeType defines an optional mime type
  47332. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47333. */
  47334. 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>, mimeType?: string): InternalTexture;
  47335. /**
  47336. * Creates a new render target texture
  47337. * @param size defines the size of the texture
  47338. * @param options defines the options used to create the texture
  47339. * @returns a new render target texture stored in an InternalTexture
  47340. */
  47341. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47342. /**
  47343. * Update the sampling mode of a given texture
  47344. * @param samplingMode defines the required sampling mode
  47345. * @param texture defines the texture to update
  47346. */
  47347. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47348. /**
  47349. * Binds the frame buffer to the specified texture.
  47350. * @param texture The texture to render to or null for the default canvas
  47351. * @param faceIndex The face of the texture to render to in case of cube texture
  47352. * @param requiredWidth The width of the target to render to
  47353. * @param requiredHeight The height of the target to render to
  47354. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47355. * @param lodLevel defines le lod level to bind to the frame buffer
  47356. */
  47357. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47358. /**
  47359. * Unbind the current render target texture from the webGL context
  47360. * @param texture defines the render target texture to unbind
  47361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47363. */
  47364. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47365. /**
  47366. * Creates a dynamic vertex buffer
  47367. * @param vertices the data for the dynamic vertex buffer
  47368. * @returns the new WebGL dynamic buffer
  47369. */
  47370. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47371. /**
  47372. * Update the content of a dynamic texture
  47373. * @param texture defines the texture to update
  47374. * @param canvas defines the canvas containing the source
  47375. * @param invertY defines if data must be stored with Y axis inverted
  47376. * @param premulAlpha defines if alpha is stored as premultiplied
  47377. * @param format defines the format of the data
  47378. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47379. */
  47380. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47381. /**
  47382. * Gets a boolean indicating if all created effects are ready
  47383. * @returns true if all effects are ready
  47384. */
  47385. areAllEffectsReady(): boolean;
  47386. /**
  47387. * @hidden
  47388. * Get the current error code of the webGL context
  47389. * @returns the error code
  47390. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47391. */
  47392. getError(): number;
  47393. /** @hidden */
  47394. _getUnpackAlignement(): number;
  47395. /** @hidden */
  47396. _unpackFlipY(value: boolean): void;
  47397. /**
  47398. * Update a dynamic index buffer
  47399. * @param indexBuffer defines the target index buffer
  47400. * @param indices defines the data to update
  47401. * @param offset defines the offset in the target index buffer where update should start
  47402. */
  47403. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47404. /**
  47405. * Updates a dynamic vertex buffer.
  47406. * @param vertexBuffer the vertex buffer to update
  47407. * @param vertices the data used to update the vertex buffer
  47408. * @param byteOffset the byte offset of the data (optional)
  47409. * @param byteLength the byte length of the data (optional)
  47410. */
  47411. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47412. /** @hidden */
  47413. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47414. /** @hidden */
  47415. _bindTexture(channel: number, texture: InternalTexture): void;
  47416. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47417. /**
  47418. * 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
  47419. */
  47420. releaseEffects(): void;
  47421. displayLoadingUI(): void;
  47422. hideLoadingUI(): void;
  47423. /** @hidden */
  47424. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47425. /** @hidden */
  47426. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47427. /** @hidden */
  47428. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47429. /** @hidden */
  47430. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47431. }
  47432. }
  47433. declare module BABYLON {
  47434. /**
  47435. * @hidden
  47436. **/
  47437. export class _TimeToken {
  47438. _startTimeQuery: Nullable<WebGLQuery>;
  47439. _endTimeQuery: Nullable<WebGLQuery>;
  47440. _timeElapsedQuery: Nullable<WebGLQuery>;
  47441. _timeElapsedQueryEnded: boolean;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. /** @hidden */
  47446. export class _OcclusionDataStorage {
  47447. /** @hidden */
  47448. occlusionInternalRetryCounter: number;
  47449. /** @hidden */
  47450. isOcclusionQueryInProgress: boolean;
  47451. /** @hidden */
  47452. isOccluded: boolean;
  47453. /** @hidden */
  47454. occlusionRetryCount: number;
  47455. /** @hidden */
  47456. occlusionType: number;
  47457. /** @hidden */
  47458. occlusionQueryAlgorithmType: number;
  47459. }
  47460. interface Engine {
  47461. /**
  47462. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47463. * @return the new query
  47464. */
  47465. createQuery(): WebGLQuery;
  47466. /**
  47467. * Delete and release a webGL query
  47468. * @param query defines the query to delete
  47469. * @return the current engine
  47470. */
  47471. deleteQuery(query: WebGLQuery): Engine;
  47472. /**
  47473. * Check if a given query has resolved and got its value
  47474. * @param query defines the query to check
  47475. * @returns true if the query got its value
  47476. */
  47477. isQueryResultAvailable(query: WebGLQuery): boolean;
  47478. /**
  47479. * Gets the value of a given query
  47480. * @param query defines the query to check
  47481. * @returns the value of the query
  47482. */
  47483. getQueryResult(query: WebGLQuery): number;
  47484. /**
  47485. * Initiates an occlusion query
  47486. * @param algorithmType defines the algorithm to use
  47487. * @param query defines the query to use
  47488. * @returns the current engine
  47489. * @see http://doc.babylonjs.com/features/occlusionquery
  47490. */
  47491. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47492. /**
  47493. * Ends an occlusion query
  47494. * @see http://doc.babylonjs.com/features/occlusionquery
  47495. * @param algorithmType defines the algorithm to use
  47496. * @returns the current engine
  47497. */
  47498. endOcclusionQuery(algorithmType: number): Engine;
  47499. /**
  47500. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47501. * Please note that only one query can be issued at a time
  47502. * @returns a time token used to track the time span
  47503. */
  47504. startTimeQuery(): Nullable<_TimeToken>;
  47505. /**
  47506. * Ends a time query
  47507. * @param token defines the token used to measure the time span
  47508. * @returns the time spent (in ns)
  47509. */
  47510. endTimeQuery(token: _TimeToken): int;
  47511. /** @hidden */
  47512. _currentNonTimestampToken: Nullable<_TimeToken>;
  47513. /** @hidden */
  47514. _createTimeQuery(): WebGLQuery;
  47515. /** @hidden */
  47516. _deleteTimeQuery(query: WebGLQuery): void;
  47517. /** @hidden */
  47518. _getGlAlgorithmType(algorithmType: number): number;
  47519. /** @hidden */
  47520. _getTimeQueryResult(query: WebGLQuery): any;
  47521. /** @hidden */
  47522. _getTimeQueryAvailability(query: WebGLQuery): any;
  47523. }
  47524. interface AbstractMesh {
  47525. /**
  47526. * Backing filed
  47527. * @hidden
  47528. */
  47529. __occlusionDataStorage: _OcclusionDataStorage;
  47530. /**
  47531. * Access property
  47532. * @hidden
  47533. */
  47534. _occlusionDataStorage: _OcclusionDataStorage;
  47535. /**
  47536. * 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.
  47537. * The default value is -1 which means don't break the query and wait till the result
  47538. * @see http://doc.babylonjs.com/features/occlusionquery
  47539. */
  47540. occlusionRetryCount: number;
  47541. /**
  47542. * 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:
  47543. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47544. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47545. * * 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.
  47546. * @see http://doc.babylonjs.com/features/occlusionquery
  47547. */
  47548. occlusionType: number;
  47549. /**
  47550. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47551. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47552. * * 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.
  47553. * @see http://doc.babylonjs.com/features/occlusionquery
  47554. */
  47555. occlusionQueryAlgorithmType: number;
  47556. /**
  47557. * 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
  47558. * @see http://doc.babylonjs.com/features/occlusionquery
  47559. */
  47560. isOccluded: boolean;
  47561. /**
  47562. * Flag to check the progress status of the query
  47563. * @see http://doc.babylonjs.com/features/occlusionquery
  47564. */
  47565. isOcclusionQueryInProgress: boolean;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /** @hidden */
  47570. export var _forceTransformFeedbackToBundle: boolean;
  47571. interface Engine {
  47572. /**
  47573. * Creates a webGL transform feedback object
  47574. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47575. * @returns the webGL transform feedback object
  47576. */
  47577. createTransformFeedback(): WebGLTransformFeedback;
  47578. /**
  47579. * Delete a webGL transform feedback object
  47580. * @param value defines the webGL transform feedback object to delete
  47581. */
  47582. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47583. /**
  47584. * Bind a webGL transform feedback object to the webgl context
  47585. * @param value defines the webGL transform feedback object to bind
  47586. */
  47587. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47588. /**
  47589. * Begins a transform feedback operation
  47590. * @param usePoints defines if points or triangles must be used
  47591. */
  47592. beginTransformFeedback(usePoints: boolean): void;
  47593. /**
  47594. * Ends a transform feedback operation
  47595. */
  47596. endTransformFeedback(): void;
  47597. /**
  47598. * Specify the varyings to use with transform feedback
  47599. * @param program defines the associated webGL program
  47600. * @param value defines the list of strings representing the varying names
  47601. */
  47602. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47603. /**
  47604. * Bind a webGL buffer for a transform feedback operation
  47605. * @param value defines the webGL buffer to bind
  47606. */
  47607. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47608. }
  47609. }
  47610. declare module BABYLON {
  47611. /**
  47612. * Creation options of the multi render target texture.
  47613. */
  47614. export interface IMultiRenderTargetOptions {
  47615. /**
  47616. * Define if the texture needs to create mip maps after render.
  47617. */
  47618. generateMipMaps?: boolean;
  47619. /**
  47620. * Define the types of all the draw buffers we want to create
  47621. */
  47622. types?: number[];
  47623. /**
  47624. * Define the sampling modes of all the draw buffers we want to create
  47625. */
  47626. samplingModes?: number[];
  47627. /**
  47628. * Define if a depth buffer is required
  47629. */
  47630. generateDepthBuffer?: boolean;
  47631. /**
  47632. * Define if a stencil buffer is required
  47633. */
  47634. generateStencilBuffer?: boolean;
  47635. /**
  47636. * Define if a depth texture is required instead of a depth buffer
  47637. */
  47638. generateDepthTexture?: boolean;
  47639. /**
  47640. * Define the number of desired draw buffers
  47641. */
  47642. textureCount?: number;
  47643. /**
  47644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47645. */
  47646. doNotChangeAspectRatio?: boolean;
  47647. /**
  47648. * Define the default type of the buffers we are creating
  47649. */
  47650. defaultType?: number;
  47651. }
  47652. /**
  47653. * A multi render target, like a render target provides the ability to render to a texture.
  47654. * Unlike the render target, it can render to several draw buffers in one draw.
  47655. * This is specially interesting in deferred rendering or for any effects requiring more than
  47656. * just one color from a single pass.
  47657. */
  47658. export class MultiRenderTarget extends RenderTargetTexture {
  47659. private _internalTextures;
  47660. private _textures;
  47661. private _multiRenderTargetOptions;
  47662. /**
  47663. * Get if draw buffers are currently supported by the used hardware and browser.
  47664. */
  47665. get isSupported(): boolean;
  47666. /**
  47667. * Get the list of textures generated by the multi render target.
  47668. */
  47669. get textures(): Texture[];
  47670. /**
  47671. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47672. */
  47673. get depthTexture(): Texture;
  47674. /**
  47675. * Set the wrapping mode on U of all the textures we are rendering to.
  47676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47677. */
  47678. set wrapU(wrap: number);
  47679. /**
  47680. * Set the wrapping mode on V of all the textures we are rendering to.
  47681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47682. */
  47683. set wrapV(wrap: number);
  47684. /**
  47685. * Instantiate a new multi render target texture.
  47686. * A multi render target, like a render target provides the ability to render to a texture.
  47687. * Unlike the render target, it can render to several draw buffers in one draw.
  47688. * This is specially interesting in deferred rendering or for any effects requiring more than
  47689. * just one color from a single pass.
  47690. * @param name Define the name of the texture
  47691. * @param size Define the size of the buffers to render to
  47692. * @param count Define the number of target we are rendering into
  47693. * @param scene Define the scene the texture belongs to
  47694. * @param options Define the options used to create the multi render target
  47695. */
  47696. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47697. /** @hidden */
  47698. _rebuild(): void;
  47699. private _createInternalTextures;
  47700. private _createTextures;
  47701. /**
  47702. * Define the number of samples used if MSAA is enabled.
  47703. */
  47704. get samples(): number;
  47705. set samples(value: number);
  47706. /**
  47707. * Resize all the textures in the multi render target.
  47708. * Be carrefull as it will recreate all the data in the new texture.
  47709. * @param size Define the new size
  47710. */
  47711. resize(size: any): void;
  47712. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47713. /**
  47714. * Dispose the render targets and their associated resources
  47715. */
  47716. dispose(): void;
  47717. /**
  47718. * Release all the underlying texture used as draw buffers.
  47719. */
  47720. releaseInternalTextures(): void;
  47721. }
  47722. }
  47723. declare module BABYLON {
  47724. interface ThinEngine {
  47725. /**
  47726. * Unbind a list of render target textures from the webGL context
  47727. * This is used only when drawBuffer extension or webGL2 are active
  47728. * @param textures defines the render target textures to unbind
  47729. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47730. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47731. */
  47732. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47733. /**
  47734. * Create a multi render target texture
  47735. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47736. * @param size defines the size of the texture
  47737. * @param options defines the creation options
  47738. * @returns the cube texture as an InternalTexture
  47739. */
  47740. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47741. /**
  47742. * Update the sample count for a given multiple render target texture
  47743. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47744. * @param textures defines the textures to update
  47745. * @param samples defines the sample count to set
  47746. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47747. */
  47748. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47749. }
  47750. }
  47751. declare module BABYLON {
  47752. /**
  47753. * Class used to define an additional view for the engine
  47754. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47755. */
  47756. export class EngineView {
  47757. /** Defines the canvas where to render the view */
  47758. target: HTMLCanvasElement;
  47759. /** Defines an optional camera used to render the view (will use active camera else) */
  47760. camera?: Camera;
  47761. }
  47762. interface Engine {
  47763. /**
  47764. * Gets or sets the HTML element to use for attaching events
  47765. */
  47766. inputElement: Nullable<HTMLElement>;
  47767. /**
  47768. * Gets the current engine view
  47769. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47770. */
  47771. activeView: Nullable<EngineView>;
  47772. /** Gets or sets the list of views */
  47773. views: EngineView[];
  47774. /**
  47775. * Register a new child canvas
  47776. * @param canvas defines the canvas to register
  47777. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47778. * @returns the associated view
  47779. */
  47780. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47781. /**
  47782. * Remove a registered child canvas
  47783. * @param canvas defines the canvas to remove
  47784. * @returns the current engine
  47785. */
  47786. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47787. }
  47788. }
  47789. declare module BABYLON {
  47790. interface Engine {
  47791. /** @hidden */
  47792. _excludedCompressedTextures: string[];
  47793. /** @hidden */
  47794. _textureFormatInUse: string;
  47795. /**
  47796. * Gets the list of texture formats supported
  47797. */
  47798. readonly texturesSupported: Array<string>;
  47799. /**
  47800. * Gets the texture format in use
  47801. */
  47802. readonly textureFormatInUse: Nullable<string>;
  47803. /**
  47804. * Set the compressed texture extensions or file names to skip.
  47805. *
  47806. * @param skippedFiles defines the list of those texture files you want to skip
  47807. * Example: [".dds", ".env", "myfile.png"]
  47808. */
  47809. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47810. /**
  47811. * Set the compressed texture format to use, based on the formats you have, and the formats
  47812. * supported by the hardware / browser.
  47813. *
  47814. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47815. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47816. * to API arguments needed to compressed textures. This puts the burden on the container
  47817. * generator to house the arcane code for determining these for current & future formats.
  47818. *
  47819. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47820. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47821. *
  47822. * Note: The result of this call is not taken into account when a texture is base64.
  47823. *
  47824. * @param formatsAvailable defines the list of those format families you have created
  47825. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47826. *
  47827. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47828. * @returns The extension selected.
  47829. */
  47830. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47831. }
  47832. }
  47833. declare module BABYLON {
  47834. /**
  47835. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47836. */
  47837. export interface CubeMapInfo {
  47838. /**
  47839. * The pixel array for the front face.
  47840. * This is stored in format, left to right, up to down format.
  47841. */
  47842. front: Nullable<ArrayBufferView>;
  47843. /**
  47844. * The pixel array for the back face.
  47845. * This is stored in format, left to right, up to down format.
  47846. */
  47847. back: Nullable<ArrayBufferView>;
  47848. /**
  47849. * The pixel array for the left face.
  47850. * This is stored in format, left to right, up to down format.
  47851. */
  47852. left: Nullable<ArrayBufferView>;
  47853. /**
  47854. * The pixel array for the right face.
  47855. * This is stored in format, left to right, up to down format.
  47856. */
  47857. right: Nullable<ArrayBufferView>;
  47858. /**
  47859. * The pixel array for the up face.
  47860. * This is stored in format, left to right, up to down format.
  47861. */
  47862. up: Nullable<ArrayBufferView>;
  47863. /**
  47864. * The pixel array for the down face.
  47865. * This is stored in format, left to right, up to down format.
  47866. */
  47867. down: Nullable<ArrayBufferView>;
  47868. /**
  47869. * The size of the cubemap stored.
  47870. *
  47871. * Each faces will be size * size pixels.
  47872. */
  47873. size: number;
  47874. /**
  47875. * The format of the texture.
  47876. *
  47877. * RGBA, RGB.
  47878. */
  47879. format: number;
  47880. /**
  47881. * The type of the texture data.
  47882. *
  47883. * UNSIGNED_INT, FLOAT.
  47884. */
  47885. type: number;
  47886. /**
  47887. * Specifies whether the texture is in gamma space.
  47888. */
  47889. gammaSpace: boolean;
  47890. }
  47891. /**
  47892. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47893. */
  47894. export class PanoramaToCubeMapTools {
  47895. private static FACE_FRONT;
  47896. private static FACE_BACK;
  47897. private static FACE_RIGHT;
  47898. private static FACE_LEFT;
  47899. private static FACE_DOWN;
  47900. private static FACE_UP;
  47901. /**
  47902. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47903. *
  47904. * @param float32Array The source data.
  47905. * @param inputWidth The width of the input panorama.
  47906. * @param inputHeight The height of the input panorama.
  47907. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47908. * @return The cubemap data
  47909. */
  47910. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47911. private static CreateCubemapTexture;
  47912. private static CalcProjectionSpherical;
  47913. }
  47914. }
  47915. declare module BABYLON {
  47916. /**
  47917. * Helper class dealing with the extraction of spherical polynomial dataArray
  47918. * from a cube map.
  47919. */
  47920. export class CubeMapToSphericalPolynomialTools {
  47921. private static FileFaces;
  47922. /**
  47923. * Converts a texture to the according Spherical Polynomial data.
  47924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47925. *
  47926. * @param texture The texture to extract the information from.
  47927. * @return The Spherical Polynomial data.
  47928. */
  47929. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47930. /**
  47931. * Converts a cubemap to the according Spherical Polynomial data.
  47932. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47933. *
  47934. * @param cubeInfo The Cube map to extract the information from.
  47935. * @return The Spherical Polynomial data.
  47936. */
  47937. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. interface BaseTexture {
  47942. /**
  47943. * Get the polynomial representation of the texture data.
  47944. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47945. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47946. */
  47947. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47948. }
  47949. }
  47950. declare module BABYLON {
  47951. /** @hidden */
  47952. export var rgbdEncodePixelShader: {
  47953. name: string;
  47954. shader: string;
  47955. };
  47956. }
  47957. declare module BABYLON {
  47958. /** @hidden */
  47959. export var rgbdDecodePixelShader: {
  47960. name: string;
  47961. shader: string;
  47962. };
  47963. }
  47964. declare module BABYLON {
  47965. /**
  47966. * Raw texture data and descriptor sufficient for WebGL texture upload
  47967. */
  47968. export interface EnvironmentTextureInfo {
  47969. /**
  47970. * Version of the environment map
  47971. */
  47972. version: number;
  47973. /**
  47974. * Width of image
  47975. */
  47976. width: number;
  47977. /**
  47978. * Irradiance information stored in the file.
  47979. */
  47980. irradiance: any;
  47981. /**
  47982. * Specular information stored in the file.
  47983. */
  47984. specular: any;
  47985. }
  47986. /**
  47987. * Defines One Image in the file. It requires only the position in the file
  47988. * as well as the length.
  47989. */
  47990. interface BufferImageData {
  47991. /**
  47992. * Length of the image data.
  47993. */
  47994. length: number;
  47995. /**
  47996. * Position of the data from the null terminator delimiting the end of the JSON.
  47997. */
  47998. position: number;
  47999. }
  48000. /**
  48001. * Defines the specular data enclosed in the file.
  48002. * This corresponds to the version 1 of the data.
  48003. */
  48004. export interface EnvironmentTextureSpecularInfoV1 {
  48005. /**
  48006. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48007. */
  48008. specularDataPosition?: number;
  48009. /**
  48010. * This contains all the images data needed to reconstruct the cubemap.
  48011. */
  48012. mipmaps: Array<BufferImageData>;
  48013. /**
  48014. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48015. */
  48016. lodGenerationScale: number;
  48017. }
  48018. /**
  48019. * Sets of helpers addressing the serialization and deserialization of environment texture
  48020. * stored in a BabylonJS env file.
  48021. * Those files are usually stored as .env files.
  48022. */
  48023. export class EnvironmentTextureTools {
  48024. /**
  48025. * Magic number identifying the env file.
  48026. */
  48027. private static _MagicBytes;
  48028. /**
  48029. * Gets the environment info from an env file.
  48030. * @param data The array buffer containing the .env bytes.
  48031. * @returns the environment file info (the json header) if successfully parsed.
  48032. */
  48033. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48034. /**
  48035. * Creates an environment texture from a loaded cube texture.
  48036. * @param texture defines the cube texture to convert in env file
  48037. * @return a promise containing the environment data if succesfull.
  48038. */
  48039. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48040. /**
  48041. * Creates a JSON representation of the spherical data.
  48042. * @param texture defines the texture containing the polynomials
  48043. * @return the JSON representation of the spherical info
  48044. */
  48045. private static _CreateEnvTextureIrradiance;
  48046. /**
  48047. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48048. * @param data the image data
  48049. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48050. * @return the views described by info providing access to the underlying buffer
  48051. */
  48052. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48053. /**
  48054. * Uploads the texture info contained in the env file to the GPU.
  48055. * @param texture defines the internal texture to upload to
  48056. * @param data defines the data to load
  48057. * @param info defines the texture info retrieved through the GetEnvInfo method
  48058. * @returns a promise
  48059. */
  48060. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48061. private static _OnImageReadyAsync;
  48062. /**
  48063. * Uploads the levels of image data to the GPU.
  48064. * @param texture defines the internal texture to upload to
  48065. * @param imageData defines the array buffer views of image data [mipmap][face]
  48066. * @returns a promise
  48067. */
  48068. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48069. /**
  48070. * Uploads spherical polynomials information to the texture.
  48071. * @param texture defines the texture we are trying to upload the information to
  48072. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48073. */
  48074. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48075. /** @hidden */
  48076. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Contains position and normal vectors for a vertex
  48082. */
  48083. export class PositionNormalVertex {
  48084. /** the position of the vertex (defaut: 0,0,0) */
  48085. position: Vector3;
  48086. /** the normal of the vertex (defaut: 0,1,0) */
  48087. normal: Vector3;
  48088. /**
  48089. * Creates a PositionNormalVertex
  48090. * @param position the position of the vertex (defaut: 0,0,0)
  48091. * @param normal the normal of the vertex (defaut: 0,1,0)
  48092. */
  48093. constructor(
  48094. /** the position of the vertex (defaut: 0,0,0) */
  48095. position?: Vector3,
  48096. /** the normal of the vertex (defaut: 0,1,0) */
  48097. normal?: Vector3);
  48098. /**
  48099. * Clones the PositionNormalVertex
  48100. * @returns the cloned PositionNormalVertex
  48101. */
  48102. clone(): PositionNormalVertex;
  48103. }
  48104. /**
  48105. * Contains position, normal and uv vectors for a vertex
  48106. */
  48107. export class PositionNormalTextureVertex {
  48108. /** the position of the vertex (defaut: 0,0,0) */
  48109. position: Vector3;
  48110. /** the normal of the vertex (defaut: 0,1,0) */
  48111. normal: Vector3;
  48112. /** the uv of the vertex (default: 0,0) */
  48113. uv: Vector2;
  48114. /**
  48115. * Creates a PositionNormalTextureVertex
  48116. * @param position the position of the vertex (defaut: 0,0,0)
  48117. * @param normal the normal of the vertex (defaut: 0,1,0)
  48118. * @param uv the uv of the vertex (default: 0,0)
  48119. */
  48120. constructor(
  48121. /** the position of the vertex (defaut: 0,0,0) */
  48122. position?: Vector3,
  48123. /** the normal of the vertex (defaut: 0,1,0) */
  48124. normal?: Vector3,
  48125. /** the uv of the vertex (default: 0,0) */
  48126. uv?: Vector2);
  48127. /**
  48128. * Clones the PositionNormalTextureVertex
  48129. * @returns the cloned PositionNormalTextureVertex
  48130. */
  48131. clone(): PositionNormalTextureVertex;
  48132. }
  48133. }
  48134. declare module BABYLON {
  48135. /** @hidden */
  48136. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48137. private _genericAttributeLocation;
  48138. private _varyingLocationCount;
  48139. private _varyingLocationMap;
  48140. private _replacements;
  48141. private _textureCount;
  48142. private _uniforms;
  48143. lineProcessor(line: string): string;
  48144. attributeProcessor(attribute: string): string;
  48145. varyingProcessor(varying: string, isFragment: boolean): string;
  48146. uniformProcessor(uniform: string): string;
  48147. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48148. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48149. }
  48150. }
  48151. declare module BABYLON {
  48152. /**
  48153. * Container for accessors for natively-stored mesh data buffers.
  48154. */
  48155. class NativeDataBuffer extends DataBuffer {
  48156. /**
  48157. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48158. */
  48159. nativeIndexBuffer?: any;
  48160. /**
  48161. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48162. */
  48163. nativeVertexBuffer?: any;
  48164. }
  48165. /** @hidden */
  48166. class NativeTexture extends InternalTexture {
  48167. getInternalTexture(): InternalTexture;
  48168. getViewCount(): number;
  48169. }
  48170. /** @hidden */
  48171. export class NativeEngine extends Engine {
  48172. private readonly _native;
  48173. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48174. private readonly INVALID_HANDLE;
  48175. getHardwareScalingLevel(): number;
  48176. constructor();
  48177. dispose(): void;
  48178. /**
  48179. * Can be used to override the current requestAnimationFrame requester.
  48180. * @hidden
  48181. */
  48182. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48183. /**
  48184. * Override default engine behavior.
  48185. * @param color
  48186. * @param backBuffer
  48187. * @param depth
  48188. * @param stencil
  48189. */
  48190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48191. /**
  48192. * Gets host document
  48193. * @returns the host document object
  48194. */
  48195. getHostDocument(): Nullable<Document>;
  48196. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48197. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48198. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48199. recordVertexArrayObject(vertexBuffers: {
  48200. [key: string]: VertexBuffer;
  48201. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48202. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48203. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48204. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48205. /**
  48206. * Draw a list of indexed primitives
  48207. * @param fillMode defines the primitive to use
  48208. * @param indexStart defines the starting index
  48209. * @param indexCount defines the number of index to draw
  48210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48211. */
  48212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48213. /**
  48214. * Draw a list of unindexed primitives
  48215. * @param fillMode defines the primitive to use
  48216. * @param verticesStart defines the index of first vertex to draw
  48217. * @param verticesCount defines the count of vertices to draw
  48218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48219. */
  48220. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48221. createPipelineContext(): IPipelineContext;
  48222. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48223. /** @hidden */
  48224. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48225. /** @hidden */
  48226. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48227. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48228. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48229. protected _setProgram(program: WebGLProgram): void;
  48230. _releaseEffect(effect: Effect): void;
  48231. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48232. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48233. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48234. bindSamplers(effect: Effect): void;
  48235. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48236. getRenderWidth(useScreen?: boolean): number;
  48237. getRenderHeight(useScreen?: boolean): number;
  48238. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48239. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48240. /**
  48241. * Set the z offset to apply to current rendering
  48242. * @param value defines the offset to apply
  48243. */
  48244. setZOffset(value: number): void;
  48245. /**
  48246. * Gets the current value of the zOffset
  48247. * @returns the current zOffset state
  48248. */
  48249. getZOffset(): number;
  48250. /**
  48251. * Enable or disable depth buffering
  48252. * @param enable defines the state to set
  48253. */
  48254. setDepthBuffer(enable: boolean): void;
  48255. /**
  48256. * Gets a boolean indicating if depth writing is enabled
  48257. * @returns the current depth writing state
  48258. */
  48259. getDepthWrite(): boolean;
  48260. /**
  48261. * Enable or disable depth writing
  48262. * @param enable defines the state to set
  48263. */
  48264. setDepthWrite(enable: boolean): void;
  48265. /**
  48266. * Enable or disable color writing
  48267. * @param enable defines the state to set
  48268. */
  48269. setColorWrite(enable: boolean): void;
  48270. /**
  48271. * Gets a boolean indicating if color writing is enabled
  48272. * @returns the current color writing state
  48273. */
  48274. getColorWrite(): boolean;
  48275. /**
  48276. * Sets alpha constants used by some alpha blending modes
  48277. * @param r defines the red component
  48278. * @param g defines the green component
  48279. * @param b defines the blue component
  48280. * @param a defines the alpha component
  48281. */
  48282. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48283. /**
  48284. * Sets the current alpha mode
  48285. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48286. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48288. */
  48289. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48290. /**
  48291. * Gets the current alpha mode
  48292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48293. * @returns the current alpha mode
  48294. */
  48295. getAlphaMode(): number;
  48296. setInt(uniform: WebGLUniformLocation, int: number): void;
  48297. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48298. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48299. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48300. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48301. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48302. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48303. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48304. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48305. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48306. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48307. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48308. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48309. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48310. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48311. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48312. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48313. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48314. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48315. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48316. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48317. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48318. wipeCaches(bruteForce?: boolean): void;
  48319. _createTexture(): WebGLTexture;
  48320. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48321. /**
  48322. * Usually called from Texture.ts.
  48323. * Passed information to create a WebGLTexture
  48324. * @param url defines a value which contains one of the following:
  48325. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48326. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48327. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48328. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48329. * @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)
  48330. * @param scene needed for loading to the correct scene
  48331. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48332. * @param onLoad optional callback to be called upon successful completion
  48333. * @param onError optional callback to be called upon failure
  48334. * @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
  48335. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48336. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48337. * @param forcedExtension defines the extension to use to pick the right loader
  48338. * @param mimeType defines an optional mime type
  48339. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48340. */
  48341. createTexture(url: 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>, mimeType?: string): InternalTexture;
  48342. /**
  48343. * Creates a cube texture
  48344. * @param rootUrl defines the url where the files to load is located
  48345. * @param scene defines the current scene
  48346. * @param files defines the list of files to load (1 per face)
  48347. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48348. * @param onLoad defines an optional callback raised when the texture is loaded
  48349. * @param onError defines an optional callback raised if there is an issue to load the texture
  48350. * @param format defines the format of the data
  48351. * @param forcedExtension defines the extension to use to pick the right loader
  48352. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48353. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48354. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48355. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48356. * @returns the cube texture as an InternalTexture
  48357. */
  48358. 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;
  48359. private _getSamplingFilter;
  48360. private static _GetNativeTextureFormat;
  48361. createRenderTargetTexture(size: number | {
  48362. width: number;
  48363. height: number;
  48364. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48365. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48366. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48367. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48368. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48369. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48370. /**
  48371. * Updates a dynamic vertex buffer.
  48372. * @param vertexBuffer the vertex buffer to update
  48373. * @param data the data used to update the vertex buffer
  48374. * @param byteOffset the byte offset of the data (optional)
  48375. * @param byteLength the byte length of the data (optional)
  48376. */
  48377. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48378. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48379. private _updateAnisotropicLevel;
  48380. private _getAddressMode;
  48381. /** @hidden */
  48382. _bindTexture(channel: number, texture: InternalTexture): void;
  48383. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48384. releaseEffects(): void;
  48385. /** @hidden */
  48386. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48387. /** @hidden */
  48388. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48389. /** @hidden */
  48390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48391. /** @hidden */
  48392. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Gather the list of clipboard event types as constants.
  48398. */
  48399. export class ClipboardEventTypes {
  48400. /**
  48401. * The clipboard event is fired when a copy command is active (pressed).
  48402. */
  48403. static readonly COPY: number;
  48404. /**
  48405. * The clipboard event is fired when a cut command is active (pressed).
  48406. */
  48407. static readonly CUT: number;
  48408. /**
  48409. * The clipboard event is fired when a paste command is active (pressed).
  48410. */
  48411. static readonly PASTE: number;
  48412. }
  48413. /**
  48414. * This class is used to store clipboard related info for the onClipboardObservable event.
  48415. */
  48416. export class ClipboardInfo {
  48417. /**
  48418. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48419. */
  48420. type: number;
  48421. /**
  48422. * Defines the related dom event
  48423. */
  48424. event: ClipboardEvent;
  48425. /**
  48426. *Creates an instance of ClipboardInfo.
  48427. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48428. * @param event Defines the related dom event
  48429. */
  48430. constructor(
  48431. /**
  48432. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48433. */
  48434. type: number,
  48435. /**
  48436. * Defines the related dom event
  48437. */
  48438. event: ClipboardEvent);
  48439. /**
  48440. * Get the clipboard event's type from the keycode.
  48441. * @param keyCode Defines the keyCode for the current keyboard event.
  48442. * @return {number}
  48443. */
  48444. static GetTypeFromCharacter(keyCode: number): number;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Google Daydream controller
  48450. */
  48451. export class DaydreamController extends WebVRController {
  48452. /**
  48453. * Base Url for the controller model.
  48454. */
  48455. static MODEL_BASE_URL: string;
  48456. /**
  48457. * File name for the controller model.
  48458. */
  48459. static MODEL_FILENAME: string;
  48460. /**
  48461. * Gamepad Id prefix used to identify Daydream Controller.
  48462. */
  48463. static readonly GAMEPAD_ID_PREFIX: string;
  48464. /**
  48465. * Creates a new DaydreamController from a gamepad
  48466. * @param vrGamepad the gamepad that the controller should be created from
  48467. */
  48468. constructor(vrGamepad: any);
  48469. /**
  48470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48471. * @param scene scene in which to add meshes
  48472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48473. */
  48474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48475. /**
  48476. * Called once for each button that changed state since the last frame
  48477. * @param buttonIdx Which button index changed
  48478. * @param state New state of the button
  48479. * @param changes Which properties on the state changed since last frame
  48480. */
  48481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48482. }
  48483. }
  48484. declare module BABYLON {
  48485. /**
  48486. * Gear VR Controller
  48487. */
  48488. export class GearVRController extends WebVRController {
  48489. /**
  48490. * Base Url for the controller model.
  48491. */
  48492. static MODEL_BASE_URL: string;
  48493. /**
  48494. * File name for the controller model.
  48495. */
  48496. static MODEL_FILENAME: string;
  48497. /**
  48498. * Gamepad Id prefix used to identify this controller.
  48499. */
  48500. static readonly GAMEPAD_ID_PREFIX: string;
  48501. private readonly _buttonIndexToObservableNameMap;
  48502. /**
  48503. * Creates a new GearVRController from a gamepad
  48504. * @param vrGamepad the gamepad that the controller should be created from
  48505. */
  48506. constructor(vrGamepad: any);
  48507. /**
  48508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48509. * @param scene scene in which to add meshes
  48510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48511. */
  48512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48513. /**
  48514. * Called once for each button that changed state since the last frame
  48515. * @param buttonIdx Which button index changed
  48516. * @param state New state of the button
  48517. * @param changes Which properties on the state changed since last frame
  48518. */
  48519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48520. }
  48521. }
  48522. declare module BABYLON {
  48523. /**
  48524. * Generic Controller
  48525. */
  48526. export class GenericController extends WebVRController {
  48527. /**
  48528. * Base Url for the controller model.
  48529. */
  48530. static readonly MODEL_BASE_URL: string;
  48531. /**
  48532. * File name for the controller model.
  48533. */
  48534. static readonly MODEL_FILENAME: string;
  48535. /**
  48536. * Creates a new GenericController from a gamepad
  48537. * @param vrGamepad the gamepad that the controller should be created from
  48538. */
  48539. constructor(vrGamepad: any);
  48540. /**
  48541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48542. * @param scene scene in which to add meshes
  48543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48544. */
  48545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48546. /**
  48547. * Called once for each button that changed state since the last frame
  48548. * @param buttonIdx Which button index changed
  48549. * @param state New state of the button
  48550. * @param changes Which properties on the state changed since last frame
  48551. */
  48552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48553. }
  48554. }
  48555. declare module BABYLON {
  48556. /**
  48557. * Oculus Touch Controller
  48558. */
  48559. export class OculusTouchController extends WebVRController {
  48560. /**
  48561. * Base Url for the controller model.
  48562. */
  48563. static MODEL_BASE_URL: string;
  48564. /**
  48565. * File name for the left controller model.
  48566. */
  48567. static MODEL_LEFT_FILENAME: string;
  48568. /**
  48569. * File name for the right controller model.
  48570. */
  48571. static MODEL_RIGHT_FILENAME: string;
  48572. /**
  48573. * Base Url for the Quest controller model.
  48574. */
  48575. static QUEST_MODEL_BASE_URL: string;
  48576. /**
  48577. * @hidden
  48578. * If the controllers are running on a device that needs the updated Quest controller models
  48579. */
  48580. static _IsQuest: boolean;
  48581. /**
  48582. * Fired when the secondary trigger on this controller is modified
  48583. */
  48584. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48585. /**
  48586. * Fired when the thumb rest on this controller is modified
  48587. */
  48588. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48589. /**
  48590. * Creates a new OculusTouchController from a gamepad
  48591. * @param vrGamepad the gamepad that the controller should be created from
  48592. */
  48593. constructor(vrGamepad: any);
  48594. /**
  48595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48596. * @param scene scene in which to add meshes
  48597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48598. */
  48599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48600. /**
  48601. * Fired when the A button on this controller is modified
  48602. */
  48603. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48604. /**
  48605. * Fired when the B button on this controller is modified
  48606. */
  48607. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48608. /**
  48609. * Fired when the X button on this controller is modified
  48610. */
  48611. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48612. /**
  48613. * Fired when the Y button on this controller is modified
  48614. */
  48615. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48616. /**
  48617. * Called once for each button that changed state since the last frame
  48618. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48619. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48620. * 2) secondary trigger (same)
  48621. * 3) A (right) X (left), touch, pressed = value
  48622. * 4) B / Y
  48623. * 5) thumb rest
  48624. * @param buttonIdx Which button index changed
  48625. * @param state New state of the button
  48626. * @param changes Which properties on the state changed since last frame
  48627. */
  48628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * Vive Controller
  48634. */
  48635. export class ViveController extends WebVRController {
  48636. /**
  48637. * Base Url for the controller model.
  48638. */
  48639. static MODEL_BASE_URL: string;
  48640. /**
  48641. * File name for the controller model.
  48642. */
  48643. static MODEL_FILENAME: string;
  48644. /**
  48645. * Creates a new ViveController from a gamepad
  48646. * @param vrGamepad the gamepad that the controller should be created from
  48647. */
  48648. constructor(vrGamepad: any);
  48649. /**
  48650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48651. * @param scene scene in which to add meshes
  48652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48653. */
  48654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48655. /**
  48656. * Fired when the left button on this controller is modified
  48657. */
  48658. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48659. /**
  48660. * Fired when the right button on this controller is modified
  48661. */
  48662. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48663. /**
  48664. * Fired when the menu button on this controller is modified
  48665. */
  48666. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48667. /**
  48668. * Called once for each button that changed state since the last frame
  48669. * Vive mapping:
  48670. * 0: touchpad
  48671. * 1: trigger
  48672. * 2: left AND right buttons
  48673. * 3: menu button
  48674. * @param buttonIdx Which button index changed
  48675. * @param state New state of the button
  48676. * @param changes Which properties on the state changed since last frame
  48677. */
  48678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48679. }
  48680. }
  48681. declare module BABYLON {
  48682. /**
  48683. * Defines the WindowsMotionController object that the state of the windows motion controller
  48684. */
  48685. export class WindowsMotionController extends WebVRController {
  48686. /**
  48687. * The base url used to load the left and right controller models
  48688. */
  48689. static MODEL_BASE_URL: string;
  48690. /**
  48691. * The name of the left controller model file
  48692. */
  48693. static MODEL_LEFT_FILENAME: string;
  48694. /**
  48695. * The name of the right controller model file
  48696. */
  48697. static MODEL_RIGHT_FILENAME: string;
  48698. /**
  48699. * The controller name prefix for this controller type
  48700. */
  48701. static readonly GAMEPAD_ID_PREFIX: string;
  48702. /**
  48703. * The controller id pattern for this controller type
  48704. */
  48705. private static readonly GAMEPAD_ID_PATTERN;
  48706. private _loadedMeshInfo;
  48707. protected readonly _mapping: {
  48708. buttons: string[];
  48709. buttonMeshNames: {
  48710. trigger: string;
  48711. menu: string;
  48712. grip: string;
  48713. thumbstick: string;
  48714. trackpad: string;
  48715. };
  48716. buttonObservableNames: {
  48717. trigger: string;
  48718. menu: string;
  48719. grip: string;
  48720. thumbstick: string;
  48721. trackpad: string;
  48722. };
  48723. axisMeshNames: string[];
  48724. pointingPoseMeshName: string;
  48725. };
  48726. /**
  48727. * Fired when the trackpad on this controller is clicked
  48728. */
  48729. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48730. /**
  48731. * Fired when the trackpad on this controller is modified
  48732. */
  48733. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48734. /**
  48735. * The current x and y values of this controller's trackpad
  48736. */
  48737. trackpad: StickValues;
  48738. /**
  48739. * Creates a new WindowsMotionController from a gamepad
  48740. * @param vrGamepad the gamepad that the controller should be created from
  48741. */
  48742. constructor(vrGamepad: any);
  48743. /**
  48744. * Fired when the trigger on this controller is modified
  48745. */
  48746. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48747. /**
  48748. * Fired when the menu button on this controller is modified
  48749. */
  48750. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48751. /**
  48752. * Fired when the grip button on this controller is modified
  48753. */
  48754. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48755. /**
  48756. * Fired when the thumbstick button on this controller is modified
  48757. */
  48758. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48759. /**
  48760. * Fired when the touchpad button on this controller is modified
  48761. */
  48762. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48763. /**
  48764. * Fired when the touchpad values on this controller are modified
  48765. */
  48766. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48767. protected _updateTrackpad(): void;
  48768. /**
  48769. * Called once per frame by the engine.
  48770. */
  48771. update(): void;
  48772. /**
  48773. * Called once for each button that changed state since the last frame
  48774. * @param buttonIdx Which button index changed
  48775. * @param state New state of the button
  48776. * @param changes Which properties on the state changed since last frame
  48777. */
  48778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48779. /**
  48780. * Moves the buttons on the controller mesh based on their current state
  48781. * @param buttonName the name of the button to move
  48782. * @param buttonValue the value of the button which determines the buttons new position
  48783. */
  48784. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48785. /**
  48786. * Moves the axis on the controller mesh based on its current state
  48787. * @param axis the index of the axis
  48788. * @param axisValue the value of the axis which determines the meshes new position
  48789. * @hidden
  48790. */
  48791. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48792. /**
  48793. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48794. * @param scene scene in which to add meshes
  48795. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48796. */
  48797. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48798. /**
  48799. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48800. * can be transformed by button presses and axes values, based on this._mapping.
  48801. *
  48802. * @param scene scene in which the meshes exist
  48803. * @param meshes list of meshes that make up the controller model to process
  48804. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48805. */
  48806. private processModel;
  48807. private createMeshInfo;
  48808. /**
  48809. * Gets the ray of the controller in the direction the controller is pointing
  48810. * @param length the length the resulting ray should be
  48811. * @returns a ray in the direction the controller is pointing
  48812. */
  48813. getForwardRay(length?: number): Ray;
  48814. /**
  48815. * Disposes of the controller
  48816. */
  48817. dispose(): void;
  48818. }
  48819. /**
  48820. * This class represents a new windows motion controller in XR.
  48821. */
  48822. export class XRWindowsMotionController extends WindowsMotionController {
  48823. /**
  48824. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48825. */
  48826. protected readonly _mapping: {
  48827. buttons: string[];
  48828. buttonMeshNames: {
  48829. trigger: string;
  48830. menu: string;
  48831. grip: string;
  48832. thumbstick: string;
  48833. trackpad: string;
  48834. };
  48835. buttonObservableNames: {
  48836. trigger: string;
  48837. menu: string;
  48838. grip: string;
  48839. thumbstick: string;
  48840. trackpad: string;
  48841. };
  48842. axisMeshNames: string[];
  48843. pointingPoseMeshName: string;
  48844. };
  48845. /**
  48846. * Construct a new XR-Based windows motion controller
  48847. *
  48848. * @param gamepadInfo the gamepad object from the browser
  48849. */
  48850. constructor(gamepadInfo: any);
  48851. /**
  48852. * holds the thumbstick values (X,Y)
  48853. */
  48854. thumbstickValues: StickValues;
  48855. /**
  48856. * Fired when the thumbstick on this controller is clicked
  48857. */
  48858. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48859. /**
  48860. * Fired when the thumbstick on this controller is modified
  48861. */
  48862. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48863. /**
  48864. * Fired when the touchpad button on this controller is modified
  48865. */
  48866. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48867. /**
  48868. * Fired when the touchpad values on this controller are modified
  48869. */
  48870. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48871. /**
  48872. * Fired when the thumbstick button on this controller is modified
  48873. * here to prevent breaking changes
  48874. */
  48875. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48876. /**
  48877. * updating the thumbstick(!) and not the trackpad.
  48878. * This is named this way due to the difference between WebVR and XR and to avoid
  48879. * changing the parent class.
  48880. */
  48881. protected _updateTrackpad(): void;
  48882. /**
  48883. * Disposes the class with joy
  48884. */
  48885. dispose(): void;
  48886. }
  48887. }
  48888. declare module BABYLON {
  48889. /**
  48890. * Class containing static functions to help procedurally build meshes
  48891. */
  48892. export class PolyhedronBuilder {
  48893. /**
  48894. * Creates a polyhedron mesh
  48895. * * 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
  48896. * * The parameter `size` (positive float, default 1) sets the polygon size
  48897. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48898. * * 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`
  48899. * * 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
  48900. * * 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)`)
  48901. * * 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
  48902. * * 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
  48903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48904. * * 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
  48905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48906. * @param name defines the name of the mesh
  48907. * @param options defines the options used to create the mesh
  48908. * @param scene defines the hosting scene
  48909. * @returns the polyhedron mesh
  48910. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48911. */
  48912. static CreatePolyhedron(name: string, options: {
  48913. type?: number;
  48914. size?: number;
  48915. sizeX?: number;
  48916. sizeY?: number;
  48917. sizeZ?: number;
  48918. custom?: any;
  48919. faceUV?: Vector4[];
  48920. faceColors?: Color4[];
  48921. flat?: boolean;
  48922. updatable?: boolean;
  48923. sideOrientation?: number;
  48924. frontUVs?: Vector4;
  48925. backUVs?: Vector4;
  48926. }, scene?: Nullable<Scene>): Mesh;
  48927. }
  48928. }
  48929. declare module BABYLON {
  48930. /**
  48931. * Gizmo that enables scaling a mesh along 3 axis
  48932. */
  48933. export class ScaleGizmo extends Gizmo {
  48934. /**
  48935. * Internal gizmo used for interactions on the x axis
  48936. */
  48937. xGizmo: AxisScaleGizmo;
  48938. /**
  48939. * Internal gizmo used for interactions on the y axis
  48940. */
  48941. yGizmo: AxisScaleGizmo;
  48942. /**
  48943. * Internal gizmo used for interactions on the z axis
  48944. */
  48945. zGizmo: AxisScaleGizmo;
  48946. /**
  48947. * Internal gizmo used to scale all axis equally
  48948. */
  48949. uniformScaleGizmo: AxisScaleGizmo;
  48950. private _meshAttached;
  48951. private _updateGizmoRotationToMatchAttachedMesh;
  48952. private _snapDistance;
  48953. private _scaleRatio;
  48954. private _uniformScalingMesh;
  48955. private _octahedron;
  48956. private _sensitivity;
  48957. /** Fires an event when any of it's sub gizmos are dragged */
  48958. onDragStartObservable: Observable<unknown>;
  48959. /** Fires an event when any of it's sub gizmos are released from dragging */
  48960. onDragEndObservable: Observable<unknown>;
  48961. get attachedMesh(): Nullable<AbstractMesh>;
  48962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48963. /**
  48964. * Creates a ScaleGizmo
  48965. * @param gizmoLayer The utility layer the gizmo will be added to
  48966. */
  48967. constructor(gizmoLayer?: UtilityLayerRenderer);
  48968. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48969. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48970. /**
  48971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48972. */
  48973. set snapDistance(value: number);
  48974. get snapDistance(): number;
  48975. /**
  48976. * Ratio for the scale of the gizmo (Default: 1)
  48977. */
  48978. set scaleRatio(value: number);
  48979. get scaleRatio(): number;
  48980. /**
  48981. * Sensitivity factor for dragging (Default: 1)
  48982. */
  48983. set sensitivity(value: number);
  48984. get sensitivity(): number;
  48985. /**
  48986. * Disposes of the gizmo
  48987. */
  48988. dispose(): void;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. /**
  48993. * Single axis scale gizmo
  48994. */
  48995. export class AxisScaleGizmo extends Gizmo {
  48996. /**
  48997. * Drag behavior responsible for the gizmos dragging interactions
  48998. */
  48999. dragBehavior: PointerDragBehavior;
  49000. private _pointerObserver;
  49001. /**
  49002. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49003. */
  49004. snapDistance: number;
  49005. /**
  49006. * Event that fires each time the gizmo snaps to a new location.
  49007. * * snapDistance is the the change in distance
  49008. */
  49009. onSnapObservable: Observable<{
  49010. snapDistance: number;
  49011. }>;
  49012. /**
  49013. * If the scaling operation should be done on all axis (default: false)
  49014. */
  49015. uniformScaling: boolean;
  49016. /**
  49017. * Custom sensitivity value for the drag strength
  49018. */
  49019. sensitivity: number;
  49020. private _isEnabled;
  49021. private _parent;
  49022. private _arrow;
  49023. private _coloredMaterial;
  49024. private _hoverMaterial;
  49025. /**
  49026. * Creates an AxisScaleGizmo
  49027. * @param gizmoLayer The utility layer the gizmo will be added to
  49028. * @param dragAxis The axis which the gizmo will be able to scale on
  49029. * @param color The color of the gizmo
  49030. */
  49031. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49032. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49033. /**
  49034. * If the gizmo is enabled
  49035. */
  49036. set isEnabled(value: boolean);
  49037. get isEnabled(): boolean;
  49038. /**
  49039. * Disposes of the gizmo
  49040. */
  49041. dispose(): void;
  49042. /**
  49043. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49044. * @param mesh The mesh to replace the default mesh of the gizmo
  49045. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49046. */
  49047. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49048. }
  49049. }
  49050. declare module BABYLON {
  49051. /**
  49052. * Bounding box gizmo
  49053. */
  49054. export class BoundingBoxGizmo extends Gizmo {
  49055. private _lineBoundingBox;
  49056. private _rotateSpheresParent;
  49057. private _scaleBoxesParent;
  49058. private _boundingDimensions;
  49059. private _renderObserver;
  49060. private _pointerObserver;
  49061. private _scaleDragSpeed;
  49062. private _tmpQuaternion;
  49063. private _tmpVector;
  49064. private _tmpRotationMatrix;
  49065. /**
  49066. * 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)
  49067. */
  49068. ignoreChildren: boolean;
  49069. /**
  49070. * 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)
  49071. */
  49072. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49073. /**
  49074. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49075. */
  49076. rotationSphereSize: number;
  49077. /**
  49078. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49079. */
  49080. scaleBoxSize: number;
  49081. /**
  49082. * 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)
  49083. */
  49084. fixedDragMeshScreenSize: boolean;
  49085. /**
  49086. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49087. */
  49088. fixedDragMeshScreenSizeDistanceFactor: number;
  49089. /**
  49090. * Fired when a rotation sphere or scale box is dragged
  49091. */
  49092. onDragStartObservable: Observable<{}>;
  49093. /**
  49094. * Fired when a scale box is dragged
  49095. */
  49096. onScaleBoxDragObservable: Observable<{}>;
  49097. /**
  49098. * Fired when a scale box drag is ended
  49099. */
  49100. onScaleBoxDragEndObservable: Observable<{}>;
  49101. /**
  49102. * Fired when a rotation sphere is dragged
  49103. */
  49104. onRotationSphereDragObservable: Observable<{}>;
  49105. /**
  49106. * Fired when a rotation sphere drag is ended
  49107. */
  49108. onRotationSphereDragEndObservable: Observable<{}>;
  49109. /**
  49110. * 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)
  49111. */
  49112. scalePivot: Nullable<Vector3>;
  49113. /**
  49114. * Mesh used as a pivot to rotate the attached mesh
  49115. */
  49116. private _anchorMesh;
  49117. private _existingMeshScale;
  49118. private _dragMesh;
  49119. private pointerDragBehavior;
  49120. private coloredMaterial;
  49121. private hoverColoredMaterial;
  49122. /**
  49123. * Sets the color of the bounding box gizmo
  49124. * @param color the color to set
  49125. */
  49126. setColor(color: Color3): void;
  49127. /**
  49128. * Creates an BoundingBoxGizmo
  49129. * @param gizmoLayer The utility layer the gizmo will be added to
  49130. * @param color The color of the gizmo
  49131. */
  49132. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49134. private _selectNode;
  49135. /**
  49136. * Updates the bounding box information for the Gizmo
  49137. */
  49138. updateBoundingBox(): void;
  49139. private _updateRotationSpheres;
  49140. private _updateScaleBoxes;
  49141. /**
  49142. * Enables rotation on the specified axis and disables rotation on the others
  49143. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49144. */
  49145. setEnabledRotationAxis(axis: string): void;
  49146. /**
  49147. * Enables/disables scaling
  49148. * @param enable if scaling should be enabled
  49149. * @param homogeneousScaling defines if scaling should only be homogeneous
  49150. */
  49151. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49152. private _updateDummy;
  49153. /**
  49154. * Enables a pointer drag behavior on the bounding box of the gizmo
  49155. */
  49156. enableDragBehavior(): void;
  49157. /**
  49158. * Disposes of the gizmo
  49159. */
  49160. dispose(): void;
  49161. /**
  49162. * 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)
  49163. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49164. * @returns the bounding box mesh with the passed in mesh as a child
  49165. */
  49166. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49167. /**
  49168. * CustomMeshes are not supported by this gizmo
  49169. * @param mesh The mesh to replace the default mesh of the gizmo
  49170. */
  49171. setCustomMesh(mesh: Mesh): void;
  49172. }
  49173. }
  49174. declare module BABYLON {
  49175. /**
  49176. * Single plane rotation gizmo
  49177. */
  49178. export class PlaneRotationGizmo extends Gizmo {
  49179. /**
  49180. * Drag behavior responsible for the gizmos dragging interactions
  49181. */
  49182. dragBehavior: PointerDragBehavior;
  49183. private _pointerObserver;
  49184. /**
  49185. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49186. */
  49187. snapDistance: number;
  49188. /**
  49189. * Event that fires each time the gizmo snaps to a new location.
  49190. * * snapDistance is the the change in distance
  49191. */
  49192. onSnapObservable: Observable<{
  49193. snapDistance: number;
  49194. }>;
  49195. private _isEnabled;
  49196. private _parent;
  49197. /**
  49198. * Creates a PlaneRotationGizmo
  49199. * @param gizmoLayer The utility layer the gizmo will be added to
  49200. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49201. * @param color The color of the gizmo
  49202. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49203. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49204. */
  49205. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49207. /**
  49208. * If the gizmo is enabled
  49209. */
  49210. set isEnabled(value: boolean);
  49211. get isEnabled(): boolean;
  49212. /**
  49213. * Disposes of the gizmo
  49214. */
  49215. dispose(): void;
  49216. }
  49217. }
  49218. declare module BABYLON {
  49219. /**
  49220. * Gizmo that enables rotating a mesh along 3 axis
  49221. */
  49222. export class RotationGizmo extends Gizmo {
  49223. /**
  49224. * Internal gizmo used for interactions on the x axis
  49225. */
  49226. xGizmo: PlaneRotationGizmo;
  49227. /**
  49228. * Internal gizmo used for interactions on the y axis
  49229. */
  49230. yGizmo: PlaneRotationGizmo;
  49231. /**
  49232. * Internal gizmo used for interactions on the z axis
  49233. */
  49234. zGizmo: PlaneRotationGizmo;
  49235. /** Fires an event when any of it's sub gizmos are dragged */
  49236. onDragStartObservable: Observable<unknown>;
  49237. /** Fires an event when any of it's sub gizmos are released from dragging */
  49238. onDragEndObservable: Observable<unknown>;
  49239. private _meshAttached;
  49240. get attachedMesh(): Nullable<AbstractMesh>;
  49241. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49242. /**
  49243. * Creates a RotationGizmo
  49244. * @param gizmoLayer The utility layer the gizmo will be added to
  49245. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49246. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49247. */
  49248. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49249. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49250. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49251. /**
  49252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49253. */
  49254. set snapDistance(value: number);
  49255. get snapDistance(): number;
  49256. /**
  49257. * Ratio for the scale of the gizmo (Default: 1)
  49258. */
  49259. set scaleRatio(value: number);
  49260. get scaleRatio(): number;
  49261. /**
  49262. * Disposes of the gizmo
  49263. */
  49264. dispose(): void;
  49265. /**
  49266. * CustomMeshes are not supported by this gizmo
  49267. * @param mesh The mesh to replace the default mesh of the gizmo
  49268. */
  49269. setCustomMesh(mesh: Mesh): void;
  49270. }
  49271. }
  49272. declare module BABYLON {
  49273. /**
  49274. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49275. */
  49276. export class GizmoManager implements IDisposable {
  49277. private scene;
  49278. /**
  49279. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49280. */
  49281. gizmos: {
  49282. positionGizmo: Nullable<PositionGizmo>;
  49283. rotationGizmo: Nullable<RotationGizmo>;
  49284. scaleGizmo: Nullable<ScaleGizmo>;
  49285. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49286. };
  49287. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49288. clearGizmoOnEmptyPointerEvent: boolean;
  49289. /** Fires an event when the manager is attached to a mesh */
  49290. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49291. private _gizmosEnabled;
  49292. private _pointerObserver;
  49293. private _attachedMesh;
  49294. private _boundingBoxColor;
  49295. private _defaultUtilityLayer;
  49296. private _defaultKeepDepthUtilityLayer;
  49297. /**
  49298. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49299. */
  49300. boundingBoxDragBehavior: SixDofDragBehavior;
  49301. /**
  49302. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49303. */
  49304. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49305. /**
  49306. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49307. */
  49308. usePointerToAttachGizmos: boolean;
  49309. /**
  49310. * Utility layer that the bounding box gizmo belongs to
  49311. */
  49312. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49313. /**
  49314. * Utility layer that all gizmos besides bounding box belong to
  49315. */
  49316. get utilityLayer(): UtilityLayerRenderer;
  49317. /**
  49318. * Instatiates a gizmo manager
  49319. * @param scene the scene to overlay the gizmos on top of
  49320. */
  49321. constructor(scene: Scene);
  49322. /**
  49323. * Attaches a set of gizmos to the specified mesh
  49324. * @param mesh The mesh the gizmo's should be attached to
  49325. */
  49326. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49327. /**
  49328. * If the position gizmo is enabled
  49329. */
  49330. set positionGizmoEnabled(value: boolean);
  49331. get positionGizmoEnabled(): boolean;
  49332. /**
  49333. * If the rotation gizmo is enabled
  49334. */
  49335. set rotationGizmoEnabled(value: boolean);
  49336. get rotationGizmoEnabled(): boolean;
  49337. /**
  49338. * If the scale gizmo is enabled
  49339. */
  49340. set scaleGizmoEnabled(value: boolean);
  49341. get scaleGizmoEnabled(): boolean;
  49342. /**
  49343. * If the boundingBox gizmo is enabled
  49344. */
  49345. set boundingBoxGizmoEnabled(value: boolean);
  49346. get boundingBoxGizmoEnabled(): boolean;
  49347. /**
  49348. * Disposes of the gizmo manager
  49349. */
  49350. dispose(): void;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * A directional light is defined by a direction (what a surprise!).
  49356. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49357. * 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.
  49358. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49359. */
  49360. export class DirectionalLight extends ShadowLight {
  49361. private _shadowFrustumSize;
  49362. /**
  49363. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49364. */
  49365. get shadowFrustumSize(): number;
  49366. /**
  49367. * Specifies a fix frustum size for the shadow generation.
  49368. */
  49369. set shadowFrustumSize(value: number);
  49370. private _shadowOrthoScale;
  49371. /**
  49372. * Gets the shadow projection scale against the optimal computed one.
  49373. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49374. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49375. */
  49376. get shadowOrthoScale(): number;
  49377. /**
  49378. * Sets the shadow projection scale against the optimal computed one.
  49379. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49380. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49381. */
  49382. set shadowOrthoScale(value: number);
  49383. /**
  49384. * Automatically compute the projection matrix to best fit (including all the casters)
  49385. * on each frame.
  49386. */
  49387. autoUpdateExtends: boolean;
  49388. /**
  49389. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49390. * on each frame. autoUpdateExtends must be set to true for this to work
  49391. */
  49392. autoCalcShadowZBounds: boolean;
  49393. private _orthoLeft;
  49394. private _orthoRight;
  49395. private _orthoTop;
  49396. private _orthoBottom;
  49397. /**
  49398. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49399. * The directional light is emitted from everywhere in the given direction.
  49400. * It can cast shadows.
  49401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49402. * @param name The friendly name of the light
  49403. * @param direction The direction of the light
  49404. * @param scene The scene the light belongs to
  49405. */
  49406. constructor(name: string, direction: Vector3, scene: Scene);
  49407. /**
  49408. * Returns the string "DirectionalLight".
  49409. * @return The class name
  49410. */
  49411. getClassName(): string;
  49412. /**
  49413. * Returns the integer 1.
  49414. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49415. */
  49416. getTypeID(): number;
  49417. /**
  49418. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49419. * Returns the DirectionalLight Shadow projection matrix.
  49420. */
  49421. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49422. /**
  49423. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49424. * Returns the DirectionalLight Shadow projection matrix.
  49425. */
  49426. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49427. /**
  49428. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49429. * Returns the DirectionalLight Shadow projection matrix.
  49430. */
  49431. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49432. protected _buildUniformLayout(): void;
  49433. /**
  49434. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49435. * @param effect The effect to update
  49436. * @param lightIndex The index of the light in the effect to update
  49437. * @returns The directional light
  49438. */
  49439. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49440. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49441. /**
  49442. * Gets the minZ used for shadow according to both the scene and the light.
  49443. *
  49444. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49445. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49446. * @param activeCamera The camera we are returning the min for
  49447. * @returns the depth min z
  49448. */
  49449. getDepthMinZ(activeCamera: Camera): number;
  49450. /**
  49451. * Gets the maxZ used for shadow according to both the scene and the light.
  49452. *
  49453. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49454. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49455. * @param activeCamera The camera we are returning the max for
  49456. * @returns the depth max z
  49457. */
  49458. getDepthMaxZ(activeCamera: Camera): number;
  49459. /**
  49460. * Prepares the list of defines specific to the light type.
  49461. * @param defines the list of defines
  49462. * @param lightIndex defines the index of the light for the effect
  49463. */
  49464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49465. }
  49466. }
  49467. declare module BABYLON {
  49468. /**
  49469. * Class containing static functions to help procedurally build meshes
  49470. */
  49471. export class HemisphereBuilder {
  49472. /**
  49473. * Creates a hemisphere mesh
  49474. * @param name defines the name of the mesh
  49475. * @param options defines the options used to create the mesh
  49476. * @param scene defines the hosting scene
  49477. * @returns the hemisphere mesh
  49478. */
  49479. static CreateHemisphere(name: string, options: {
  49480. segments?: number;
  49481. diameter?: number;
  49482. sideOrientation?: number;
  49483. }, scene: any): Mesh;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49489. * These values define a cone of light starting from the position, emitting toward the direction.
  49490. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49491. * and the exponent defines the speed of the decay of the light with distance (reach).
  49492. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49493. */
  49494. export class SpotLight extends ShadowLight {
  49495. private _angle;
  49496. private _innerAngle;
  49497. private _cosHalfAngle;
  49498. private _lightAngleScale;
  49499. private _lightAngleOffset;
  49500. /**
  49501. * Gets the cone angle of the spot light in Radians.
  49502. */
  49503. get angle(): number;
  49504. /**
  49505. * Sets the cone angle of the spot light in Radians.
  49506. */
  49507. set angle(value: number);
  49508. /**
  49509. * Only used in gltf falloff mode, this defines the angle where
  49510. * the directional falloff will start before cutting at angle which could be seen
  49511. * as outer angle.
  49512. */
  49513. get innerAngle(): number;
  49514. /**
  49515. * Only used in gltf falloff mode, this defines the angle where
  49516. * the directional falloff will start before cutting at angle which could be seen
  49517. * as outer angle.
  49518. */
  49519. set innerAngle(value: number);
  49520. private _shadowAngleScale;
  49521. /**
  49522. * Allows scaling the angle of the light for shadow generation only.
  49523. */
  49524. get shadowAngleScale(): number;
  49525. /**
  49526. * Allows scaling the angle of the light for shadow generation only.
  49527. */
  49528. set shadowAngleScale(value: number);
  49529. /**
  49530. * The light decay speed with the distance from the emission spot.
  49531. */
  49532. exponent: number;
  49533. private _projectionTextureMatrix;
  49534. /**
  49535. * Allows reading the projecton texture
  49536. */
  49537. get projectionTextureMatrix(): Matrix;
  49538. protected _projectionTextureLightNear: number;
  49539. /**
  49540. * Gets the near clip of the Spotlight for texture projection.
  49541. */
  49542. get projectionTextureLightNear(): number;
  49543. /**
  49544. * Sets the near clip of the Spotlight for texture projection.
  49545. */
  49546. set projectionTextureLightNear(value: number);
  49547. protected _projectionTextureLightFar: number;
  49548. /**
  49549. * Gets the far clip of the Spotlight for texture projection.
  49550. */
  49551. get projectionTextureLightFar(): number;
  49552. /**
  49553. * Sets the far clip of the Spotlight for texture projection.
  49554. */
  49555. set projectionTextureLightFar(value: number);
  49556. protected _projectionTextureUpDirection: Vector3;
  49557. /**
  49558. * Gets the Up vector of the Spotlight for texture projection.
  49559. */
  49560. get projectionTextureUpDirection(): Vector3;
  49561. /**
  49562. * Sets the Up vector of the Spotlight for texture projection.
  49563. */
  49564. set projectionTextureUpDirection(value: Vector3);
  49565. private _projectionTexture;
  49566. /**
  49567. * Gets the projection texture of the light.
  49568. */
  49569. get projectionTexture(): Nullable<BaseTexture>;
  49570. /**
  49571. * Sets the projection texture of the light.
  49572. */
  49573. set projectionTexture(value: Nullable<BaseTexture>);
  49574. private _projectionTextureViewLightDirty;
  49575. private _projectionTextureProjectionLightDirty;
  49576. private _projectionTextureDirty;
  49577. private _projectionTextureViewTargetVector;
  49578. private _projectionTextureViewLightMatrix;
  49579. private _projectionTextureProjectionLightMatrix;
  49580. private _projectionTextureScalingMatrix;
  49581. /**
  49582. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49583. * It can cast shadows.
  49584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49585. * @param name The light friendly name
  49586. * @param position The position of the spot light in the scene
  49587. * @param direction The direction of the light in the scene
  49588. * @param angle The cone angle of the light in Radians
  49589. * @param exponent The light decay speed with the distance from the emission spot
  49590. * @param scene The scene the lights belongs to
  49591. */
  49592. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49593. /**
  49594. * Returns the string "SpotLight".
  49595. * @returns the class name
  49596. */
  49597. getClassName(): string;
  49598. /**
  49599. * Returns the integer 2.
  49600. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49601. */
  49602. getTypeID(): number;
  49603. /**
  49604. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49605. */
  49606. protected _setDirection(value: Vector3): void;
  49607. /**
  49608. * Overrides the position setter to recompute the projection texture view light Matrix.
  49609. */
  49610. protected _setPosition(value: Vector3): void;
  49611. /**
  49612. * 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.
  49613. * Returns the SpotLight.
  49614. */
  49615. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49616. protected _computeProjectionTextureViewLightMatrix(): void;
  49617. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49618. /**
  49619. * Main function for light texture projection matrix computing.
  49620. */
  49621. protected _computeProjectionTextureMatrix(): void;
  49622. protected _buildUniformLayout(): void;
  49623. private _computeAngleValues;
  49624. /**
  49625. * Sets the passed Effect "effect" with the Light textures.
  49626. * @param effect The effect to update
  49627. * @param lightIndex The index of the light in the effect to update
  49628. * @returns The light
  49629. */
  49630. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49631. /**
  49632. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49633. * @param effect The effect to update
  49634. * @param lightIndex The index of the light in the effect to update
  49635. * @returns The spot light
  49636. */
  49637. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49638. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49639. /**
  49640. * Disposes the light and the associated resources.
  49641. */
  49642. dispose(): void;
  49643. /**
  49644. * Prepares the list of defines specific to the light type.
  49645. * @param defines the list of defines
  49646. * @param lightIndex defines the index of the light for the effect
  49647. */
  49648. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49649. }
  49650. }
  49651. declare module BABYLON {
  49652. /**
  49653. * Gizmo that enables viewing a light
  49654. */
  49655. export class LightGizmo extends Gizmo {
  49656. private _lightMesh;
  49657. private _material;
  49658. private _cachedPosition;
  49659. private _cachedForward;
  49660. private _attachedMeshParent;
  49661. /**
  49662. * Creates a LightGizmo
  49663. * @param gizmoLayer The utility layer the gizmo will be added to
  49664. */
  49665. constructor(gizmoLayer?: UtilityLayerRenderer);
  49666. private _light;
  49667. /**
  49668. * The light that the gizmo is attached to
  49669. */
  49670. set light(light: Nullable<Light>);
  49671. get light(): Nullable<Light>;
  49672. /**
  49673. * Gets the material used to render the light gizmo
  49674. */
  49675. get material(): StandardMaterial;
  49676. /**
  49677. * @hidden
  49678. * Updates the gizmo to match the attached mesh's position/rotation
  49679. */
  49680. protected _update(): void;
  49681. private static _Scale;
  49682. /**
  49683. * Creates the lines for a light mesh
  49684. */
  49685. private static _CreateLightLines;
  49686. /**
  49687. * Disposes of the light gizmo
  49688. */
  49689. dispose(): void;
  49690. private static _CreateHemisphericLightMesh;
  49691. private static _CreatePointLightMesh;
  49692. private static _CreateSpotLightMesh;
  49693. private static _CreateDirectionalLightMesh;
  49694. }
  49695. }
  49696. declare module BABYLON {
  49697. /** @hidden */
  49698. export var backgroundFragmentDeclaration: {
  49699. name: string;
  49700. shader: string;
  49701. };
  49702. }
  49703. declare module BABYLON {
  49704. /** @hidden */
  49705. export var backgroundUboDeclaration: {
  49706. name: string;
  49707. shader: string;
  49708. };
  49709. }
  49710. declare module BABYLON {
  49711. /** @hidden */
  49712. export var backgroundPixelShader: {
  49713. name: string;
  49714. shader: string;
  49715. };
  49716. }
  49717. declare module BABYLON {
  49718. /** @hidden */
  49719. export var backgroundVertexDeclaration: {
  49720. name: string;
  49721. shader: string;
  49722. };
  49723. }
  49724. declare module BABYLON {
  49725. /** @hidden */
  49726. export var backgroundVertexShader: {
  49727. name: string;
  49728. shader: string;
  49729. };
  49730. }
  49731. declare module BABYLON {
  49732. /**
  49733. * Background material used to create an efficient environement around your scene.
  49734. */
  49735. export class BackgroundMaterial extends PushMaterial {
  49736. /**
  49737. * Standard reflectance value at parallel view angle.
  49738. */
  49739. static StandardReflectance0: number;
  49740. /**
  49741. * Standard reflectance value at grazing angle.
  49742. */
  49743. static StandardReflectance90: number;
  49744. protected _primaryColor: Color3;
  49745. /**
  49746. * Key light Color (multiply against the environement texture)
  49747. */
  49748. primaryColor: Color3;
  49749. protected __perceptualColor: Nullable<Color3>;
  49750. /**
  49751. * Experimental Internal Use Only.
  49752. *
  49753. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49754. * This acts as a helper to set the primary color to a more "human friendly" value.
  49755. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49756. * output color as close as possible from the chosen value.
  49757. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49758. * part of lighting setup.)
  49759. */
  49760. get _perceptualColor(): Nullable<Color3>;
  49761. set _perceptualColor(value: Nullable<Color3>);
  49762. protected _primaryColorShadowLevel: float;
  49763. /**
  49764. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49765. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49766. */
  49767. get primaryColorShadowLevel(): float;
  49768. set primaryColorShadowLevel(value: float);
  49769. protected _primaryColorHighlightLevel: float;
  49770. /**
  49771. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49772. * The primary color is used at the level chosen to define what the white area would look.
  49773. */
  49774. get primaryColorHighlightLevel(): float;
  49775. set primaryColorHighlightLevel(value: float);
  49776. protected _reflectionTexture: Nullable<BaseTexture>;
  49777. /**
  49778. * Reflection Texture used in the material.
  49779. * Should be author in a specific way for the best result (refer to the documentation).
  49780. */
  49781. reflectionTexture: Nullable<BaseTexture>;
  49782. protected _reflectionBlur: float;
  49783. /**
  49784. * Reflection Texture level of blur.
  49785. *
  49786. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49787. * texture twice.
  49788. */
  49789. reflectionBlur: float;
  49790. protected _diffuseTexture: Nullable<BaseTexture>;
  49791. /**
  49792. * Diffuse Texture used in the material.
  49793. * Should be author in a specific way for the best result (refer to the documentation).
  49794. */
  49795. diffuseTexture: Nullable<BaseTexture>;
  49796. protected _shadowLights: Nullable<IShadowLight[]>;
  49797. /**
  49798. * Specify the list of lights casting shadow on the material.
  49799. * All scene shadow lights will be included if null.
  49800. */
  49801. shadowLights: Nullable<IShadowLight[]>;
  49802. protected _shadowLevel: float;
  49803. /**
  49804. * Helps adjusting the shadow to a softer level if required.
  49805. * 0 means black shadows and 1 means no shadows.
  49806. */
  49807. shadowLevel: float;
  49808. protected _sceneCenter: Vector3;
  49809. /**
  49810. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49811. * It is usually zero but might be interesting to modify according to your setup.
  49812. */
  49813. sceneCenter: Vector3;
  49814. protected _opacityFresnel: boolean;
  49815. /**
  49816. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49817. * This helps ensuring a nice transition when the camera goes under the ground.
  49818. */
  49819. opacityFresnel: boolean;
  49820. protected _reflectionFresnel: boolean;
  49821. /**
  49822. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49823. * This helps adding a mirror texture on the ground.
  49824. */
  49825. reflectionFresnel: boolean;
  49826. protected _reflectionFalloffDistance: number;
  49827. /**
  49828. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49829. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49830. */
  49831. reflectionFalloffDistance: number;
  49832. protected _reflectionAmount: number;
  49833. /**
  49834. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49835. */
  49836. reflectionAmount: number;
  49837. protected _reflectionReflectance0: number;
  49838. /**
  49839. * This specifies the weight of the reflection at grazing angle.
  49840. */
  49841. reflectionReflectance0: number;
  49842. protected _reflectionReflectance90: number;
  49843. /**
  49844. * This specifies the weight of the reflection at a perpendicular point of view.
  49845. */
  49846. reflectionReflectance90: number;
  49847. /**
  49848. * Sets the reflection reflectance fresnel values according to the default standard
  49849. * empirically know to work well :-)
  49850. */
  49851. set reflectionStandardFresnelWeight(value: number);
  49852. protected _useRGBColor: boolean;
  49853. /**
  49854. * Helps to directly use the maps channels instead of their level.
  49855. */
  49856. useRGBColor: boolean;
  49857. protected _enableNoise: boolean;
  49858. /**
  49859. * This helps reducing the banding effect that could occur on the background.
  49860. */
  49861. enableNoise: boolean;
  49862. /**
  49863. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49864. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49865. * Recommended to be keep at 1.0 except for special cases.
  49866. */
  49867. get fovMultiplier(): number;
  49868. set fovMultiplier(value: number);
  49869. private _fovMultiplier;
  49870. /**
  49871. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49872. */
  49873. useEquirectangularFOV: boolean;
  49874. private _maxSimultaneousLights;
  49875. /**
  49876. * Number of Simultaneous lights allowed on the material.
  49877. */
  49878. maxSimultaneousLights: int;
  49879. /**
  49880. * Default configuration related to image processing available in the Background Material.
  49881. */
  49882. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49883. /**
  49884. * Keep track of the image processing observer to allow dispose and replace.
  49885. */
  49886. private _imageProcessingObserver;
  49887. /**
  49888. * Attaches a new image processing configuration to the PBR Material.
  49889. * @param configuration (if null the scene configuration will be use)
  49890. */
  49891. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49892. /**
  49893. * Gets the image processing configuration used either in this material.
  49894. */
  49895. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. get cameraColorCurvesEnabled(): boolean;
  49906. /**
  49907. * Sets wether the color curves effect is enabled.
  49908. */
  49909. set cameraColorCurvesEnabled(value: boolean);
  49910. /**
  49911. * Gets wether the color grading effect is enabled.
  49912. */
  49913. get cameraColorGradingEnabled(): boolean;
  49914. /**
  49915. * Gets wether the color grading effect is enabled.
  49916. */
  49917. set cameraColorGradingEnabled(value: boolean);
  49918. /**
  49919. * Gets wether tonemapping is enabled or not.
  49920. */
  49921. get cameraToneMappingEnabled(): boolean;
  49922. /**
  49923. * Sets wether tonemapping is enabled or not
  49924. */
  49925. set cameraToneMappingEnabled(value: boolean);
  49926. /**
  49927. * The camera exposure used on this material.
  49928. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49929. * This corresponds to a photographic exposure.
  49930. */
  49931. get cameraExposure(): float;
  49932. /**
  49933. * The camera exposure used on this material.
  49934. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49935. * This corresponds to a photographic exposure.
  49936. */
  49937. set cameraExposure(value: float);
  49938. /**
  49939. * Gets The camera contrast used on this material.
  49940. */
  49941. get cameraContrast(): float;
  49942. /**
  49943. * Sets The camera contrast used on this material.
  49944. */
  49945. set cameraContrast(value: float);
  49946. /**
  49947. * Gets the Color Grading 2D Lookup Texture.
  49948. */
  49949. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49950. /**
  49951. * Sets the Color Grading 2D Lookup Texture.
  49952. */
  49953. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * 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;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. get cameraColorCurves(): Nullable<ColorCurves>;
  49961. /**
  49962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49964. * 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;
  49965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49966. */
  49967. set cameraColorCurves(value: Nullable<ColorCurves>);
  49968. /**
  49969. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49970. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49971. */
  49972. switchToBGR: boolean;
  49973. private _renderTargets;
  49974. private _reflectionControls;
  49975. private _white;
  49976. private _primaryShadowColor;
  49977. private _primaryHighlightColor;
  49978. /**
  49979. * Instantiates a Background Material in the given scene
  49980. * @param name The friendly name of the material
  49981. * @param scene The scene to add the material to
  49982. */
  49983. constructor(name: string, scene: Scene);
  49984. /**
  49985. * Gets a boolean indicating that current material needs to register RTT
  49986. */
  49987. get hasRenderTargetTextures(): boolean;
  49988. /**
  49989. * The entire material has been created in order to prevent overdraw.
  49990. * @returns false
  49991. */
  49992. needAlphaTesting(): boolean;
  49993. /**
  49994. * The entire material has been created in order to prevent overdraw.
  49995. * @returns true if blending is enable
  49996. */
  49997. needAlphaBlending(): boolean;
  49998. /**
  49999. * Checks wether the material is ready to be rendered for a given mesh.
  50000. * @param mesh The mesh to render
  50001. * @param subMesh The submesh to check against
  50002. * @param useInstances Specify wether or not the material is used with instances
  50003. * @returns true if all the dependencies are ready (Textures, Effects...)
  50004. */
  50005. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50006. /**
  50007. * Compute the primary color according to the chosen perceptual color.
  50008. */
  50009. private _computePrimaryColorFromPerceptualColor;
  50010. /**
  50011. * Compute the highlights and shadow colors according to their chosen levels.
  50012. */
  50013. private _computePrimaryColors;
  50014. /**
  50015. * Build the uniform buffer used in the material.
  50016. */
  50017. buildUniformLayout(): void;
  50018. /**
  50019. * Unbind the material.
  50020. */
  50021. unbind(): void;
  50022. /**
  50023. * Bind only the world matrix to the material.
  50024. * @param world The world matrix to bind.
  50025. */
  50026. bindOnlyWorldMatrix(world: Matrix): void;
  50027. /**
  50028. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50029. * @param world The world matrix to bind.
  50030. * @param subMesh The submesh to bind for.
  50031. */
  50032. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50033. /**
  50034. * Checks to see if a texture is used in the material.
  50035. * @param texture - Base texture to use.
  50036. * @returns - Boolean specifying if a texture is used in the material.
  50037. */
  50038. hasTexture(texture: BaseTexture): boolean;
  50039. /**
  50040. * Dispose the material.
  50041. * @param forceDisposeEffect Force disposal of the associated effect.
  50042. * @param forceDisposeTextures Force disposal of the associated textures.
  50043. */
  50044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50045. /**
  50046. * Clones the material.
  50047. * @param name The cloned name.
  50048. * @returns The cloned material.
  50049. */
  50050. clone(name: string): BackgroundMaterial;
  50051. /**
  50052. * Serializes the current material to its JSON representation.
  50053. * @returns The JSON representation.
  50054. */
  50055. serialize(): any;
  50056. /**
  50057. * Gets the class name of the material
  50058. * @returns "BackgroundMaterial"
  50059. */
  50060. getClassName(): string;
  50061. /**
  50062. * Parse a JSON input to create back a background material.
  50063. * @param source The JSON data to parse
  50064. * @param scene The scene to create the parsed material in
  50065. * @param rootUrl The root url of the assets the material depends upon
  50066. * @returns the instantiated BackgroundMaterial.
  50067. */
  50068. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /**
  50073. * Represents the different options available during the creation of
  50074. * a Environment helper.
  50075. *
  50076. * This can control the default ground, skybox and image processing setup of your scene.
  50077. */
  50078. export interface IEnvironmentHelperOptions {
  50079. /**
  50080. * Specifies whether or not to create a ground.
  50081. * True by default.
  50082. */
  50083. createGround: boolean;
  50084. /**
  50085. * Specifies the ground size.
  50086. * 15 by default.
  50087. */
  50088. groundSize: number;
  50089. /**
  50090. * The texture used on the ground for the main color.
  50091. * Comes from the BabylonJS CDN by default.
  50092. *
  50093. * Remarks: Can be either a texture or a url.
  50094. */
  50095. groundTexture: string | BaseTexture;
  50096. /**
  50097. * The color mixed in the ground texture by default.
  50098. * BabylonJS clearColor by default.
  50099. */
  50100. groundColor: Color3;
  50101. /**
  50102. * Specifies the ground opacity.
  50103. * 1 by default.
  50104. */
  50105. groundOpacity: number;
  50106. /**
  50107. * Enables the ground to receive shadows.
  50108. * True by default.
  50109. */
  50110. enableGroundShadow: boolean;
  50111. /**
  50112. * Helps preventing the shadow to be fully black on the ground.
  50113. * 0.5 by default.
  50114. */
  50115. groundShadowLevel: number;
  50116. /**
  50117. * Creates a mirror texture attach to the ground.
  50118. * false by default.
  50119. */
  50120. enableGroundMirror: boolean;
  50121. /**
  50122. * Specifies the ground mirror size ratio.
  50123. * 0.3 by default as the default kernel is 64.
  50124. */
  50125. groundMirrorSizeRatio: number;
  50126. /**
  50127. * Specifies the ground mirror blur kernel size.
  50128. * 64 by default.
  50129. */
  50130. groundMirrorBlurKernel: number;
  50131. /**
  50132. * Specifies the ground mirror visibility amount.
  50133. * 1 by default
  50134. */
  50135. groundMirrorAmount: number;
  50136. /**
  50137. * Specifies the ground mirror reflectance weight.
  50138. * This uses the standard weight of the background material to setup the fresnel effect
  50139. * of the mirror.
  50140. * 1 by default.
  50141. */
  50142. groundMirrorFresnelWeight: number;
  50143. /**
  50144. * Specifies the ground mirror Falloff distance.
  50145. * This can helps reducing the size of the reflection.
  50146. * 0 by Default.
  50147. */
  50148. groundMirrorFallOffDistance: number;
  50149. /**
  50150. * Specifies the ground mirror texture type.
  50151. * Unsigned Int by Default.
  50152. */
  50153. groundMirrorTextureType: number;
  50154. /**
  50155. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50156. * the shown objects.
  50157. */
  50158. groundYBias: number;
  50159. /**
  50160. * Specifies whether or not to create a skybox.
  50161. * True by default.
  50162. */
  50163. createSkybox: boolean;
  50164. /**
  50165. * Specifies the skybox size.
  50166. * 20 by default.
  50167. */
  50168. skyboxSize: number;
  50169. /**
  50170. * The texture used on the skybox for the main color.
  50171. * Comes from the BabylonJS CDN by default.
  50172. *
  50173. * Remarks: Can be either a texture or a url.
  50174. */
  50175. skyboxTexture: string | BaseTexture;
  50176. /**
  50177. * The color mixed in the skybox texture by default.
  50178. * BabylonJS clearColor by default.
  50179. */
  50180. skyboxColor: Color3;
  50181. /**
  50182. * The background rotation around the Y axis of the scene.
  50183. * This helps aligning the key lights of your scene with the background.
  50184. * 0 by default.
  50185. */
  50186. backgroundYRotation: number;
  50187. /**
  50188. * Compute automatically the size of the elements to best fit with the scene.
  50189. */
  50190. sizeAuto: boolean;
  50191. /**
  50192. * Default position of the rootMesh if autoSize is not true.
  50193. */
  50194. rootPosition: Vector3;
  50195. /**
  50196. * Sets up the image processing in the scene.
  50197. * true by default.
  50198. */
  50199. setupImageProcessing: boolean;
  50200. /**
  50201. * The texture used as your environment texture in the scene.
  50202. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50203. *
  50204. * Remarks: Can be either a texture or a url.
  50205. */
  50206. environmentTexture: string | BaseTexture;
  50207. /**
  50208. * The value of the exposure to apply to the scene.
  50209. * 0.6 by default if setupImageProcessing is true.
  50210. */
  50211. cameraExposure: number;
  50212. /**
  50213. * The value of the contrast to apply to the scene.
  50214. * 1.6 by default if setupImageProcessing is true.
  50215. */
  50216. cameraContrast: number;
  50217. /**
  50218. * Specifies whether or not tonemapping should be enabled in the scene.
  50219. * true by default if setupImageProcessing is true.
  50220. */
  50221. toneMappingEnabled: boolean;
  50222. }
  50223. /**
  50224. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50225. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50226. * It also helps with the default setup of your imageProcessing configuration.
  50227. */
  50228. export class EnvironmentHelper {
  50229. /**
  50230. * Default ground texture URL.
  50231. */
  50232. private static _groundTextureCDNUrl;
  50233. /**
  50234. * Default skybox texture URL.
  50235. */
  50236. private static _skyboxTextureCDNUrl;
  50237. /**
  50238. * Default environment texture URL.
  50239. */
  50240. private static _environmentTextureCDNUrl;
  50241. /**
  50242. * Creates the default options for the helper.
  50243. */
  50244. private static _getDefaultOptions;
  50245. private _rootMesh;
  50246. /**
  50247. * Gets the root mesh created by the helper.
  50248. */
  50249. get rootMesh(): Mesh;
  50250. private _skybox;
  50251. /**
  50252. * Gets the skybox created by the helper.
  50253. */
  50254. get skybox(): Nullable<Mesh>;
  50255. private _skyboxTexture;
  50256. /**
  50257. * Gets the skybox texture created by the helper.
  50258. */
  50259. get skyboxTexture(): Nullable<BaseTexture>;
  50260. private _skyboxMaterial;
  50261. /**
  50262. * Gets the skybox material created by the helper.
  50263. */
  50264. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50265. private _ground;
  50266. /**
  50267. * Gets the ground mesh created by the helper.
  50268. */
  50269. get ground(): Nullable<Mesh>;
  50270. private _groundTexture;
  50271. /**
  50272. * Gets the ground texture created by the helper.
  50273. */
  50274. get groundTexture(): Nullable<BaseTexture>;
  50275. private _groundMirror;
  50276. /**
  50277. * Gets the ground mirror created by the helper.
  50278. */
  50279. get groundMirror(): Nullable<MirrorTexture>;
  50280. /**
  50281. * Gets the ground mirror render list to helps pushing the meshes
  50282. * you wish in the ground reflection.
  50283. */
  50284. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50285. private _groundMaterial;
  50286. /**
  50287. * Gets the ground material created by the helper.
  50288. */
  50289. get groundMaterial(): Nullable<BackgroundMaterial>;
  50290. /**
  50291. * Stores the creation options.
  50292. */
  50293. private readonly _scene;
  50294. private _options;
  50295. /**
  50296. * This observable will be notified with any error during the creation of the environment,
  50297. * mainly texture creation errors.
  50298. */
  50299. onErrorObservable: Observable<{
  50300. message?: string;
  50301. exception?: any;
  50302. }>;
  50303. /**
  50304. * constructor
  50305. * @param options Defines the options we want to customize the helper
  50306. * @param scene The scene to add the material to
  50307. */
  50308. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50309. /**
  50310. * Updates the background according to the new options
  50311. * @param options
  50312. */
  50313. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50314. /**
  50315. * Sets the primary color of all the available elements.
  50316. * @param color the main color to affect to the ground and the background
  50317. */
  50318. setMainColor(color: Color3): void;
  50319. /**
  50320. * Setup the image processing according to the specified options.
  50321. */
  50322. private _setupImageProcessing;
  50323. /**
  50324. * Setup the environment texture according to the specified options.
  50325. */
  50326. private _setupEnvironmentTexture;
  50327. /**
  50328. * Setup the background according to the specified options.
  50329. */
  50330. private _setupBackground;
  50331. /**
  50332. * Get the scene sizes according to the setup.
  50333. */
  50334. private _getSceneSize;
  50335. /**
  50336. * Setup the ground according to the specified options.
  50337. */
  50338. private _setupGround;
  50339. /**
  50340. * Setup the ground material according to the specified options.
  50341. */
  50342. private _setupGroundMaterial;
  50343. /**
  50344. * Setup the ground diffuse texture according to the specified options.
  50345. */
  50346. private _setupGroundDiffuseTexture;
  50347. /**
  50348. * Setup the ground mirror texture according to the specified options.
  50349. */
  50350. private _setupGroundMirrorTexture;
  50351. /**
  50352. * Setup the ground to receive the mirror texture.
  50353. */
  50354. private _setupMirrorInGroundMaterial;
  50355. /**
  50356. * Setup the skybox according to the specified options.
  50357. */
  50358. private _setupSkybox;
  50359. /**
  50360. * Setup the skybox material according to the specified options.
  50361. */
  50362. private _setupSkyboxMaterial;
  50363. /**
  50364. * Setup the skybox reflection texture according to the specified options.
  50365. */
  50366. private _setupSkyboxReflectionTexture;
  50367. private _errorHandler;
  50368. /**
  50369. * Dispose all the elements created by the Helper.
  50370. */
  50371. dispose(): void;
  50372. }
  50373. }
  50374. declare module BABYLON {
  50375. /**
  50376. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50377. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50378. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50379. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50380. */
  50381. export class PhotoDome extends TransformNode {
  50382. /**
  50383. * Define the image as a Monoscopic panoramic 360 image.
  50384. */
  50385. static readonly MODE_MONOSCOPIC: number;
  50386. /**
  50387. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50388. */
  50389. static readonly MODE_TOPBOTTOM: number;
  50390. /**
  50391. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50392. */
  50393. static readonly MODE_SIDEBYSIDE: number;
  50394. private _useDirectMapping;
  50395. /**
  50396. * The texture being displayed on the sphere
  50397. */
  50398. protected _photoTexture: Texture;
  50399. /**
  50400. * Gets or sets the texture being displayed on the sphere
  50401. */
  50402. get photoTexture(): Texture;
  50403. set photoTexture(value: Texture);
  50404. /**
  50405. * Observable raised when an error occured while loading the 360 image
  50406. */
  50407. onLoadErrorObservable: Observable<string>;
  50408. /**
  50409. * The skybox material
  50410. */
  50411. protected _material: BackgroundMaterial;
  50412. /**
  50413. * The surface used for the skybox
  50414. */
  50415. protected _mesh: Mesh;
  50416. /**
  50417. * Gets the mesh used for the skybox.
  50418. */
  50419. get mesh(): Mesh;
  50420. /**
  50421. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50422. * Also see the options.resolution property.
  50423. */
  50424. get fovMultiplier(): number;
  50425. set fovMultiplier(value: number);
  50426. private _imageMode;
  50427. /**
  50428. * Gets or set the current video mode for the video. It can be:
  50429. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50430. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50431. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50432. */
  50433. get imageMode(): number;
  50434. set imageMode(value: number);
  50435. /**
  50436. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50437. * @param name Element's name, child elements will append suffixes for their own names.
  50438. * @param urlsOfPhoto defines the url of the photo to display
  50439. * @param options defines an object containing optional or exposed sub element properties
  50440. * @param onError defines a callback called when an error occured while loading the texture
  50441. */
  50442. constructor(name: string, urlOfPhoto: string, options: {
  50443. resolution?: number;
  50444. size?: number;
  50445. useDirectMapping?: boolean;
  50446. faceForward?: boolean;
  50447. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50448. private _onBeforeCameraRenderObserver;
  50449. private _changeImageMode;
  50450. /**
  50451. * Releases resources associated with this node.
  50452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50454. */
  50455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50456. }
  50457. }
  50458. declare module BABYLON {
  50459. /**
  50460. * Class used to host RGBD texture specific utilities
  50461. */
  50462. export class RGBDTextureTools {
  50463. /**
  50464. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50465. * @param texture the texture to expand.
  50466. */
  50467. static ExpandRGBDTexture(texture: Texture): void;
  50468. }
  50469. }
  50470. declare module BABYLON {
  50471. /**
  50472. * Class used to host texture specific utilities
  50473. */
  50474. export class BRDFTextureTools {
  50475. /**
  50476. * Prevents texture cache collision
  50477. */
  50478. private static _instanceNumber;
  50479. /**
  50480. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50481. * @param scene defines the hosting scene
  50482. * @returns the environment BRDF texture
  50483. */
  50484. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50485. private static _environmentBRDFBase64Texture;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * @hidden
  50491. */
  50492. export interface IMaterialClearCoatDefines {
  50493. CLEARCOAT: boolean;
  50494. CLEARCOAT_DEFAULTIOR: boolean;
  50495. CLEARCOAT_TEXTURE: boolean;
  50496. CLEARCOAT_TEXTUREDIRECTUV: number;
  50497. CLEARCOAT_BUMP: boolean;
  50498. CLEARCOAT_BUMPDIRECTUV: number;
  50499. CLEARCOAT_TINT: boolean;
  50500. CLEARCOAT_TINT_TEXTURE: boolean;
  50501. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50502. /** @hidden */
  50503. _areTexturesDirty: boolean;
  50504. }
  50505. /**
  50506. * Define the code related to the clear coat parameters of the pbr material.
  50507. */
  50508. export class PBRClearCoatConfiguration {
  50509. /**
  50510. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50511. * The default fits with a polyurethane material.
  50512. */
  50513. private static readonly _DefaultIndexOfRefraction;
  50514. private _isEnabled;
  50515. /**
  50516. * Defines if the clear coat is enabled in the material.
  50517. */
  50518. isEnabled: boolean;
  50519. /**
  50520. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50521. */
  50522. intensity: number;
  50523. /**
  50524. * Defines the clear coat layer roughness.
  50525. */
  50526. roughness: number;
  50527. private _indexOfRefraction;
  50528. /**
  50529. * Defines the index of refraction of the clear coat.
  50530. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50531. * The default fits with a polyurethane material.
  50532. * Changing the default value is more performance intensive.
  50533. */
  50534. indexOfRefraction: number;
  50535. private _texture;
  50536. /**
  50537. * Stores the clear coat values in a texture.
  50538. */
  50539. texture: Nullable<BaseTexture>;
  50540. private _bumpTexture;
  50541. /**
  50542. * Define the clear coat specific bump texture.
  50543. */
  50544. bumpTexture: Nullable<BaseTexture>;
  50545. private _isTintEnabled;
  50546. /**
  50547. * Defines if the clear coat tint is enabled in the material.
  50548. */
  50549. isTintEnabled: boolean;
  50550. /**
  50551. * Defines the clear coat tint of the material.
  50552. * This is only use if tint is enabled
  50553. */
  50554. tintColor: Color3;
  50555. /**
  50556. * Defines the distance at which the tint color should be found in the
  50557. * clear coat media.
  50558. * This is only use if tint is enabled
  50559. */
  50560. tintColorAtDistance: number;
  50561. /**
  50562. * Defines the clear coat layer thickness.
  50563. * This is only use if tint is enabled
  50564. */
  50565. tintThickness: number;
  50566. private _tintTexture;
  50567. /**
  50568. * Stores the clear tint values in a texture.
  50569. * rgb is tint
  50570. * a is a thickness factor
  50571. */
  50572. tintTexture: Nullable<BaseTexture>;
  50573. /** @hidden */
  50574. private _internalMarkAllSubMeshesAsTexturesDirty;
  50575. /** @hidden */
  50576. _markAllSubMeshesAsTexturesDirty(): void;
  50577. /**
  50578. * Instantiate a new istance of clear coat configuration.
  50579. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50580. */
  50581. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50582. /**
  50583. * Gets wehter the submesh is ready to be used or not.
  50584. * @param defines the list of "defines" to update.
  50585. * @param scene defines the scene the material belongs to.
  50586. * @param engine defines the engine the material belongs to.
  50587. * @param disableBumpMap defines wether the material disables bump or not.
  50588. * @returns - boolean indicating that the submesh is ready or not.
  50589. */
  50590. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50591. /**
  50592. * Checks to see if a texture is used in the material.
  50593. * @param defines the list of "defines" to update.
  50594. * @param scene defines the scene to the material belongs to.
  50595. */
  50596. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50597. /**
  50598. * Binds the material data.
  50599. * @param uniformBuffer defines the Uniform buffer to fill in.
  50600. * @param scene defines the scene the material belongs to.
  50601. * @param engine defines the engine the material belongs to.
  50602. * @param disableBumpMap defines wether the material disables bump or not.
  50603. * @param isFrozen defines wether the material is frozen or not.
  50604. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50605. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50606. */
  50607. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50608. /**
  50609. * Checks to see if a texture is used in the material.
  50610. * @param texture - Base texture to use.
  50611. * @returns - Boolean specifying if a texture is used in the material.
  50612. */
  50613. hasTexture(texture: BaseTexture): boolean;
  50614. /**
  50615. * Returns an array of the actively used textures.
  50616. * @param activeTextures Array of BaseTextures
  50617. */
  50618. getActiveTextures(activeTextures: BaseTexture[]): void;
  50619. /**
  50620. * Returns the animatable textures.
  50621. * @param animatables Array of animatable textures.
  50622. */
  50623. getAnimatables(animatables: IAnimatable[]): void;
  50624. /**
  50625. * Disposes the resources of the material.
  50626. * @param forceDisposeTextures - Forces the disposal of all textures.
  50627. */
  50628. dispose(forceDisposeTextures?: boolean): void;
  50629. /**
  50630. * Get the current class name of the texture useful for serialization or dynamic coding.
  50631. * @returns "PBRClearCoatConfiguration"
  50632. */
  50633. getClassName(): string;
  50634. /**
  50635. * Add fallbacks to the effect fallbacks list.
  50636. * @param defines defines the Base texture to use.
  50637. * @param fallbacks defines the current fallback list.
  50638. * @param currentRank defines the current fallback rank.
  50639. * @returns the new fallback rank.
  50640. */
  50641. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50642. /**
  50643. * Add the required uniforms to the current list.
  50644. * @param uniforms defines the current uniform list.
  50645. */
  50646. static AddUniforms(uniforms: string[]): void;
  50647. /**
  50648. * Add the required samplers to the current list.
  50649. * @param samplers defines the current sampler list.
  50650. */
  50651. static AddSamplers(samplers: string[]): void;
  50652. /**
  50653. * Add the required uniforms to the current buffer.
  50654. * @param uniformBuffer defines the current uniform buffer.
  50655. */
  50656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50657. /**
  50658. * Makes a duplicate of the current configuration into another one.
  50659. * @param clearCoatConfiguration define the config where to copy the info
  50660. */
  50661. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50662. /**
  50663. * Serializes this clear coat configuration.
  50664. * @returns - An object with the serialized config.
  50665. */
  50666. serialize(): any;
  50667. /**
  50668. * Parses a anisotropy Configuration from a serialized object.
  50669. * @param source - Serialized object.
  50670. * @param scene Defines the scene we are parsing for
  50671. * @param rootUrl Defines the rootUrl to load from
  50672. */
  50673. parse(source: any, scene: Scene, rootUrl: string): void;
  50674. }
  50675. }
  50676. declare module BABYLON {
  50677. /**
  50678. * @hidden
  50679. */
  50680. export interface IMaterialAnisotropicDefines {
  50681. ANISOTROPIC: boolean;
  50682. ANISOTROPIC_TEXTURE: boolean;
  50683. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50684. MAINUV1: boolean;
  50685. _areTexturesDirty: boolean;
  50686. _needUVs: boolean;
  50687. }
  50688. /**
  50689. * Define the code related to the anisotropic parameters of the pbr material.
  50690. */
  50691. export class PBRAnisotropicConfiguration {
  50692. private _isEnabled;
  50693. /**
  50694. * Defines if the anisotropy is enabled in the material.
  50695. */
  50696. isEnabled: boolean;
  50697. /**
  50698. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50699. */
  50700. intensity: number;
  50701. /**
  50702. * Defines if the effect is along the tangents, bitangents or in between.
  50703. * By default, the effect is "strectching" the highlights along the tangents.
  50704. */
  50705. direction: Vector2;
  50706. private _texture;
  50707. /**
  50708. * Stores the anisotropy values in a texture.
  50709. * rg is direction (like normal from -1 to 1)
  50710. * b is a intensity
  50711. */
  50712. texture: Nullable<BaseTexture>;
  50713. /** @hidden */
  50714. private _internalMarkAllSubMeshesAsTexturesDirty;
  50715. /** @hidden */
  50716. _markAllSubMeshesAsTexturesDirty(): void;
  50717. /**
  50718. * Instantiate a new istance of anisotropy configuration.
  50719. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50720. */
  50721. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50722. /**
  50723. * Specifies that the submesh is ready to be used.
  50724. * @param defines the list of "defines" to update.
  50725. * @param scene defines the scene the material belongs to.
  50726. * @returns - boolean indicating that the submesh is ready or not.
  50727. */
  50728. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50729. /**
  50730. * Checks to see if a texture is used in the material.
  50731. * @param defines the list of "defines" to update.
  50732. * @param mesh the mesh we are preparing the defines for.
  50733. * @param scene defines the scene the material belongs to.
  50734. */
  50735. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50736. /**
  50737. * Binds the material data.
  50738. * @param uniformBuffer defines the Uniform buffer to fill in.
  50739. * @param scene defines the scene the material belongs to.
  50740. * @param isFrozen defines wether the material is frozen or not.
  50741. */
  50742. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50743. /**
  50744. * Checks to see if a texture is used in the material.
  50745. * @param texture - Base texture to use.
  50746. * @returns - Boolean specifying if a texture is used in the material.
  50747. */
  50748. hasTexture(texture: BaseTexture): boolean;
  50749. /**
  50750. * Returns an array of the actively used textures.
  50751. * @param activeTextures Array of BaseTextures
  50752. */
  50753. getActiveTextures(activeTextures: BaseTexture[]): void;
  50754. /**
  50755. * Returns the animatable textures.
  50756. * @param animatables Array of animatable textures.
  50757. */
  50758. getAnimatables(animatables: IAnimatable[]): void;
  50759. /**
  50760. * Disposes the resources of the material.
  50761. * @param forceDisposeTextures - Forces the disposal of all textures.
  50762. */
  50763. dispose(forceDisposeTextures?: boolean): void;
  50764. /**
  50765. * Get the current class name of the texture useful for serialization or dynamic coding.
  50766. * @returns "PBRAnisotropicConfiguration"
  50767. */
  50768. getClassName(): string;
  50769. /**
  50770. * Add fallbacks to the effect fallbacks list.
  50771. * @param defines defines the Base texture to use.
  50772. * @param fallbacks defines the current fallback list.
  50773. * @param currentRank defines the current fallback rank.
  50774. * @returns the new fallback rank.
  50775. */
  50776. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50777. /**
  50778. * Add the required uniforms to the current list.
  50779. * @param uniforms defines the current uniform list.
  50780. */
  50781. static AddUniforms(uniforms: string[]): void;
  50782. /**
  50783. * Add the required uniforms to the current buffer.
  50784. * @param uniformBuffer defines the current uniform buffer.
  50785. */
  50786. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50787. /**
  50788. * Add the required samplers to the current list.
  50789. * @param samplers defines the current sampler list.
  50790. */
  50791. static AddSamplers(samplers: string[]): void;
  50792. /**
  50793. * Makes a duplicate of the current configuration into another one.
  50794. * @param anisotropicConfiguration define the config where to copy the info
  50795. */
  50796. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50797. /**
  50798. * Serializes this anisotropy configuration.
  50799. * @returns - An object with the serialized config.
  50800. */
  50801. serialize(): any;
  50802. /**
  50803. * Parses a anisotropy Configuration from a serialized object.
  50804. * @param source - Serialized object.
  50805. * @param scene Defines the scene we are parsing for
  50806. * @param rootUrl Defines the rootUrl to load from
  50807. */
  50808. parse(source: any, scene: Scene, rootUrl: string): void;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * @hidden
  50814. */
  50815. export interface IMaterialBRDFDefines {
  50816. BRDF_V_HEIGHT_CORRELATED: boolean;
  50817. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50818. SPHERICAL_HARMONICS: boolean;
  50819. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50820. /** @hidden */
  50821. _areMiscDirty: boolean;
  50822. }
  50823. /**
  50824. * Define the code related to the BRDF parameters of the pbr material.
  50825. */
  50826. export class PBRBRDFConfiguration {
  50827. /**
  50828. * Default value used for the energy conservation.
  50829. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50830. */
  50831. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50832. /**
  50833. * Default value used for the Smith Visibility Height Correlated mode.
  50834. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50835. */
  50836. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50837. /**
  50838. * Default value used for the IBL diffuse part.
  50839. * This can help switching back to the polynomials mode globally which is a tiny bit
  50840. * less GPU intensive at the drawback of a lower quality.
  50841. */
  50842. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50843. /**
  50844. * Default value used for activating energy conservation for the specular workflow.
  50845. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50846. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50847. */
  50848. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50849. private _useEnergyConservation;
  50850. /**
  50851. * Defines if the material uses energy conservation.
  50852. */
  50853. useEnergyConservation: boolean;
  50854. private _useSmithVisibilityHeightCorrelated;
  50855. /**
  50856. * LEGACY Mode set to false
  50857. * Defines if the material uses height smith correlated visibility term.
  50858. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50859. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50860. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50861. * Not relying on height correlated will also disable energy conservation.
  50862. */
  50863. useSmithVisibilityHeightCorrelated: boolean;
  50864. private _useSphericalHarmonics;
  50865. /**
  50866. * LEGACY Mode set to false
  50867. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50868. * diffuse part of the IBL.
  50869. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50870. * to the ground truth.
  50871. */
  50872. useSphericalHarmonics: boolean;
  50873. private _useSpecularGlossinessInputEnergyConservation;
  50874. /**
  50875. * Defines if the material uses energy conservation, when the specular workflow is active.
  50876. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50877. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50878. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50879. */
  50880. useSpecularGlossinessInputEnergyConservation: boolean;
  50881. /** @hidden */
  50882. private _internalMarkAllSubMeshesAsMiscDirty;
  50883. /** @hidden */
  50884. _markAllSubMeshesAsMiscDirty(): void;
  50885. /**
  50886. * Instantiate a new istance of clear coat configuration.
  50887. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50888. */
  50889. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50890. /**
  50891. * Checks to see if a texture is used in the material.
  50892. * @param defines the list of "defines" to update.
  50893. */
  50894. prepareDefines(defines: IMaterialBRDFDefines): void;
  50895. /**
  50896. * Get the current class name of the texture useful for serialization or dynamic coding.
  50897. * @returns "PBRClearCoatConfiguration"
  50898. */
  50899. getClassName(): string;
  50900. /**
  50901. * Makes a duplicate of the current configuration into another one.
  50902. * @param brdfConfiguration define the config where to copy the info
  50903. */
  50904. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50905. /**
  50906. * Serializes this BRDF configuration.
  50907. * @returns - An object with the serialized config.
  50908. */
  50909. serialize(): any;
  50910. /**
  50911. * Parses a anisotropy Configuration from a serialized object.
  50912. * @param source - Serialized object.
  50913. * @param scene Defines the scene we are parsing for
  50914. * @param rootUrl Defines the rootUrl to load from
  50915. */
  50916. parse(source: any, scene: Scene, rootUrl: string): void;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. /**
  50921. * @hidden
  50922. */
  50923. export interface IMaterialSheenDefines {
  50924. SHEEN: boolean;
  50925. SHEEN_TEXTURE: boolean;
  50926. SHEEN_TEXTUREDIRECTUV: number;
  50927. SHEEN_LINKWITHALBEDO: boolean;
  50928. SHEEN_ROUGHNESS: boolean;
  50929. SHEEN_ALBEDOSCALING: boolean;
  50930. /** @hidden */
  50931. _areTexturesDirty: boolean;
  50932. }
  50933. /**
  50934. * Define the code related to the Sheen parameters of the pbr material.
  50935. */
  50936. export class PBRSheenConfiguration {
  50937. private _isEnabled;
  50938. /**
  50939. * Defines if the material uses sheen.
  50940. */
  50941. isEnabled: boolean;
  50942. private _linkSheenWithAlbedo;
  50943. /**
  50944. * Defines if the sheen is linked to the sheen color.
  50945. */
  50946. linkSheenWithAlbedo: boolean;
  50947. /**
  50948. * Defines the sheen intensity.
  50949. */
  50950. intensity: number;
  50951. /**
  50952. * Defines the sheen color.
  50953. */
  50954. color: Color3;
  50955. private _texture;
  50956. /**
  50957. * Stores the sheen tint values in a texture.
  50958. * rgb is tint
  50959. * a is a intensity
  50960. */
  50961. texture: Nullable<BaseTexture>;
  50962. private _roughness;
  50963. /**
  50964. * Defines the sheen roughness.
  50965. * It is not taken into account if linkSheenWithAlbedo is true.
  50966. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50967. */
  50968. roughness: Nullable<number>;
  50969. private _albedoScaling;
  50970. /**
  50971. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50972. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50973. * making it easier to setup and tweak the effect
  50974. */
  50975. albedoScaling: boolean;
  50976. /** @hidden */
  50977. private _internalMarkAllSubMeshesAsTexturesDirty;
  50978. /** @hidden */
  50979. _markAllSubMeshesAsTexturesDirty(): void;
  50980. /**
  50981. * Instantiate a new istance of clear coat configuration.
  50982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50983. */
  50984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50985. /**
  50986. * Specifies that the submesh is ready to be used.
  50987. * @param defines the list of "defines" to update.
  50988. * @param scene defines the scene the material belongs to.
  50989. * @returns - boolean indicating that the submesh is ready or not.
  50990. */
  50991. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50992. /**
  50993. * Checks to see if a texture is used in the material.
  50994. * @param defines the list of "defines" to update.
  50995. * @param scene defines the scene the material belongs to.
  50996. */
  50997. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50998. /**
  50999. * Binds the material data.
  51000. * @param uniformBuffer defines the Uniform buffer to fill in.
  51001. * @param scene defines the scene the material belongs to.
  51002. * @param isFrozen defines wether the material is frozen or not.
  51003. */
  51004. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51005. /**
  51006. * Checks to see if a texture is used in the material.
  51007. * @param texture - Base texture to use.
  51008. * @returns - Boolean specifying if a texture is used in the material.
  51009. */
  51010. hasTexture(texture: BaseTexture): boolean;
  51011. /**
  51012. * Returns an array of the actively used textures.
  51013. * @param activeTextures Array of BaseTextures
  51014. */
  51015. getActiveTextures(activeTextures: BaseTexture[]): void;
  51016. /**
  51017. * Returns the animatable textures.
  51018. * @param animatables Array of animatable textures.
  51019. */
  51020. getAnimatables(animatables: IAnimatable[]): void;
  51021. /**
  51022. * Disposes the resources of the material.
  51023. * @param forceDisposeTextures - Forces the disposal of all textures.
  51024. */
  51025. dispose(forceDisposeTextures?: boolean): void;
  51026. /**
  51027. * Get the current class name of the texture useful for serialization or dynamic coding.
  51028. * @returns "PBRSheenConfiguration"
  51029. */
  51030. getClassName(): string;
  51031. /**
  51032. * Add fallbacks to the effect fallbacks list.
  51033. * @param defines defines the Base texture to use.
  51034. * @param fallbacks defines the current fallback list.
  51035. * @param currentRank defines the current fallback rank.
  51036. * @returns the new fallback rank.
  51037. */
  51038. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51039. /**
  51040. * Add the required uniforms to the current list.
  51041. * @param uniforms defines the current uniform list.
  51042. */
  51043. static AddUniforms(uniforms: string[]): void;
  51044. /**
  51045. * Add the required uniforms to the current buffer.
  51046. * @param uniformBuffer defines the current uniform buffer.
  51047. */
  51048. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51049. /**
  51050. * Add the required samplers to the current list.
  51051. * @param samplers defines the current sampler list.
  51052. */
  51053. static AddSamplers(samplers: string[]): void;
  51054. /**
  51055. * Makes a duplicate of the current configuration into another one.
  51056. * @param sheenConfiguration define the config where to copy the info
  51057. */
  51058. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51059. /**
  51060. * Serializes this BRDF configuration.
  51061. * @returns - An object with the serialized config.
  51062. */
  51063. serialize(): any;
  51064. /**
  51065. * Parses a anisotropy Configuration from a serialized object.
  51066. * @param source - Serialized object.
  51067. * @param scene Defines the scene we are parsing for
  51068. * @param rootUrl Defines the rootUrl to load from
  51069. */
  51070. parse(source: any, scene: Scene, rootUrl: string): void;
  51071. }
  51072. }
  51073. declare module BABYLON {
  51074. /**
  51075. * @hidden
  51076. */
  51077. export interface IMaterialSubSurfaceDefines {
  51078. SUBSURFACE: boolean;
  51079. SS_REFRACTION: boolean;
  51080. SS_TRANSLUCENCY: boolean;
  51081. SS_SCATERRING: boolean;
  51082. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51083. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51084. SS_REFRACTIONMAP_3D: boolean;
  51085. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51086. SS_LODINREFRACTIONALPHA: boolean;
  51087. SS_GAMMAREFRACTION: boolean;
  51088. SS_RGBDREFRACTION: boolean;
  51089. SS_LINEARSPECULARREFRACTION: boolean;
  51090. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51091. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51092. /** @hidden */
  51093. _areTexturesDirty: boolean;
  51094. }
  51095. /**
  51096. * Define the code related to the sub surface parameters of the pbr material.
  51097. */
  51098. export class PBRSubSurfaceConfiguration {
  51099. private _isRefractionEnabled;
  51100. /**
  51101. * Defines if the refraction is enabled in the material.
  51102. */
  51103. isRefractionEnabled: boolean;
  51104. private _isTranslucencyEnabled;
  51105. /**
  51106. * Defines if the translucency is enabled in the material.
  51107. */
  51108. isTranslucencyEnabled: boolean;
  51109. private _isScatteringEnabled;
  51110. /**
  51111. * Defines the refraction intensity of the material.
  51112. * The refraction when enabled replaces the Diffuse part of the material.
  51113. * The intensity helps transitionning between diffuse and refraction.
  51114. */
  51115. refractionIntensity: number;
  51116. /**
  51117. * Defines the translucency intensity of the material.
  51118. * When translucency has been enabled, this defines how much of the "translucency"
  51119. * is addded to the diffuse part of the material.
  51120. */
  51121. translucencyIntensity: number;
  51122. /**
  51123. * Defines the scattering intensity of the material.
  51124. * When scattering has been enabled, this defines how much of the "scattered light"
  51125. * is addded to the diffuse part of the material.
  51126. */
  51127. scatteringIntensity: number;
  51128. private _thicknessTexture;
  51129. /**
  51130. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51131. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51132. * 0 would mean minimumThickness
  51133. * 1 would mean maximumThickness
  51134. * The other channels might be use as a mask to vary the different effects intensity.
  51135. */
  51136. thicknessTexture: Nullable<BaseTexture>;
  51137. private _refractionTexture;
  51138. /**
  51139. * Defines the texture to use for refraction.
  51140. */
  51141. refractionTexture: Nullable<BaseTexture>;
  51142. private _indexOfRefraction;
  51143. /**
  51144. * Defines the index of refraction used in the material.
  51145. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51146. */
  51147. indexOfRefraction: number;
  51148. private _invertRefractionY;
  51149. /**
  51150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51151. */
  51152. invertRefractionY: boolean;
  51153. private _linkRefractionWithTransparency;
  51154. /**
  51155. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51156. * Materials half opaque for instance using refraction could benefit from this control.
  51157. */
  51158. linkRefractionWithTransparency: boolean;
  51159. /**
  51160. * Defines the minimum thickness stored in the thickness map.
  51161. * If no thickness map is defined, this value will be used to simulate thickness.
  51162. */
  51163. minimumThickness: number;
  51164. /**
  51165. * Defines the maximum thickness stored in the thickness map.
  51166. */
  51167. maximumThickness: number;
  51168. /**
  51169. * Defines the volume tint of the material.
  51170. * This is used for both translucency and scattering.
  51171. */
  51172. tintColor: Color3;
  51173. /**
  51174. * Defines the distance at which the tint color should be found in the media.
  51175. * This is used for refraction only.
  51176. */
  51177. tintColorAtDistance: number;
  51178. /**
  51179. * Defines how far each channel transmit through the media.
  51180. * It is defined as a color to simplify it selection.
  51181. */
  51182. diffusionDistance: Color3;
  51183. private _useMaskFromThicknessTexture;
  51184. /**
  51185. * Stores the intensity of the different subsurface effects in the thickness texture.
  51186. * * the green channel is the translucency intensity.
  51187. * * the blue channel is the scattering intensity.
  51188. * * the alpha channel is the refraction intensity.
  51189. */
  51190. useMaskFromThicknessTexture: boolean;
  51191. /** @hidden */
  51192. private _internalMarkAllSubMeshesAsTexturesDirty;
  51193. /** @hidden */
  51194. _markAllSubMeshesAsTexturesDirty(): void;
  51195. /**
  51196. * Instantiate a new istance of sub surface configuration.
  51197. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51198. */
  51199. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51200. /**
  51201. * Gets wehter the submesh is ready to be used or not.
  51202. * @param defines the list of "defines" to update.
  51203. * @param scene defines the scene the material belongs to.
  51204. * @returns - boolean indicating that the submesh is ready or not.
  51205. */
  51206. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51207. /**
  51208. * Checks to see if a texture is used in the material.
  51209. * @param defines the list of "defines" to update.
  51210. * @param scene defines the scene to the material belongs to.
  51211. */
  51212. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51213. /**
  51214. * Binds the material data.
  51215. * @param uniformBuffer defines the Uniform buffer to fill in.
  51216. * @param scene defines the scene the material belongs to.
  51217. * @param engine defines the engine the material belongs to.
  51218. * @param isFrozen defines wether the material is frozen or not.
  51219. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51220. */
  51221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51222. /**
  51223. * Unbinds the material from the mesh.
  51224. * @param activeEffect defines the effect that should be unbound from.
  51225. * @returns true if unbound, otherwise false
  51226. */
  51227. unbind(activeEffect: Effect): boolean;
  51228. /**
  51229. * Returns the texture used for refraction or null if none is used.
  51230. * @param scene defines the scene the material belongs to.
  51231. * @returns - Refraction texture if present. If no refraction texture and refraction
  51232. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51233. */
  51234. private _getRefractionTexture;
  51235. /**
  51236. * Returns true if alpha blending should be disabled.
  51237. */
  51238. get disableAlphaBlending(): boolean;
  51239. /**
  51240. * Fills the list of render target textures.
  51241. * @param renderTargets the list of render targets to update
  51242. */
  51243. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51244. /**
  51245. * Checks to see if a texture is used in the material.
  51246. * @param texture - Base texture to use.
  51247. * @returns - Boolean specifying if a texture is used in the material.
  51248. */
  51249. hasTexture(texture: BaseTexture): boolean;
  51250. /**
  51251. * Gets a boolean indicating that current material needs to register RTT
  51252. * @returns true if this uses a render target otherwise false.
  51253. */
  51254. hasRenderTargetTextures(): boolean;
  51255. /**
  51256. * Returns an array of the actively used textures.
  51257. * @param activeTextures Array of BaseTextures
  51258. */
  51259. getActiveTextures(activeTextures: BaseTexture[]): void;
  51260. /**
  51261. * Returns the animatable textures.
  51262. * @param animatables Array of animatable textures.
  51263. */
  51264. getAnimatables(animatables: IAnimatable[]): void;
  51265. /**
  51266. * Disposes the resources of the material.
  51267. * @param forceDisposeTextures - Forces the disposal of all textures.
  51268. */
  51269. dispose(forceDisposeTextures?: boolean): void;
  51270. /**
  51271. * Get the current class name of the texture useful for serialization or dynamic coding.
  51272. * @returns "PBRSubSurfaceConfiguration"
  51273. */
  51274. getClassName(): string;
  51275. /**
  51276. * Add fallbacks to the effect fallbacks list.
  51277. * @param defines defines the Base texture to use.
  51278. * @param fallbacks defines the current fallback list.
  51279. * @param currentRank defines the current fallback rank.
  51280. * @returns the new fallback rank.
  51281. */
  51282. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51283. /**
  51284. * Add the required uniforms to the current list.
  51285. * @param uniforms defines the current uniform list.
  51286. */
  51287. static AddUniforms(uniforms: string[]): void;
  51288. /**
  51289. * Add the required samplers to the current list.
  51290. * @param samplers defines the current sampler list.
  51291. */
  51292. static AddSamplers(samplers: string[]): void;
  51293. /**
  51294. * Add the required uniforms to the current buffer.
  51295. * @param uniformBuffer defines the current uniform buffer.
  51296. */
  51297. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51298. /**
  51299. * Makes a duplicate of the current configuration into another one.
  51300. * @param configuration define the config where to copy the info
  51301. */
  51302. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51303. /**
  51304. * Serializes this Sub Surface configuration.
  51305. * @returns - An object with the serialized config.
  51306. */
  51307. serialize(): any;
  51308. /**
  51309. * Parses a anisotropy Configuration from a serialized object.
  51310. * @param source - Serialized object.
  51311. * @param scene Defines the scene we are parsing for
  51312. * @param rootUrl Defines the rootUrl to load from
  51313. */
  51314. parse(source: any, scene: Scene, rootUrl: string): void;
  51315. }
  51316. }
  51317. declare module BABYLON {
  51318. /** @hidden */
  51319. export var pbrFragmentDeclaration: {
  51320. name: string;
  51321. shader: string;
  51322. };
  51323. }
  51324. declare module BABYLON {
  51325. /** @hidden */
  51326. export var pbrUboDeclaration: {
  51327. name: string;
  51328. shader: string;
  51329. };
  51330. }
  51331. declare module BABYLON {
  51332. /** @hidden */
  51333. export var pbrFragmentExtraDeclaration: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module BABYLON {
  51339. /** @hidden */
  51340. export var pbrFragmentSamplersDeclaration: {
  51341. name: string;
  51342. shader: string;
  51343. };
  51344. }
  51345. declare module BABYLON {
  51346. /** @hidden */
  51347. export var pbrHelperFunctions: {
  51348. name: string;
  51349. shader: string;
  51350. };
  51351. }
  51352. declare module BABYLON {
  51353. /** @hidden */
  51354. export var harmonicsFunctions: {
  51355. name: string;
  51356. shader: string;
  51357. };
  51358. }
  51359. declare module BABYLON {
  51360. /** @hidden */
  51361. export var pbrDirectLightingSetupFunctions: {
  51362. name: string;
  51363. shader: string;
  51364. };
  51365. }
  51366. declare module BABYLON {
  51367. /** @hidden */
  51368. export var pbrDirectLightingFalloffFunctions: {
  51369. name: string;
  51370. shader: string;
  51371. };
  51372. }
  51373. declare module BABYLON {
  51374. /** @hidden */
  51375. export var pbrBRDFFunctions: {
  51376. name: string;
  51377. shader: string;
  51378. };
  51379. }
  51380. declare module BABYLON {
  51381. /** @hidden */
  51382. export var pbrDirectLightingFunctions: {
  51383. name: string;
  51384. shader: string;
  51385. };
  51386. }
  51387. declare module BABYLON {
  51388. /** @hidden */
  51389. export var pbrIBLFunctions: {
  51390. name: string;
  51391. shader: string;
  51392. };
  51393. }
  51394. declare module BABYLON {
  51395. /** @hidden */
  51396. export var pbrBlockAlbedoOpacity: {
  51397. name: string;
  51398. shader: string;
  51399. };
  51400. }
  51401. declare module BABYLON {
  51402. /** @hidden */
  51403. export var pbrBlockReflectivity: {
  51404. name: string;
  51405. shader: string;
  51406. };
  51407. }
  51408. declare module BABYLON {
  51409. /** @hidden */
  51410. export var pbrBlockAmbientOcclusion: {
  51411. name: string;
  51412. shader: string;
  51413. };
  51414. }
  51415. declare module BABYLON {
  51416. /** @hidden */
  51417. export var pbrBlockAlphaFresnel: {
  51418. name: string;
  51419. shader: string;
  51420. };
  51421. }
  51422. declare module BABYLON {
  51423. /** @hidden */
  51424. export var pbrBlockAnisotropic: {
  51425. name: string;
  51426. shader: string;
  51427. };
  51428. }
  51429. declare module BABYLON {
  51430. /** @hidden */
  51431. export var pbrBlockReflection: {
  51432. name: string;
  51433. shader: string;
  51434. };
  51435. }
  51436. declare module BABYLON {
  51437. /** @hidden */
  51438. export var pbrBlockSheen: {
  51439. name: string;
  51440. shader: string;
  51441. };
  51442. }
  51443. declare module BABYLON {
  51444. /** @hidden */
  51445. export var pbrBlockClearcoat: {
  51446. name: string;
  51447. shader: string;
  51448. };
  51449. }
  51450. declare module BABYLON {
  51451. /** @hidden */
  51452. export var pbrBlockSubSurface: {
  51453. name: string;
  51454. shader: string;
  51455. };
  51456. }
  51457. declare module BABYLON {
  51458. /** @hidden */
  51459. export var pbrBlockNormalGeometric: {
  51460. name: string;
  51461. shader: string;
  51462. };
  51463. }
  51464. declare module BABYLON {
  51465. /** @hidden */
  51466. export var pbrBlockNormalFinal: {
  51467. name: string;
  51468. shader: string;
  51469. };
  51470. }
  51471. declare module BABYLON {
  51472. /** @hidden */
  51473. export var pbrBlockGeometryInfo: {
  51474. name: string;
  51475. shader: string;
  51476. };
  51477. }
  51478. declare module BABYLON {
  51479. /** @hidden */
  51480. export var pbrBlockReflectance0: {
  51481. name: string;
  51482. shader: string;
  51483. };
  51484. }
  51485. declare module BABYLON {
  51486. /** @hidden */
  51487. export var pbrBlockReflectance: {
  51488. name: string;
  51489. shader: string;
  51490. };
  51491. }
  51492. declare module BABYLON {
  51493. /** @hidden */
  51494. export var pbrBlockDirectLighting: {
  51495. name: string;
  51496. shader: string;
  51497. };
  51498. }
  51499. declare module BABYLON {
  51500. /** @hidden */
  51501. export var pbrBlockFinalLitComponents: {
  51502. name: string;
  51503. shader: string;
  51504. };
  51505. }
  51506. declare module BABYLON {
  51507. /** @hidden */
  51508. export var pbrBlockFinalUnlitComponents: {
  51509. name: string;
  51510. shader: string;
  51511. };
  51512. }
  51513. declare module BABYLON {
  51514. /** @hidden */
  51515. export var pbrBlockFinalColorComposition: {
  51516. name: string;
  51517. shader: string;
  51518. };
  51519. }
  51520. declare module BABYLON {
  51521. /** @hidden */
  51522. export var pbrBlockImageProcessing: {
  51523. name: string;
  51524. shader: string;
  51525. };
  51526. }
  51527. declare module BABYLON {
  51528. /** @hidden */
  51529. export var pbrDebug: {
  51530. name: string;
  51531. shader: string;
  51532. };
  51533. }
  51534. declare module BABYLON {
  51535. /** @hidden */
  51536. export var pbrPixelShader: {
  51537. name: string;
  51538. shader: string;
  51539. };
  51540. }
  51541. declare module BABYLON {
  51542. /** @hidden */
  51543. export var pbrVertexDeclaration: {
  51544. name: string;
  51545. shader: string;
  51546. };
  51547. }
  51548. declare module BABYLON {
  51549. /** @hidden */
  51550. export var pbrVertexShader: {
  51551. name: string;
  51552. shader: string;
  51553. };
  51554. }
  51555. declare module BABYLON {
  51556. /**
  51557. * Manages the defines for the PBR Material.
  51558. * @hidden
  51559. */
  51560. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51561. PBR: boolean;
  51562. MAINUV1: boolean;
  51563. MAINUV2: boolean;
  51564. UV1: boolean;
  51565. UV2: boolean;
  51566. ALBEDO: boolean;
  51567. GAMMAALBEDO: boolean;
  51568. ALBEDODIRECTUV: number;
  51569. VERTEXCOLOR: boolean;
  51570. AMBIENT: boolean;
  51571. AMBIENTDIRECTUV: number;
  51572. AMBIENTINGRAYSCALE: boolean;
  51573. OPACITY: boolean;
  51574. VERTEXALPHA: boolean;
  51575. OPACITYDIRECTUV: number;
  51576. OPACITYRGB: boolean;
  51577. ALPHATEST: boolean;
  51578. DEPTHPREPASS: boolean;
  51579. ALPHABLEND: boolean;
  51580. ALPHAFROMALBEDO: boolean;
  51581. ALPHATESTVALUE: string;
  51582. SPECULAROVERALPHA: boolean;
  51583. RADIANCEOVERALPHA: boolean;
  51584. ALPHAFRESNEL: boolean;
  51585. LINEARALPHAFRESNEL: boolean;
  51586. PREMULTIPLYALPHA: boolean;
  51587. EMISSIVE: boolean;
  51588. EMISSIVEDIRECTUV: number;
  51589. REFLECTIVITY: boolean;
  51590. REFLECTIVITYDIRECTUV: number;
  51591. SPECULARTERM: boolean;
  51592. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51593. MICROSURFACEAUTOMATIC: boolean;
  51594. LODBASEDMICROSFURACE: boolean;
  51595. MICROSURFACEMAP: boolean;
  51596. MICROSURFACEMAPDIRECTUV: number;
  51597. METALLICWORKFLOW: boolean;
  51598. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51599. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51600. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51601. AOSTOREINMETALMAPRED: boolean;
  51602. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51603. ENVIRONMENTBRDF: boolean;
  51604. ENVIRONMENTBRDF_RGBD: boolean;
  51605. NORMAL: boolean;
  51606. TANGENT: boolean;
  51607. BUMP: boolean;
  51608. BUMPDIRECTUV: number;
  51609. OBJECTSPACE_NORMALMAP: boolean;
  51610. PARALLAX: boolean;
  51611. PARALLAXOCCLUSION: boolean;
  51612. NORMALXYSCALE: boolean;
  51613. LIGHTMAP: boolean;
  51614. LIGHTMAPDIRECTUV: number;
  51615. USELIGHTMAPASSHADOWMAP: boolean;
  51616. GAMMALIGHTMAP: boolean;
  51617. RGBDLIGHTMAP: boolean;
  51618. REFLECTION: boolean;
  51619. REFLECTIONMAP_3D: boolean;
  51620. REFLECTIONMAP_SPHERICAL: boolean;
  51621. REFLECTIONMAP_PLANAR: boolean;
  51622. REFLECTIONMAP_CUBIC: boolean;
  51623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51624. REFLECTIONMAP_PROJECTION: boolean;
  51625. REFLECTIONMAP_SKYBOX: boolean;
  51626. REFLECTIONMAP_EXPLICIT: boolean;
  51627. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51628. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51629. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51630. INVERTCUBICMAP: boolean;
  51631. USESPHERICALFROMREFLECTIONMAP: boolean;
  51632. USEIRRADIANCEMAP: boolean;
  51633. SPHERICAL_HARMONICS: boolean;
  51634. USESPHERICALINVERTEX: boolean;
  51635. REFLECTIONMAP_OPPOSITEZ: boolean;
  51636. LODINREFLECTIONALPHA: boolean;
  51637. GAMMAREFLECTION: boolean;
  51638. RGBDREFLECTION: boolean;
  51639. LINEARSPECULARREFLECTION: boolean;
  51640. RADIANCEOCCLUSION: boolean;
  51641. HORIZONOCCLUSION: boolean;
  51642. INSTANCES: boolean;
  51643. NUM_BONE_INFLUENCERS: number;
  51644. BonesPerMesh: number;
  51645. BONETEXTURE: boolean;
  51646. NONUNIFORMSCALING: boolean;
  51647. MORPHTARGETS: boolean;
  51648. MORPHTARGETS_NORMAL: boolean;
  51649. MORPHTARGETS_TANGENT: boolean;
  51650. MORPHTARGETS_UV: boolean;
  51651. NUM_MORPH_INFLUENCERS: number;
  51652. IMAGEPROCESSING: boolean;
  51653. VIGNETTE: boolean;
  51654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51655. VIGNETTEBLENDMODEOPAQUE: boolean;
  51656. TONEMAPPING: boolean;
  51657. TONEMAPPING_ACES: boolean;
  51658. CONTRAST: boolean;
  51659. COLORCURVES: boolean;
  51660. COLORGRADING: boolean;
  51661. COLORGRADING3D: boolean;
  51662. SAMPLER3DGREENDEPTH: boolean;
  51663. SAMPLER3DBGRMAP: boolean;
  51664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51665. EXPOSURE: boolean;
  51666. MULTIVIEW: boolean;
  51667. USEPHYSICALLIGHTFALLOFF: boolean;
  51668. USEGLTFLIGHTFALLOFF: boolean;
  51669. TWOSIDEDLIGHTING: boolean;
  51670. SHADOWFLOAT: boolean;
  51671. CLIPPLANE: boolean;
  51672. CLIPPLANE2: boolean;
  51673. CLIPPLANE3: boolean;
  51674. CLIPPLANE4: boolean;
  51675. CLIPPLANE5: boolean;
  51676. CLIPPLANE6: boolean;
  51677. POINTSIZE: boolean;
  51678. FOG: boolean;
  51679. LOGARITHMICDEPTH: boolean;
  51680. FORCENORMALFORWARD: boolean;
  51681. SPECULARAA: boolean;
  51682. CLEARCOAT: boolean;
  51683. CLEARCOAT_DEFAULTIOR: boolean;
  51684. CLEARCOAT_TEXTURE: boolean;
  51685. CLEARCOAT_TEXTUREDIRECTUV: number;
  51686. CLEARCOAT_BUMP: boolean;
  51687. CLEARCOAT_BUMPDIRECTUV: number;
  51688. CLEARCOAT_TINT: boolean;
  51689. CLEARCOAT_TINT_TEXTURE: boolean;
  51690. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51691. ANISOTROPIC: boolean;
  51692. ANISOTROPIC_TEXTURE: boolean;
  51693. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51694. BRDF_V_HEIGHT_CORRELATED: boolean;
  51695. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51696. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51697. SHEEN: boolean;
  51698. SHEEN_TEXTURE: boolean;
  51699. SHEEN_TEXTUREDIRECTUV: number;
  51700. SHEEN_LINKWITHALBEDO: boolean;
  51701. SHEEN_ROUGHNESS: boolean;
  51702. SHEEN_ALBEDOSCALING: boolean;
  51703. SUBSURFACE: boolean;
  51704. SS_REFRACTION: boolean;
  51705. SS_TRANSLUCENCY: boolean;
  51706. SS_SCATERRING: boolean;
  51707. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51708. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51709. SS_REFRACTIONMAP_3D: boolean;
  51710. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51711. SS_LODINREFRACTIONALPHA: boolean;
  51712. SS_GAMMAREFRACTION: boolean;
  51713. SS_RGBDREFRACTION: boolean;
  51714. SS_LINEARSPECULARREFRACTION: boolean;
  51715. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51716. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51717. UNLIT: boolean;
  51718. DEBUGMODE: number;
  51719. /**
  51720. * Initializes the PBR Material defines.
  51721. */
  51722. constructor();
  51723. /**
  51724. * Resets the PBR Material defines.
  51725. */
  51726. reset(): void;
  51727. }
  51728. /**
  51729. * The Physically based material base class of BJS.
  51730. *
  51731. * This offers the main features of a standard PBR material.
  51732. * For more information, please refer to the documentation :
  51733. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51734. */
  51735. export abstract class PBRBaseMaterial extends PushMaterial {
  51736. /**
  51737. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51738. */
  51739. static readonly PBRMATERIAL_OPAQUE: number;
  51740. /**
  51741. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51742. */
  51743. static readonly PBRMATERIAL_ALPHATEST: number;
  51744. /**
  51745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51746. */
  51747. static readonly PBRMATERIAL_ALPHABLEND: number;
  51748. /**
  51749. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51750. * They are also discarded below the alpha cutoff threshold to improve performances.
  51751. */
  51752. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51753. /**
  51754. * Defines the default value of how much AO map is occluding the analytical lights
  51755. * (point spot...).
  51756. */
  51757. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51758. /**
  51759. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51760. */
  51761. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51762. /**
  51763. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51764. * to enhance interoperability with other engines.
  51765. */
  51766. static readonly LIGHTFALLOFF_GLTF: number;
  51767. /**
  51768. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51769. * to enhance interoperability with other materials.
  51770. */
  51771. static readonly LIGHTFALLOFF_STANDARD: number;
  51772. /**
  51773. * Intensity of the direct lights e.g. the four lights available in your scene.
  51774. * This impacts both the direct diffuse and specular highlights.
  51775. */
  51776. protected _directIntensity: number;
  51777. /**
  51778. * Intensity of the emissive part of the material.
  51779. * This helps controlling the emissive effect without modifying the emissive color.
  51780. */
  51781. protected _emissiveIntensity: number;
  51782. /**
  51783. * Intensity of the environment e.g. how much the environment will light the object
  51784. * either through harmonics for rough material or through the refelction for shiny ones.
  51785. */
  51786. protected _environmentIntensity: number;
  51787. /**
  51788. * This is a special control allowing the reduction of the specular highlights coming from the
  51789. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51790. */
  51791. protected _specularIntensity: number;
  51792. /**
  51793. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51794. */
  51795. private _lightingInfos;
  51796. /**
  51797. * Debug Control allowing disabling the bump map on this material.
  51798. */
  51799. protected _disableBumpMap: boolean;
  51800. /**
  51801. * AKA Diffuse Texture in standard nomenclature.
  51802. */
  51803. protected _albedoTexture: Nullable<BaseTexture>;
  51804. /**
  51805. * AKA Occlusion Texture in other nomenclature.
  51806. */
  51807. protected _ambientTexture: Nullable<BaseTexture>;
  51808. /**
  51809. * AKA Occlusion Texture Intensity in other nomenclature.
  51810. */
  51811. protected _ambientTextureStrength: number;
  51812. /**
  51813. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51814. * 1 means it completely occludes it
  51815. * 0 mean it has no impact
  51816. */
  51817. protected _ambientTextureImpactOnAnalyticalLights: number;
  51818. /**
  51819. * Stores the alpha values in a texture.
  51820. */
  51821. protected _opacityTexture: Nullable<BaseTexture>;
  51822. /**
  51823. * Stores the reflection values in a texture.
  51824. */
  51825. protected _reflectionTexture: Nullable<BaseTexture>;
  51826. /**
  51827. * Stores the emissive values in a texture.
  51828. */
  51829. protected _emissiveTexture: Nullable<BaseTexture>;
  51830. /**
  51831. * AKA Specular texture in other nomenclature.
  51832. */
  51833. protected _reflectivityTexture: Nullable<BaseTexture>;
  51834. /**
  51835. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51836. */
  51837. protected _metallicTexture: Nullable<BaseTexture>;
  51838. /**
  51839. * Specifies the metallic scalar of the metallic/roughness workflow.
  51840. * Can also be used to scale the metalness values of the metallic texture.
  51841. */
  51842. protected _metallic: Nullable<number>;
  51843. /**
  51844. * Specifies the roughness scalar of the metallic/roughness workflow.
  51845. * Can also be used to scale the roughness values of the metallic texture.
  51846. */
  51847. protected _roughness: Nullable<number>;
  51848. /**
  51849. * Specifies the an F0 factor to help configuring the material F0.
  51850. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51851. * to 0.5 the previously hard coded value stays the same.
  51852. * Can also be used to scale the F0 values of the metallic texture.
  51853. */
  51854. protected _metallicF0Factor: number;
  51855. /**
  51856. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51857. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51858. * your expectation as it multiplies with the texture data.
  51859. */
  51860. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51861. /**
  51862. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51863. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51864. */
  51865. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51866. /**
  51867. * Stores surface normal data used to displace a mesh in a texture.
  51868. */
  51869. protected _bumpTexture: Nullable<BaseTexture>;
  51870. /**
  51871. * Stores the pre-calculated light information of a mesh in a texture.
  51872. */
  51873. protected _lightmapTexture: Nullable<BaseTexture>;
  51874. /**
  51875. * The color of a material in ambient lighting.
  51876. */
  51877. protected _ambientColor: Color3;
  51878. /**
  51879. * AKA Diffuse Color in other nomenclature.
  51880. */
  51881. protected _albedoColor: Color3;
  51882. /**
  51883. * AKA Specular Color in other nomenclature.
  51884. */
  51885. protected _reflectivityColor: Color3;
  51886. /**
  51887. * The color applied when light is reflected from a material.
  51888. */
  51889. protected _reflectionColor: Color3;
  51890. /**
  51891. * The color applied when light is emitted from a material.
  51892. */
  51893. protected _emissiveColor: Color3;
  51894. /**
  51895. * AKA Glossiness in other nomenclature.
  51896. */
  51897. protected _microSurface: number;
  51898. /**
  51899. * Specifies that the material will use the light map as a show map.
  51900. */
  51901. protected _useLightmapAsShadowmap: boolean;
  51902. /**
  51903. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51904. * makes the reflect vector face the model (under horizon).
  51905. */
  51906. protected _useHorizonOcclusion: boolean;
  51907. /**
  51908. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51909. * too much the area relying on ambient texture to define their ambient occlusion.
  51910. */
  51911. protected _useRadianceOcclusion: boolean;
  51912. /**
  51913. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51914. */
  51915. protected _useAlphaFromAlbedoTexture: boolean;
  51916. /**
  51917. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51918. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51919. */
  51920. protected _useSpecularOverAlpha: boolean;
  51921. /**
  51922. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51923. */
  51924. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51925. /**
  51926. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51927. */
  51928. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51929. /**
  51930. * Specifies if the metallic texture contains the roughness information in its green channel.
  51931. */
  51932. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51933. /**
  51934. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51935. */
  51936. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51937. /**
  51938. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51939. */
  51940. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51941. /**
  51942. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51943. */
  51944. protected _useAmbientInGrayScale: boolean;
  51945. /**
  51946. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51947. * The material will try to infer what glossiness each pixel should be.
  51948. */
  51949. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51950. /**
  51951. * Defines the falloff type used in this material.
  51952. * It by default is Physical.
  51953. */
  51954. protected _lightFalloff: number;
  51955. /**
  51956. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51957. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51958. */
  51959. protected _useRadianceOverAlpha: boolean;
  51960. /**
  51961. * Allows using an object space normal map (instead of tangent space).
  51962. */
  51963. protected _useObjectSpaceNormalMap: boolean;
  51964. /**
  51965. * Allows using the bump map in parallax mode.
  51966. */
  51967. protected _useParallax: boolean;
  51968. /**
  51969. * Allows using the bump map in parallax occlusion mode.
  51970. */
  51971. protected _useParallaxOcclusion: boolean;
  51972. /**
  51973. * Controls the scale bias of the parallax mode.
  51974. */
  51975. protected _parallaxScaleBias: number;
  51976. /**
  51977. * If sets to true, disables all the lights affecting the material.
  51978. */
  51979. protected _disableLighting: boolean;
  51980. /**
  51981. * Number of Simultaneous lights allowed on the material.
  51982. */
  51983. protected _maxSimultaneousLights: number;
  51984. /**
  51985. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51986. */
  51987. protected _invertNormalMapX: boolean;
  51988. /**
  51989. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51990. */
  51991. protected _invertNormalMapY: boolean;
  51992. /**
  51993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51994. */
  51995. protected _twoSidedLighting: boolean;
  51996. /**
  51997. * Defines the alpha limits in alpha test mode.
  51998. */
  51999. protected _alphaCutOff: number;
  52000. /**
  52001. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52002. */
  52003. protected _forceAlphaTest: boolean;
  52004. /**
  52005. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52006. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52007. */
  52008. protected _useAlphaFresnel: boolean;
  52009. /**
  52010. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52011. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52012. */
  52013. protected _useLinearAlphaFresnel: boolean;
  52014. /**
  52015. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52016. * from cos thetav and roughness:
  52017. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52018. */
  52019. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52020. /**
  52021. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52022. */
  52023. protected _forceIrradianceInFragment: boolean;
  52024. /**
  52025. * Force normal to face away from face.
  52026. */
  52027. protected _forceNormalForward: boolean;
  52028. /**
  52029. * Enables specular anti aliasing in the PBR shader.
  52030. * It will both interacts on the Geometry for analytical and IBL lighting.
  52031. * It also prefilter the roughness map based on the bump values.
  52032. */
  52033. protected _enableSpecularAntiAliasing: boolean;
  52034. /**
  52035. * Default configuration related to image processing available in the PBR Material.
  52036. */
  52037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52038. /**
  52039. * Keep track of the image processing observer to allow dispose and replace.
  52040. */
  52041. private _imageProcessingObserver;
  52042. /**
  52043. * Attaches a new image processing configuration to the PBR Material.
  52044. * @param configuration
  52045. */
  52046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52047. /**
  52048. * Stores the available render targets.
  52049. */
  52050. private _renderTargets;
  52051. /**
  52052. * Sets the global ambient color for the material used in lighting calculations.
  52053. */
  52054. private _globalAmbientColor;
  52055. /**
  52056. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52057. */
  52058. private _useLogarithmicDepth;
  52059. /**
  52060. * If set to true, no lighting calculations will be applied.
  52061. */
  52062. private _unlit;
  52063. private _debugMode;
  52064. /**
  52065. * @hidden
  52066. * This is reserved for the inspector.
  52067. * Defines the material debug mode.
  52068. * It helps seeing only some components of the material while troubleshooting.
  52069. */
  52070. debugMode: number;
  52071. /**
  52072. * @hidden
  52073. * This is reserved for the inspector.
  52074. * Specify from where on screen the debug mode should start.
  52075. * The value goes from -1 (full screen) to 1 (not visible)
  52076. * It helps with side by side comparison against the final render
  52077. * This defaults to -1
  52078. */
  52079. private debugLimit;
  52080. /**
  52081. * @hidden
  52082. * This is reserved for the inspector.
  52083. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52084. * You can use the factor to better multiply the final value.
  52085. */
  52086. private debugFactor;
  52087. /**
  52088. * Defines the clear coat layer parameters for the material.
  52089. */
  52090. readonly clearCoat: PBRClearCoatConfiguration;
  52091. /**
  52092. * Defines the anisotropic parameters for the material.
  52093. */
  52094. readonly anisotropy: PBRAnisotropicConfiguration;
  52095. /**
  52096. * Defines the BRDF parameters for the material.
  52097. */
  52098. readonly brdf: PBRBRDFConfiguration;
  52099. /**
  52100. * Defines the Sheen parameters for the material.
  52101. */
  52102. readonly sheen: PBRSheenConfiguration;
  52103. /**
  52104. * Defines the SubSurface parameters for the material.
  52105. */
  52106. readonly subSurface: PBRSubSurfaceConfiguration;
  52107. protected _rebuildInParallel: boolean;
  52108. /**
  52109. * Instantiates a new PBRMaterial instance.
  52110. *
  52111. * @param name The material name
  52112. * @param scene The scene the material will be use in.
  52113. */
  52114. constructor(name: string, scene: Scene);
  52115. /**
  52116. * Gets a boolean indicating that current material needs to register RTT
  52117. */
  52118. get hasRenderTargetTextures(): boolean;
  52119. /**
  52120. * Gets the name of the material class.
  52121. */
  52122. getClassName(): string;
  52123. /**
  52124. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52125. */
  52126. get useLogarithmicDepth(): boolean;
  52127. /**
  52128. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52129. */
  52130. set useLogarithmicDepth(value: boolean);
  52131. /**
  52132. * Returns true if alpha blending should be disabled.
  52133. */
  52134. protected get _disableAlphaBlending(): boolean;
  52135. /**
  52136. * Specifies whether or not this material should be rendered in alpha blend mode.
  52137. */
  52138. needAlphaBlending(): boolean;
  52139. /**
  52140. * Specifies whether or not this material should be rendered in alpha test mode.
  52141. */
  52142. needAlphaTesting(): boolean;
  52143. /**
  52144. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52145. */
  52146. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52147. /**
  52148. * Gets the texture used for the alpha test.
  52149. */
  52150. getAlphaTestTexture(): Nullable<BaseTexture>;
  52151. /**
  52152. * Specifies that the submesh is ready to be used.
  52153. * @param mesh - BJS mesh.
  52154. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52155. * @param useInstances - Specifies that instances should be used.
  52156. * @returns - boolean indicating that the submesh is ready or not.
  52157. */
  52158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52159. /**
  52160. * Specifies if the material uses metallic roughness workflow.
  52161. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52162. */
  52163. isMetallicWorkflow(): boolean;
  52164. private _prepareEffect;
  52165. private _prepareDefines;
  52166. /**
  52167. * Force shader compilation
  52168. */
  52169. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52170. /**
  52171. * Initializes the uniform buffer layout for the shader.
  52172. */
  52173. buildUniformLayout(): void;
  52174. /**
  52175. * Unbinds the material from the mesh
  52176. */
  52177. unbind(): void;
  52178. /**
  52179. * Binds the submesh data.
  52180. * @param world - The world matrix.
  52181. * @param mesh - The BJS mesh.
  52182. * @param subMesh - A submesh of the BJS mesh.
  52183. */
  52184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52185. /**
  52186. * Returns the animatable textures.
  52187. * @returns - Array of animatable textures.
  52188. */
  52189. getAnimatables(): IAnimatable[];
  52190. /**
  52191. * Returns the texture used for reflections.
  52192. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52193. */
  52194. private _getReflectionTexture;
  52195. /**
  52196. * Returns an array of the actively used textures.
  52197. * @returns - Array of BaseTextures
  52198. */
  52199. getActiveTextures(): BaseTexture[];
  52200. /**
  52201. * Checks to see if a texture is used in the material.
  52202. * @param texture - Base texture to use.
  52203. * @returns - Boolean specifying if a texture is used in the material.
  52204. */
  52205. hasTexture(texture: BaseTexture): boolean;
  52206. /**
  52207. * Disposes the resources of the material.
  52208. * @param forceDisposeEffect - Forces the disposal of effects.
  52209. * @param forceDisposeTextures - Forces the disposal of all textures.
  52210. */
  52211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52212. }
  52213. }
  52214. declare module BABYLON {
  52215. /**
  52216. * The Physically based material of BJS.
  52217. *
  52218. * This offers the main features of a standard PBR material.
  52219. * For more information, please refer to the documentation :
  52220. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52221. */
  52222. export class PBRMaterial extends PBRBaseMaterial {
  52223. /**
  52224. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52225. */
  52226. static readonly PBRMATERIAL_OPAQUE: number;
  52227. /**
  52228. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52229. */
  52230. static readonly PBRMATERIAL_ALPHATEST: number;
  52231. /**
  52232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52233. */
  52234. static readonly PBRMATERIAL_ALPHABLEND: number;
  52235. /**
  52236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52237. * They are also discarded below the alpha cutoff threshold to improve performances.
  52238. */
  52239. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52240. /**
  52241. * Defines the default value of how much AO map is occluding the analytical lights
  52242. * (point spot...).
  52243. */
  52244. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52245. /**
  52246. * Intensity of the direct lights e.g. the four lights available in your scene.
  52247. * This impacts both the direct diffuse and specular highlights.
  52248. */
  52249. directIntensity: number;
  52250. /**
  52251. * Intensity of the emissive part of the material.
  52252. * This helps controlling the emissive effect without modifying the emissive color.
  52253. */
  52254. emissiveIntensity: number;
  52255. /**
  52256. * Intensity of the environment e.g. how much the environment will light the object
  52257. * either through harmonics for rough material or through the refelction for shiny ones.
  52258. */
  52259. environmentIntensity: number;
  52260. /**
  52261. * This is a special control allowing the reduction of the specular highlights coming from the
  52262. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52263. */
  52264. specularIntensity: number;
  52265. /**
  52266. * Debug Control allowing disabling the bump map on this material.
  52267. */
  52268. disableBumpMap: boolean;
  52269. /**
  52270. * AKA Diffuse Texture in standard nomenclature.
  52271. */
  52272. albedoTexture: BaseTexture;
  52273. /**
  52274. * AKA Occlusion Texture in other nomenclature.
  52275. */
  52276. ambientTexture: BaseTexture;
  52277. /**
  52278. * AKA Occlusion Texture Intensity in other nomenclature.
  52279. */
  52280. ambientTextureStrength: number;
  52281. /**
  52282. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52283. * 1 means it completely occludes it
  52284. * 0 mean it has no impact
  52285. */
  52286. ambientTextureImpactOnAnalyticalLights: number;
  52287. /**
  52288. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52289. */
  52290. opacityTexture: BaseTexture;
  52291. /**
  52292. * Stores the reflection values in a texture.
  52293. */
  52294. reflectionTexture: Nullable<BaseTexture>;
  52295. /**
  52296. * Stores the emissive values in a texture.
  52297. */
  52298. emissiveTexture: BaseTexture;
  52299. /**
  52300. * AKA Specular texture in other nomenclature.
  52301. */
  52302. reflectivityTexture: BaseTexture;
  52303. /**
  52304. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52305. */
  52306. metallicTexture: BaseTexture;
  52307. /**
  52308. * Specifies the metallic scalar of the metallic/roughness workflow.
  52309. * Can also be used to scale the metalness values of the metallic texture.
  52310. */
  52311. metallic: Nullable<number>;
  52312. /**
  52313. * Specifies the roughness scalar of the metallic/roughness workflow.
  52314. * Can also be used to scale the roughness values of the metallic texture.
  52315. */
  52316. roughness: Nullable<number>;
  52317. /**
  52318. * Specifies the an F0 factor to help configuring the material F0.
  52319. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52320. * to 0.5 the previously hard coded value stays the same.
  52321. * Can also be used to scale the F0 values of the metallic texture.
  52322. */
  52323. metallicF0Factor: number;
  52324. /**
  52325. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52326. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52327. * your expectation as it multiplies with the texture data.
  52328. */
  52329. useMetallicF0FactorFromMetallicTexture: boolean;
  52330. /**
  52331. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52332. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52333. */
  52334. microSurfaceTexture: BaseTexture;
  52335. /**
  52336. * Stores surface normal data used to displace a mesh in a texture.
  52337. */
  52338. bumpTexture: BaseTexture;
  52339. /**
  52340. * Stores the pre-calculated light information of a mesh in a texture.
  52341. */
  52342. lightmapTexture: BaseTexture;
  52343. /**
  52344. * Stores the refracted light information in a texture.
  52345. */
  52346. get refractionTexture(): Nullable<BaseTexture>;
  52347. set refractionTexture(value: Nullable<BaseTexture>);
  52348. /**
  52349. * The color of a material in ambient lighting.
  52350. */
  52351. ambientColor: Color3;
  52352. /**
  52353. * AKA Diffuse Color in other nomenclature.
  52354. */
  52355. albedoColor: Color3;
  52356. /**
  52357. * AKA Specular Color in other nomenclature.
  52358. */
  52359. reflectivityColor: Color3;
  52360. /**
  52361. * The color reflected from the material.
  52362. */
  52363. reflectionColor: Color3;
  52364. /**
  52365. * The color emitted from the material.
  52366. */
  52367. emissiveColor: Color3;
  52368. /**
  52369. * AKA Glossiness in other nomenclature.
  52370. */
  52371. microSurface: number;
  52372. /**
  52373. * source material index of refraction (IOR)' / 'destination material IOR.
  52374. */
  52375. get indexOfRefraction(): number;
  52376. set indexOfRefraction(value: number);
  52377. /**
  52378. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52379. */
  52380. get invertRefractionY(): boolean;
  52381. set invertRefractionY(value: boolean);
  52382. /**
  52383. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52384. * Materials half opaque for instance using refraction could benefit from this control.
  52385. */
  52386. get linkRefractionWithTransparency(): boolean;
  52387. set linkRefractionWithTransparency(value: boolean);
  52388. /**
  52389. * If true, the light map contains occlusion information instead of lighting info.
  52390. */
  52391. useLightmapAsShadowmap: boolean;
  52392. /**
  52393. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52394. */
  52395. useAlphaFromAlbedoTexture: boolean;
  52396. /**
  52397. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52398. */
  52399. forceAlphaTest: boolean;
  52400. /**
  52401. * Defines the alpha limits in alpha test mode.
  52402. */
  52403. alphaCutOff: number;
  52404. /**
  52405. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52406. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52407. */
  52408. useSpecularOverAlpha: boolean;
  52409. /**
  52410. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52411. */
  52412. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52413. /**
  52414. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52415. */
  52416. useRoughnessFromMetallicTextureAlpha: boolean;
  52417. /**
  52418. * Specifies if the metallic texture contains the roughness information in its green channel.
  52419. */
  52420. useRoughnessFromMetallicTextureGreen: boolean;
  52421. /**
  52422. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52423. */
  52424. useMetallnessFromMetallicTextureBlue: boolean;
  52425. /**
  52426. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52427. */
  52428. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52429. /**
  52430. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52431. */
  52432. useAmbientInGrayScale: boolean;
  52433. /**
  52434. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52435. * The material will try to infer what glossiness each pixel should be.
  52436. */
  52437. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52438. /**
  52439. * BJS is using an harcoded light falloff based on a manually sets up range.
  52440. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52441. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52442. */
  52443. get usePhysicalLightFalloff(): boolean;
  52444. /**
  52445. * BJS is using an harcoded light falloff based on a manually sets up range.
  52446. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52447. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52448. */
  52449. set usePhysicalLightFalloff(value: boolean);
  52450. /**
  52451. * In order to support the falloff compatibility with gltf, a special mode has been added
  52452. * to reproduce the gltf light falloff.
  52453. */
  52454. get useGLTFLightFalloff(): boolean;
  52455. /**
  52456. * In order to support the falloff compatibility with gltf, a special mode has been added
  52457. * to reproduce the gltf light falloff.
  52458. */
  52459. set useGLTFLightFalloff(value: boolean);
  52460. /**
  52461. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52462. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52463. */
  52464. useRadianceOverAlpha: boolean;
  52465. /**
  52466. * Allows using an object space normal map (instead of tangent space).
  52467. */
  52468. useObjectSpaceNormalMap: boolean;
  52469. /**
  52470. * Allows using the bump map in parallax mode.
  52471. */
  52472. useParallax: boolean;
  52473. /**
  52474. * Allows using the bump map in parallax occlusion mode.
  52475. */
  52476. useParallaxOcclusion: boolean;
  52477. /**
  52478. * Controls the scale bias of the parallax mode.
  52479. */
  52480. parallaxScaleBias: number;
  52481. /**
  52482. * If sets to true, disables all the lights affecting the material.
  52483. */
  52484. disableLighting: boolean;
  52485. /**
  52486. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52487. */
  52488. forceIrradianceInFragment: boolean;
  52489. /**
  52490. * Number of Simultaneous lights allowed on the material.
  52491. */
  52492. maxSimultaneousLights: number;
  52493. /**
  52494. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52495. */
  52496. invertNormalMapX: boolean;
  52497. /**
  52498. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52499. */
  52500. invertNormalMapY: boolean;
  52501. /**
  52502. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52503. */
  52504. twoSidedLighting: boolean;
  52505. /**
  52506. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52507. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52508. */
  52509. useAlphaFresnel: boolean;
  52510. /**
  52511. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52512. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52513. */
  52514. useLinearAlphaFresnel: boolean;
  52515. /**
  52516. * Let user defines the brdf lookup texture used for IBL.
  52517. * A default 8bit version is embedded but you could point at :
  52518. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52519. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52520. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52521. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52522. */
  52523. environmentBRDFTexture: Nullable<BaseTexture>;
  52524. /**
  52525. * Force normal to face away from face.
  52526. */
  52527. forceNormalForward: boolean;
  52528. /**
  52529. * Enables specular anti aliasing in the PBR shader.
  52530. * It will both interacts on the Geometry for analytical and IBL lighting.
  52531. * It also prefilter the roughness map based on the bump values.
  52532. */
  52533. enableSpecularAntiAliasing: boolean;
  52534. /**
  52535. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52536. * makes the reflect vector face the model (under horizon).
  52537. */
  52538. useHorizonOcclusion: boolean;
  52539. /**
  52540. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52541. * too much the area relying on ambient texture to define their ambient occlusion.
  52542. */
  52543. useRadianceOcclusion: boolean;
  52544. /**
  52545. * If set to true, no lighting calculations will be applied.
  52546. */
  52547. unlit: boolean;
  52548. /**
  52549. * Gets the image processing configuration used either in this material.
  52550. */
  52551. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52552. /**
  52553. * Sets the Default image processing configuration used either in the this material.
  52554. *
  52555. * If sets to null, the scene one is in use.
  52556. */
  52557. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52558. /**
  52559. * Gets wether the color curves effect is enabled.
  52560. */
  52561. get cameraColorCurvesEnabled(): boolean;
  52562. /**
  52563. * Sets wether the color curves effect is enabled.
  52564. */
  52565. set cameraColorCurvesEnabled(value: boolean);
  52566. /**
  52567. * Gets wether the color grading effect is enabled.
  52568. */
  52569. get cameraColorGradingEnabled(): boolean;
  52570. /**
  52571. * Gets wether the color grading effect is enabled.
  52572. */
  52573. set cameraColorGradingEnabled(value: boolean);
  52574. /**
  52575. * Gets wether tonemapping is enabled or not.
  52576. */
  52577. get cameraToneMappingEnabled(): boolean;
  52578. /**
  52579. * Sets wether tonemapping is enabled or not
  52580. */
  52581. set cameraToneMappingEnabled(value: boolean);
  52582. /**
  52583. * The camera exposure used on this material.
  52584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52585. * This corresponds to a photographic exposure.
  52586. */
  52587. get cameraExposure(): number;
  52588. /**
  52589. * The camera exposure used on this material.
  52590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52591. * This corresponds to a photographic exposure.
  52592. */
  52593. set cameraExposure(value: number);
  52594. /**
  52595. * Gets The camera contrast used on this material.
  52596. */
  52597. get cameraContrast(): number;
  52598. /**
  52599. * Sets The camera contrast used on this material.
  52600. */
  52601. set cameraContrast(value: number);
  52602. /**
  52603. * Gets the Color Grading 2D Lookup Texture.
  52604. */
  52605. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52606. /**
  52607. * Sets the Color Grading 2D Lookup Texture.
  52608. */
  52609. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52610. /**
  52611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52613. * 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;
  52614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52615. */
  52616. get cameraColorCurves(): Nullable<ColorCurves>;
  52617. /**
  52618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52620. * 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;
  52621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52622. */
  52623. set cameraColorCurves(value: Nullable<ColorCurves>);
  52624. /**
  52625. * Instantiates a new PBRMaterial instance.
  52626. *
  52627. * @param name The material name
  52628. * @param scene The scene the material will be use in.
  52629. */
  52630. constructor(name: string, scene: Scene);
  52631. /**
  52632. * Returns the name of this material class.
  52633. */
  52634. getClassName(): string;
  52635. /**
  52636. * Makes a duplicate of the current material.
  52637. * @param name - name to use for the new material.
  52638. */
  52639. clone(name: string): PBRMaterial;
  52640. /**
  52641. * Serializes this PBR Material.
  52642. * @returns - An object with the serialized material.
  52643. */
  52644. serialize(): any;
  52645. /**
  52646. * Parses a PBR Material from a serialized object.
  52647. * @param source - Serialized object.
  52648. * @param scene - BJS scene instance.
  52649. * @param rootUrl - url for the scene object
  52650. * @returns - PBRMaterial
  52651. */
  52652. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52653. }
  52654. }
  52655. declare module BABYLON {
  52656. /**
  52657. * Direct draw surface info
  52658. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52659. */
  52660. export interface DDSInfo {
  52661. /**
  52662. * Width of the texture
  52663. */
  52664. width: number;
  52665. /**
  52666. * Width of the texture
  52667. */
  52668. height: number;
  52669. /**
  52670. * Number of Mipmaps for the texture
  52671. * @see https://en.wikipedia.org/wiki/Mipmap
  52672. */
  52673. mipmapCount: number;
  52674. /**
  52675. * If the textures format is a known fourCC format
  52676. * @see https://www.fourcc.org/
  52677. */
  52678. isFourCC: boolean;
  52679. /**
  52680. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52681. */
  52682. isRGB: boolean;
  52683. /**
  52684. * If the texture is a lumincance format
  52685. */
  52686. isLuminance: boolean;
  52687. /**
  52688. * If this is a cube texture
  52689. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52690. */
  52691. isCube: boolean;
  52692. /**
  52693. * If the texture is a compressed format eg. FOURCC_DXT1
  52694. */
  52695. isCompressed: boolean;
  52696. /**
  52697. * The dxgiFormat of the texture
  52698. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52699. */
  52700. dxgiFormat: number;
  52701. /**
  52702. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52703. */
  52704. textureType: number;
  52705. /**
  52706. * Sphericle polynomial created for the dds texture
  52707. */
  52708. sphericalPolynomial?: SphericalPolynomial;
  52709. }
  52710. /**
  52711. * Class used to provide DDS decompression tools
  52712. */
  52713. export class DDSTools {
  52714. /**
  52715. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52716. */
  52717. static StoreLODInAlphaChannel: boolean;
  52718. /**
  52719. * Gets DDS information from an array buffer
  52720. * @param data defines the array buffer view to read data from
  52721. * @returns the DDS information
  52722. */
  52723. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52724. private static _FloatView;
  52725. private static _Int32View;
  52726. private static _ToHalfFloat;
  52727. private static _FromHalfFloat;
  52728. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52729. private static _GetHalfFloatRGBAArrayBuffer;
  52730. private static _GetFloatRGBAArrayBuffer;
  52731. private static _GetFloatAsUIntRGBAArrayBuffer;
  52732. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52733. private static _GetRGBAArrayBuffer;
  52734. private static _ExtractLongWordOrder;
  52735. private static _GetRGBArrayBuffer;
  52736. private static _GetLuminanceArrayBuffer;
  52737. /**
  52738. * Uploads DDS Levels to a Babylon Texture
  52739. * @hidden
  52740. */
  52741. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52742. }
  52743. interface ThinEngine {
  52744. /**
  52745. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52746. * @param rootUrl defines the url where the file to load is located
  52747. * @param scene defines the current scene
  52748. * @param lodScale defines scale to apply to the mip map selection
  52749. * @param lodOffset defines offset to apply to the mip map selection
  52750. * @param onLoad defines an optional callback raised when the texture is loaded
  52751. * @param onError defines an optional callback raised if there is an issue to load the texture
  52752. * @param format defines the format of the data
  52753. * @param forcedExtension defines the extension to use to pick the right loader
  52754. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52755. * @returns the cube texture as an InternalTexture
  52756. */
  52757. 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;
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Implementation of the DDS Texture Loader.
  52763. * @hidden
  52764. */
  52765. export class _DDSTextureLoader implements IInternalTextureLoader {
  52766. /**
  52767. * Defines wether the loader supports cascade loading the different faces.
  52768. */
  52769. readonly supportCascades: boolean;
  52770. /**
  52771. * This returns if the loader support the current file information.
  52772. * @param extension defines the file extension of the file being loaded
  52773. * @returns true if the loader can load the specified file
  52774. */
  52775. canLoad(extension: string): boolean;
  52776. /**
  52777. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52778. * @param data contains the texture data
  52779. * @param texture defines the BabylonJS internal texture
  52780. * @param createPolynomials will be true if polynomials have been requested
  52781. * @param onLoad defines the callback to trigger once the texture is ready
  52782. * @param onError defines the callback to trigger in case of error
  52783. */
  52784. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52785. /**
  52786. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52787. * @param data contains the texture data
  52788. * @param texture defines the BabylonJS internal texture
  52789. * @param callback defines the method to call once ready to upload
  52790. */
  52791. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Implementation of the ENV Texture Loader.
  52797. * @hidden
  52798. */
  52799. export class _ENVTextureLoader implements IInternalTextureLoader {
  52800. /**
  52801. * Defines wether the loader supports cascade loading the different faces.
  52802. */
  52803. readonly supportCascades: boolean;
  52804. /**
  52805. * This returns if the loader support the current file information.
  52806. * @param extension defines the file extension of the file being loaded
  52807. * @returns true if the loader can load the specified file
  52808. */
  52809. canLoad(extension: string): boolean;
  52810. /**
  52811. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52812. * @param data contains the texture data
  52813. * @param texture defines the BabylonJS internal texture
  52814. * @param createPolynomials will be true if polynomials have been requested
  52815. * @param onLoad defines the callback to trigger once the texture is ready
  52816. * @param onError defines the callback to trigger in case of error
  52817. */
  52818. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52819. /**
  52820. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52821. * @param data contains the texture data
  52822. * @param texture defines the BabylonJS internal texture
  52823. * @param callback defines the method to call once ready to upload
  52824. */
  52825. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /**
  52830. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52831. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52832. */
  52833. export class KhronosTextureContainer {
  52834. /** contents of the KTX container file */
  52835. data: ArrayBufferView;
  52836. private static HEADER_LEN;
  52837. private static COMPRESSED_2D;
  52838. private static COMPRESSED_3D;
  52839. private static TEX_2D;
  52840. private static TEX_3D;
  52841. /**
  52842. * Gets the openGL type
  52843. */
  52844. glType: number;
  52845. /**
  52846. * Gets the openGL type size
  52847. */
  52848. glTypeSize: number;
  52849. /**
  52850. * Gets the openGL format
  52851. */
  52852. glFormat: number;
  52853. /**
  52854. * Gets the openGL internal format
  52855. */
  52856. glInternalFormat: number;
  52857. /**
  52858. * Gets the base internal format
  52859. */
  52860. glBaseInternalFormat: number;
  52861. /**
  52862. * Gets image width in pixel
  52863. */
  52864. pixelWidth: number;
  52865. /**
  52866. * Gets image height in pixel
  52867. */
  52868. pixelHeight: number;
  52869. /**
  52870. * Gets image depth in pixels
  52871. */
  52872. pixelDepth: number;
  52873. /**
  52874. * Gets the number of array elements
  52875. */
  52876. numberOfArrayElements: number;
  52877. /**
  52878. * Gets the number of faces
  52879. */
  52880. numberOfFaces: number;
  52881. /**
  52882. * Gets the number of mipmap levels
  52883. */
  52884. numberOfMipmapLevels: number;
  52885. /**
  52886. * Gets the bytes of key value data
  52887. */
  52888. bytesOfKeyValueData: number;
  52889. /**
  52890. * Gets the load type
  52891. */
  52892. loadType: number;
  52893. /**
  52894. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52895. */
  52896. isInvalid: boolean;
  52897. /**
  52898. * Creates a new KhronosTextureContainer
  52899. * @param data contents of the KTX container file
  52900. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52901. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52902. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52903. */
  52904. constructor(
  52905. /** contents of the KTX container file */
  52906. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52907. /**
  52908. * Uploads KTX content to a Babylon Texture.
  52909. * It is assumed that the texture has already been created & is currently bound
  52910. * @hidden
  52911. */
  52912. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52913. private _upload2DCompressedLevels;
  52914. /**
  52915. * Checks if the given data starts with a KTX file identifier.
  52916. * @param data the data to check
  52917. * @returns true if the data is a KTX file or false otherwise
  52918. */
  52919. static IsValid(data: ArrayBufferView): boolean;
  52920. }
  52921. }
  52922. declare module BABYLON {
  52923. /**
  52924. * Class for loading KTX2 files
  52925. * !!! Experimental Extension Subject to Changes !!!
  52926. * @hidden
  52927. */
  52928. export class KhronosTextureContainer2 {
  52929. private static _ModulePromise;
  52930. private static _TranscodeFormat;
  52931. constructor(engine: ThinEngine);
  52932. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52933. private _determineTranscodeFormat;
  52934. /**
  52935. * Checks if the given data starts with a KTX2 file identifier.
  52936. * @param data the data to check
  52937. * @returns true if the data is a KTX2 file or false otherwise
  52938. */
  52939. static IsValid(data: ArrayBufferView): boolean;
  52940. }
  52941. }
  52942. declare module BABYLON {
  52943. /**
  52944. * Implementation of the KTX Texture Loader.
  52945. * @hidden
  52946. */
  52947. export class _KTXTextureLoader implements IInternalTextureLoader {
  52948. /**
  52949. * Defines wether the loader supports cascade loading the different faces.
  52950. */
  52951. readonly supportCascades: boolean;
  52952. /**
  52953. * This returns if the loader support the current file information.
  52954. * @param extension defines the file extension of the file being loaded
  52955. * @returns true if the loader can load the specified file
  52956. */
  52957. canLoad(extension: string): boolean;
  52958. /**
  52959. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52960. * @param data contains the texture data
  52961. * @param texture defines the BabylonJS internal texture
  52962. * @param createPolynomials will be true if polynomials have been requested
  52963. * @param onLoad defines the callback to trigger once the texture is ready
  52964. * @param onError defines the callback to trigger in case of error
  52965. */
  52966. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52967. /**
  52968. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52969. * @param data contains the texture data
  52970. * @param texture defines the BabylonJS internal texture
  52971. * @param callback defines the method to call once ready to upload
  52972. */
  52973. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /** @hidden */
  52978. export var _forceSceneHelpersToBundle: boolean;
  52979. interface Scene {
  52980. /**
  52981. * Creates a default light for the scene.
  52982. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52983. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52984. */
  52985. createDefaultLight(replace?: boolean): void;
  52986. /**
  52987. * Creates a default camera for the scene.
  52988. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52989. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52990. * @param replace has default false, when true replaces the active camera in the scene
  52991. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52992. */
  52993. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52994. /**
  52995. * Creates a default camera and a default light.
  52996. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52997. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52998. * @param replace has the default false, when true replaces the active camera/light in the scene
  52999. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53000. */
  53001. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53002. /**
  53003. * Creates a new sky box
  53004. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53005. * @param environmentTexture defines the texture to use as environment texture
  53006. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53007. * @param scale defines the overall scale of the skybox
  53008. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53009. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53010. * @returns a new mesh holding the sky box
  53011. */
  53012. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53013. /**
  53014. * Creates a new environment
  53015. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53016. * @param options defines the options you can use to configure the environment
  53017. * @returns the new EnvironmentHelper
  53018. */
  53019. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53020. /**
  53021. * Creates a new VREXperienceHelper
  53022. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53023. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53024. * @returns a new VREXperienceHelper
  53025. */
  53026. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53027. /**
  53028. * Creates a new WebXRDefaultExperience
  53029. * @see http://doc.babylonjs.com/how_to/webxr
  53030. * @param options experience options
  53031. * @returns a promise for a new WebXRDefaultExperience
  53032. */
  53033. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53034. }
  53035. }
  53036. declare module BABYLON {
  53037. /**
  53038. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53039. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53040. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53041. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53042. */
  53043. export class VideoDome extends TransformNode {
  53044. /**
  53045. * Define the video source as a Monoscopic panoramic 360 video.
  53046. */
  53047. static readonly MODE_MONOSCOPIC: number;
  53048. /**
  53049. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53050. */
  53051. static readonly MODE_TOPBOTTOM: number;
  53052. /**
  53053. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53054. */
  53055. static readonly MODE_SIDEBYSIDE: number;
  53056. private _halfDome;
  53057. private _useDirectMapping;
  53058. /**
  53059. * The video texture being displayed on the sphere
  53060. */
  53061. protected _videoTexture: VideoTexture;
  53062. /**
  53063. * Gets the video texture being displayed on the sphere
  53064. */
  53065. get videoTexture(): VideoTexture;
  53066. /**
  53067. * The skybox material
  53068. */
  53069. protected _material: BackgroundMaterial;
  53070. /**
  53071. * The surface used for the skybox
  53072. */
  53073. protected _mesh: Mesh;
  53074. /**
  53075. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53076. */
  53077. private _halfDomeMask;
  53078. /**
  53079. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53080. * Also see the options.resolution property.
  53081. */
  53082. get fovMultiplier(): number;
  53083. set fovMultiplier(value: number);
  53084. private _videoMode;
  53085. /**
  53086. * Gets or set the current video mode for the video. It can be:
  53087. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53088. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53089. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53090. */
  53091. get videoMode(): number;
  53092. set videoMode(value: number);
  53093. /**
  53094. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53095. *
  53096. */
  53097. get halfDome(): boolean;
  53098. /**
  53099. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53100. */
  53101. set halfDome(enabled: boolean);
  53102. /**
  53103. * Oberserver used in Stereoscopic VR Mode.
  53104. */
  53105. private _onBeforeCameraRenderObserver;
  53106. /**
  53107. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53108. * @param name Element's name, child elements will append suffixes for their own names.
  53109. * @param urlsOrVideo defines the url(s) or the video element to use
  53110. * @param options An object containing optional or exposed sub element properties
  53111. */
  53112. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53113. resolution?: number;
  53114. clickToPlay?: boolean;
  53115. autoPlay?: boolean;
  53116. loop?: boolean;
  53117. size?: number;
  53118. poster?: string;
  53119. faceForward?: boolean;
  53120. useDirectMapping?: boolean;
  53121. halfDomeMode?: boolean;
  53122. }, scene: Scene);
  53123. private _changeVideoMode;
  53124. /**
  53125. * Releases resources associated with this node.
  53126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53128. */
  53129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53130. }
  53131. }
  53132. declare module BABYLON {
  53133. /**
  53134. * This class can be used to get instrumentation data from a Babylon engine
  53135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53136. */
  53137. export class EngineInstrumentation implements IDisposable {
  53138. /**
  53139. * Define the instrumented engine.
  53140. */
  53141. engine: Engine;
  53142. private _captureGPUFrameTime;
  53143. private _gpuFrameTimeToken;
  53144. private _gpuFrameTime;
  53145. private _captureShaderCompilationTime;
  53146. private _shaderCompilationTime;
  53147. private _onBeginFrameObserver;
  53148. private _onEndFrameObserver;
  53149. private _onBeforeShaderCompilationObserver;
  53150. private _onAfterShaderCompilationObserver;
  53151. /**
  53152. * Gets the perf counter used for GPU frame time
  53153. */
  53154. get gpuFrameTimeCounter(): PerfCounter;
  53155. /**
  53156. * Gets the GPU frame time capture status
  53157. */
  53158. get captureGPUFrameTime(): boolean;
  53159. /**
  53160. * Enable or disable the GPU frame time capture
  53161. */
  53162. set captureGPUFrameTime(value: boolean);
  53163. /**
  53164. * Gets the perf counter used for shader compilation time
  53165. */
  53166. get shaderCompilationTimeCounter(): PerfCounter;
  53167. /**
  53168. * Gets the shader compilation time capture status
  53169. */
  53170. get captureShaderCompilationTime(): boolean;
  53171. /**
  53172. * Enable or disable the shader compilation time capture
  53173. */
  53174. set captureShaderCompilationTime(value: boolean);
  53175. /**
  53176. * Instantiates a new engine instrumentation.
  53177. * This class can be used to get instrumentation data from a Babylon engine
  53178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53179. * @param engine Defines the engine to instrument
  53180. */
  53181. constructor(
  53182. /**
  53183. * Define the instrumented engine.
  53184. */
  53185. engine: Engine);
  53186. /**
  53187. * Dispose and release associated resources.
  53188. */
  53189. dispose(): void;
  53190. }
  53191. }
  53192. declare module BABYLON {
  53193. /**
  53194. * This class can be used to get instrumentation data from a Babylon engine
  53195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53196. */
  53197. export class SceneInstrumentation implements IDisposable {
  53198. /**
  53199. * Defines the scene to instrument
  53200. */
  53201. scene: Scene;
  53202. private _captureActiveMeshesEvaluationTime;
  53203. private _activeMeshesEvaluationTime;
  53204. private _captureRenderTargetsRenderTime;
  53205. private _renderTargetsRenderTime;
  53206. private _captureFrameTime;
  53207. private _frameTime;
  53208. private _captureRenderTime;
  53209. private _renderTime;
  53210. private _captureInterFrameTime;
  53211. private _interFrameTime;
  53212. private _captureParticlesRenderTime;
  53213. private _particlesRenderTime;
  53214. private _captureSpritesRenderTime;
  53215. private _spritesRenderTime;
  53216. private _capturePhysicsTime;
  53217. private _physicsTime;
  53218. private _captureAnimationsTime;
  53219. private _animationsTime;
  53220. private _captureCameraRenderTime;
  53221. private _cameraRenderTime;
  53222. private _onBeforeActiveMeshesEvaluationObserver;
  53223. private _onAfterActiveMeshesEvaluationObserver;
  53224. private _onBeforeRenderTargetsRenderObserver;
  53225. private _onAfterRenderTargetsRenderObserver;
  53226. private _onAfterRenderObserver;
  53227. private _onBeforeDrawPhaseObserver;
  53228. private _onAfterDrawPhaseObserver;
  53229. private _onBeforeAnimationsObserver;
  53230. private _onBeforeParticlesRenderingObserver;
  53231. private _onAfterParticlesRenderingObserver;
  53232. private _onBeforeSpritesRenderingObserver;
  53233. private _onAfterSpritesRenderingObserver;
  53234. private _onBeforePhysicsObserver;
  53235. private _onAfterPhysicsObserver;
  53236. private _onAfterAnimationsObserver;
  53237. private _onBeforeCameraRenderObserver;
  53238. private _onAfterCameraRenderObserver;
  53239. /**
  53240. * Gets the perf counter used for active meshes evaluation time
  53241. */
  53242. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53243. /**
  53244. * Gets the active meshes evaluation time capture status
  53245. */
  53246. get captureActiveMeshesEvaluationTime(): boolean;
  53247. /**
  53248. * Enable or disable the active meshes evaluation time capture
  53249. */
  53250. set captureActiveMeshesEvaluationTime(value: boolean);
  53251. /**
  53252. * Gets the perf counter used for render targets render time
  53253. */
  53254. get renderTargetsRenderTimeCounter(): PerfCounter;
  53255. /**
  53256. * Gets the render targets render time capture status
  53257. */
  53258. get captureRenderTargetsRenderTime(): boolean;
  53259. /**
  53260. * Enable or disable the render targets render time capture
  53261. */
  53262. set captureRenderTargetsRenderTime(value: boolean);
  53263. /**
  53264. * Gets the perf counter used for particles render time
  53265. */
  53266. get particlesRenderTimeCounter(): PerfCounter;
  53267. /**
  53268. * Gets the particles render time capture status
  53269. */
  53270. get captureParticlesRenderTime(): boolean;
  53271. /**
  53272. * Enable or disable the particles render time capture
  53273. */
  53274. set captureParticlesRenderTime(value: boolean);
  53275. /**
  53276. * Gets the perf counter used for sprites render time
  53277. */
  53278. get spritesRenderTimeCounter(): PerfCounter;
  53279. /**
  53280. * Gets the sprites render time capture status
  53281. */
  53282. get captureSpritesRenderTime(): boolean;
  53283. /**
  53284. * Enable or disable the sprites render time capture
  53285. */
  53286. set captureSpritesRenderTime(value: boolean);
  53287. /**
  53288. * Gets the perf counter used for physics time
  53289. */
  53290. get physicsTimeCounter(): PerfCounter;
  53291. /**
  53292. * Gets the physics time capture status
  53293. */
  53294. get capturePhysicsTime(): boolean;
  53295. /**
  53296. * Enable or disable the physics time capture
  53297. */
  53298. set capturePhysicsTime(value: boolean);
  53299. /**
  53300. * Gets the perf counter used for animations time
  53301. */
  53302. get animationsTimeCounter(): PerfCounter;
  53303. /**
  53304. * Gets the animations time capture status
  53305. */
  53306. get captureAnimationsTime(): boolean;
  53307. /**
  53308. * Enable or disable the animations time capture
  53309. */
  53310. set captureAnimationsTime(value: boolean);
  53311. /**
  53312. * Gets the perf counter used for frame time capture
  53313. */
  53314. get frameTimeCounter(): PerfCounter;
  53315. /**
  53316. * Gets the frame time capture status
  53317. */
  53318. get captureFrameTime(): boolean;
  53319. /**
  53320. * Enable or disable the frame time capture
  53321. */
  53322. set captureFrameTime(value: boolean);
  53323. /**
  53324. * Gets the perf counter used for inter-frames time capture
  53325. */
  53326. get interFrameTimeCounter(): PerfCounter;
  53327. /**
  53328. * Gets the inter-frames time capture status
  53329. */
  53330. get captureInterFrameTime(): boolean;
  53331. /**
  53332. * Enable or disable the inter-frames time capture
  53333. */
  53334. set captureInterFrameTime(value: boolean);
  53335. /**
  53336. * Gets the perf counter used for render time capture
  53337. */
  53338. get renderTimeCounter(): PerfCounter;
  53339. /**
  53340. * Gets the render time capture status
  53341. */
  53342. get captureRenderTime(): boolean;
  53343. /**
  53344. * Enable or disable the render time capture
  53345. */
  53346. set captureRenderTime(value: boolean);
  53347. /**
  53348. * Gets the perf counter used for camera render time capture
  53349. */
  53350. get cameraRenderTimeCounter(): PerfCounter;
  53351. /**
  53352. * Gets the camera render time capture status
  53353. */
  53354. get captureCameraRenderTime(): boolean;
  53355. /**
  53356. * Enable or disable the camera render time capture
  53357. */
  53358. set captureCameraRenderTime(value: boolean);
  53359. /**
  53360. * Gets the perf counter used for draw calls
  53361. */
  53362. get drawCallsCounter(): PerfCounter;
  53363. /**
  53364. * Instantiates a new scene instrumentation.
  53365. * This class can be used to get instrumentation data from a Babylon engine
  53366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53367. * @param scene Defines the scene to instrument
  53368. */
  53369. constructor(
  53370. /**
  53371. * Defines the scene to instrument
  53372. */
  53373. scene: Scene);
  53374. /**
  53375. * Dispose and release associated resources.
  53376. */
  53377. dispose(): void;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export var glowMapGenerationPixelShader: {
  53383. name: string;
  53384. shader: string;
  53385. };
  53386. }
  53387. declare module BABYLON {
  53388. /** @hidden */
  53389. export var glowMapGenerationVertexShader: {
  53390. name: string;
  53391. shader: string;
  53392. };
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * Effect layer options. This helps customizing the behaviour
  53397. * of the effect layer.
  53398. */
  53399. export interface IEffectLayerOptions {
  53400. /**
  53401. * Multiplication factor apply to the canvas size to compute the render target size
  53402. * used to generated the objects (the smaller the faster).
  53403. */
  53404. mainTextureRatio: number;
  53405. /**
  53406. * Enforces a fixed size texture to ensure effect stability across devices.
  53407. */
  53408. mainTextureFixedSize?: number;
  53409. /**
  53410. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53411. */
  53412. alphaBlendingMode: number;
  53413. /**
  53414. * The camera attached to the layer.
  53415. */
  53416. camera: Nullable<Camera>;
  53417. /**
  53418. * The rendering group to draw the layer in.
  53419. */
  53420. renderingGroupId: number;
  53421. }
  53422. /**
  53423. * The effect layer Helps adding post process effect blended with the main pass.
  53424. *
  53425. * This can be for instance use to generate glow or higlight effects on the scene.
  53426. *
  53427. * The effect layer class can not be used directly and is intented to inherited from to be
  53428. * customized per effects.
  53429. */
  53430. export abstract class EffectLayer {
  53431. private _vertexBuffers;
  53432. private _indexBuffer;
  53433. private _cachedDefines;
  53434. private _effectLayerMapGenerationEffect;
  53435. private _effectLayerOptions;
  53436. private _mergeEffect;
  53437. protected _scene: Scene;
  53438. protected _engine: Engine;
  53439. protected _maxSize: number;
  53440. protected _mainTextureDesiredSize: ISize;
  53441. protected _mainTexture: RenderTargetTexture;
  53442. protected _shouldRender: boolean;
  53443. protected _postProcesses: PostProcess[];
  53444. protected _textures: BaseTexture[];
  53445. protected _emissiveTextureAndColor: {
  53446. texture: Nullable<BaseTexture>;
  53447. color: Color4;
  53448. };
  53449. /**
  53450. * The name of the layer
  53451. */
  53452. name: string;
  53453. /**
  53454. * The clear color of the texture used to generate the glow map.
  53455. */
  53456. neutralColor: Color4;
  53457. /**
  53458. * Specifies whether the highlight layer is enabled or not.
  53459. */
  53460. isEnabled: boolean;
  53461. /**
  53462. * Gets the camera attached to the layer.
  53463. */
  53464. get camera(): Nullable<Camera>;
  53465. /**
  53466. * Gets the rendering group id the layer should render in.
  53467. */
  53468. get renderingGroupId(): number;
  53469. set renderingGroupId(renderingGroupId: number);
  53470. /**
  53471. * An event triggered when the effect layer has been disposed.
  53472. */
  53473. onDisposeObservable: Observable<EffectLayer>;
  53474. /**
  53475. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53476. */
  53477. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53478. /**
  53479. * An event triggered when the generated texture is being merged in the scene.
  53480. */
  53481. onBeforeComposeObservable: Observable<EffectLayer>;
  53482. /**
  53483. * An event triggered when the mesh is rendered into the effect render target.
  53484. */
  53485. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53486. /**
  53487. * An event triggered after the mesh has been rendered into the effect render target.
  53488. */
  53489. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53490. /**
  53491. * An event triggered when the generated texture has been merged in the scene.
  53492. */
  53493. onAfterComposeObservable: Observable<EffectLayer>;
  53494. /**
  53495. * An event triggered when the efffect layer changes its size.
  53496. */
  53497. onSizeChangedObservable: Observable<EffectLayer>;
  53498. /** @hidden */
  53499. static _SceneComponentInitialization: (scene: Scene) => void;
  53500. /**
  53501. * Instantiates a new effect Layer and references it in the scene.
  53502. * @param name The name of the layer
  53503. * @param scene The scene to use the layer in
  53504. */
  53505. constructor(
  53506. /** The Friendly of the effect in the scene */
  53507. name: string, scene: Scene);
  53508. /**
  53509. * Get the effect name of the layer.
  53510. * @return The effect name
  53511. */
  53512. abstract getEffectName(): string;
  53513. /**
  53514. * Checks for the readiness of the element composing the layer.
  53515. * @param subMesh the mesh to check for
  53516. * @param useInstances specify whether or not to use instances to render the mesh
  53517. * @return true if ready otherwise, false
  53518. */
  53519. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53520. /**
  53521. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53522. * @returns true if the effect requires stencil during the main canvas render pass.
  53523. */
  53524. abstract needStencil(): boolean;
  53525. /**
  53526. * Create the merge effect. This is the shader use to blit the information back
  53527. * to the main canvas at the end of the scene rendering.
  53528. * @returns The effect containing the shader used to merge the effect on the main canvas
  53529. */
  53530. protected abstract _createMergeEffect(): Effect;
  53531. /**
  53532. * Creates the render target textures and post processes used in the effect layer.
  53533. */
  53534. protected abstract _createTextureAndPostProcesses(): void;
  53535. /**
  53536. * Implementation specific of rendering the generating effect on the main canvas.
  53537. * @param effect The effect used to render through
  53538. */
  53539. protected abstract _internalRender(effect: Effect): void;
  53540. /**
  53541. * Sets the required values for both the emissive texture and and the main color.
  53542. */
  53543. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53544. /**
  53545. * Free any resources and references associated to a mesh.
  53546. * Internal use
  53547. * @param mesh The mesh to free.
  53548. */
  53549. abstract _disposeMesh(mesh: Mesh): void;
  53550. /**
  53551. * Serializes this layer (Glow or Highlight for example)
  53552. * @returns a serialized layer object
  53553. */
  53554. abstract serialize?(): any;
  53555. /**
  53556. * Initializes the effect layer with the required options.
  53557. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53558. */
  53559. protected _init(options: Partial<IEffectLayerOptions>): void;
  53560. /**
  53561. * Generates the index buffer of the full screen quad blending to the main canvas.
  53562. */
  53563. private _generateIndexBuffer;
  53564. /**
  53565. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53566. */
  53567. private _generateVertexBuffer;
  53568. /**
  53569. * Sets the main texture desired size which is the closest power of two
  53570. * of the engine canvas size.
  53571. */
  53572. private _setMainTextureSize;
  53573. /**
  53574. * Creates the main texture for the effect layer.
  53575. */
  53576. protected _createMainTexture(): void;
  53577. /**
  53578. * Adds specific effects defines.
  53579. * @param defines The defines to add specifics to.
  53580. */
  53581. protected _addCustomEffectDefines(defines: string[]): void;
  53582. /**
  53583. * Checks for the readiness of the element composing the layer.
  53584. * @param subMesh the mesh to check for
  53585. * @param useInstances specify whether or not to use instances to render the mesh
  53586. * @param emissiveTexture the associated emissive texture used to generate the glow
  53587. * @return true if ready otherwise, false
  53588. */
  53589. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53590. /**
  53591. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53592. */
  53593. render(): void;
  53594. /**
  53595. * Determine if a given mesh will be used in the current effect.
  53596. * @param mesh mesh to test
  53597. * @returns true if the mesh will be used
  53598. */
  53599. hasMesh(mesh: AbstractMesh): boolean;
  53600. /**
  53601. * Returns true if the layer contains information to display, otherwise false.
  53602. * @returns true if the glow layer should be rendered
  53603. */
  53604. shouldRender(): boolean;
  53605. /**
  53606. * Returns true if the mesh should render, otherwise false.
  53607. * @param mesh The mesh to render
  53608. * @returns true if it should render otherwise false
  53609. */
  53610. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53611. /**
  53612. * Returns true if the mesh can be rendered, otherwise false.
  53613. * @param mesh The mesh to render
  53614. * @param material The material used on the mesh
  53615. * @returns true if it can be rendered otherwise false
  53616. */
  53617. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53618. /**
  53619. * Returns true if the mesh should render, otherwise false.
  53620. * @param mesh The mesh to render
  53621. * @returns true if it should render otherwise false
  53622. */
  53623. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53624. /**
  53625. * Renders the submesh passed in parameter to the generation map.
  53626. */
  53627. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53628. /**
  53629. * Defines whether the current material of the mesh should be use to render the effect.
  53630. * @param mesh defines the current mesh to render
  53631. */
  53632. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53633. /**
  53634. * Rebuild the required buffers.
  53635. * @hidden Internal use only.
  53636. */
  53637. _rebuild(): void;
  53638. /**
  53639. * Dispose only the render target textures and post process.
  53640. */
  53641. private _disposeTextureAndPostProcesses;
  53642. /**
  53643. * Dispose the highlight layer and free resources.
  53644. */
  53645. dispose(): void;
  53646. /**
  53647. * Gets the class name of the effect layer
  53648. * @returns the string with the class name of the effect layer
  53649. */
  53650. getClassName(): string;
  53651. /**
  53652. * Creates an effect layer from parsed effect layer data
  53653. * @param parsedEffectLayer defines effect layer data
  53654. * @param scene defines the current scene
  53655. * @param rootUrl defines the root URL containing the effect layer information
  53656. * @returns a parsed effect Layer
  53657. */
  53658. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53659. }
  53660. }
  53661. declare module BABYLON {
  53662. interface AbstractScene {
  53663. /**
  53664. * The list of effect layers (highlights/glow) added to the scene
  53665. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53666. * @see http://doc.babylonjs.com/how_to/glow_layer
  53667. */
  53668. effectLayers: Array<EffectLayer>;
  53669. /**
  53670. * Removes the given effect layer from this scene.
  53671. * @param toRemove defines the effect layer to remove
  53672. * @returns the index of the removed effect layer
  53673. */
  53674. removeEffectLayer(toRemove: EffectLayer): number;
  53675. /**
  53676. * Adds the given effect layer to this scene
  53677. * @param newEffectLayer defines the effect layer to add
  53678. */
  53679. addEffectLayer(newEffectLayer: EffectLayer): void;
  53680. }
  53681. /**
  53682. * Defines the layer scene component responsible to manage any effect layers
  53683. * in a given scene.
  53684. */
  53685. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53686. /**
  53687. * The component name helpfull to identify the component in the list of scene components.
  53688. */
  53689. readonly name: string;
  53690. /**
  53691. * The scene the component belongs to.
  53692. */
  53693. scene: Scene;
  53694. private _engine;
  53695. private _renderEffects;
  53696. private _needStencil;
  53697. private _previousStencilState;
  53698. /**
  53699. * Creates a new instance of the component for the given scene
  53700. * @param scene Defines the scene to register the component in
  53701. */
  53702. constructor(scene: Scene);
  53703. /**
  53704. * Registers the component in a given scene
  53705. */
  53706. register(): void;
  53707. /**
  53708. * Rebuilds the elements related to this component in case of
  53709. * context lost for instance.
  53710. */
  53711. rebuild(): void;
  53712. /**
  53713. * Serializes the component data to the specified json object
  53714. * @param serializationObject The object to serialize to
  53715. */
  53716. serialize(serializationObject: any): void;
  53717. /**
  53718. * Adds all the elements from the container to the scene
  53719. * @param container the container holding the elements
  53720. */
  53721. addFromContainer(container: AbstractScene): void;
  53722. /**
  53723. * Removes all the elements in the container from the scene
  53724. * @param container contains the elements to remove
  53725. * @param dispose if the removed element should be disposed (default: false)
  53726. */
  53727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53728. /**
  53729. * Disposes the component and the associated ressources.
  53730. */
  53731. dispose(): void;
  53732. private _isReadyForMesh;
  53733. private _renderMainTexture;
  53734. private _setStencil;
  53735. private _setStencilBack;
  53736. private _draw;
  53737. private _drawCamera;
  53738. private _drawRenderingGroup;
  53739. }
  53740. }
  53741. declare module BABYLON {
  53742. /** @hidden */
  53743. export var glowMapMergePixelShader: {
  53744. name: string;
  53745. shader: string;
  53746. };
  53747. }
  53748. declare module BABYLON {
  53749. /** @hidden */
  53750. export var glowMapMergeVertexShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module BABYLON {
  53756. interface AbstractScene {
  53757. /**
  53758. * Return a the first highlight layer of the scene with a given name.
  53759. * @param name The name of the highlight layer to look for.
  53760. * @return The highlight layer if found otherwise null.
  53761. */
  53762. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53763. }
  53764. /**
  53765. * Glow layer options. This helps customizing the behaviour
  53766. * of the glow layer.
  53767. */
  53768. export interface IGlowLayerOptions {
  53769. /**
  53770. * Multiplication factor apply to the canvas size to compute the render target size
  53771. * used to generated the glowing objects (the smaller the faster).
  53772. */
  53773. mainTextureRatio: number;
  53774. /**
  53775. * Enforces a fixed size texture to ensure resize independant blur.
  53776. */
  53777. mainTextureFixedSize?: number;
  53778. /**
  53779. * How big is the kernel of the blur texture.
  53780. */
  53781. blurKernelSize: number;
  53782. /**
  53783. * The camera attached to the layer.
  53784. */
  53785. camera: Nullable<Camera>;
  53786. /**
  53787. * Enable MSAA by chosing the number of samples.
  53788. */
  53789. mainTextureSamples?: number;
  53790. /**
  53791. * The rendering group to draw the layer in.
  53792. */
  53793. renderingGroupId: number;
  53794. }
  53795. /**
  53796. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53797. *
  53798. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53799. *
  53800. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53801. */
  53802. export class GlowLayer extends EffectLayer {
  53803. /**
  53804. * Effect Name of the layer.
  53805. */
  53806. static readonly EffectName: string;
  53807. /**
  53808. * The default blur kernel size used for the glow.
  53809. */
  53810. static DefaultBlurKernelSize: number;
  53811. /**
  53812. * The default texture size ratio used for the glow.
  53813. */
  53814. static DefaultTextureRatio: number;
  53815. /**
  53816. * Sets the kernel size of the blur.
  53817. */
  53818. set blurKernelSize(value: number);
  53819. /**
  53820. * Gets the kernel size of the blur.
  53821. */
  53822. get blurKernelSize(): number;
  53823. /**
  53824. * Sets the glow intensity.
  53825. */
  53826. set intensity(value: number);
  53827. /**
  53828. * Gets the glow intensity.
  53829. */
  53830. get intensity(): number;
  53831. private _options;
  53832. private _intensity;
  53833. private _horizontalBlurPostprocess1;
  53834. private _verticalBlurPostprocess1;
  53835. private _horizontalBlurPostprocess2;
  53836. private _verticalBlurPostprocess2;
  53837. private _blurTexture1;
  53838. private _blurTexture2;
  53839. private _postProcesses1;
  53840. private _postProcesses2;
  53841. private _includedOnlyMeshes;
  53842. private _excludedMeshes;
  53843. private _meshesUsingTheirOwnMaterials;
  53844. /**
  53845. * Callback used to let the user override the color selection on a per mesh basis
  53846. */
  53847. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53848. /**
  53849. * Callback used to let the user override the texture selection on a per mesh basis
  53850. */
  53851. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53852. /**
  53853. * Instantiates a new glow Layer and references it to the scene.
  53854. * @param name The name of the layer
  53855. * @param scene The scene to use the layer in
  53856. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53857. */
  53858. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53859. /**
  53860. * Get the effect name of the layer.
  53861. * @return The effect name
  53862. */
  53863. getEffectName(): string;
  53864. /**
  53865. * Create the merge effect. This is the shader use to blit the information back
  53866. * to the main canvas at the end of the scene rendering.
  53867. */
  53868. protected _createMergeEffect(): Effect;
  53869. /**
  53870. * Creates the render target textures and post processes used in the glow layer.
  53871. */
  53872. protected _createTextureAndPostProcesses(): void;
  53873. /**
  53874. * Checks for the readiness of the element composing the layer.
  53875. * @param subMesh the mesh to check for
  53876. * @param useInstances specify wether or not to use instances to render the mesh
  53877. * @param emissiveTexture the associated emissive texture used to generate the glow
  53878. * @return true if ready otherwise, false
  53879. */
  53880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53881. /**
  53882. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53883. */
  53884. needStencil(): boolean;
  53885. /**
  53886. * Returns true if the mesh can be rendered, otherwise false.
  53887. * @param mesh The mesh to render
  53888. * @param material The material used on the mesh
  53889. * @returns true if it can be rendered otherwise false
  53890. */
  53891. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53892. /**
  53893. * Implementation specific of rendering the generating effect on the main canvas.
  53894. * @param effect The effect used to render through
  53895. */
  53896. protected _internalRender(effect: Effect): void;
  53897. /**
  53898. * Sets the required values for both the emissive texture and and the main color.
  53899. */
  53900. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53901. /**
  53902. * Returns true if the mesh should render, otherwise false.
  53903. * @param mesh The mesh to render
  53904. * @returns true if it should render otherwise false
  53905. */
  53906. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53907. /**
  53908. * Adds specific effects defines.
  53909. * @param defines The defines to add specifics to.
  53910. */
  53911. protected _addCustomEffectDefines(defines: string[]): void;
  53912. /**
  53913. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53914. * @param mesh The mesh to exclude from the glow layer
  53915. */
  53916. addExcludedMesh(mesh: Mesh): void;
  53917. /**
  53918. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53919. * @param mesh The mesh to remove
  53920. */
  53921. removeExcludedMesh(mesh: Mesh): void;
  53922. /**
  53923. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53924. * @param mesh The mesh to include in the glow layer
  53925. */
  53926. addIncludedOnlyMesh(mesh: Mesh): void;
  53927. /**
  53928. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53929. * @param mesh The mesh to remove
  53930. */
  53931. removeIncludedOnlyMesh(mesh: Mesh): void;
  53932. /**
  53933. * Determine if a given mesh will be used in the glow layer
  53934. * @param mesh The mesh to test
  53935. * @returns true if the mesh will be highlighted by the current glow layer
  53936. */
  53937. hasMesh(mesh: AbstractMesh): boolean;
  53938. /**
  53939. * Defines whether the current material of the mesh should be use to render the effect.
  53940. * @param mesh defines the current mesh to render
  53941. */
  53942. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53943. /**
  53944. * Add a mesh to be rendered through its own material and not with emissive only.
  53945. * @param mesh The mesh for which we need to use its material
  53946. */
  53947. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53948. /**
  53949. * Remove a mesh from being rendered through its own material and not with emissive only.
  53950. * @param mesh The mesh for which we need to not use its material
  53951. */
  53952. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53953. /**
  53954. * Free any resources and references associated to a mesh.
  53955. * Internal use
  53956. * @param mesh The mesh to free.
  53957. * @hidden
  53958. */
  53959. _disposeMesh(mesh: Mesh): void;
  53960. /**
  53961. * Gets the class name of the effect layer
  53962. * @returns the string with the class name of the effect layer
  53963. */
  53964. getClassName(): string;
  53965. /**
  53966. * Serializes this glow layer
  53967. * @returns a serialized glow layer object
  53968. */
  53969. serialize(): any;
  53970. /**
  53971. * Creates a Glow Layer from parsed glow layer data
  53972. * @param parsedGlowLayer defines glow layer data
  53973. * @param scene defines the current scene
  53974. * @param rootUrl defines the root URL containing the glow layer information
  53975. * @returns a parsed Glow Layer
  53976. */
  53977. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53978. }
  53979. }
  53980. declare module BABYLON {
  53981. /** @hidden */
  53982. export var glowBlurPostProcessPixelShader: {
  53983. name: string;
  53984. shader: string;
  53985. };
  53986. }
  53987. declare module BABYLON {
  53988. interface AbstractScene {
  53989. /**
  53990. * Return a the first highlight layer of the scene with a given name.
  53991. * @param name The name of the highlight layer to look for.
  53992. * @return The highlight layer if found otherwise null.
  53993. */
  53994. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53995. }
  53996. /**
  53997. * Highlight layer options. This helps customizing the behaviour
  53998. * of the highlight layer.
  53999. */
  54000. export interface IHighlightLayerOptions {
  54001. /**
  54002. * Multiplication factor apply to the canvas size to compute the render target size
  54003. * used to generated the glowing objects (the smaller the faster).
  54004. */
  54005. mainTextureRatio: number;
  54006. /**
  54007. * Enforces a fixed size texture to ensure resize independant blur.
  54008. */
  54009. mainTextureFixedSize?: number;
  54010. /**
  54011. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54012. * of the picture to blur (the smaller the faster).
  54013. */
  54014. blurTextureSizeRatio: number;
  54015. /**
  54016. * How big in texel of the blur texture is the vertical blur.
  54017. */
  54018. blurVerticalSize: number;
  54019. /**
  54020. * How big in texel of the blur texture is the horizontal blur.
  54021. */
  54022. blurHorizontalSize: number;
  54023. /**
  54024. * Alpha blending mode used to apply the blur. Default is combine.
  54025. */
  54026. alphaBlendingMode: number;
  54027. /**
  54028. * The camera attached to the layer.
  54029. */
  54030. camera: Nullable<Camera>;
  54031. /**
  54032. * Should we display highlight as a solid stroke?
  54033. */
  54034. isStroke?: boolean;
  54035. /**
  54036. * The rendering group to draw the layer in.
  54037. */
  54038. renderingGroupId: number;
  54039. }
  54040. /**
  54041. * The highlight layer Helps adding a glow effect around a mesh.
  54042. *
  54043. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54044. * glowy meshes to your scene.
  54045. *
  54046. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54047. */
  54048. export class HighlightLayer extends EffectLayer {
  54049. name: string;
  54050. /**
  54051. * Effect Name of the highlight layer.
  54052. */
  54053. static readonly EffectName: string;
  54054. /**
  54055. * The neutral color used during the preparation of the glow effect.
  54056. * This is black by default as the blend operation is a blend operation.
  54057. */
  54058. static NeutralColor: Color4;
  54059. /**
  54060. * Stencil value used for glowing meshes.
  54061. */
  54062. static GlowingMeshStencilReference: number;
  54063. /**
  54064. * Stencil value used for the other meshes in the scene.
  54065. */
  54066. static NormalMeshStencilReference: number;
  54067. /**
  54068. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54069. */
  54070. innerGlow: boolean;
  54071. /**
  54072. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54073. */
  54074. outerGlow: boolean;
  54075. /**
  54076. * Specifies the horizontal size of the blur.
  54077. */
  54078. set blurHorizontalSize(value: number);
  54079. /**
  54080. * Specifies the vertical size of the blur.
  54081. */
  54082. set blurVerticalSize(value: number);
  54083. /**
  54084. * Gets the horizontal size of the blur.
  54085. */
  54086. get blurHorizontalSize(): number;
  54087. /**
  54088. * Gets the vertical size of the blur.
  54089. */
  54090. get blurVerticalSize(): number;
  54091. /**
  54092. * An event triggered when the highlight layer is being blurred.
  54093. */
  54094. onBeforeBlurObservable: Observable<HighlightLayer>;
  54095. /**
  54096. * An event triggered when the highlight layer has been blurred.
  54097. */
  54098. onAfterBlurObservable: Observable<HighlightLayer>;
  54099. private _instanceGlowingMeshStencilReference;
  54100. private _options;
  54101. private _downSamplePostprocess;
  54102. private _horizontalBlurPostprocess;
  54103. private _verticalBlurPostprocess;
  54104. private _blurTexture;
  54105. private _meshes;
  54106. private _excludedMeshes;
  54107. /**
  54108. * Instantiates a new highlight Layer and references it to the scene..
  54109. * @param name The name of the layer
  54110. * @param scene The scene to use the layer in
  54111. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54112. */
  54113. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54114. /**
  54115. * Get the effect name of the layer.
  54116. * @return The effect name
  54117. */
  54118. getEffectName(): string;
  54119. /**
  54120. * Create the merge effect. This is the shader use to blit the information back
  54121. * to the main canvas at the end of the scene rendering.
  54122. */
  54123. protected _createMergeEffect(): Effect;
  54124. /**
  54125. * Creates the render target textures and post processes used in the highlight layer.
  54126. */
  54127. protected _createTextureAndPostProcesses(): void;
  54128. /**
  54129. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54130. */
  54131. needStencil(): boolean;
  54132. /**
  54133. * Checks for the readiness of the element composing the layer.
  54134. * @param subMesh the mesh to check for
  54135. * @param useInstances specify wether or not to use instances to render the mesh
  54136. * @param emissiveTexture the associated emissive texture used to generate the glow
  54137. * @return true if ready otherwise, false
  54138. */
  54139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54140. /**
  54141. * Implementation specific of rendering the generating effect on the main canvas.
  54142. * @param effect The effect used to render through
  54143. */
  54144. protected _internalRender(effect: Effect): void;
  54145. /**
  54146. * Returns true if the layer contains information to display, otherwise false.
  54147. */
  54148. shouldRender(): boolean;
  54149. /**
  54150. * Returns true if the mesh should render, otherwise false.
  54151. * @param mesh The mesh to render
  54152. * @returns true if it should render otherwise false
  54153. */
  54154. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54155. /**
  54156. * Adds specific effects defines.
  54157. * @param defines The defines to add specifics to.
  54158. */
  54159. protected _addCustomEffectDefines(defines: string[]): void;
  54160. /**
  54161. * Sets the required values for both the emissive texture and and the main color.
  54162. */
  54163. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54164. /**
  54165. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54166. * @param mesh The mesh to exclude from the highlight layer
  54167. */
  54168. addExcludedMesh(mesh: Mesh): void;
  54169. /**
  54170. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54171. * @param mesh The mesh to highlight
  54172. */
  54173. removeExcludedMesh(mesh: Mesh): void;
  54174. /**
  54175. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54176. * @param mesh mesh to test
  54177. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54178. */
  54179. hasMesh(mesh: AbstractMesh): boolean;
  54180. /**
  54181. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54182. * @param mesh The mesh to highlight
  54183. * @param color The color of the highlight
  54184. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54185. */
  54186. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54187. /**
  54188. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54189. * @param mesh The mesh to highlight
  54190. */
  54191. removeMesh(mesh: Mesh): void;
  54192. /**
  54193. * Remove all the meshes currently referenced in the highlight layer
  54194. */
  54195. removeAllMeshes(): void;
  54196. /**
  54197. * Force the stencil to the normal expected value for none glowing parts
  54198. */
  54199. private _defaultStencilReference;
  54200. /**
  54201. * Free any resources and references associated to a mesh.
  54202. * Internal use
  54203. * @param mesh The mesh to free.
  54204. * @hidden
  54205. */
  54206. _disposeMesh(mesh: Mesh): void;
  54207. /**
  54208. * Dispose the highlight layer and free resources.
  54209. */
  54210. dispose(): void;
  54211. /**
  54212. * Gets the class name of the effect layer
  54213. * @returns the string with the class name of the effect layer
  54214. */
  54215. getClassName(): string;
  54216. /**
  54217. * Serializes this Highlight layer
  54218. * @returns a serialized Highlight layer object
  54219. */
  54220. serialize(): any;
  54221. /**
  54222. * Creates a Highlight layer from parsed Highlight layer data
  54223. * @param parsedHightlightLayer defines the Highlight layer data
  54224. * @param scene defines the current scene
  54225. * @param rootUrl defines the root URL containing the Highlight layer information
  54226. * @returns a parsed Highlight layer
  54227. */
  54228. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54229. }
  54230. }
  54231. declare module BABYLON {
  54232. interface AbstractScene {
  54233. /**
  54234. * The list of layers (background and foreground) of the scene
  54235. */
  54236. layers: Array<Layer>;
  54237. }
  54238. /**
  54239. * Defines the layer scene component responsible to manage any layers
  54240. * in a given scene.
  54241. */
  54242. export class LayerSceneComponent implements ISceneComponent {
  54243. /**
  54244. * The component name helpfull to identify the component in the list of scene components.
  54245. */
  54246. readonly name: string;
  54247. /**
  54248. * The scene the component belongs to.
  54249. */
  54250. scene: Scene;
  54251. private _engine;
  54252. /**
  54253. * Creates a new instance of the component for the given scene
  54254. * @param scene Defines the scene to register the component in
  54255. */
  54256. constructor(scene: Scene);
  54257. /**
  54258. * Registers the component in a given scene
  54259. */
  54260. register(): void;
  54261. /**
  54262. * Rebuilds the elements related to this component in case of
  54263. * context lost for instance.
  54264. */
  54265. rebuild(): void;
  54266. /**
  54267. * Disposes the component and the associated ressources.
  54268. */
  54269. dispose(): void;
  54270. private _draw;
  54271. private _drawCameraPredicate;
  54272. private _drawCameraBackground;
  54273. private _drawCameraForeground;
  54274. private _drawRenderTargetPredicate;
  54275. private _drawRenderTargetBackground;
  54276. private _drawRenderTargetForeground;
  54277. /**
  54278. * Adds all the elements from the container to the scene
  54279. * @param container the container holding the elements
  54280. */
  54281. addFromContainer(container: AbstractScene): void;
  54282. /**
  54283. * Removes all the elements in the container from the scene
  54284. * @param container contains the elements to remove
  54285. * @param dispose if the removed element should be disposed (default: false)
  54286. */
  54287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /** @hidden */
  54292. export var layerPixelShader: {
  54293. name: string;
  54294. shader: string;
  54295. };
  54296. }
  54297. declare module BABYLON {
  54298. /** @hidden */
  54299. export var layerVertexShader: {
  54300. name: string;
  54301. shader: string;
  54302. };
  54303. }
  54304. declare module BABYLON {
  54305. /**
  54306. * This represents a full screen 2d layer.
  54307. * This can be useful to display a picture in the background of your scene for instance.
  54308. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54309. */
  54310. export class Layer {
  54311. /**
  54312. * Define the name of the layer.
  54313. */
  54314. name: string;
  54315. /**
  54316. * Define the texture the layer should display.
  54317. */
  54318. texture: Nullable<Texture>;
  54319. /**
  54320. * Is the layer in background or foreground.
  54321. */
  54322. isBackground: boolean;
  54323. /**
  54324. * Define the color of the layer (instead of texture).
  54325. */
  54326. color: Color4;
  54327. /**
  54328. * Define the scale of the layer in order to zoom in out of the texture.
  54329. */
  54330. scale: Vector2;
  54331. /**
  54332. * Define an offset for the layer in order to shift the texture.
  54333. */
  54334. offset: Vector2;
  54335. /**
  54336. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54337. */
  54338. alphaBlendingMode: number;
  54339. /**
  54340. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54341. * Alpha test will not mix with the background color in case of transparency.
  54342. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54343. */
  54344. alphaTest: boolean;
  54345. /**
  54346. * Define a mask to restrict the layer to only some of the scene cameras.
  54347. */
  54348. layerMask: number;
  54349. /**
  54350. * Define the list of render target the layer is visible into.
  54351. */
  54352. renderTargetTextures: RenderTargetTexture[];
  54353. /**
  54354. * Define if the layer is only used in renderTarget or if it also
  54355. * renders in the main frame buffer of the canvas.
  54356. */
  54357. renderOnlyInRenderTargetTextures: boolean;
  54358. private _scene;
  54359. private _vertexBuffers;
  54360. private _indexBuffer;
  54361. private _effect;
  54362. private _previousDefines;
  54363. /**
  54364. * An event triggered when the layer is disposed.
  54365. */
  54366. onDisposeObservable: Observable<Layer>;
  54367. private _onDisposeObserver;
  54368. /**
  54369. * Back compatibility with callback before the onDisposeObservable existed.
  54370. * The set callback will be triggered when the layer has been disposed.
  54371. */
  54372. set onDispose(callback: () => void);
  54373. /**
  54374. * An event triggered before rendering the scene
  54375. */
  54376. onBeforeRenderObservable: Observable<Layer>;
  54377. private _onBeforeRenderObserver;
  54378. /**
  54379. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54380. * The set callback will be triggered just before rendering the layer.
  54381. */
  54382. set onBeforeRender(callback: () => void);
  54383. /**
  54384. * An event triggered after rendering the scene
  54385. */
  54386. onAfterRenderObservable: Observable<Layer>;
  54387. private _onAfterRenderObserver;
  54388. /**
  54389. * Back compatibility with callback before the onAfterRenderObservable existed.
  54390. * The set callback will be triggered just after rendering the layer.
  54391. */
  54392. set onAfterRender(callback: () => void);
  54393. /**
  54394. * Instantiates a new layer.
  54395. * This represents a full screen 2d layer.
  54396. * This can be useful to display a picture in the background of your scene for instance.
  54397. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54398. * @param name Define the name of the layer in the scene
  54399. * @param imgUrl Define the url of the texture to display in the layer
  54400. * @param scene Define the scene the layer belongs to
  54401. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54402. * @param color Defines a color for the layer
  54403. */
  54404. constructor(
  54405. /**
  54406. * Define the name of the layer.
  54407. */
  54408. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54409. private _createIndexBuffer;
  54410. /** @hidden */
  54411. _rebuild(): void;
  54412. /**
  54413. * Renders the layer in the scene.
  54414. */
  54415. render(): void;
  54416. /**
  54417. * Disposes and releases the associated ressources.
  54418. */
  54419. dispose(): void;
  54420. }
  54421. }
  54422. declare module BABYLON {
  54423. /** @hidden */
  54424. export var lensFlarePixelShader: {
  54425. name: string;
  54426. shader: string;
  54427. };
  54428. }
  54429. declare module BABYLON {
  54430. /** @hidden */
  54431. export var lensFlareVertexShader: {
  54432. name: string;
  54433. shader: string;
  54434. };
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54439. * It is usually composed of several `lensFlare`.
  54440. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54441. */
  54442. export class LensFlareSystem {
  54443. /**
  54444. * Define the name of the lens flare system
  54445. */
  54446. name: string;
  54447. /**
  54448. * List of lens flares used in this system.
  54449. */
  54450. lensFlares: LensFlare[];
  54451. /**
  54452. * Define a limit from the border the lens flare can be visible.
  54453. */
  54454. borderLimit: number;
  54455. /**
  54456. * Define a viewport border we do not want to see the lens flare in.
  54457. */
  54458. viewportBorder: number;
  54459. /**
  54460. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54461. */
  54462. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54463. /**
  54464. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54465. */
  54466. layerMask: number;
  54467. /**
  54468. * Define the id of the lens flare system in the scene.
  54469. * (equal to name by default)
  54470. */
  54471. id: string;
  54472. private _scene;
  54473. private _emitter;
  54474. private _vertexBuffers;
  54475. private _indexBuffer;
  54476. private _effect;
  54477. private _positionX;
  54478. private _positionY;
  54479. private _isEnabled;
  54480. /** @hidden */
  54481. static _SceneComponentInitialization: (scene: Scene) => void;
  54482. /**
  54483. * Instantiates a lens flare system.
  54484. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54485. * It is usually composed of several `lensFlare`.
  54486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54487. * @param name Define the name of the lens flare system in the scene
  54488. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54489. * @param scene Define the scene the lens flare system belongs to
  54490. */
  54491. constructor(
  54492. /**
  54493. * Define the name of the lens flare system
  54494. */
  54495. name: string, emitter: any, scene: Scene);
  54496. /**
  54497. * Define if the lens flare system is enabled.
  54498. */
  54499. get isEnabled(): boolean;
  54500. set isEnabled(value: boolean);
  54501. /**
  54502. * Get the scene the effects belongs to.
  54503. * @returns the scene holding the lens flare system
  54504. */
  54505. getScene(): Scene;
  54506. /**
  54507. * Get the emitter of the lens flare system.
  54508. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54509. * @returns the emitter of the lens flare system
  54510. */
  54511. getEmitter(): any;
  54512. /**
  54513. * Set the emitter of the lens flare system.
  54514. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54515. * @param newEmitter Define the new emitter of the system
  54516. */
  54517. setEmitter(newEmitter: any): void;
  54518. /**
  54519. * Get the lens flare system emitter position.
  54520. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54521. * @returns the position
  54522. */
  54523. getEmitterPosition(): Vector3;
  54524. /**
  54525. * @hidden
  54526. */
  54527. computeEffectivePosition(globalViewport: Viewport): boolean;
  54528. /** @hidden */
  54529. _isVisible(): boolean;
  54530. /**
  54531. * @hidden
  54532. */
  54533. render(): boolean;
  54534. /**
  54535. * Dispose and release the lens flare with its associated resources.
  54536. */
  54537. dispose(): void;
  54538. /**
  54539. * Parse a lens flare system from a JSON repressentation
  54540. * @param parsedLensFlareSystem Define the JSON to parse
  54541. * @param scene Define the scene the parsed system should be instantiated in
  54542. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54543. * @returns the parsed system
  54544. */
  54545. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54546. /**
  54547. * Serialize the current Lens Flare System into a JSON representation.
  54548. * @returns the serialized JSON
  54549. */
  54550. serialize(): any;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /**
  54555. * This represents one of the lens effect in a `lensFlareSystem`.
  54556. * It controls one of the indiviual texture used in the effect.
  54557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54558. */
  54559. export class LensFlare {
  54560. /**
  54561. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54562. */
  54563. size: number;
  54564. /**
  54565. * 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.
  54566. */
  54567. position: number;
  54568. /**
  54569. * Define the lens color.
  54570. */
  54571. color: Color3;
  54572. /**
  54573. * Define the lens texture.
  54574. */
  54575. texture: Nullable<Texture>;
  54576. /**
  54577. * Define the alpha mode to render this particular lens.
  54578. */
  54579. alphaMode: number;
  54580. private _system;
  54581. /**
  54582. * Creates a new Lens Flare.
  54583. * This represents one of the lens effect in a `lensFlareSystem`.
  54584. * It controls one of the indiviual texture used in the effect.
  54585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54586. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54587. * @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.
  54588. * @param color Define the lens color
  54589. * @param imgUrl Define the lens texture url
  54590. * @param system Define the `lensFlareSystem` this flare is part of
  54591. * @returns The newly created Lens Flare
  54592. */
  54593. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54594. /**
  54595. * Instantiates a new Lens Flare.
  54596. * This represents one of the lens effect in a `lensFlareSystem`.
  54597. * It controls one of the indiviual texture used in the effect.
  54598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54599. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54600. * @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.
  54601. * @param color Define the lens color
  54602. * @param imgUrl Define the lens texture url
  54603. * @param system Define the `lensFlareSystem` this flare is part of
  54604. */
  54605. constructor(
  54606. /**
  54607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54608. */
  54609. size: number,
  54610. /**
  54611. * 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.
  54612. */
  54613. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54614. /**
  54615. * Dispose and release the lens flare with its associated resources.
  54616. */
  54617. dispose(): void;
  54618. }
  54619. }
  54620. declare module BABYLON {
  54621. interface AbstractScene {
  54622. /**
  54623. * The list of lens flare system added to the scene
  54624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54625. */
  54626. lensFlareSystems: Array<LensFlareSystem>;
  54627. /**
  54628. * Removes the given lens flare system from this scene.
  54629. * @param toRemove The lens flare system to remove
  54630. * @returns The index of the removed lens flare system
  54631. */
  54632. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54633. /**
  54634. * Adds the given lens flare system to this scene
  54635. * @param newLensFlareSystem The lens flare system to add
  54636. */
  54637. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54638. /**
  54639. * Gets a lens flare system using its name
  54640. * @param name defines the name to look for
  54641. * @returns the lens flare system or null if not found
  54642. */
  54643. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54644. /**
  54645. * Gets a lens flare system using its id
  54646. * @param id defines the id to look for
  54647. * @returns the lens flare system or null if not found
  54648. */
  54649. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54650. }
  54651. /**
  54652. * Defines the lens flare scene component responsible to manage any lens flares
  54653. * in a given scene.
  54654. */
  54655. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54656. /**
  54657. * The component name helpfull to identify the component in the list of scene components.
  54658. */
  54659. readonly name: string;
  54660. /**
  54661. * The scene the component belongs to.
  54662. */
  54663. scene: Scene;
  54664. /**
  54665. * Creates a new instance of the component for the given scene
  54666. * @param scene Defines the scene to register the component in
  54667. */
  54668. constructor(scene: Scene);
  54669. /**
  54670. * Registers the component in a given scene
  54671. */
  54672. register(): void;
  54673. /**
  54674. * Rebuilds the elements related to this component in case of
  54675. * context lost for instance.
  54676. */
  54677. rebuild(): void;
  54678. /**
  54679. * Adds all the elements from the container to the scene
  54680. * @param container the container holding the elements
  54681. */
  54682. addFromContainer(container: AbstractScene): void;
  54683. /**
  54684. * Removes all the elements in the container from the scene
  54685. * @param container contains the elements to remove
  54686. * @param dispose if the removed element should be disposed (default: false)
  54687. */
  54688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54689. /**
  54690. * Serializes the component data to the specified json object
  54691. * @param serializationObject The object to serialize to
  54692. */
  54693. serialize(serializationObject: any): void;
  54694. /**
  54695. * Disposes the component and the associated ressources.
  54696. */
  54697. dispose(): void;
  54698. private _draw;
  54699. }
  54700. }
  54701. declare module BABYLON {
  54702. /** @hidden */
  54703. export var depthPixelShader: {
  54704. name: string;
  54705. shader: string;
  54706. };
  54707. }
  54708. declare module BABYLON {
  54709. /** @hidden */
  54710. export var depthVertexShader: {
  54711. name: string;
  54712. shader: string;
  54713. };
  54714. }
  54715. declare module BABYLON {
  54716. /**
  54717. * This represents a depth renderer in Babylon.
  54718. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54719. */
  54720. export class DepthRenderer {
  54721. private _scene;
  54722. private _depthMap;
  54723. private _effect;
  54724. private readonly _storeNonLinearDepth;
  54725. private readonly _clearColor;
  54726. /** Get if the depth renderer is using packed depth or not */
  54727. readonly isPacked: boolean;
  54728. private _cachedDefines;
  54729. private _camera;
  54730. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54731. enabled: boolean;
  54732. /**
  54733. * Specifiess that the depth renderer will only be used within
  54734. * the camera it is created for.
  54735. * This can help forcing its rendering during the camera processing.
  54736. */
  54737. useOnlyInActiveCamera: boolean;
  54738. /** @hidden */
  54739. static _SceneComponentInitialization: (scene: Scene) => void;
  54740. /**
  54741. * Instantiates a depth renderer
  54742. * @param scene The scene the renderer belongs to
  54743. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54744. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54745. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54746. */
  54747. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54748. /**
  54749. * Creates the depth rendering effect and checks if the effect is ready.
  54750. * @param subMesh The submesh to be used to render the depth map of
  54751. * @param useInstances If multiple world instances should be used
  54752. * @returns if the depth renderer is ready to render the depth map
  54753. */
  54754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54755. /**
  54756. * Gets the texture which the depth map will be written to.
  54757. * @returns The depth map texture
  54758. */
  54759. getDepthMap(): RenderTargetTexture;
  54760. /**
  54761. * Disposes of the depth renderer.
  54762. */
  54763. dispose(): void;
  54764. }
  54765. }
  54766. declare module BABYLON {
  54767. /** @hidden */
  54768. export var minmaxReduxPixelShader: {
  54769. name: string;
  54770. shader: string;
  54771. };
  54772. }
  54773. declare module BABYLON {
  54774. /**
  54775. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54776. * and maximum values from all values of the texture.
  54777. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54778. * The source values are read from the red channel of the texture.
  54779. */
  54780. export class MinMaxReducer {
  54781. /**
  54782. * Observable triggered when the computation has been performed
  54783. */
  54784. onAfterReductionPerformed: Observable<{
  54785. min: number;
  54786. max: number;
  54787. }>;
  54788. protected _camera: Camera;
  54789. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54790. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54791. protected _postProcessManager: PostProcessManager;
  54792. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54793. protected _forceFullscreenViewport: boolean;
  54794. /**
  54795. * Creates a min/max reducer
  54796. * @param camera The camera to use for the post processes
  54797. */
  54798. constructor(camera: Camera);
  54799. /**
  54800. * Gets the texture used to read the values from.
  54801. */
  54802. get sourceTexture(): Nullable<RenderTargetTexture>;
  54803. /**
  54804. * Sets the source texture to read the values from.
  54805. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54806. * because in such textures '1' value must not be taken into account to compute the maximum
  54807. * as this value is used to clear the texture.
  54808. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54809. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54810. * @param depthRedux Indicates if the texture is a depth texture or not
  54811. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54812. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54813. */
  54814. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54815. /**
  54816. * Defines the refresh rate of the computation.
  54817. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54818. */
  54819. get refreshRate(): number;
  54820. set refreshRate(value: number);
  54821. protected _activated: boolean;
  54822. /**
  54823. * Gets the activation status of the reducer
  54824. */
  54825. get activated(): boolean;
  54826. /**
  54827. * Activates the reduction computation.
  54828. * When activated, the observers registered in onAfterReductionPerformed are
  54829. * called after the compuation is performed
  54830. */
  54831. activate(): void;
  54832. /**
  54833. * Deactivates the reduction computation.
  54834. */
  54835. deactivate(): void;
  54836. /**
  54837. * Disposes the min/max reducer
  54838. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54839. */
  54840. dispose(disposeAll?: boolean): void;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /**
  54845. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54846. */
  54847. export class DepthReducer extends MinMaxReducer {
  54848. private _depthRenderer;
  54849. private _depthRendererId;
  54850. /**
  54851. * Gets the depth renderer used for the computation.
  54852. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54853. */
  54854. get depthRenderer(): Nullable<DepthRenderer>;
  54855. /**
  54856. * Creates a depth reducer
  54857. * @param camera The camera used to render the depth texture
  54858. */
  54859. constructor(camera: Camera);
  54860. /**
  54861. * Sets the depth renderer to use to generate the depth map
  54862. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54863. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54864. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54865. */
  54866. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54867. /** @hidden */
  54868. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54869. /**
  54870. * Activates the reduction computation.
  54871. * When activated, the observers registered in onAfterReductionPerformed are
  54872. * called after the compuation is performed
  54873. */
  54874. activate(): void;
  54875. /**
  54876. * Deactivates the reduction computation.
  54877. */
  54878. deactivate(): void;
  54879. /**
  54880. * Disposes the depth reducer
  54881. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54882. */
  54883. dispose(disposeAll?: boolean): void;
  54884. }
  54885. }
  54886. declare module BABYLON {
  54887. /**
  54888. * A CSM implementation allowing casting shadows on large scenes.
  54889. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54890. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54891. */
  54892. export class CascadedShadowGenerator extends ShadowGenerator {
  54893. private static readonly frustumCornersNDCSpace;
  54894. /**
  54895. * Name of the CSM class
  54896. */
  54897. static CLASSNAME: string;
  54898. /**
  54899. * Defines the default number of cascades used by the CSM.
  54900. */
  54901. static readonly DEFAULT_CASCADES_COUNT: number;
  54902. /**
  54903. * Defines the minimum number of cascades used by the CSM.
  54904. */
  54905. static readonly MIN_CASCADES_COUNT: number;
  54906. /**
  54907. * Defines the maximum number of cascades used by the CSM.
  54908. */
  54909. static readonly MAX_CASCADES_COUNT: number;
  54910. protected _validateFilter(filter: number): number;
  54911. /**
  54912. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54913. */
  54914. penumbraDarkness: number;
  54915. private _numCascades;
  54916. /**
  54917. * Gets or set the number of cascades used by the CSM.
  54918. */
  54919. get numCascades(): number;
  54920. set numCascades(value: number);
  54921. /**
  54922. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54923. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54924. */
  54925. stabilizeCascades: boolean;
  54926. private _freezeShadowCastersBoundingInfo;
  54927. private _freezeShadowCastersBoundingInfoObservable;
  54928. /**
  54929. * Enables or disables the shadow casters bounding info computation.
  54930. * If your shadow casters don't move, you can disable this feature.
  54931. * If it is enabled, the bounding box computation is done every frame.
  54932. */
  54933. get freezeShadowCastersBoundingInfo(): boolean;
  54934. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54935. private _scbiMin;
  54936. private _scbiMax;
  54937. protected _computeShadowCastersBoundingInfo(): void;
  54938. protected _shadowCastersBoundingInfo: BoundingInfo;
  54939. /**
  54940. * Gets or sets the shadow casters bounding info.
  54941. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54942. * so that the system won't overwrite the bounds you provide
  54943. */
  54944. get shadowCastersBoundingInfo(): BoundingInfo;
  54945. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54946. protected _breaksAreDirty: boolean;
  54947. protected _minDistance: number;
  54948. protected _maxDistance: number;
  54949. /**
  54950. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54951. *
  54952. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54953. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54954. * @param min minimal distance for the breaks (default to 0.)
  54955. * @param max maximal distance for the breaks (default to 1.)
  54956. */
  54957. setMinMaxDistance(min: number, max: number): void;
  54958. /** Gets the minimal distance used in the cascade break computation */
  54959. get minDistance(): number;
  54960. /** Gets the maximal distance used in the cascade break computation */
  54961. get maxDistance(): number;
  54962. /**
  54963. * Gets the class name of that object
  54964. * @returns "CascadedShadowGenerator"
  54965. */
  54966. getClassName(): string;
  54967. private _cascadeMinExtents;
  54968. private _cascadeMaxExtents;
  54969. /**
  54970. * Gets a cascade minimum extents
  54971. * @param cascadeIndex index of the cascade
  54972. * @returns the minimum cascade extents
  54973. */
  54974. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54975. /**
  54976. * Gets a cascade maximum extents
  54977. * @param cascadeIndex index of the cascade
  54978. * @returns the maximum cascade extents
  54979. */
  54980. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54981. private _cascades;
  54982. private _currentLayer;
  54983. private _viewSpaceFrustumsZ;
  54984. private _viewMatrices;
  54985. private _projectionMatrices;
  54986. private _transformMatrices;
  54987. private _transformMatricesAsArray;
  54988. private _frustumLengths;
  54989. private _lightSizeUVCorrection;
  54990. private _depthCorrection;
  54991. private _frustumCornersWorldSpace;
  54992. private _frustumCenter;
  54993. private _shadowCameraPos;
  54994. private _shadowMaxZ;
  54995. /**
  54996. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54997. * It defaults to camera.maxZ
  54998. */
  54999. get shadowMaxZ(): number;
  55000. /**
  55001. * Sets the shadow max z distance.
  55002. */
  55003. set shadowMaxZ(value: number);
  55004. protected _debug: boolean;
  55005. /**
  55006. * Gets or sets the debug flag.
  55007. * When enabled, the cascades are materialized by different colors on the screen.
  55008. */
  55009. get debug(): boolean;
  55010. set debug(dbg: boolean);
  55011. private _depthClamp;
  55012. /**
  55013. * Gets or sets the depth clamping value.
  55014. *
  55015. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55016. * to account for the shadow casters far away.
  55017. *
  55018. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55019. */
  55020. get depthClamp(): boolean;
  55021. set depthClamp(value: boolean);
  55022. private _cascadeBlendPercentage;
  55023. /**
  55024. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55025. * It defaults to 0.1 (10% blending).
  55026. */
  55027. get cascadeBlendPercentage(): number;
  55028. set cascadeBlendPercentage(value: number);
  55029. private _lambda;
  55030. /**
  55031. * Gets or set the lambda parameter.
  55032. * This parameter is used to split the camera frustum and create the cascades.
  55033. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  55034. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55035. */
  55036. get lambda(): number;
  55037. set lambda(value: number);
  55038. /**
  55039. * Gets the view matrix corresponding to a given cascade
  55040. * @param cascadeNum cascade to retrieve the view matrix from
  55041. * @returns the cascade view matrix
  55042. */
  55043. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55044. /**
  55045. * Gets the projection matrix corresponding to a given cascade
  55046. * @param cascadeNum cascade to retrieve the projection matrix from
  55047. * @returns the cascade projection matrix
  55048. */
  55049. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55050. /**
  55051. * Gets the transformation matrix corresponding to a given cascade
  55052. * @param cascadeNum cascade to retrieve the transformation matrix from
  55053. * @returns the cascade transformation matrix
  55054. */
  55055. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55056. private _depthRenderer;
  55057. /**
  55058. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55059. *
  55060. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55061. *
  55062. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55063. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55064. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  55065. */
  55066. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55067. private _depthReducer;
  55068. private _autoCalcDepthBounds;
  55069. /**
  55070. * Gets or sets the autoCalcDepthBounds property.
  55071. *
  55072. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55073. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55074. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55075. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55076. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55077. */
  55078. get autoCalcDepthBounds(): boolean;
  55079. set autoCalcDepthBounds(value: boolean);
  55080. /**
  55081. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55082. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55083. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55084. * for setting the refresh rate on the renderer yourself!
  55085. */
  55086. get autoCalcDepthBoundsRefreshRate(): number;
  55087. set autoCalcDepthBoundsRefreshRate(value: number);
  55088. /**
  55089. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55090. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55091. * you change the camera near/far planes!
  55092. */
  55093. splitFrustum(): void;
  55094. private _splitFrustum;
  55095. private _computeMatrices;
  55096. private _computeFrustumInWorldSpace;
  55097. private _computeCascadeFrustum;
  55098. /**
  55099. * Support test.
  55100. */
  55101. static get IsSupported(): boolean;
  55102. /** @hidden */
  55103. static _SceneComponentInitialization: (scene: Scene) => void;
  55104. /**
  55105. * Creates a Cascaded Shadow Generator object.
  55106. * A ShadowGenerator is the required tool to use the shadows.
  55107. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55108. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55109. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55110. * @param light The directional light object generating the shadows.
  55111. * @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.
  55112. */
  55113. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55114. protected _initializeGenerator(): void;
  55115. protected _createTargetRenderTexture(): void;
  55116. protected _initializeShadowMap(): void;
  55117. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55118. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55119. /**
  55120. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55121. * @param defines Defines of the material we want to update
  55122. * @param lightIndex Index of the light in the enabled light list of the material
  55123. */
  55124. prepareDefines(defines: any, lightIndex: number): void;
  55125. /**
  55126. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55127. * defined in the generator but impacting the effect).
  55128. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55129. * @param effect The effect we are binfing the information for
  55130. */
  55131. bindShadowLight(lightIndex: string, effect: Effect): void;
  55132. /**
  55133. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55134. * (eq to view projection * shadow projection matrices)
  55135. * @returns The transform matrix used to create the shadow map
  55136. */
  55137. getTransformMatrix(): Matrix;
  55138. /**
  55139. * Disposes the ShadowGenerator.
  55140. * Returns nothing.
  55141. */
  55142. dispose(): void;
  55143. /**
  55144. * Serializes the shadow generator setup to a json object.
  55145. * @returns The serialized JSON object
  55146. */
  55147. serialize(): any;
  55148. /**
  55149. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55150. * @param parsedShadowGenerator The JSON object to parse
  55151. * @param scene The scene to create the shadow map for
  55152. * @returns The parsed shadow generator
  55153. */
  55154. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55155. }
  55156. }
  55157. declare module BABYLON {
  55158. /**
  55159. * Defines the shadow generator component responsible to manage any shadow generators
  55160. * in a given scene.
  55161. */
  55162. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55163. /**
  55164. * The component name helpfull to identify the component in the list of scene components.
  55165. */
  55166. readonly name: string;
  55167. /**
  55168. * The scene the component belongs to.
  55169. */
  55170. scene: Scene;
  55171. /**
  55172. * Creates a new instance of the component for the given scene
  55173. * @param scene Defines the scene to register the component in
  55174. */
  55175. constructor(scene: Scene);
  55176. /**
  55177. * Registers the component in a given scene
  55178. */
  55179. register(): void;
  55180. /**
  55181. * Rebuilds the elements related to this component in case of
  55182. * context lost for instance.
  55183. */
  55184. rebuild(): void;
  55185. /**
  55186. * Serializes the component data to the specified json object
  55187. * @param serializationObject The object to serialize to
  55188. */
  55189. serialize(serializationObject: any): void;
  55190. /**
  55191. * Adds all the elements from the container to the scene
  55192. * @param container the container holding the elements
  55193. */
  55194. addFromContainer(container: AbstractScene): void;
  55195. /**
  55196. * Removes all the elements in the container from the scene
  55197. * @param container contains the elements to remove
  55198. * @param dispose if the removed element should be disposed (default: false)
  55199. */
  55200. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55201. /**
  55202. * Rebuilds the elements related to this component in case of
  55203. * context lost for instance.
  55204. */
  55205. dispose(): void;
  55206. private _gatherRenderTargets;
  55207. }
  55208. }
  55209. declare module BABYLON {
  55210. /**
  55211. * A point light is a light defined by an unique point in world space.
  55212. * The light is emitted in every direction from this point.
  55213. * A good example of a point light is a standard light bulb.
  55214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55215. */
  55216. export class PointLight extends ShadowLight {
  55217. private _shadowAngle;
  55218. /**
  55219. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55220. * This specifies what angle the shadow will use to be created.
  55221. *
  55222. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55223. */
  55224. get shadowAngle(): number;
  55225. /**
  55226. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55227. * This specifies what angle the shadow will use to be created.
  55228. *
  55229. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55230. */
  55231. set shadowAngle(value: number);
  55232. /**
  55233. * Gets the direction if it has been set.
  55234. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55235. */
  55236. get direction(): Vector3;
  55237. /**
  55238. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55239. */
  55240. set direction(value: Vector3);
  55241. /**
  55242. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55243. * A PointLight emits the light in every direction.
  55244. * It can cast shadows.
  55245. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55246. * ```javascript
  55247. * var pointLight = new PointLight("pl", camera.position, scene);
  55248. * ```
  55249. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55250. * @param name The light friendly name
  55251. * @param position The position of the point light in the scene
  55252. * @param scene The scene the lights belongs to
  55253. */
  55254. constructor(name: string, position: Vector3, scene: Scene);
  55255. /**
  55256. * Returns the string "PointLight"
  55257. * @returns the class name
  55258. */
  55259. getClassName(): string;
  55260. /**
  55261. * Returns the integer 0.
  55262. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55263. */
  55264. getTypeID(): number;
  55265. /**
  55266. * Specifies wether or not the shadowmap should be a cube texture.
  55267. * @returns true if the shadowmap needs to be a cube texture.
  55268. */
  55269. needCube(): boolean;
  55270. /**
  55271. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55272. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55273. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55274. */
  55275. getShadowDirection(faceIndex?: number): Vector3;
  55276. /**
  55277. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55278. * - fov = PI / 2
  55279. * - aspect ratio : 1.0
  55280. * - z-near and far equal to the active camera minZ and maxZ.
  55281. * Returns the PointLight.
  55282. */
  55283. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55284. protected _buildUniformLayout(): void;
  55285. /**
  55286. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55287. * @param effect The effect to update
  55288. * @param lightIndex The index of the light in the effect to update
  55289. * @returns The point light
  55290. */
  55291. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55292. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55293. /**
  55294. * Prepares the list of defines specific to the light type.
  55295. * @param defines the list of defines
  55296. * @param lightIndex defines the index of the light for the effect
  55297. */
  55298. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /**
  55303. * Header information of HDR texture files.
  55304. */
  55305. export interface HDRInfo {
  55306. /**
  55307. * The height of the texture in pixels.
  55308. */
  55309. height: number;
  55310. /**
  55311. * The width of the texture in pixels.
  55312. */
  55313. width: number;
  55314. /**
  55315. * The index of the beginning of the data in the binary file.
  55316. */
  55317. dataPosition: number;
  55318. }
  55319. /**
  55320. * This groups tools to convert HDR texture to native colors array.
  55321. */
  55322. export class HDRTools {
  55323. private static Ldexp;
  55324. private static Rgbe2float;
  55325. private static readStringLine;
  55326. /**
  55327. * Reads header information from an RGBE texture stored in a native array.
  55328. * More information on this format are available here:
  55329. * https://en.wikipedia.org/wiki/RGBE_image_format
  55330. *
  55331. * @param uint8array The binary file stored in native array.
  55332. * @return The header information.
  55333. */
  55334. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55335. /**
  55336. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55337. * This RGBE texture needs to store the information as a panorama.
  55338. *
  55339. * More information on this format are available here:
  55340. * https://en.wikipedia.org/wiki/RGBE_image_format
  55341. *
  55342. * @param buffer The binary file stored in an array buffer.
  55343. * @param size The expected size of the extracted cubemap.
  55344. * @return The Cube Map information.
  55345. */
  55346. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55347. /**
  55348. * Returns the pixels data extracted from an RGBE texture.
  55349. * This pixels will be stored left to right up to down in the R G B order in one array.
  55350. *
  55351. * More information on this format are available here:
  55352. * https://en.wikipedia.org/wiki/RGBE_image_format
  55353. *
  55354. * @param uint8array The binary file stored in an array buffer.
  55355. * @param hdrInfo The header information of the file.
  55356. * @return The pixels data in RGB right to left up to down order.
  55357. */
  55358. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55359. private static RGBE_ReadPixels_RLE;
  55360. }
  55361. }
  55362. declare module BABYLON {
  55363. /**
  55364. * This represents a texture coming from an HDR input.
  55365. *
  55366. * The only supported format is currently panorama picture stored in RGBE format.
  55367. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55368. */
  55369. export class HDRCubeTexture extends BaseTexture {
  55370. private static _facesMapping;
  55371. private _generateHarmonics;
  55372. private _noMipmap;
  55373. private _textureMatrix;
  55374. private _size;
  55375. private _onLoad;
  55376. private _onError;
  55377. /**
  55378. * The texture URL.
  55379. */
  55380. url: string;
  55381. /**
  55382. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55383. */
  55384. coordinatesMode: number;
  55385. protected _isBlocking: boolean;
  55386. /**
  55387. * Sets wether or not the texture is blocking during loading.
  55388. */
  55389. set isBlocking(value: boolean);
  55390. /**
  55391. * Gets wether or not the texture is blocking during loading.
  55392. */
  55393. get isBlocking(): boolean;
  55394. protected _rotationY: number;
  55395. /**
  55396. * Sets texture matrix rotation angle around Y axis in radians.
  55397. */
  55398. set rotationY(value: number);
  55399. /**
  55400. * Gets texture matrix rotation angle around Y axis radians.
  55401. */
  55402. get rotationY(): number;
  55403. /**
  55404. * Gets or sets the center of the bounding box associated with the cube texture
  55405. * It must define where the camera used to render the texture was set
  55406. */
  55407. boundingBoxPosition: Vector3;
  55408. private _boundingBoxSize;
  55409. /**
  55410. * Gets or sets the size of the bounding box associated with the cube texture
  55411. * When defined, the cubemap will switch to local mode
  55412. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55413. * @example https://www.babylonjs-playground.com/#RNASML
  55414. */
  55415. set boundingBoxSize(value: Vector3);
  55416. get boundingBoxSize(): Vector3;
  55417. /**
  55418. * Instantiates an HDRTexture from the following parameters.
  55419. *
  55420. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55421. * @param scene The scene the texture will be used in
  55422. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55423. * @param noMipmap Forces to not generate the mipmap if true
  55424. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55425. * @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)
  55426. * @param reserved Reserved flag for internal use.
  55427. */
  55428. 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>);
  55429. /**
  55430. * Get the current class name of the texture useful for serialization or dynamic coding.
  55431. * @returns "HDRCubeTexture"
  55432. */
  55433. getClassName(): string;
  55434. /**
  55435. * Occurs when the file is raw .hdr file.
  55436. */
  55437. private loadTexture;
  55438. clone(): HDRCubeTexture;
  55439. delayLoad(): void;
  55440. /**
  55441. * Get the texture reflection matrix used to rotate/transform the reflection.
  55442. * @returns the reflection matrix
  55443. */
  55444. getReflectionTextureMatrix(): Matrix;
  55445. /**
  55446. * Set the texture reflection matrix used to rotate/transform the reflection.
  55447. * @param value Define the reflection matrix to set
  55448. */
  55449. setReflectionTextureMatrix(value: Matrix): void;
  55450. /**
  55451. * Parses a JSON representation of an HDR Texture in order to create the texture
  55452. * @param parsedTexture Define the JSON representation
  55453. * @param scene Define the scene the texture should be created in
  55454. * @param rootUrl Define the root url in case we need to load relative dependencies
  55455. * @returns the newly created texture after parsing
  55456. */
  55457. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55458. serialize(): any;
  55459. }
  55460. }
  55461. declare module BABYLON {
  55462. /**
  55463. * Class used to control physics engine
  55464. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55465. */
  55466. export class PhysicsEngine implements IPhysicsEngine {
  55467. private _physicsPlugin;
  55468. /**
  55469. * Global value used to control the smallest number supported by the simulation
  55470. */
  55471. static Epsilon: number;
  55472. private _impostors;
  55473. private _joints;
  55474. private _subTimeStep;
  55475. /**
  55476. * Gets the gravity vector used by the simulation
  55477. */
  55478. gravity: Vector3;
  55479. /**
  55480. * Factory used to create the default physics plugin.
  55481. * @returns The default physics plugin
  55482. */
  55483. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55484. /**
  55485. * Creates a new Physics Engine
  55486. * @param gravity defines the gravity vector used by the simulation
  55487. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55488. */
  55489. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55490. /**
  55491. * Sets the gravity vector used by the simulation
  55492. * @param gravity defines the gravity vector to use
  55493. */
  55494. setGravity(gravity: Vector3): void;
  55495. /**
  55496. * Set the time step of the physics engine.
  55497. * Default is 1/60.
  55498. * To slow it down, enter 1/600 for example.
  55499. * To speed it up, 1/30
  55500. * @param newTimeStep defines the new timestep to apply to this world.
  55501. */
  55502. setTimeStep(newTimeStep?: number): void;
  55503. /**
  55504. * Get the time step of the physics engine.
  55505. * @returns the current time step
  55506. */
  55507. getTimeStep(): number;
  55508. /**
  55509. * Set the sub time step of the physics engine.
  55510. * Default is 0 meaning there is no sub steps
  55511. * To increase physics resolution precision, set a small value (like 1 ms)
  55512. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55513. */
  55514. setSubTimeStep(subTimeStep?: number): void;
  55515. /**
  55516. * Get the sub time step of the physics engine.
  55517. * @returns the current sub time step
  55518. */
  55519. getSubTimeStep(): number;
  55520. /**
  55521. * Release all resources
  55522. */
  55523. dispose(): void;
  55524. /**
  55525. * Gets the name of the current physics plugin
  55526. * @returns the name of the plugin
  55527. */
  55528. getPhysicsPluginName(): string;
  55529. /**
  55530. * Adding a new impostor for the impostor tracking.
  55531. * This will be done by the impostor itself.
  55532. * @param impostor the impostor to add
  55533. */
  55534. addImpostor(impostor: PhysicsImpostor): void;
  55535. /**
  55536. * Remove an impostor from the engine.
  55537. * This impostor and its mesh will not longer be updated by the physics engine.
  55538. * @param impostor the impostor to remove
  55539. */
  55540. removeImpostor(impostor: PhysicsImpostor): void;
  55541. /**
  55542. * Add a joint to the physics engine
  55543. * @param mainImpostor defines the main impostor to which the joint is added.
  55544. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55545. * @param joint defines the joint that will connect both impostors.
  55546. */
  55547. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55548. /**
  55549. * Removes a joint from the simulation
  55550. * @param mainImpostor defines the impostor used with the joint
  55551. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55552. * @param joint defines the joint to remove
  55553. */
  55554. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55555. /**
  55556. * Called by the scene. No need to call it.
  55557. * @param delta defines the timespam between frames
  55558. */
  55559. _step(delta: number): void;
  55560. /**
  55561. * Gets the current plugin used to run the simulation
  55562. * @returns current plugin
  55563. */
  55564. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55565. /**
  55566. * Gets the list of physic impostors
  55567. * @returns an array of PhysicsImpostor
  55568. */
  55569. getImpostors(): Array<PhysicsImpostor>;
  55570. /**
  55571. * Gets the impostor for a physics enabled object
  55572. * @param object defines the object impersonated by the impostor
  55573. * @returns the PhysicsImpostor or null if not found
  55574. */
  55575. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55576. /**
  55577. * Gets the impostor for a physics body object
  55578. * @param body defines physics body used by the impostor
  55579. * @returns the PhysicsImpostor or null if not found
  55580. */
  55581. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55582. /**
  55583. * Does a raycast in the physics world
  55584. * @param from when should the ray start?
  55585. * @param to when should the ray end?
  55586. * @returns PhysicsRaycastResult
  55587. */
  55588. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55589. }
  55590. }
  55591. declare module BABYLON {
  55592. /** @hidden */
  55593. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55594. private _useDeltaForWorldStep;
  55595. world: any;
  55596. name: string;
  55597. private _physicsMaterials;
  55598. private _fixedTimeStep;
  55599. private _cannonRaycastResult;
  55600. private _raycastResult;
  55601. private _physicsBodysToRemoveAfterStep;
  55602. BJSCANNON: any;
  55603. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55604. setGravity(gravity: Vector3): void;
  55605. setTimeStep(timeStep: number): void;
  55606. getTimeStep(): number;
  55607. executeStep(delta: number): void;
  55608. private _removeMarkedPhysicsBodiesFromWorld;
  55609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55610. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55612. private _processChildMeshes;
  55613. removePhysicsBody(impostor: PhysicsImpostor): void;
  55614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55615. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55616. private _addMaterial;
  55617. private _checkWithEpsilon;
  55618. private _createShape;
  55619. private _createHeightmap;
  55620. private _minus90X;
  55621. private _plus90X;
  55622. private _tmpPosition;
  55623. private _tmpDeltaPosition;
  55624. private _tmpUnityRotation;
  55625. private _updatePhysicsBodyTransformation;
  55626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55628. isSupported(): boolean;
  55629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55634. getBodyMass(impostor: PhysicsImpostor): number;
  55635. getBodyFriction(impostor: PhysicsImpostor): number;
  55636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55637. getBodyRestitution(impostor: PhysicsImpostor): number;
  55638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55639. sleepBody(impostor: PhysicsImpostor): void;
  55640. wakeUpBody(impostor: PhysicsImpostor): void;
  55641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55642. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55644. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55645. getRadius(impostor: PhysicsImpostor): number;
  55646. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55647. dispose(): void;
  55648. private _extendNamespace;
  55649. /**
  55650. * Does a raycast in the physics world
  55651. * @param from when should the ray start?
  55652. * @param to when should the ray end?
  55653. * @returns PhysicsRaycastResult
  55654. */
  55655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55656. }
  55657. }
  55658. declare module BABYLON {
  55659. /** @hidden */
  55660. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55661. private _useDeltaForWorldStep;
  55662. world: any;
  55663. name: string;
  55664. BJSOIMO: any;
  55665. private _raycastResult;
  55666. private _fixedTimeStep;
  55667. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55668. setGravity(gravity: Vector3): void;
  55669. setTimeStep(timeStep: number): void;
  55670. getTimeStep(): number;
  55671. private _tmpImpostorsArray;
  55672. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55673. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55674. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55675. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55676. private _tmpPositionVector;
  55677. removePhysicsBody(impostor: PhysicsImpostor): void;
  55678. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55679. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55680. isSupported(): boolean;
  55681. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55682. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55683. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55684. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55685. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55686. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55687. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55688. getBodyMass(impostor: PhysicsImpostor): number;
  55689. getBodyFriction(impostor: PhysicsImpostor): number;
  55690. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55691. getBodyRestitution(impostor: PhysicsImpostor): number;
  55692. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55693. sleepBody(impostor: PhysicsImpostor): void;
  55694. wakeUpBody(impostor: PhysicsImpostor): void;
  55695. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55696. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55697. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55698. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55699. getRadius(impostor: PhysicsImpostor): number;
  55700. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55701. dispose(): void;
  55702. /**
  55703. * Does a raycast in the physics world
  55704. * @param from when should the ray start?
  55705. * @param to when should the ray end?
  55706. * @returns PhysicsRaycastResult
  55707. */
  55708. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55709. }
  55710. }
  55711. declare module BABYLON {
  55712. /**
  55713. * Class containing static functions to help procedurally build meshes
  55714. */
  55715. export class RibbonBuilder {
  55716. /**
  55717. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55718. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55719. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55720. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55721. * * 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
  55722. * * 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
  55723. * * 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
  55724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55725. * * 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
  55726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55727. * * 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
  55728. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55729. * * 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
  55730. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55732. * @param name defines the name of the mesh
  55733. * @param options defines the options used to create the mesh
  55734. * @param scene defines the hosting scene
  55735. * @returns the ribbon mesh
  55736. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55738. */
  55739. static CreateRibbon(name: string, options: {
  55740. pathArray: Vector3[][];
  55741. closeArray?: boolean;
  55742. closePath?: boolean;
  55743. offset?: number;
  55744. updatable?: boolean;
  55745. sideOrientation?: number;
  55746. frontUVs?: Vector4;
  55747. backUVs?: Vector4;
  55748. instance?: Mesh;
  55749. invertUV?: boolean;
  55750. uvs?: Vector2[];
  55751. colors?: Color4[];
  55752. }, scene?: Nullable<Scene>): Mesh;
  55753. }
  55754. }
  55755. declare module BABYLON {
  55756. /**
  55757. * Class containing static functions to help procedurally build meshes
  55758. */
  55759. export class ShapeBuilder {
  55760. /**
  55761. * 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.
  55762. * * 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.
  55763. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55764. * * 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.
  55765. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55766. * * 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
  55767. * * 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
  55768. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55773. * @param name defines the name of the mesh
  55774. * @param options defines the options used to create the mesh
  55775. * @param scene defines the hosting scene
  55776. * @returns the extruded shape mesh
  55777. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55779. */
  55780. static ExtrudeShape(name: string, options: {
  55781. shape: Vector3[];
  55782. path: Vector3[];
  55783. scale?: number;
  55784. rotation?: number;
  55785. cap?: number;
  55786. updatable?: boolean;
  55787. sideOrientation?: number;
  55788. frontUVs?: Vector4;
  55789. backUVs?: Vector4;
  55790. instance?: Mesh;
  55791. invertUV?: boolean;
  55792. }, scene?: Nullable<Scene>): Mesh;
  55793. /**
  55794. * Creates an custom extruded shape mesh.
  55795. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55796. * * 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.
  55797. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55798. * * 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
  55799. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55800. * * 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
  55801. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55802. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55803. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55804. * * 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
  55805. * * 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
  55806. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55808. * * 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
  55809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55811. * @param name defines the name of the mesh
  55812. * @param options defines the options used to create the mesh
  55813. * @param scene defines the hosting scene
  55814. * @returns the custom extruded shape mesh
  55815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55818. */
  55819. static ExtrudeShapeCustom(name: string, options: {
  55820. shape: Vector3[];
  55821. path: Vector3[];
  55822. scaleFunction?: any;
  55823. rotationFunction?: any;
  55824. ribbonCloseArray?: boolean;
  55825. ribbonClosePath?: boolean;
  55826. cap?: number;
  55827. updatable?: boolean;
  55828. sideOrientation?: number;
  55829. frontUVs?: Vector4;
  55830. backUVs?: Vector4;
  55831. instance?: Mesh;
  55832. invertUV?: boolean;
  55833. }, scene?: Nullable<Scene>): Mesh;
  55834. private static _ExtrudeShapeGeneric;
  55835. }
  55836. }
  55837. declare module BABYLON {
  55838. /**
  55839. * AmmoJS Physics plugin
  55840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55841. * @see https://github.com/kripken/ammo.js/
  55842. */
  55843. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55844. private _useDeltaForWorldStep;
  55845. /**
  55846. * Reference to the Ammo library
  55847. */
  55848. bjsAMMO: any;
  55849. /**
  55850. * Created ammoJS world which physics bodies are added to
  55851. */
  55852. world: any;
  55853. /**
  55854. * Name of the plugin
  55855. */
  55856. name: string;
  55857. private _timeStep;
  55858. private _fixedTimeStep;
  55859. private _maxSteps;
  55860. private _tmpQuaternion;
  55861. private _tmpAmmoTransform;
  55862. private _tmpAmmoQuaternion;
  55863. private _tmpAmmoConcreteContactResultCallback;
  55864. private _collisionConfiguration;
  55865. private _dispatcher;
  55866. private _overlappingPairCache;
  55867. private _solver;
  55868. private _softBodySolver;
  55869. private _tmpAmmoVectorA;
  55870. private _tmpAmmoVectorB;
  55871. private _tmpAmmoVectorC;
  55872. private _tmpAmmoVectorD;
  55873. private _tmpContactCallbackResult;
  55874. private _tmpAmmoVectorRCA;
  55875. private _tmpAmmoVectorRCB;
  55876. private _raycastResult;
  55877. private static readonly DISABLE_COLLISION_FLAG;
  55878. private static readonly KINEMATIC_FLAG;
  55879. private static readonly DISABLE_DEACTIVATION_FLAG;
  55880. /**
  55881. * Initializes the ammoJS plugin
  55882. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55883. * @param ammoInjection can be used to inject your own ammo reference
  55884. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55885. */
  55886. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55887. /**
  55888. * Sets the gravity of the physics world (m/(s^2))
  55889. * @param gravity Gravity to set
  55890. */
  55891. setGravity(gravity: Vector3): void;
  55892. /**
  55893. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55894. * @param timeStep timestep to use in seconds
  55895. */
  55896. setTimeStep(timeStep: number): void;
  55897. /**
  55898. * 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)
  55899. * @param fixedTimeStep fixedTimeStep to use in seconds
  55900. */
  55901. setFixedTimeStep(fixedTimeStep: number): void;
  55902. /**
  55903. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55904. * @param maxSteps the maximum number of steps by the physics engine per frame
  55905. */
  55906. setMaxSteps(maxSteps: number): void;
  55907. /**
  55908. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55909. * @returns the current timestep in seconds
  55910. */
  55911. getTimeStep(): number;
  55912. /**
  55913. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55914. */
  55915. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55916. private _isImpostorInContact;
  55917. private _isImpostorPairInContact;
  55918. private _stepSimulation;
  55919. /**
  55920. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55921. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55922. * After the step the babylon meshes are set to the position of the physics imposters
  55923. * @param delta amount of time to step forward
  55924. * @param impostors array of imposters to update before/after the step
  55925. */
  55926. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55927. /**
  55928. * Update babylon mesh to match physics world object
  55929. * @param impostor imposter to match
  55930. */
  55931. private _afterSoftStep;
  55932. /**
  55933. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55934. * @param impostor imposter to match
  55935. */
  55936. private _ropeStep;
  55937. /**
  55938. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55939. * @param impostor imposter to match
  55940. */
  55941. private _softbodyOrClothStep;
  55942. private _tmpMatrix;
  55943. /**
  55944. * Applies an impulse on the imposter
  55945. * @param impostor imposter to apply impulse to
  55946. * @param force amount of force to be applied to the imposter
  55947. * @param contactPoint the location to apply the impulse on the imposter
  55948. */
  55949. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55950. /**
  55951. * Applies a force on the imposter
  55952. * @param impostor imposter to apply force
  55953. * @param force amount of force to be applied to the imposter
  55954. * @param contactPoint the location to apply the force on the imposter
  55955. */
  55956. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55957. /**
  55958. * Creates a physics body using the plugin
  55959. * @param impostor the imposter to create the physics body on
  55960. */
  55961. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55962. /**
  55963. * Removes the physics body from the imposter and disposes of the body's memory
  55964. * @param impostor imposter to remove the physics body from
  55965. */
  55966. removePhysicsBody(impostor: PhysicsImpostor): void;
  55967. /**
  55968. * Generates a joint
  55969. * @param impostorJoint the imposter joint to create the joint with
  55970. */
  55971. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55972. /**
  55973. * Removes a joint
  55974. * @param impostorJoint the imposter joint to remove the joint from
  55975. */
  55976. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55977. private _addMeshVerts;
  55978. /**
  55979. * Initialise the soft body vertices to match its object's (mesh) vertices
  55980. * Softbody vertices (nodes) are in world space and to match this
  55981. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55982. * @param impostor to create the softbody for
  55983. */
  55984. private _softVertexData;
  55985. /**
  55986. * Create an impostor's soft body
  55987. * @param impostor to create the softbody for
  55988. */
  55989. private _createSoftbody;
  55990. /**
  55991. * Create cloth for an impostor
  55992. * @param impostor to create the softbody for
  55993. */
  55994. private _createCloth;
  55995. /**
  55996. * Create rope for an impostor
  55997. * @param impostor to create the softbody for
  55998. */
  55999. private _createRope;
  56000. /**
  56001. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56002. * @param impostor to create the custom physics shape for
  56003. */
  56004. private _createCustom;
  56005. private _addHullVerts;
  56006. private _createShape;
  56007. /**
  56008. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56009. * @param impostor imposter containing the physics body and babylon object
  56010. */
  56011. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56012. /**
  56013. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56014. * @param impostor imposter containing the physics body and babylon object
  56015. * @param newPosition new position
  56016. * @param newRotation new rotation
  56017. */
  56018. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56019. /**
  56020. * If this plugin is supported
  56021. * @returns true if its supported
  56022. */
  56023. isSupported(): boolean;
  56024. /**
  56025. * Sets the linear velocity of the physics body
  56026. * @param impostor imposter to set the velocity on
  56027. * @param velocity velocity to set
  56028. */
  56029. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56030. /**
  56031. * Sets the angular velocity of the physics body
  56032. * @param impostor imposter to set the velocity on
  56033. * @param velocity velocity to set
  56034. */
  56035. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56036. /**
  56037. * gets the linear velocity
  56038. * @param impostor imposter to get linear velocity from
  56039. * @returns linear velocity
  56040. */
  56041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56042. /**
  56043. * gets the angular velocity
  56044. * @param impostor imposter to get angular velocity from
  56045. * @returns angular velocity
  56046. */
  56047. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56048. /**
  56049. * Sets the mass of physics body
  56050. * @param impostor imposter to set the mass on
  56051. * @param mass mass to set
  56052. */
  56053. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56054. /**
  56055. * Gets the mass of the physics body
  56056. * @param impostor imposter to get the mass from
  56057. * @returns mass
  56058. */
  56059. getBodyMass(impostor: PhysicsImpostor): number;
  56060. /**
  56061. * Gets friction of the impostor
  56062. * @param impostor impostor to get friction from
  56063. * @returns friction value
  56064. */
  56065. getBodyFriction(impostor: PhysicsImpostor): number;
  56066. /**
  56067. * Sets friction of the impostor
  56068. * @param impostor impostor to set friction on
  56069. * @param friction friction value
  56070. */
  56071. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56072. /**
  56073. * Gets restitution of the impostor
  56074. * @param impostor impostor to get restitution from
  56075. * @returns restitution value
  56076. */
  56077. getBodyRestitution(impostor: PhysicsImpostor): number;
  56078. /**
  56079. * Sets resitution of the impostor
  56080. * @param impostor impostor to set resitution on
  56081. * @param restitution resitution value
  56082. */
  56083. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56084. /**
  56085. * Gets pressure inside the impostor
  56086. * @param impostor impostor to get pressure from
  56087. * @returns pressure value
  56088. */
  56089. getBodyPressure(impostor: PhysicsImpostor): number;
  56090. /**
  56091. * Sets pressure inside a soft body impostor
  56092. * Cloth and rope must remain 0 pressure
  56093. * @param impostor impostor to set pressure on
  56094. * @param pressure pressure value
  56095. */
  56096. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56097. /**
  56098. * Gets stiffness of the impostor
  56099. * @param impostor impostor to get stiffness from
  56100. * @returns pressure value
  56101. */
  56102. getBodyStiffness(impostor: PhysicsImpostor): number;
  56103. /**
  56104. * Sets stiffness of the impostor
  56105. * @param impostor impostor to set stiffness on
  56106. * @param stiffness stiffness value from 0 to 1
  56107. */
  56108. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56109. /**
  56110. * Gets velocityIterations of the impostor
  56111. * @param impostor impostor to get velocity iterations from
  56112. * @returns velocityIterations value
  56113. */
  56114. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56115. /**
  56116. * Sets velocityIterations of the impostor
  56117. * @param impostor impostor to set velocity iterations on
  56118. * @param velocityIterations velocityIterations value
  56119. */
  56120. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56121. /**
  56122. * Gets positionIterations of the impostor
  56123. * @param impostor impostor to get position iterations from
  56124. * @returns positionIterations value
  56125. */
  56126. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56127. /**
  56128. * Sets positionIterations of the impostor
  56129. * @param impostor impostor to set position on
  56130. * @param positionIterations positionIterations value
  56131. */
  56132. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56133. /**
  56134. * Append an anchor to a cloth object
  56135. * @param impostor is the cloth impostor to add anchor to
  56136. * @param otherImpostor is the rigid impostor to anchor to
  56137. * @param width ratio across width from 0 to 1
  56138. * @param height ratio up height from 0 to 1
  56139. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56140. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56141. */
  56142. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56143. /**
  56144. * Append an hook to a rope object
  56145. * @param impostor is the rope impostor to add hook to
  56146. * @param otherImpostor is the rigid impostor to hook to
  56147. * @param length ratio along the rope from 0 to 1
  56148. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56149. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56150. */
  56151. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56152. /**
  56153. * Sleeps the physics body and stops it from being active
  56154. * @param impostor impostor to sleep
  56155. */
  56156. sleepBody(impostor: PhysicsImpostor): void;
  56157. /**
  56158. * Activates the physics body
  56159. * @param impostor impostor to activate
  56160. */
  56161. wakeUpBody(impostor: PhysicsImpostor): void;
  56162. /**
  56163. * Updates the distance parameters of the joint
  56164. * @param joint joint to update
  56165. * @param maxDistance maximum distance of the joint
  56166. * @param minDistance minimum distance of the joint
  56167. */
  56168. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56169. /**
  56170. * Sets a motor on the joint
  56171. * @param joint joint to set motor on
  56172. * @param speed speed of the motor
  56173. * @param maxForce maximum force of the motor
  56174. * @param motorIndex index of the motor
  56175. */
  56176. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56177. /**
  56178. * Sets the motors limit
  56179. * @param joint joint to set limit on
  56180. * @param upperLimit upper limit
  56181. * @param lowerLimit lower limit
  56182. */
  56183. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56184. /**
  56185. * Syncs the position and rotation of a mesh with the impostor
  56186. * @param mesh mesh to sync
  56187. * @param impostor impostor to update the mesh with
  56188. */
  56189. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56190. /**
  56191. * Gets the radius of the impostor
  56192. * @param impostor impostor to get radius from
  56193. * @returns the radius
  56194. */
  56195. getRadius(impostor: PhysicsImpostor): number;
  56196. /**
  56197. * Gets the box size of the impostor
  56198. * @param impostor impostor to get box size from
  56199. * @param result the resulting box size
  56200. */
  56201. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56202. /**
  56203. * Disposes of the impostor
  56204. */
  56205. dispose(): void;
  56206. /**
  56207. * Does a raycast in the physics world
  56208. * @param from when should the ray start?
  56209. * @param to when should the ray end?
  56210. * @returns PhysicsRaycastResult
  56211. */
  56212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56213. }
  56214. }
  56215. declare module BABYLON {
  56216. interface AbstractScene {
  56217. /**
  56218. * The list of reflection probes added to the scene
  56219. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56220. */
  56221. reflectionProbes: Array<ReflectionProbe>;
  56222. /**
  56223. * Removes the given reflection probe from this scene.
  56224. * @param toRemove The reflection probe to remove
  56225. * @returns The index of the removed reflection probe
  56226. */
  56227. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56228. /**
  56229. * Adds the given reflection probe to this scene.
  56230. * @param newReflectionProbe The reflection probe to add
  56231. */
  56232. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56233. }
  56234. /**
  56235. * Class used to generate realtime reflection / refraction cube textures
  56236. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56237. */
  56238. export class ReflectionProbe {
  56239. /** defines the name of the probe */
  56240. name: string;
  56241. private _scene;
  56242. private _renderTargetTexture;
  56243. private _projectionMatrix;
  56244. private _viewMatrix;
  56245. private _target;
  56246. private _add;
  56247. private _attachedMesh;
  56248. private _invertYAxis;
  56249. /** Gets or sets probe position (center of the cube map) */
  56250. position: Vector3;
  56251. /**
  56252. * Creates a new reflection probe
  56253. * @param name defines the name of the probe
  56254. * @param size defines the texture resolution (for each face)
  56255. * @param scene defines the hosting scene
  56256. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56257. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56258. */
  56259. constructor(
  56260. /** defines the name of the probe */
  56261. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56262. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56263. get samples(): number;
  56264. set samples(value: number);
  56265. /** Gets or sets the refresh rate to use (on every frame by default) */
  56266. get refreshRate(): number;
  56267. set refreshRate(value: number);
  56268. /**
  56269. * Gets the hosting scene
  56270. * @returns a Scene
  56271. */
  56272. getScene(): Scene;
  56273. /** Gets the internal CubeTexture used to render to */
  56274. get cubeTexture(): RenderTargetTexture;
  56275. /** Gets the list of meshes to render */
  56276. get renderList(): Nullable<AbstractMesh[]>;
  56277. /**
  56278. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56279. * @param mesh defines the mesh to attach to
  56280. */
  56281. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56282. /**
  56283. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56284. * @param renderingGroupId The rendering group id corresponding to its index
  56285. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56286. */
  56287. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56288. /**
  56289. * Clean all associated resources
  56290. */
  56291. dispose(): void;
  56292. /**
  56293. * Converts the reflection probe information to a readable string for debug purpose.
  56294. * @param fullDetails Supports for multiple levels of logging within scene loading
  56295. * @returns the human readable reflection probe info
  56296. */
  56297. toString(fullDetails?: boolean): string;
  56298. /**
  56299. * Get the class name of the relfection probe.
  56300. * @returns "ReflectionProbe"
  56301. */
  56302. getClassName(): string;
  56303. /**
  56304. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56305. * @returns The JSON representation of the texture
  56306. */
  56307. serialize(): any;
  56308. /**
  56309. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56310. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56311. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56312. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56313. * @returns The parsed reflection probe if successful
  56314. */
  56315. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56316. }
  56317. }
  56318. declare module BABYLON {
  56319. /** @hidden */
  56320. export var _BabylonLoaderRegistered: boolean;
  56321. /**
  56322. * Helps setting up some configuration for the babylon file loader.
  56323. */
  56324. export class BabylonFileLoaderConfiguration {
  56325. /**
  56326. * The loader does not allow injecting custom physix engine into the plugins.
  56327. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56328. * So you could set this variable to your engine import to make it work.
  56329. */
  56330. static LoaderInjectedPhysicsEngine: any;
  56331. }
  56332. }
  56333. declare module BABYLON {
  56334. /**
  56335. * The Physically based simple base material of BJS.
  56336. *
  56337. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56338. * It is used as the base class for both the specGloss and metalRough conventions.
  56339. */
  56340. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56341. /**
  56342. * Number of Simultaneous lights allowed on the material.
  56343. */
  56344. maxSimultaneousLights: number;
  56345. /**
  56346. * If sets to true, disables all the lights affecting the material.
  56347. */
  56348. disableLighting: boolean;
  56349. /**
  56350. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56351. */
  56352. environmentTexture: BaseTexture;
  56353. /**
  56354. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56355. */
  56356. invertNormalMapX: boolean;
  56357. /**
  56358. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56359. */
  56360. invertNormalMapY: boolean;
  56361. /**
  56362. * Normal map used in the model.
  56363. */
  56364. normalTexture: BaseTexture;
  56365. /**
  56366. * Emissivie color used to self-illuminate the model.
  56367. */
  56368. emissiveColor: Color3;
  56369. /**
  56370. * Emissivie texture used to self-illuminate the model.
  56371. */
  56372. emissiveTexture: BaseTexture;
  56373. /**
  56374. * Occlusion Channel Strenght.
  56375. */
  56376. occlusionStrength: number;
  56377. /**
  56378. * Occlusion Texture of the material (adding extra occlusion effects).
  56379. */
  56380. occlusionTexture: BaseTexture;
  56381. /**
  56382. * Defines the alpha limits in alpha test mode.
  56383. */
  56384. alphaCutOff: number;
  56385. /**
  56386. * Gets the current double sided mode.
  56387. */
  56388. get doubleSided(): boolean;
  56389. /**
  56390. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56391. */
  56392. set doubleSided(value: boolean);
  56393. /**
  56394. * Stores the pre-calculated light information of a mesh in a texture.
  56395. */
  56396. lightmapTexture: BaseTexture;
  56397. /**
  56398. * If true, the light map contains occlusion information instead of lighting info.
  56399. */
  56400. useLightmapAsShadowmap: boolean;
  56401. /**
  56402. * Instantiates a new PBRMaterial instance.
  56403. *
  56404. * @param name The material name
  56405. * @param scene The scene the material will be use in.
  56406. */
  56407. constructor(name: string, scene: Scene);
  56408. getClassName(): string;
  56409. }
  56410. }
  56411. declare module BABYLON {
  56412. /**
  56413. * The PBR material of BJS following the metal roughness convention.
  56414. *
  56415. * This fits to the PBR convention in the GLTF definition:
  56416. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56417. */
  56418. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56419. /**
  56420. * The base color has two different interpretations depending on the value of metalness.
  56421. * When the material is a metal, the base color is the specific measured reflectance value
  56422. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56423. * of the material.
  56424. */
  56425. baseColor: Color3;
  56426. /**
  56427. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56428. * well as opacity information in the alpha channel.
  56429. */
  56430. baseTexture: BaseTexture;
  56431. /**
  56432. * Specifies the metallic scalar value of the material.
  56433. * Can also be used to scale the metalness values of the metallic texture.
  56434. */
  56435. metallic: number;
  56436. /**
  56437. * Specifies the roughness scalar value of the material.
  56438. * Can also be used to scale the roughness values of the metallic texture.
  56439. */
  56440. roughness: number;
  56441. /**
  56442. * Texture containing both the metallic value in the B channel and the
  56443. * roughness value in the G channel to keep better precision.
  56444. */
  56445. metallicRoughnessTexture: BaseTexture;
  56446. /**
  56447. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56448. *
  56449. * @param name The material name
  56450. * @param scene The scene the material will be use in.
  56451. */
  56452. constructor(name: string, scene: Scene);
  56453. /**
  56454. * Return the currrent class name of the material.
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Makes a duplicate of the current material.
  56459. * @param name - name to use for the new material.
  56460. */
  56461. clone(name: string): PBRMetallicRoughnessMaterial;
  56462. /**
  56463. * Serialize the material to a parsable JSON object.
  56464. */
  56465. serialize(): any;
  56466. /**
  56467. * Parses a JSON object correponding to the serialize function.
  56468. */
  56469. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56470. }
  56471. }
  56472. declare module BABYLON {
  56473. /**
  56474. * The PBR material of BJS following the specular glossiness convention.
  56475. *
  56476. * This fits to the PBR convention in the GLTF definition:
  56477. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56478. */
  56479. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56480. /**
  56481. * Specifies the diffuse color of the material.
  56482. */
  56483. diffuseColor: Color3;
  56484. /**
  56485. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56486. * channel.
  56487. */
  56488. diffuseTexture: BaseTexture;
  56489. /**
  56490. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56491. */
  56492. specularColor: Color3;
  56493. /**
  56494. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56495. */
  56496. glossiness: number;
  56497. /**
  56498. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56499. */
  56500. specularGlossinessTexture: BaseTexture;
  56501. /**
  56502. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56503. *
  56504. * @param name The material name
  56505. * @param scene The scene the material will be use in.
  56506. */
  56507. constructor(name: string, scene: Scene);
  56508. /**
  56509. * Return the currrent class name of the material.
  56510. */
  56511. getClassName(): string;
  56512. /**
  56513. * Makes a duplicate of the current material.
  56514. * @param name - name to use for the new material.
  56515. */
  56516. clone(name: string): PBRSpecularGlossinessMaterial;
  56517. /**
  56518. * Serialize the material to a parsable JSON object.
  56519. */
  56520. serialize(): any;
  56521. /**
  56522. * Parses a JSON object correponding to the serialize function.
  56523. */
  56524. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56525. }
  56526. }
  56527. declare module BABYLON {
  56528. /**
  56529. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56530. * It can help converting any input color in a desired output one. This can then be used to create effects
  56531. * from sepia, black and white to sixties or futuristic rendering...
  56532. *
  56533. * The only supported format is currently 3dl.
  56534. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56535. */
  56536. export class ColorGradingTexture extends BaseTexture {
  56537. /**
  56538. * The texture URL.
  56539. */
  56540. url: string;
  56541. /**
  56542. * Empty line regex stored for GC.
  56543. */
  56544. private static _noneEmptyLineRegex;
  56545. private _textureMatrix;
  56546. private _engine;
  56547. private _onLoad;
  56548. /**
  56549. * Instantiates a ColorGradingTexture from the following parameters.
  56550. *
  56551. * @param url The location of the color gradind data (currently only supporting 3dl)
  56552. * @param sceneOrEngine The scene or engine the texture will be used in
  56553. * @param onLoad defines a callback triggered when the texture has been loaded
  56554. */
  56555. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56556. /**
  56557. * Fires the onload event from the constructor if requested.
  56558. */
  56559. private _triggerOnLoad;
  56560. /**
  56561. * Returns the texture matrix used in most of the material.
  56562. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56563. */
  56564. getTextureMatrix(): Matrix;
  56565. /**
  56566. * Occurs when the file being loaded is a .3dl LUT file.
  56567. */
  56568. private load3dlTexture;
  56569. /**
  56570. * Starts the loading process of the texture.
  56571. */
  56572. private loadTexture;
  56573. /**
  56574. * Clones the color gradind texture.
  56575. */
  56576. clone(): ColorGradingTexture;
  56577. /**
  56578. * Called during delayed load for textures.
  56579. */
  56580. delayLoad(): void;
  56581. /**
  56582. * Parses a color grading texture serialized by Babylon.
  56583. * @param parsedTexture The texture information being parsedTexture
  56584. * @param scene The scene to load the texture in
  56585. * @param rootUrl The root url of the data assets to load
  56586. * @return A color gradind texture
  56587. */
  56588. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56589. /**
  56590. * Serializes the LUT texture to json format.
  56591. */
  56592. serialize(): any;
  56593. /**
  56594. * Returns true if the passed parameter is a scene object (can be use for typings)
  56595. * @param sceneOrEngine The object to test.
  56596. */
  56597. private static _isScene;
  56598. }
  56599. }
  56600. declare module BABYLON {
  56601. /**
  56602. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56603. */
  56604. export class EquiRectangularCubeTexture extends BaseTexture {
  56605. /** The six faces of the cube. */
  56606. private static _FacesMapping;
  56607. private _noMipmap;
  56608. private _onLoad;
  56609. private _onError;
  56610. /** The size of the cubemap. */
  56611. private _size;
  56612. /** The buffer of the image. */
  56613. private _buffer;
  56614. /** The width of the input image. */
  56615. private _width;
  56616. /** The height of the input image. */
  56617. private _height;
  56618. /** The URL to the image. */
  56619. url: string;
  56620. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56621. coordinatesMode: number;
  56622. /**
  56623. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56624. * @param url The location of the image
  56625. * @param scene The scene the texture will be used in
  56626. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56627. * @param noMipmap Forces to not generate the mipmap if true
  56628. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56629. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56630. * @param onLoad — defines a callback called when texture is loaded
  56631. * @param onError — defines a callback called if there is an error
  56632. */
  56633. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56634. /**
  56635. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56636. */
  56637. private loadImage;
  56638. /**
  56639. * Convert the image buffer into a cubemap and create a CubeTexture.
  56640. */
  56641. private loadTexture;
  56642. /**
  56643. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56644. * @param buffer The ArrayBuffer that should be converted.
  56645. * @returns The buffer as Float32Array.
  56646. */
  56647. private getFloat32ArrayFromArrayBuffer;
  56648. /**
  56649. * Get the current class name of the texture useful for serialization or dynamic coding.
  56650. * @returns "EquiRectangularCubeTexture"
  56651. */
  56652. getClassName(): string;
  56653. /**
  56654. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56655. * @returns A clone of the current EquiRectangularCubeTexture.
  56656. */
  56657. clone(): EquiRectangularCubeTexture;
  56658. }
  56659. }
  56660. declare module BABYLON {
  56661. /**
  56662. * Based on jsTGALoader - Javascript loader for TGA file
  56663. * By Vincent Thibault
  56664. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56665. */
  56666. export class TGATools {
  56667. private static _TYPE_INDEXED;
  56668. private static _TYPE_RGB;
  56669. private static _TYPE_GREY;
  56670. private static _TYPE_RLE_INDEXED;
  56671. private static _TYPE_RLE_RGB;
  56672. private static _TYPE_RLE_GREY;
  56673. private static _ORIGIN_MASK;
  56674. private static _ORIGIN_SHIFT;
  56675. private static _ORIGIN_BL;
  56676. private static _ORIGIN_BR;
  56677. private static _ORIGIN_UL;
  56678. private static _ORIGIN_UR;
  56679. /**
  56680. * Gets the header of a TGA file
  56681. * @param data defines the TGA data
  56682. * @returns the header
  56683. */
  56684. static GetTGAHeader(data: Uint8Array): any;
  56685. /**
  56686. * Uploads TGA content to a Babylon Texture
  56687. * @hidden
  56688. */
  56689. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56690. /** @hidden */
  56691. 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;
  56692. /** @hidden */
  56693. 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;
  56694. /** @hidden */
  56695. 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;
  56696. /** @hidden */
  56697. 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;
  56698. /** @hidden */
  56699. 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;
  56700. /** @hidden */
  56701. 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;
  56702. }
  56703. }
  56704. declare module BABYLON {
  56705. /**
  56706. * Implementation of the TGA Texture Loader.
  56707. * @hidden
  56708. */
  56709. export class _TGATextureLoader implements IInternalTextureLoader {
  56710. /**
  56711. * Defines wether the loader supports cascade loading the different faces.
  56712. */
  56713. readonly supportCascades: boolean;
  56714. /**
  56715. * This returns if the loader support the current file information.
  56716. * @param extension defines the file extension of the file being loaded
  56717. * @returns true if the loader can load the specified file
  56718. */
  56719. canLoad(extension: string): boolean;
  56720. /**
  56721. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56722. * @param data contains the texture data
  56723. * @param texture defines the BabylonJS internal texture
  56724. * @param createPolynomials will be true if polynomials have been requested
  56725. * @param onLoad defines the callback to trigger once the texture is ready
  56726. * @param onError defines the callback to trigger in case of error
  56727. */
  56728. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56729. /**
  56730. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56731. * @param data contains the texture data
  56732. * @param texture defines the BabylonJS internal texture
  56733. * @param callback defines the method to call once ready to upload
  56734. */
  56735. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56736. }
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * Info about the .basis files
  56741. */
  56742. class BasisFileInfo {
  56743. /**
  56744. * If the file has alpha
  56745. */
  56746. hasAlpha: boolean;
  56747. /**
  56748. * Info about each image of the basis file
  56749. */
  56750. images: Array<{
  56751. levels: Array<{
  56752. width: number;
  56753. height: number;
  56754. transcodedPixels: ArrayBufferView;
  56755. }>;
  56756. }>;
  56757. }
  56758. /**
  56759. * Result of transcoding a basis file
  56760. */
  56761. class TranscodeResult {
  56762. /**
  56763. * Info about the .basis file
  56764. */
  56765. fileInfo: BasisFileInfo;
  56766. /**
  56767. * Format to use when loading the file
  56768. */
  56769. format: number;
  56770. }
  56771. /**
  56772. * Configuration options for the Basis transcoder
  56773. */
  56774. export class BasisTranscodeConfiguration {
  56775. /**
  56776. * Supported compression formats used to determine the supported output format of the transcoder
  56777. */
  56778. supportedCompressionFormats?: {
  56779. /**
  56780. * etc1 compression format
  56781. */
  56782. etc1?: boolean;
  56783. /**
  56784. * s3tc compression format
  56785. */
  56786. s3tc?: boolean;
  56787. /**
  56788. * pvrtc compression format
  56789. */
  56790. pvrtc?: boolean;
  56791. /**
  56792. * etc2 compression format
  56793. */
  56794. etc2?: boolean;
  56795. };
  56796. /**
  56797. * If mipmap levels should be loaded for transcoded images (Default: true)
  56798. */
  56799. loadMipmapLevels?: boolean;
  56800. /**
  56801. * Index of a single image to load (Default: all images)
  56802. */
  56803. loadSingleImage?: number;
  56804. }
  56805. /**
  56806. * Used to load .Basis files
  56807. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56808. */
  56809. export class BasisTools {
  56810. private static _IgnoreSupportedFormats;
  56811. /**
  56812. * URL to use when loading the basis transcoder
  56813. */
  56814. static JSModuleURL: string;
  56815. /**
  56816. * URL to use when loading the wasm module for the transcoder
  56817. */
  56818. static WasmModuleURL: string;
  56819. /**
  56820. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56821. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56822. * @returns internal format corresponding to the Basis format
  56823. */
  56824. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56825. private static _WorkerPromise;
  56826. private static _Worker;
  56827. private static _actionId;
  56828. private static _CreateWorkerAsync;
  56829. /**
  56830. * Transcodes a loaded image file to compressed pixel data
  56831. * @param data image data to transcode
  56832. * @param config configuration options for the transcoding
  56833. * @returns a promise resulting in the transcoded image
  56834. */
  56835. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56836. /**
  56837. * Loads a texture from the transcode result
  56838. * @param texture texture load to
  56839. * @param transcodeResult the result of transcoding the basis file to load from
  56840. */
  56841. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56842. }
  56843. }
  56844. declare module BABYLON {
  56845. /**
  56846. * Loader for .basis file format
  56847. */
  56848. export class _BasisTextureLoader implements IInternalTextureLoader {
  56849. /**
  56850. * Defines whether the loader supports cascade loading the different faces.
  56851. */
  56852. readonly supportCascades: boolean;
  56853. /**
  56854. * This returns if the loader support the current file information.
  56855. * @param extension defines the file extension of the file being loaded
  56856. * @returns true if the loader can load the specified file
  56857. */
  56858. canLoad(extension: string): boolean;
  56859. /**
  56860. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56861. * @param data contains the texture data
  56862. * @param texture defines the BabylonJS internal texture
  56863. * @param createPolynomials will be true if polynomials have been requested
  56864. * @param onLoad defines the callback to trigger once the texture is ready
  56865. * @param onError defines the callback to trigger in case of error
  56866. */
  56867. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56868. /**
  56869. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56870. * @param data contains the texture data
  56871. * @param texture defines the BabylonJS internal texture
  56872. * @param callback defines the method to call once ready to upload
  56873. */
  56874. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56875. }
  56876. }
  56877. declare module BABYLON {
  56878. /**
  56879. * 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.
  56880. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56881. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56882. */
  56883. export class CustomProceduralTexture extends ProceduralTexture {
  56884. private _animate;
  56885. private _time;
  56886. private _config;
  56887. private _texturePath;
  56888. /**
  56889. * Instantiates a new Custom Procedural Texture.
  56890. * 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.
  56891. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56892. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56893. * @param name Define the name of the texture
  56894. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56895. * @param size Define the size of the texture to create
  56896. * @param scene Define the scene the texture belongs to
  56897. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56898. * @param generateMipMaps Define if the texture should creates mip maps or not
  56899. */
  56900. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56901. private _loadJson;
  56902. /**
  56903. * Is the texture ready to be used ? (rendered at least once)
  56904. * @returns true if ready, otherwise, false.
  56905. */
  56906. isReady(): boolean;
  56907. /**
  56908. * Render the texture to its associated render target.
  56909. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56910. */
  56911. render(useCameraPostProcess?: boolean): void;
  56912. /**
  56913. * Update the list of dependant textures samplers in the shader.
  56914. */
  56915. updateTextures(): void;
  56916. /**
  56917. * Update the uniform values of the procedural texture in the shader.
  56918. */
  56919. updateShaderUniforms(): void;
  56920. /**
  56921. * Define if the texture animates or not.
  56922. */
  56923. get animate(): boolean;
  56924. set animate(value: boolean);
  56925. }
  56926. }
  56927. declare module BABYLON {
  56928. /** @hidden */
  56929. export var noisePixelShader: {
  56930. name: string;
  56931. shader: string;
  56932. };
  56933. }
  56934. declare module BABYLON {
  56935. /**
  56936. * Class used to generate noise procedural textures
  56937. */
  56938. export class NoiseProceduralTexture extends ProceduralTexture {
  56939. private _time;
  56940. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56941. brightness: number;
  56942. /** Defines the number of octaves to process */
  56943. octaves: number;
  56944. /** Defines the level of persistence (0.8 by default) */
  56945. persistence: number;
  56946. /** Gets or sets animation speed factor (default is 1) */
  56947. animationSpeedFactor: number;
  56948. /**
  56949. * Creates a new NoiseProceduralTexture
  56950. * @param name defines the name fo the texture
  56951. * @param size defines the size of the texture (default is 256)
  56952. * @param scene defines the hosting scene
  56953. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56954. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56955. */
  56956. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56957. private _updateShaderUniforms;
  56958. protected _getDefines(): string;
  56959. /** Generate the current state of the procedural texture */
  56960. render(useCameraPostProcess?: boolean): void;
  56961. /**
  56962. * Serializes this noise procedural texture
  56963. * @returns a serialized noise procedural texture object
  56964. */
  56965. serialize(): any;
  56966. /**
  56967. * Clone the texture.
  56968. * @returns the cloned texture
  56969. */
  56970. clone(): NoiseProceduralTexture;
  56971. /**
  56972. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56973. * @param parsedTexture defines parsed texture data
  56974. * @param scene defines the current scene
  56975. * @param rootUrl defines the root URL containing noise procedural texture information
  56976. * @returns a parsed NoiseProceduralTexture
  56977. */
  56978. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56979. }
  56980. }
  56981. declare module BABYLON {
  56982. /**
  56983. * Raw cube texture where the raw buffers are passed in
  56984. */
  56985. export class RawCubeTexture extends CubeTexture {
  56986. /**
  56987. * Creates a cube texture where the raw buffers are passed in.
  56988. * @param scene defines the scene the texture is attached to
  56989. * @param data defines the array of data to use to create each face
  56990. * @param size defines the size of the textures
  56991. * @param format defines the format of the data
  56992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56993. * @param generateMipMaps defines if the engine should generate the mip levels
  56994. * @param invertY defines if data must be stored with Y axis inverted
  56995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56996. * @param compression defines the compression used (null by default)
  56997. */
  56998. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56999. /**
  57000. * Updates the raw cube texture.
  57001. * @param data defines the data to store
  57002. * @param format defines the data format
  57003. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57004. * @param invertY defines if data must be stored with Y axis inverted
  57005. * @param compression defines the compression used (null by default)
  57006. * @param level defines which level of the texture to update
  57007. */
  57008. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57009. /**
  57010. * Updates a raw cube texture with RGBD encoded data.
  57011. * @param data defines the array of data [mipmap][face] to use to create each face
  57012. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57013. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57014. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57015. * @returns a promsie that resolves when the operation is complete
  57016. */
  57017. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57018. /**
  57019. * Clones the raw cube texture.
  57020. * @return a new cube texture
  57021. */
  57022. clone(): CubeTexture;
  57023. /** @hidden */
  57024. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57025. }
  57026. }
  57027. declare module BABYLON {
  57028. /**
  57029. * Class used to store 3D textures containing user data
  57030. */
  57031. export class RawTexture3D extends Texture {
  57032. /** Gets or sets the texture format to use */
  57033. format: number;
  57034. private _engine;
  57035. /**
  57036. * Create a new RawTexture3D
  57037. * @param data defines the data of the texture
  57038. * @param width defines the width of the texture
  57039. * @param height defines the height of the texture
  57040. * @param depth defines the depth of the texture
  57041. * @param format defines the texture format to use
  57042. * @param scene defines the hosting scene
  57043. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57044. * @param invertY defines if texture must be stored with Y axis inverted
  57045. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57046. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57047. */
  57048. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57049. /** Gets or sets the texture format to use */
  57050. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57051. /**
  57052. * Update the texture with new data
  57053. * @param data defines the data to store in the texture
  57054. */
  57055. update(data: ArrayBufferView): void;
  57056. }
  57057. }
  57058. declare module BABYLON {
  57059. /**
  57060. * Class used to store 2D array textures containing user data
  57061. */
  57062. export class RawTexture2DArray extends Texture {
  57063. /** Gets or sets the texture format to use */
  57064. format: number;
  57065. private _engine;
  57066. /**
  57067. * Create a new RawTexture2DArray
  57068. * @param data defines the data of the texture
  57069. * @param width defines the width of the texture
  57070. * @param height defines the height of the texture
  57071. * @param depth defines the number of layers of the texture
  57072. * @param format defines the texture format to use
  57073. * @param scene defines the hosting scene
  57074. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57075. * @param invertY defines if texture must be stored with Y axis inverted
  57076. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57077. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57078. */
  57079. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57080. /** Gets or sets the texture format to use */
  57081. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57082. /**
  57083. * Update the texture with new data
  57084. * @param data defines the data to store in the texture
  57085. */
  57086. update(data: ArrayBufferView): void;
  57087. }
  57088. }
  57089. declare module BABYLON {
  57090. /**
  57091. * Creates a refraction texture used by refraction channel of the standard material.
  57092. * It is like a mirror but to see through a material.
  57093. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57094. */
  57095. export class RefractionTexture extends RenderTargetTexture {
  57096. /**
  57097. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57098. * 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.
  57099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57100. */
  57101. refractionPlane: Plane;
  57102. /**
  57103. * Define how deep under the surface we should see.
  57104. */
  57105. depth: number;
  57106. /**
  57107. * Creates a refraction texture used by refraction channel of the standard material.
  57108. * It is like a mirror but to see through a material.
  57109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57110. * @param name Define the texture name
  57111. * @param size Define the size of the underlying texture
  57112. * @param scene Define the scene the refraction belongs to
  57113. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57114. */
  57115. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57116. /**
  57117. * Clone the refraction texture.
  57118. * @returns the cloned texture
  57119. */
  57120. clone(): RefractionTexture;
  57121. /**
  57122. * Serialize the texture to a JSON representation you could use in Parse later on
  57123. * @returns the serialized JSON representation
  57124. */
  57125. serialize(): any;
  57126. }
  57127. }
  57128. declare module BABYLON {
  57129. /**
  57130. * Defines the options related to the creation of an HtmlElementTexture
  57131. */
  57132. export interface IHtmlElementTextureOptions {
  57133. /**
  57134. * Defines wether mip maps should be created or not.
  57135. */
  57136. generateMipMaps?: boolean;
  57137. /**
  57138. * Defines the sampling mode of the texture.
  57139. */
  57140. samplingMode?: number;
  57141. /**
  57142. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57143. */
  57144. engine: Nullable<ThinEngine>;
  57145. /**
  57146. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57147. */
  57148. scene: Nullable<Scene>;
  57149. }
  57150. /**
  57151. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57152. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57153. * is automatically managed.
  57154. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57155. * in your application.
  57156. *
  57157. * As the update is not automatic, you need to call them manually.
  57158. */
  57159. export class HtmlElementTexture extends BaseTexture {
  57160. /**
  57161. * The texture URL.
  57162. */
  57163. element: HTMLVideoElement | HTMLCanvasElement;
  57164. private static readonly DefaultOptions;
  57165. private _textureMatrix;
  57166. private _engine;
  57167. private _isVideo;
  57168. private _generateMipMaps;
  57169. private _samplingMode;
  57170. /**
  57171. * Instantiates a HtmlElementTexture from the following parameters.
  57172. *
  57173. * @param name Defines the name of the texture
  57174. * @param element Defines the video or canvas the texture is filled with
  57175. * @param options Defines the other none mandatory texture creation options
  57176. */
  57177. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57178. private _createInternalTexture;
  57179. /**
  57180. * Returns the texture matrix used in most of the material.
  57181. */
  57182. getTextureMatrix(): Matrix;
  57183. /**
  57184. * Updates the content of the texture.
  57185. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57186. */
  57187. update(invertY?: Nullable<boolean>): void;
  57188. }
  57189. }
  57190. declare module BABYLON {
  57191. /**
  57192. * Defines the basic options interface of a TexturePacker Frame
  57193. */
  57194. export interface ITexturePackerFrame {
  57195. /**
  57196. * The frame ID
  57197. */
  57198. id: number;
  57199. /**
  57200. * The frames Scale
  57201. */
  57202. scale: Vector2;
  57203. /**
  57204. * The Frames offset
  57205. */
  57206. offset: Vector2;
  57207. }
  57208. /**
  57209. * This is a support class for frame Data on texture packer sets.
  57210. */
  57211. export class TexturePackerFrame implements ITexturePackerFrame {
  57212. /**
  57213. * The frame ID
  57214. */
  57215. id: number;
  57216. /**
  57217. * The frames Scale
  57218. */
  57219. scale: Vector2;
  57220. /**
  57221. * The Frames offset
  57222. */
  57223. offset: Vector2;
  57224. /**
  57225. * Initializes a texture package frame.
  57226. * @param id The numerical frame identifier
  57227. * @param scale Scalar Vector2 for UV frame
  57228. * @param offset Vector2 for the frame position in UV units.
  57229. * @returns TexturePackerFrame
  57230. */
  57231. constructor(id: number, scale: Vector2, offset: Vector2);
  57232. }
  57233. }
  57234. declare module BABYLON {
  57235. /**
  57236. * Defines the basic options interface of a TexturePacker
  57237. */
  57238. export interface ITexturePackerOptions {
  57239. /**
  57240. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57241. */
  57242. map?: string[];
  57243. /**
  57244. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57245. */
  57246. uvsIn?: string;
  57247. /**
  57248. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57249. */
  57250. uvsOut?: string;
  57251. /**
  57252. * number representing the layout style. Defaults to LAYOUT_STRIP
  57253. */
  57254. layout?: number;
  57255. /**
  57256. * number of columns if using custom column count layout(2). This defaults to 4.
  57257. */
  57258. colnum?: number;
  57259. /**
  57260. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57261. */
  57262. updateInputMeshes?: boolean;
  57263. /**
  57264. * boolean flag to dispose all the source textures. Defaults to true.
  57265. */
  57266. disposeSources?: boolean;
  57267. /**
  57268. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57269. */
  57270. fillBlanks?: boolean;
  57271. /**
  57272. * string value representing the context fill style color. Defaults to 'black'.
  57273. */
  57274. customFillColor?: string;
  57275. /**
  57276. * Width and Height Value of each Frame in the TexturePacker Sets
  57277. */
  57278. frameSize?: number;
  57279. /**
  57280. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57281. */
  57282. paddingRatio?: number;
  57283. /**
  57284. * Number that declares the fill method for the padding gutter.
  57285. */
  57286. paddingMode?: number;
  57287. /**
  57288. * If in SUBUV_COLOR padding mode what color to use.
  57289. */
  57290. paddingColor?: Color3 | Color4;
  57291. }
  57292. /**
  57293. * Defines the basic interface of a TexturePacker JSON File
  57294. */
  57295. export interface ITexturePackerJSON {
  57296. /**
  57297. * The frame ID
  57298. */
  57299. name: string;
  57300. /**
  57301. * The base64 channel data
  57302. */
  57303. sets: any;
  57304. /**
  57305. * The options of the Packer
  57306. */
  57307. options: ITexturePackerOptions;
  57308. /**
  57309. * The frame data of the Packer
  57310. */
  57311. frames: Array<number>;
  57312. }
  57313. /**
  57314. * This is a support class that generates a series of packed texture sets.
  57315. * @see https://doc.babylonjs.com/babylon101/materials
  57316. */
  57317. export class TexturePacker {
  57318. /** Packer Layout Constant 0 */
  57319. static readonly LAYOUT_STRIP: number;
  57320. /** Packer Layout Constant 1 */
  57321. static readonly LAYOUT_POWER2: number;
  57322. /** Packer Layout Constant 2 */
  57323. static readonly LAYOUT_COLNUM: number;
  57324. /** Packer Layout Constant 0 */
  57325. static readonly SUBUV_WRAP: number;
  57326. /** Packer Layout Constant 1 */
  57327. static readonly SUBUV_EXTEND: number;
  57328. /** Packer Layout Constant 2 */
  57329. static readonly SUBUV_COLOR: number;
  57330. /** The Name of the Texture Package */
  57331. name: string;
  57332. /** The scene scope of the TexturePacker */
  57333. scene: Scene;
  57334. /** The Meshes to target */
  57335. meshes: AbstractMesh[];
  57336. /** Arguments passed with the Constructor */
  57337. options: ITexturePackerOptions;
  57338. /** The promise that is started upon initialization */
  57339. promise: Nullable<Promise<TexturePacker | string>>;
  57340. /** The Container object for the channel sets that are generated */
  57341. sets: object;
  57342. /** The Container array for the frames that are generated */
  57343. frames: TexturePackerFrame[];
  57344. /** The expected number of textures the system is parsing. */
  57345. private _expecting;
  57346. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57347. private _paddingValue;
  57348. /**
  57349. * Initializes a texture package series from an array of meshes or a single mesh.
  57350. * @param name The name of the package
  57351. * @param meshes The target meshes to compose the package from
  57352. * @param options The arguments that texture packer should follow while building.
  57353. * @param scene The scene which the textures are scoped to.
  57354. * @returns TexturePacker
  57355. */
  57356. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57357. /**
  57358. * Starts the package process
  57359. * @param resolve The promises resolution function
  57360. * @returns TexturePacker
  57361. */
  57362. private _createFrames;
  57363. /**
  57364. * Calculates the Size of the Channel Sets
  57365. * @returns Vector2
  57366. */
  57367. private _calculateSize;
  57368. /**
  57369. * Calculates the UV data for the frames.
  57370. * @param baseSize the base frameSize
  57371. * @param padding the base frame padding
  57372. * @param dtSize size of the Dynamic Texture for that channel
  57373. * @param dtUnits is 1/dtSize
  57374. * @param update flag to update the input meshes
  57375. */
  57376. private _calculateMeshUVFrames;
  57377. /**
  57378. * Calculates the frames Offset.
  57379. * @param index of the frame
  57380. * @returns Vector2
  57381. */
  57382. private _getFrameOffset;
  57383. /**
  57384. * Updates a Mesh to the frame data
  57385. * @param mesh that is the target
  57386. * @param frameID or the frame index
  57387. */
  57388. private _updateMeshUV;
  57389. /**
  57390. * Updates a Meshes materials to use the texture packer channels
  57391. * @param m is the mesh to target
  57392. * @param force all channels on the packer to be set.
  57393. */
  57394. private _updateTextureReferences;
  57395. /**
  57396. * Public method to set a Mesh to a frame
  57397. * @param m that is the target
  57398. * @param frameID or the frame index
  57399. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57400. */
  57401. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57402. /**
  57403. * Starts the async promise to compile the texture packer.
  57404. * @returns Promise<void>
  57405. */
  57406. processAsync(): Promise<void>;
  57407. /**
  57408. * Disposes all textures associated with this packer
  57409. */
  57410. dispose(): void;
  57411. /**
  57412. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57413. * @param imageType is the image type to use.
  57414. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57415. */
  57416. download(imageType?: string, quality?: number): void;
  57417. /**
  57418. * Public method to load a texturePacker JSON file.
  57419. * @param data of the JSON file in string format.
  57420. */
  57421. updateFromJSON(data: string): void;
  57422. }
  57423. }
  57424. declare module BABYLON {
  57425. /**
  57426. * Enum used to define the target of a block
  57427. */
  57428. export enum NodeMaterialBlockTargets {
  57429. /** Vertex shader */
  57430. Vertex = 1,
  57431. /** Fragment shader */
  57432. Fragment = 2,
  57433. /** Neutral */
  57434. Neutral = 4,
  57435. /** Vertex and Fragment */
  57436. VertexAndFragment = 3
  57437. }
  57438. }
  57439. declare module BABYLON {
  57440. /**
  57441. * Defines the kind of connection point for node based material
  57442. */
  57443. export enum NodeMaterialBlockConnectionPointTypes {
  57444. /** Float */
  57445. Float = 1,
  57446. /** Int */
  57447. Int = 2,
  57448. /** Vector2 */
  57449. Vector2 = 4,
  57450. /** Vector3 */
  57451. Vector3 = 8,
  57452. /** Vector4 */
  57453. Vector4 = 16,
  57454. /** Color3 */
  57455. Color3 = 32,
  57456. /** Color4 */
  57457. Color4 = 64,
  57458. /** Matrix */
  57459. Matrix = 128,
  57460. /** Detect type based on connection */
  57461. AutoDetect = 1024,
  57462. /** Output type that will be defined by input type */
  57463. BasedOnInput = 2048
  57464. }
  57465. }
  57466. declare module BABYLON {
  57467. /**
  57468. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57469. */
  57470. export enum NodeMaterialBlockConnectionPointMode {
  57471. /** Value is an uniform */
  57472. Uniform = 0,
  57473. /** Value is a mesh attribute */
  57474. Attribute = 1,
  57475. /** Value is a varying between vertex and fragment shaders */
  57476. Varying = 2,
  57477. /** Mode is undefined */
  57478. Undefined = 3
  57479. }
  57480. }
  57481. declare module BABYLON {
  57482. /**
  57483. * Enum used to define system values e.g. values automatically provided by the system
  57484. */
  57485. export enum NodeMaterialSystemValues {
  57486. /** World */
  57487. World = 1,
  57488. /** View */
  57489. View = 2,
  57490. /** Projection */
  57491. Projection = 3,
  57492. /** ViewProjection */
  57493. ViewProjection = 4,
  57494. /** WorldView */
  57495. WorldView = 5,
  57496. /** WorldViewProjection */
  57497. WorldViewProjection = 6,
  57498. /** CameraPosition */
  57499. CameraPosition = 7,
  57500. /** Fog Color */
  57501. FogColor = 8,
  57502. /** Delta time */
  57503. DeltaTime = 9
  57504. }
  57505. }
  57506. declare module BABYLON {
  57507. /**
  57508. * Root class for all node material optimizers
  57509. */
  57510. export class NodeMaterialOptimizer {
  57511. /**
  57512. * Function used to optimize a NodeMaterial graph
  57513. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57514. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57515. */
  57516. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57522. */
  57523. export class TransformBlock extends NodeMaterialBlock {
  57524. /**
  57525. * Defines the value to use to complement W value to transform it to a Vector4
  57526. */
  57527. complementW: number;
  57528. /**
  57529. * Defines the value to use to complement z value to transform it to a Vector4
  57530. */
  57531. complementZ: number;
  57532. /**
  57533. * Creates a new TransformBlock
  57534. * @param name defines the block name
  57535. */
  57536. constructor(name: string);
  57537. /**
  57538. * Gets the current class name
  57539. * @returns the class name
  57540. */
  57541. getClassName(): string;
  57542. /**
  57543. * Gets the vector input
  57544. */
  57545. get vector(): NodeMaterialConnectionPoint;
  57546. /**
  57547. * Gets the output component
  57548. */
  57549. get output(): NodeMaterialConnectionPoint;
  57550. /**
  57551. * Gets the xyz output component
  57552. */
  57553. get xyz(): NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the matrix transform input
  57556. */
  57557. get transform(): NodeMaterialConnectionPoint;
  57558. protected _buildBlock(state: NodeMaterialBuildState): this;
  57559. serialize(): any;
  57560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57561. protected _dumpPropertiesCode(): string;
  57562. }
  57563. }
  57564. declare module BABYLON {
  57565. /**
  57566. * Block used to output the vertex position
  57567. */
  57568. export class VertexOutputBlock extends NodeMaterialBlock {
  57569. /**
  57570. * Creates a new VertexOutputBlock
  57571. * @param name defines the block name
  57572. */
  57573. constructor(name: string);
  57574. /**
  57575. * Gets the current class name
  57576. * @returns the class name
  57577. */
  57578. getClassName(): string;
  57579. /**
  57580. * Gets the vector input component
  57581. */
  57582. get vector(): NodeMaterialConnectionPoint;
  57583. protected _buildBlock(state: NodeMaterialBuildState): this;
  57584. }
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * Block used to output the final color
  57589. */
  57590. export class FragmentOutputBlock extends NodeMaterialBlock {
  57591. /**
  57592. * Create a new FragmentOutputBlock
  57593. * @param name defines the block name
  57594. */
  57595. constructor(name: string);
  57596. /**
  57597. * Gets the current class name
  57598. * @returns the class name
  57599. */
  57600. getClassName(): string;
  57601. /**
  57602. * Gets the rgba input component
  57603. */
  57604. get rgba(): NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the rgb input component
  57607. */
  57608. get rgb(): NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the a input component
  57611. */
  57612. get a(): NodeMaterialConnectionPoint;
  57613. protected _buildBlock(state: NodeMaterialBuildState): this;
  57614. }
  57615. }
  57616. declare module BABYLON {
  57617. /**
  57618. * Block used to read a reflection texture from a sampler
  57619. */
  57620. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57621. private _define3DName;
  57622. private _defineCubicName;
  57623. private _defineExplicitName;
  57624. private _defineProjectionName;
  57625. private _defineLocalCubicName;
  57626. private _defineSphericalName;
  57627. private _definePlanarName;
  57628. private _defineEquirectangularName;
  57629. private _defineMirroredEquirectangularFixedName;
  57630. private _defineEquirectangularFixedName;
  57631. private _defineSkyboxName;
  57632. private _cubeSamplerName;
  57633. private _2DSamplerName;
  57634. private _positionUVWName;
  57635. private _directionWName;
  57636. private _reflectionCoordsName;
  57637. private _reflection2DCoordsName;
  57638. private _reflectionColorName;
  57639. private _reflectionMatrixName;
  57640. /**
  57641. * Gets or sets the texture associated with the node
  57642. */
  57643. texture: Nullable<BaseTexture>;
  57644. /**
  57645. * Create a new TextureBlock
  57646. * @param name defines the block name
  57647. */
  57648. constructor(name: string);
  57649. /**
  57650. * Gets the current class name
  57651. * @returns the class name
  57652. */
  57653. getClassName(): string;
  57654. /**
  57655. * Gets the world position input component
  57656. */
  57657. get position(): NodeMaterialConnectionPoint;
  57658. /**
  57659. * Gets the world position input component
  57660. */
  57661. get worldPosition(): NodeMaterialConnectionPoint;
  57662. /**
  57663. * Gets the world normal input component
  57664. */
  57665. get worldNormal(): NodeMaterialConnectionPoint;
  57666. /**
  57667. * Gets the world input component
  57668. */
  57669. get world(): NodeMaterialConnectionPoint;
  57670. /**
  57671. * Gets the camera (or eye) position component
  57672. */
  57673. get cameraPosition(): NodeMaterialConnectionPoint;
  57674. /**
  57675. * Gets the view input component
  57676. */
  57677. get view(): NodeMaterialConnectionPoint;
  57678. /**
  57679. * Gets the rgb output component
  57680. */
  57681. get rgb(): NodeMaterialConnectionPoint;
  57682. /**
  57683. * Gets the r output component
  57684. */
  57685. get r(): NodeMaterialConnectionPoint;
  57686. /**
  57687. * Gets the g output component
  57688. */
  57689. get g(): NodeMaterialConnectionPoint;
  57690. /**
  57691. * Gets the b output component
  57692. */
  57693. get b(): NodeMaterialConnectionPoint;
  57694. autoConfigure(material: NodeMaterial): void;
  57695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57696. isReady(): boolean;
  57697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57698. private _injectVertexCode;
  57699. private _writeOutput;
  57700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57701. protected _dumpPropertiesCode(): string;
  57702. serialize(): any;
  57703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Interface used to configure the node material editor
  57709. */
  57710. export interface INodeMaterialEditorOptions {
  57711. /** Define the URl to load node editor script */
  57712. editorURL?: string;
  57713. }
  57714. /** @hidden */
  57715. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57716. NORMAL: boolean;
  57717. TANGENT: boolean;
  57718. UV1: boolean;
  57719. /** BONES */
  57720. NUM_BONE_INFLUENCERS: number;
  57721. BonesPerMesh: number;
  57722. BONETEXTURE: boolean;
  57723. /** MORPH TARGETS */
  57724. MORPHTARGETS: boolean;
  57725. MORPHTARGETS_NORMAL: boolean;
  57726. MORPHTARGETS_TANGENT: boolean;
  57727. MORPHTARGETS_UV: boolean;
  57728. NUM_MORPH_INFLUENCERS: number;
  57729. /** IMAGE PROCESSING */
  57730. IMAGEPROCESSING: boolean;
  57731. VIGNETTE: boolean;
  57732. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57733. VIGNETTEBLENDMODEOPAQUE: boolean;
  57734. TONEMAPPING: boolean;
  57735. TONEMAPPING_ACES: boolean;
  57736. CONTRAST: boolean;
  57737. EXPOSURE: boolean;
  57738. COLORCURVES: boolean;
  57739. COLORGRADING: boolean;
  57740. COLORGRADING3D: boolean;
  57741. SAMPLER3DGREENDEPTH: boolean;
  57742. SAMPLER3DBGRMAP: boolean;
  57743. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57744. /** MISC. */
  57745. BUMPDIRECTUV: number;
  57746. constructor();
  57747. setValue(name: string, value: boolean): void;
  57748. }
  57749. /**
  57750. * Class used to configure NodeMaterial
  57751. */
  57752. export interface INodeMaterialOptions {
  57753. /**
  57754. * Defines if blocks should emit comments
  57755. */
  57756. emitComments: boolean;
  57757. }
  57758. /**
  57759. * Class used to create a node based material built by assembling shader blocks
  57760. */
  57761. export class NodeMaterial extends PushMaterial {
  57762. private static _BuildIdGenerator;
  57763. private _options;
  57764. private _vertexCompilationState;
  57765. private _fragmentCompilationState;
  57766. private _sharedData;
  57767. private _buildId;
  57768. private _buildWasSuccessful;
  57769. private _cachedWorldViewMatrix;
  57770. private _cachedWorldViewProjectionMatrix;
  57771. private _optimizers;
  57772. private _animationFrame;
  57773. /** Define the Url to load node editor script */
  57774. static EditorURL: string;
  57775. /** Define the Url to load snippets */
  57776. static SnippetUrl: string;
  57777. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57778. static IgnoreTexturesAtLoadTime: boolean;
  57779. private BJSNODEMATERIALEDITOR;
  57780. /** Get the inspector from bundle or global */
  57781. private _getGlobalNodeMaterialEditor;
  57782. /**
  57783. * Snippet ID if the material was created from the snippet server
  57784. */
  57785. snippetId: string;
  57786. /**
  57787. * Gets or sets data used by visual editor
  57788. * @see https://nme.babylonjs.com
  57789. */
  57790. editorData: any;
  57791. /**
  57792. * 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)
  57793. */
  57794. ignoreAlpha: boolean;
  57795. /**
  57796. * Defines the maximum number of lights that can be used in the material
  57797. */
  57798. maxSimultaneousLights: number;
  57799. /**
  57800. * Observable raised when the material is built
  57801. */
  57802. onBuildObservable: Observable<NodeMaterial>;
  57803. /**
  57804. * Gets or sets the root nodes of the material vertex shader
  57805. */
  57806. _vertexOutputNodes: NodeMaterialBlock[];
  57807. /**
  57808. * Gets or sets the root nodes of the material fragment (pixel) shader
  57809. */
  57810. _fragmentOutputNodes: NodeMaterialBlock[];
  57811. /** Gets or sets options to control the node material overall behavior */
  57812. get options(): INodeMaterialOptions;
  57813. set options(options: INodeMaterialOptions);
  57814. /**
  57815. * Default configuration related to image processing available in the standard Material.
  57816. */
  57817. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57818. /**
  57819. * Gets the image processing configuration used either in this material.
  57820. */
  57821. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57822. /**
  57823. * Sets the Default image processing configuration used either in the this material.
  57824. *
  57825. * If sets to null, the scene one is in use.
  57826. */
  57827. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57828. /**
  57829. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57830. */
  57831. attachedBlocks: NodeMaterialBlock[];
  57832. /**
  57833. * Create a new node based material
  57834. * @param name defines the material name
  57835. * @param scene defines the hosting scene
  57836. * @param options defines creation option
  57837. */
  57838. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57839. /**
  57840. * Gets the current class name of the material e.g. "NodeMaterial"
  57841. * @returns the class name
  57842. */
  57843. getClassName(): string;
  57844. /**
  57845. * Keep track of the image processing observer to allow dispose and replace.
  57846. */
  57847. private _imageProcessingObserver;
  57848. /**
  57849. * Attaches a new image processing configuration to the Standard Material.
  57850. * @param configuration
  57851. */
  57852. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57853. /**
  57854. * Get a block by its name
  57855. * @param name defines the name of the block to retrieve
  57856. * @returns the required block or null if not found
  57857. */
  57858. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57859. /**
  57860. * Get a block by its name
  57861. * @param predicate defines the predicate used to find the good candidate
  57862. * @returns the required block or null if not found
  57863. */
  57864. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57865. /**
  57866. * Get an input block by its name
  57867. * @param predicate defines the predicate used to find the good candidate
  57868. * @returns the required input block or null if not found
  57869. */
  57870. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57871. /**
  57872. * Gets the list of input blocks attached to this material
  57873. * @returns an array of InputBlocks
  57874. */
  57875. getInputBlocks(): InputBlock[];
  57876. /**
  57877. * Adds a new optimizer to the list of optimizers
  57878. * @param optimizer defines the optimizers to add
  57879. * @returns the current material
  57880. */
  57881. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57882. /**
  57883. * Remove an optimizer from the list of optimizers
  57884. * @param optimizer defines the optimizers to remove
  57885. * @returns the current material
  57886. */
  57887. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57888. /**
  57889. * Add a new block to the list of output nodes
  57890. * @param node defines the node to add
  57891. * @returns the current material
  57892. */
  57893. addOutputNode(node: NodeMaterialBlock): this;
  57894. /**
  57895. * Remove a block from the list of root nodes
  57896. * @param node defines the node to remove
  57897. * @returns the current material
  57898. */
  57899. removeOutputNode(node: NodeMaterialBlock): this;
  57900. private _addVertexOutputNode;
  57901. private _removeVertexOutputNode;
  57902. private _addFragmentOutputNode;
  57903. private _removeFragmentOutputNode;
  57904. /**
  57905. * Specifies if the material will require alpha blending
  57906. * @returns a boolean specifying if alpha blending is needed
  57907. */
  57908. needAlphaBlending(): boolean;
  57909. /**
  57910. * Specifies if this material should be rendered in alpha test mode
  57911. * @returns a boolean specifying if an alpha test is needed.
  57912. */
  57913. needAlphaTesting(): boolean;
  57914. private _initializeBlock;
  57915. private _resetDualBlocks;
  57916. /**
  57917. * Remove a block from the current node material
  57918. * @param block defines the block to remove
  57919. */
  57920. removeBlock(block: NodeMaterialBlock): void;
  57921. /**
  57922. * Build the material and generates the inner effect
  57923. * @param verbose defines if the build should log activity
  57924. */
  57925. build(verbose?: boolean): void;
  57926. /**
  57927. * Runs an otpimization phase to try to improve the shader code
  57928. */
  57929. optimize(): void;
  57930. private _prepareDefinesForAttributes;
  57931. /**
  57932. * Get if the submesh is ready to be used and all its information available.
  57933. * Child classes can use it to update shaders
  57934. * @param mesh defines the mesh to check
  57935. * @param subMesh defines which submesh to check
  57936. * @param useInstances specifies that instances should be used
  57937. * @returns a boolean indicating that the submesh is ready or not
  57938. */
  57939. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57940. /**
  57941. * Get a string representing the shaders built by the current node graph
  57942. */
  57943. get compiledShaders(): string;
  57944. /**
  57945. * Binds the world matrix to the material
  57946. * @param world defines the world transformation matrix
  57947. */
  57948. bindOnlyWorldMatrix(world: Matrix): void;
  57949. /**
  57950. * Binds the submesh to this material by preparing the effect and shader to draw
  57951. * @param world defines the world transformation matrix
  57952. * @param mesh defines the mesh containing the submesh
  57953. * @param subMesh defines the submesh to bind the material to
  57954. */
  57955. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57956. /**
  57957. * Gets the active textures from the material
  57958. * @returns an array of textures
  57959. */
  57960. getActiveTextures(): BaseTexture[];
  57961. /**
  57962. * Gets the list of texture blocks
  57963. * @returns an array of texture blocks
  57964. */
  57965. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57966. /**
  57967. * Specifies if the material uses a texture
  57968. * @param texture defines the texture to check against the material
  57969. * @returns a boolean specifying if the material uses the texture
  57970. */
  57971. hasTexture(texture: BaseTexture): boolean;
  57972. /**
  57973. * Disposes the material
  57974. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57975. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57976. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57977. */
  57978. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57979. /** Creates the node editor window. */
  57980. private _createNodeEditor;
  57981. /**
  57982. * Launch the node material editor
  57983. * @param config Define the configuration of the editor
  57984. * @return a promise fulfilled when the node editor is visible
  57985. */
  57986. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57987. /**
  57988. * Clear the current material
  57989. */
  57990. clear(): void;
  57991. /**
  57992. * Clear the current material and set it to a default state
  57993. */
  57994. setToDefault(): void;
  57995. /**
  57996. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57997. * @param url defines the url to load from
  57998. * @returns a promise that will fullfil when the material is fully loaded
  57999. */
  58000. loadAsync(url: string): Promise<void>;
  58001. private _gatherBlocks;
  58002. /**
  58003. * Generate a string containing the code declaration required to create an equivalent of this material
  58004. * @returns a string
  58005. */
  58006. generateCode(): string;
  58007. /**
  58008. * Serializes this material in a JSON representation
  58009. * @returns the serialized material object
  58010. */
  58011. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58012. private _restoreConnections;
  58013. /**
  58014. * Clear the current graph and load a new one from a serialization object
  58015. * @param source defines the JSON representation of the material
  58016. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58017. */
  58018. loadFromSerialization(source: any, rootUrl?: string): void;
  58019. /**
  58020. * Makes a duplicate of the current material.
  58021. * @param name - name to use for the new material.
  58022. */
  58023. clone(name: string): NodeMaterial;
  58024. /**
  58025. * Creates a node material from parsed material data
  58026. * @param source defines the JSON representation of the material
  58027. * @param scene defines the hosting scene
  58028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58029. * @returns a new node material
  58030. */
  58031. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58032. /**
  58033. * Creates a node material from a snippet saved in a remote file
  58034. * @param name defines the name of the material to create
  58035. * @param url defines the url to load from
  58036. * @param scene defines the hosting scene
  58037. * @returns a promise that will resolve to the new node material
  58038. */
  58039. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58040. /**
  58041. * Creates a node material from a snippet saved by the node material editor
  58042. * @param snippetId defines the snippet to load
  58043. * @param scene defines the hosting scene
  58044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58045. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58046. * @returns a promise that will resolve to the new node material
  58047. */
  58048. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58049. /**
  58050. * Creates a new node material set to default basic configuration
  58051. * @param name defines the name of the material
  58052. * @param scene defines the hosting scene
  58053. * @returns a new NodeMaterial
  58054. */
  58055. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58056. }
  58057. }
  58058. declare module BABYLON {
  58059. /**
  58060. * Block used to read a texture from a sampler
  58061. */
  58062. export class TextureBlock extends NodeMaterialBlock {
  58063. private _defineName;
  58064. private _linearDefineName;
  58065. private _tempTextureRead;
  58066. private _samplerName;
  58067. private _transformedUVName;
  58068. private _textureTransformName;
  58069. private _textureInfoName;
  58070. private _mainUVName;
  58071. private _mainUVDefineName;
  58072. /**
  58073. * Gets or sets the texture associated with the node
  58074. */
  58075. texture: Nullable<Texture>;
  58076. /**
  58077. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58078. */
  58079. convertToGammaSpace: boolean;
  58080. /**
  58081. * Create a new TextureBlock
  58082. * @param name defines the block name
  58083. */
  58084. constructor(name: string);
  58085. /**
  58086. * Gets the current class name
  58087. * @returns the class name
  58088. */
  58089. getClassName(): string;
  58090. /**
  58091. * Gets the uv input component
  58092. */
  58093. get uv(): NodeMaterialConnectionPoint;
  58094. /**
  58095. * Gets the rgba output component
  58096. */
  58097. get rgba(): NodeMaterialConnectionPoint;
  58098. /**
  58099. * Gets the rgb output component
  58100. */
  58101. get rgb(): NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the r output component
  58104. */
  58105. get r(): NodeMaterialConnectionPoint;
  58106. /**
  58107. * Gets the g output component
  58108. */
  58109. get g(): NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the b output component
  58112. */
  58113. get b(): NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the a output component
  58116. */
  58117. get a(): NodeMaterialConnectionPoint;
  58118. get target(): NodeMaterialBlockTargets;
  58119. autoConfigure(material: NodeMaterial): void;
  58120. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58122. isReady(): boolean;
  58123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58124. private get _isMixed();
  58125. private _injectVertexCode;
  58126. private _writeTextureRead;
  58127. private _writeOutput;
  58128. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58129. protected _dumpPropertiesCode(): string;
  58130. serialize(): any;
  58131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58132. }
  58133. }
  58134. declare module BABYLON {
  58135. /**
  58136. * Class used to store shared data between 2 NodeMaterialBuildState
  58137. */
  58138. export class NodeMaterialBuildStateSharedData {
  58139. /**
  58140. * Gets the list of emitted varyings
  58141. */
  58142. temps: string[];
  58143. /**
  58144. * Gets the list of emitted varyings
  58145. */
  58146. varyings: string[];
  58147. /**
  58148. * Gets the varying declaration string
  58149. */
  58150. varyingDeclaration: string;
  58151. /**
  58152. * Input blocks
  58153. */
  58154. inputBlocks: InputBlock[];
  58155. /**
  58156. * Input blocks
  58157. */
  58158. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58159. /**
  58160. * Bindable blocks (Blocks that need to set data to the effect)
  58161. */
  58162. bindableBlocks: NodeMaterialBlock[];
  58163. /**
  58164. * List of blocks that can provide a compilation fallback
  58165. */
  58166. blocksWithFallbacks: NodeMaterialBlock[];
  58167. /**
  58168. * List of blocks that can provide a define update
  58169. */
  58170. blocksWithDefines: NodeMaterialBlock[];
  58171. /**
  58172. * List of blocks that can provide a repeatable content
  58173. */
  58174. repeatableContentBlocks: NodeMaterialBlock[];
  58175. /**
  58176. * List of blocks that can provide a dynamic list of uniforms
  58177. */
  58178. dynamicUniformBlocks: NodeMaterialBlock[];
  58179. /**
  58180. * List of blocks that can block the isReady function for the material
  58181. */
  58182. blockingBlocks: NodeMaterialBlock[];
  58183. /**
  58184. * Gets the list of animated inputs
  58185. */
  58186. animatedInputs: InputBlock[];
  58187. /**
  58188. * Build Id used to avoid multiple recompilations
  58189. */
  58190. buildId: number;
  58191. /** List of emitted variables */
  58192. variableNames: {
  58193. [key: string]: number;
  58194. };
  58195. /** List of emitted defines */
  58196. defineNames: {
  58197. [key: string]: number;
  58198. };
  58199. /** Should emit comments? */
  58200. emitComments: boolean;
  58201. /** Emit build activity */
  58202. verbose: boolean;
  58203. /** Gets or sets the hosting scene */
  58204. scene: Scene;
  58205. /**
  58206. * Gets the compilation hints emitted at compilation time
  58207. */
  58208. hints: {
  58209. needWorldViewMatrix: boolean;
  58210. needWorldViewProjectionMatrix: boolean;
  58211. needAlphaBlending: boolean;
  58212. needAlphaTesting: boolean;
  58213. };
  58214. /**
  58215. * List of compilation checks
  58216. */
  58217. checks: {
  58218. emitVertex: boolean;
  58219. emitFragment: boolean;
  58220. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58221. };
  58222. /** Creates a new shared data */
  58223. constructor();
  58224. /**
  58225. * Emits console errors and exceptions if there is a failing check
  58226. */
  58227. emitErrors(): void;
  58228. }
  58229. }
  58230. declare module BABYLON {
  58231. /**
  58232. * Class used to store node based material build state
  58233. */
  58234. export class NodeMaterialBuildState {
  58235. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58236. supportUniformBuffers: boolean;
  58237. /**
  58238. * Gets the list of emitted attributes
  58239. */
  58240. attributes: string[];
  58241. /**
  58242. * Gets the list of emitted uniforms
  58243. */
  58244. uniforms: string[];
  58245. /**
  58246. * Gets the list of emitted constants
  58247. */
  58248. constants: string[];
  58249. /**
  58250. * Gets the list of emitted samplers
  58251. */
  58252. samplers: string[];
  58253. /**
  58254. * Gets the list of emitted functions
  58255. */
  58256. functions: {
  58257. [key: string]: string;
  58258. };
  58259. /**
  58260. * Gets the list of emitted extensions
  58261. */
  58262. extensions: {
  58263. [key: string]: string;
  58264. };
  58265. /**
  58266. * Gets the target of the compilation state
  58267. */
  58268. target: NodeMaterialBlockTargets;
  58269. /**
  58270. * Gets the list of emitted counters
  58271. */
  58272. counters: {
  58273. [key: string]: number;
  58274. };
  58275. /**
  58276. * Shared data between multiple NodeMaterialBuildState instances
  58277. */
  58278. sharedData: NodeMaterialBuildStateSharedData;
  58279. /** @hidden */
  58280. _vertexState: NodeMaterialBuildState;
  58281. /** @hidden */
  58282. _attributeDeclaration: string;
  58283. /** @hidden */
  58284. _uniformDeclaration: string;
  58285. /** @hidden */
  58286. _constantDeclaration: string;
  58287. /** @hidden */
  58288. _samplerDeclaration: string;
  58289. /** @hidden */
  58290. _varyingTransfer: string;
  58291. private _repeatableContentAnchorIndex;
  58292. /** @hidden */
  58293. _builtCompilationString: string;
  58294. /**
  58295. * Gets the emitted compilation strings
  58296. */
  58297. compilationString: string;
  58298. /**
  58299. * Finalize the compilation strings
  58300. * @param state defines the current compilation state
  58301. */
  58302. finalize(state: NodeMaterialBuildState): void;
  58303. /** @hidden */
  58304. get _repeatableContentAnchor(): string;
  58305. /** @hidden */
  58306. _getFreeVariableName(prefix: string): string;
  58307. /** @hidden */
  58308. _getFreeDefineName(prefix: string): string;
  58309. /** @hidden */
  58310. _excludeVariableName(name: string): void;
  58311. /** @hidden */
  58312. _emit2DSampler(name: string): void;
  58313. /** @hidden */
  58314. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58315. /** @hidden */
  58316. _emitExtension(name: string, extension: string): void;
  58317. /** @hidden */
  58318. _emitFunction(name: string, code: string, comments: string): void;
  58319. /** @hidden */
  58320. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58321. replaceStrings?: {
  58322. search: RegExp;
  58323. replace: string;
  58324. }[];
  58325. repeatKey?: string;
  58326. }): string;
  58327. /** @hidden */
  58328. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58329. repeatKey?: string;
  58330. removeAttributes?: boolean;
  58331. removeUniforms?: boolean;
  58332. removeVaryings?: boolean;
  58333. removeIfDef?: boolean;
  58334. replaceStrings?: {
  58335. search: RegExp;
  58336. replace: string;
  58337. }[];
  58338. }, storeKey?: string): void;
  58339. /** @hidden */
  58340. _registerTempVariable(name: string): boolean;
  58341. /** @hidden */
  58342. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58343. /** @hidden */
  58344. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58345. /** @hidden */
  58346. _emitFloat(value: number): string;
  58347. }
  58348. }
  58349. declare module BABYLON {
  58350. /**
  58351. * Defines a block that can be used inside a node based material
  58352. */
  58353. export class NodeMaterialBlock {
  58354. private _buildId;
  58355. private _buildTarget;
  58356. private _target;
  58357. private _isFinalMerger;
  58358. private _isInput;
  58359. protected _isUnique: boolean;
  58360. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58361. inputsAreExclusive: boolean;
  58362. /** @hidden */
  58363. _codeVariableName: string;
  58364. /** @hidden */
  58365. _inputs: NodeMaterialConnectionPoint[];
  58366. /** @hidden */
  58367. _outputs: NodeMaterialConnectionPoint[];
  58368. /** @hidden */
  58369. _preparationId: number;
  58370. /**
  58371. * Gets or sets the name of the block
  58372. */
  58373. name: string;
  58374. /**
  58375. * Gets or sets the unique id of the node
  58376. */
  58377. uniqueId: number;
  58378. /**
  58379. * Gets or sets the comments associated with this block
  58380. */
  58381. comments: string;
  58382. /**
  58383. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58384. */
  58385. get isUnique(): boolean;
  58386. /**
  58387. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58388. */
  58389. get isFinalMerger(): boolean;
  58390. /**
  58391. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58392. */
  58393. get isInput(): boolean;
  58394. /**
  58395. * Gets or sets the build Id
  58396. */
  58397. get buildId(): number;
  58398. set buildId(value: number);
  58399. /**
  58400. * Gets or sets the target of the block
  58401. */
  58402. get target(): NodeMaterialBlockTargets;
  58403. set target(value: NodeMaterialBlockTargets);
  58404. /**
  58405. * Gets the list of input points
  58406. */
  58407. get inputs(): NodeMaterialConnectionPoint[];
  58408. /** Gets the list of output points */
  58409. get outputs(): NodeMaterialConnectionPoint[];
  58410. /**
  58411. * Find an input by its name
  58412. * @param name defines the name of the input to look for
  58413. * @returns the input or null if not found
  58414. */
  58415. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58416. /**
  58417. * Find an output by its name
  58418. * @param name defines the name of the outputto look for
  58419. * @returns the output or null if not found
  58420. */
  58421. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58422. /**
  58423. * Creates a new NodeMaterialBlock
  58424. * @param name defines the block name
  58425. * @param target defines the target of that block (Vertex by default)
  58426. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58427. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58428. */
  58429. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58430. /**
  58431. * Initialize the block and prepare the context for build
  58432. * @param state defines the state that will be used for the build
  58433. */
  58434. initialize(state: NodeMaterialBuildState): void;
  58435. /**
  58436. * Bind data to effect. Will only be called for blocks with isBindable === true
  58437. * @param effect defines the effect to bind data to
  58438. * @param nodeMaterial defines the hosting NodeMaterial
  58439. * @param mesh defines the mesh that will be rendered
  58440. */
  58441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58442. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58443. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58444. protected _writeFloat(value: number): string;
  58445. /**
  58446. * Gets the current class name e.g. "NodeMaterialBlock"
  58447. * @returns the class name
  58448. */
  58449. getClassName(): string;
  58450. /**
  58451. * Register a new input. Must be called inside a block constructor
  58452. * @param name defines the connection point name
  58453. * @param type defines the connection point type
  58454. * @param isOptional defines a boolean indicating that this input can be omitted
  58455. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58456. * @returns the current block
  58457. */
  58458. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58459. /**
  58460. * Register a new output. Must be called inside a block constructor
  58461. * @param name defines the connection point name
  58462. * @param type defines the connection point type
  58463. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58464. * @returns the current block
  58465. */
  58466. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58467. /**
  58468. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58469. * @param forOutput defines an optional connection point to check compatibility with
  58470. * @returns the first available input or null
  58471. */
  58472. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58473. /**
  58474. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58475. * @param forBlock defines an optional block to check compatibility with
  58476. * @returns the first available input or null
  58477. */
  58478. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58479. /**
  58480. * Gets the sibling of the given output
  58481. * @param current defines the current output
  58482. * @returns the next output in the list or null
  58483. */
  58484. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58485. /**
  58486. * Connect current block with another block
  58487. * @param other defines the block to connect with
  58488. * @param options define the various options to help pick the right connections
  58489. * @returns the current block
  58490. */
  58491. connectTo(other: NodeMaterialBlock, options?: {
  58492. input?: string;
  58493. output?: string;
  58494. outputSwizzle?: string;
  58495. }): this | undefined;
  58496. protected _buildBlock(state: NodeMaterialBuildState): void;
  58497. /**
  58498. * Add uniforms, samplers and uniform buffers at compilation time
  58499. * @param state defines the state to update
  58500. * @param nodeMaterial defines the node material requesting the update
  58501. * @param defines defines the material defines to update
  58502. * @param uniformBuffers defines the list of uniform buffer names
  58503. */
  58504. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58505. /**
  58506. * Add potential fallbacks if shader compilation fails
  58507. * @param mesh defines the mesh to be rendered
  58508. * @param fallbacks defines the current prioritized list of fallbacks
  58509. */
  58510. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58511. /**
  58512. * Initialize defines for shader compilation
  58513. * @param mesh defines the mesh to be rendered
  58514. * @param nodeMaterial defines the node material requesting the update
  58515. * @param defines defines the material defines to update
  58516. * @param useInstances specifies that instances should be used
  58517. */
  58518. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58519. /**
  58520. * Update defines for shader compilation
  58521. * @param mesh defines the mesh to be rendered
  58522. * @param nodeMaterial defines the node material requesting the update
  58523. * @param defines defines the material defines to update
  58524. * @param useInstances specifies that instances should be used
  58525. */
  58526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58527. /**
  58528. * Lets the block try to connect some inputs automatically
  58529. * @param material defines the hosting NodeMaterial
  58530. */
  58531. autoConfigure(material: NodeMaterial): void;
  58532. /**
  58533. * Function called when a block is declared as repeatable content generator
  58534. * @param vertexShaderState defines the current compilation state for the vertex shader
  58535. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58536. * @param mesh defines the mesh to be rendered
  58537. * @param defines defines the material defines to update
  58538. */
  58539. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58540. /**
  58541. * Checks if the block is ready
  58542. * @param mesh defines the mesh to be rendered
  58543. * @param nodeMaterial defines the node material requesting the update
  58544. * @param defines defines the material defines to update
  58545. * @param useInstances specifies that instances should be used
  58546. * @returns true if the block is ready
  58547. */
  58548. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58549. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58550. private _processBuild;
  58551. /**
  58552. * Compile the current node and generate the shader code
  58553. * @param state defines the current compilation state (uniforms, samplers, current string)
  58554. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58555. * @returns true if already built
  58556. */
  58557. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58558. protected _inputRename(name: string): string;
  58559. protected _outputRename(name: string): string;
  58560. protected _dumpPropertiesCode(): string;
  58561. /** @hidden */
  58562. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58563. /** @hidden */
  58564. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58565. /**
  58566. * Clone the current block to a new identical block
  58567. * @param scene defines the hosting scene
  58568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58569. * @returns a copy of the current block
  58570. */
  58571. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58572. /**
  58573. * Serializes this block in a JSON representation
  58574. * @returns the serialized block object
  58575. */
  58576. serialize(): any;
  58577. /** @hidden */
  58578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58579. /**
  58580. * Release resources
  58581. */
  58582. dispose(): void;
  58583. }
  58584. }
  58585. declare module BABYLON {
  58586. /**
  58587. * Enum defining the type of animations supported by InputBlock
  58588. */
  58589. export enum AnimatedInputBlockTypes {
  58590. /** No animation */
  58591. None = 0,
  58592. /** Time based animation. Will only work for floats */
  58593. Time = 1
  58594. }
  58595. }
  58596. declare module BABYLON {
  58597. /**
  58598. * Block used to expose an input value
  58599. */
  58600. export class InputBlock extends NodeMaterialBlock {
  58601. private _mode;
  58602. private _associatedVariableName;
  58603. private _storedValue;
  58604. private _valueCallback;
  58605. private _type;
  58606. private _animationType;
  58607. /** Gets or set a value used to limit the range of float values */
  58608. min: number;
  58609. /** Gets or set a value used to limit the range of float values */
  58610. max: number;
  58611. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58612. isBoolean: boolean;
  58613. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58614. matrixMode: number;
  58615. /** @hidden */
  58616. _systemValue: Nullable<NodeMaterialSystemValues>;
  58617. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58618. visibleInInspector: boolean;
  58619. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58620. isConstant: boolean;
  58621. /** Gets or sets the group to use to display this block in the Inspector */
  58622. groupInInspector: string;
  58623. /** Gets an observable raised when the value is changed */
  58624. onValueChangedObservable: Observable<InputBlock>;
  58625. /**
  58626. * Gets or sets the connection point type (default is float)
  58627. */
  58628. get type(): NodeMaterialBlockConnectionPointTypes;
  58629. /**
  58630. * Creates a new InputBlock
  58631. * @param name defines the block name
  58632. * @param target defines the target of that block (Vertex by default)
  58633. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58634. */
  58635. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58636. /**
  58637. * Gets the output component
  58638. */
  58639. get output(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Set the source of this connection point to a vertex attribute
  58642. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58643. * @returns the current connection point
  58644. */
  58645. setAsAttribute(attributeName?: string): InputBlock;
  58646. /**
  58647. * Set the source of this connection point to a system value
  58648. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58649. * @returns the current connection point
  58650. */
  58651. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58652. /**
  58653. * Gets or sets the value of that point.
  58654. * Please note that this value will be ignored if valueCallback is defined
  58655. */
  58656. get value(): any;
  58657. set value(value: any);
  58658. /**
  58659. * Gets or sets a callback used to get the value of that point.
  58660. * Please note that setting this value will force the connection point to ignore the value property
  58661. */
  58662. get valueCallback(): () => any;
  58663. set valueCallback(value: () => any);
  58664. /**
  58665. * Gets or sets the associated variable name in the shader
  58666. */
  58667. get associatedVariableName(): string;
  58668. set associatedVariableName(value: string);
  58669. /** Gets or sets the type of animation applied to the input */
  58670. get animationType(): AnimatedInputBlockTypes;
  58671. set animationType(value: AnimatedInputBlockTypes);
  58672. /**
  58673. * Gets a boolean indicating that this connection point not defined yet
  58674. */
  58675. get isUndefined(): boolean;
  58676. /**
  58677. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58678. * In this case the connection point name must be the name of the uniform to use.
  58679. * Can only be set on inputs
  58680. */
  58681. get isUniform(): boolean;
  58682. set isUniform(value: boolean);
  58683. /**
  58684. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58685. * In this case the connection point name must be the name of the attribute to use
  58686. * Can only be set on inputs
  58687. */
  58688. get isAttribute(): boolean;
  58689. set isAttribute(value: boolean);
  58690. /**
  58691. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58692. * Can only be set on exit points
  58693. */
  58694. get isVarying(): boolean;
  58695. set isVarying(value: boolean);
  58696. /**
  58697. * Gets a boolean indicating that the current connection point is a system value
  58698. */
  58699. get isSystemValue(): boolean;
  58700. /**
  58701. * Gets or sets the current well known value or null if not defined as a system value
  58702. */
  58703. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58704. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58705. /**
  58706. * Gets the current class name
  58707. * @returns the class name
  58708. */
  58709. getClassName(): string;
  58710. /**
  58711. * Animate the input if animationType !== None
  58712. * @param scene defines the rendering scene
  58713. */
  58714. animate(scene: Scene): void;
  58715. private _emitDefine;
  58716. initialize(state: NodeMaterialBuildState): void;
  58717. /**
  58718. * Set the input block to its default value (based on its type)
  58719. */
  58720. setDefaultValue(): void;
  58721. private _emitConstant;
  58722. private _emit;
  58723. /** @hidden */
  58724. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58725. /** @hidden */
  58726. _transmit(effect: Effect, scene: Scene): void;
  58727. protected _buildBlock(state: NodeMaterialBuildState): void;
  58728. protected _dumpPropertiesCode(): string;
  58729. dispose(): void;
  58730. serialize(): any;
  58731. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58732. }
  58733. }
  58734. declare module BABYLON {
  58735. /**
  58736. * Enum used to define the compatibility state between two connection points
  58737. */
  58738. export enum NodeMaterialConnectionPointCompatibilityStates {
  58739. /** Points are compatibles */
  58740. Compatible = 0,
  58741. /** Points are incompatible because of their types */
  58742. TypeIncompatible = 1,
  58743. /** Points are incompatible because of their targets (vertex vs fragment) */
  58744. TargetIncompatible = 2
  58745. }
  58746. /**
  58747. * Defines the direction of a connection point
  58748. */
  58749. export enum NodeMaterialConnectionPointDirection {
  58750. /** Input */
  58751. Input = 0,
  58752. /** Output */
  58753. Output = 1
  58754. }
  58755. /**
  58756. * Defines a connection point for a block
  58757. */
  58758. export class NodeMaterialConnectionPoint {
  58759. /** @hidden */
  58760. _ownerBlock: NodeMaterialBlock;
  58761. /** @hidden */
  58762. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58763. private _endpoints;
  58764. private _associatedVariableName;
  58765. private _direction;
  58766. /** @hidden */
  58767. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58768. /** @hidden */
  58769. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58770. private _type;
  58771. /** @hidden */
  58772. _enforceAssociatedVariableName: boolean;
  58773. /** Gets the direction of the point */
  58774. get direction(): NodeMaterialConnectionPointDirection;
  58775. /**
  58776. * Gets or sets the additional types supported by this connection point
  58777. */
  58778. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58779. /**
  58780. * Gets or sets the additional types excluded by this connection point
  58781. */
  58782. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58783. /**
  58784. * Observable triggered when this point is connected
  58785. */
  58786. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58787. /**
  58788. * Gets or sets the associated variable name in the shader
  58789. */
  58790. get associatedVariableName(): string;
  58791. set associatedVariableName(value: string);
  58792. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58793. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58794. /**
  58795. * Gets or sets the connection point type (default is float)
  58796. */
  58797. get type(): NodeMaterialBlockConnectionPointTypes;
  58798. set type(value: NodeMaterialBlockConnectionPointTypes);
  58799. /**
  58800. * Gets or sets the connection point name
  58801. */
  58802. name: string;
  58803. /**
  58804. * Gets or sets a boolean indicating that this connection point can be omitted
  58805. */
  58806. isOptional: boolean;
  58807. /**
  58808. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58809. */
  58810. define: string;
  58811. /** @hidden */
  58812. _prioritizeVertex: boolean;
  58813. private _target;
  58814. /** Gets or sets the target of that connection point */
  58815. get target(): NodeMaterialBlockTargets;
  58816. set target(value: NodeMaterialBlockTargets);
  58817. /**
  58818. * Gets a boolean indicating that the current point is connected
  58819. */
  58820. get isConnected(): boolean;
  58821. /**
  58822. * Gets a boolean indicating that the current point is connected to an input block
  58823. */
  58824. get isConnectedToInputBlock(): boolean;
  58825. /**
  58826. * Gets a the connected input block (if any)
  58827. */
  58828. get connectInputBlock(): Nullable<InputBlock>;
  58829. /** Get the other side of the connection (if any) */
  58830. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58831. /** Get the block that owns this connection point */
  58832. get ownerBlock(): NodeMaterialBlock;
  58833. /** Get the block connected on the other side of this connection (if any) */
  58834. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58835. /** Get the block connected on the endpoints of this connection (if any) */
  58836. get connectedBlocks(): Array<NodeMaterialBlock>;
  58837. /** Gets the list of connected endpoints */
  58838. get endpoints(): NodeMaterialConnectionPoint[];
  58839. /** Gets a boolean indicating if that output point is connected to at least one input */
  58840. get hasEndpoints(): boolean;
  58841. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58842. get isConnectedInVertexShader(): boolean;
  58843. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58844. get isConnectedInFragmentShader(): boolean;
  58845. /**
  58846. * Creates a new connection point
  58847. * @param name defines the connection point name
  58848. * @param ownerBlock defines the block hosting this connection point
  58849. * @param direction defines the direction of the connection point
  58850. */
  58851. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58852. /**
  58853. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58854. * @returns the class name
  58855. */
  58856. getClassName(): string;
  58857. /**
  58858. * Gets a boolean indicating if the current point can be connected to another point
  58859. * @param connectionPoint defines the other connection point
  58860. * @returns a boolean
  58861. */
  58862. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58863. /**
  58864. * Gets a number indicating if the current point can be connected to another point
  58865. * @param connectionPoint defines the other connection point
  58866. * @returns a number defining the compatibility state
  58867. */
  58868. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58869. /**
  58870. * Connect this point to another connection point
  58871. * @param connectionPoint defines the other connection point
  58872. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58873. * @returns the current connection point
  58874. */
  58875. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Disconnect this point from one of his endpoint
  58878. * @param endpoint defines the other connection point
  58879. * @returns the current connection point
  58880. */
  58881. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58882. /**
  58883. * Serializes this point in a JSON representation
  58884. * @returns the serialized point object
  58885. */
  58886. serialize(): any;
  58887. /**
  58888. * Release resources
  58889. */
  58890. dispose(): void;
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /**
  58895. * Block used to add support for vertex skinning (bones)
  58896. */
  58897. export class BonesBlock extends NodeMaterialBlock {
  58898. /**
  58899. * Creates a new BonesBlock
  58900. * @param name defines the block name
  58901. */
  58902. constructor(name: string);
  58903. /**
  58904. * Initialize the block and prepare the context for build
  58905. * @param state defines the state that will be used for the build
  58906. */
  58907. initialize(state: NodeMaterialBuildState): void;
  58908. /**
  58909. * Gets the current class name
  58910. * @returns the class name
  58911. */
  58912. getClassName(): string;
  58913. /**
  58914. * Gets the matrix indices input component
  58915. */
  58916. get matricesIndices(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the matrix weights input component
  58919. */
  58920. get matricesWeights(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the extra matrix indices input component
  58923. */
  58924. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the extra matrix weights input component
  58927. */
  58928. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the world input component
  58931. */
  58932. get world(): NodeMaterialConnectionPoint;
  58933. /**
  58934. * Gets the output component
  58935. */
  58936. get output(): NodeMaterialConnectionPoint;
  58937. autoConfigure(material: NodeMaterial): void;
  58938. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58941. protected _buildBlock(state: NodeMaterialBuildState): this;
  58942. }
  58943. }
  58944. declare module BABYLON {
  58945. /**
  58946. * Block used to add support for instances
  58947. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58948. */
  58949. export class InstancesBlock extends NodeMaterialBlock {
  58950. /**
  58951. * Creates a new InstancesBlock
  58952. * @param name defines the block name
  58953. */
  58954. constructor(name: string);
  58955. /**
  58956. * Gets the current class name
  58957. * @returns the class name
  58958. */
  58959. getClassName(): string;
  58960. /**
  58961. * Gets the first world row input component
  58962. */
  58963. get world0(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the second world row input component
  58966. */
  58967. get world1(): NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the third world row input component
  58970. */
  58971. get world2(): NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the forth world row input component
  58974. */
  58975. get world3(): NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the world input component
  58978. */
  58979. get world(): NodeMaterialConnectionPoint;
  58980. /**
  58981. * Gets the output component
  58982. */
  58983. get output(): NodeMaterialConnectionPoint;
  58984. /**
  58985. * Gets the isntanceID component
  58986. */
  58987. get instanceID(): NodeMaterialConnectionPoint;
  58988. autoConfigure(material: NodeMaterial): void;
  58989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58990. protected _buildBlock(state: NodeMaterialBuildState): this;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to add morph targets support to vertex shader
  58996. */
  58997. export class MorphTargetsBlock extends NodeMaterialBlock {
  58998. private _repeatableContentAnchor;
  58999. /**
  59000. * Create a new MorphTargetsBlock
  59001. * @param name defines the block name
  59002. */
  59003. constructor(name: string);
  59004. /**
  59005. * Gets the current class name
  59006. * @returns the class name
  59007. */
  59008. getClassName(): string;
  59009. /**
  59010. * Gets the position input component
  59011. */
  59012. get position(): NodeMaterialConnectionPoint;
  59013. /**
  59014. * Gets the normal input component
  59015. */
  59016. get normal(): NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the tangent input component
  59019. */
  59020. get tangent(): NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the tangent input component
  59023. */
  59024. get uv(): NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the position output component
  59027. */
  59028. get positionOutput(): NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the normal output component
  59031. */
  59032. get normalOutput(): NodeMaterialConnectionPoint;
  59033. /**
  59034. * Gets the tangent output component
  59035. */
  59036. get tangentOutput(): NodeMaterialConnectionPoint;
  59037. /**
  59038. * Gets the tangent output component
  59039. */
  59040. get uvOutput(): NodeMaterialConnectionPoint;
  59041. initialize(state: NodeMaterialBuildState): void;
  59042. autoConfigure(material: NodeMaterial): void;
  59043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59045. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59046. protected _buildBlock(state: NodeMaterialBuildState): this;
  59047. }
  59048. }
  59049. declare module BABYLON {
  59050. /**
  59051. * Block used to get data information from a light
  59052. */
  59053. export class LightInformationBlock extends NodeMaterialBlock {
  59054. private _lightDataUniformName;
  59055. private _lightColorUniformName;
  59056. private _lightTypeDefineName;
  59057. /**
  59058. * Gets or sets the light associated with this block
  59059. */
  59060. light: Nullable<Light>;
  59061. /**
  59062. * Creates a new LightInformationBlock
  59063. * @param name defines the block name
  59064. */
  59065. constructor(name: string);
  59066. /**
  59067. * Gets the current class name
  59068. * @returns the class name
  59069. */
  59070. getClassName(): string;
  59071. /**
  59072. * Gets the world position input component
  59073. */
  59074. get worldPosition(): NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the direction output component
  59077. */
  59078. get direction(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the direction output component
  59081. */
  59082. get color(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the direction output component
  59085. */
  59086. get intensity(): NodeMaterialConnectionPoint;
  59087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59089. protected _buildBlock(state: NodeMaterialBuildState): this;
  59090. serialize(): any;
  59091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59092. }
  59093. }
  59094. declare module BABYLON {
  59095. /**
  59096. * Block used to add image processing support to fragment shader
  59097. */
  59098. export class ImageProcessingBlock extends NodeMaterialBlock {
  59099. /**
  59100. * Create a new ImageProcessingBlock
  59101. * @param name defines the block name
  59102. */
  59103. constructor(name: string);
  59104. /**
  59105. * Gets the current class name
  59106. * @returns the class name
  59107. */
  59108. getClassName(): string;
  59109. /**
  59110. * Gets the color input component
  59111. */
  59112. get color(): NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the output component
  59115. */
  59116. get output(): NodeMaterialConnectionPoint;
  59117. /**
  59118. * Initialize the block and prepare the context for build
  59119. * @param state defines the state that will be used for the build
  59120. */
  59121. initialize(state: NodeMaterialBuildState): void;
  59122. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59125. protected _buildBlock(state: NodeMaterialBuildState): this;
  59126. }
  59127. }
  59128. declare module BABYLON {
  59129. /**
  59130. * Block used to pertub normals based on a normal map
  59131. */
  59132. export class PerturbNormalBlock extends NodeMaterialBlock {
  59133. private _tangentSpaceParameterName;
  59134. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59135. invertX: boolean;
  59136. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59137. invertY: boolean;
  59138. /**
  59139. * Create a new PerturbNormalBlock
  59140. * @param name defines the block name
  59141. */
  59142. constructor(name: string);
  59143. /**
  59144. * Gets the current class name
  59145. * @returns the class name
  59146. */
  59147. getClassName(): string;
  59148. /**
  59149. * Gets the world position input component
  59150. */
  59151. get worldPosition(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the world normal input component
  59154. */
  59155. get worldNormal(): NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the world tangent input component
  59158. */
  59159. get worldTangent(): NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the uv input component
  59162. */
  59163. get uv(): NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the normal map color input component
  59166. */
  59167. get normalMapColor(): NodeMaterialConnectionPoint;
  59168. /**
  59169. * Gets the strength input component
  59170. */
  59171. get strength(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the output component
  59174. */
  59175. get output(): NodeMaterialConnectionPoint;
  59176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59178. autoConfigure(material: NodeMaterial): void;
  59179. protected _buildBlock(state: NodeMaterialBuildState): this;
  59180. protected _dumpPropertiesCode(): string;
  59181. serialize(): any;
  59182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59183. }
  59184. }
  59185. declare module BABYLON {
  59186. /**
  59187. * Block used to discard a pixel if a value is smaller than a cutoff
  59188. */
  59189. export class DiscardBlock extends NodeMaterialBlock {
  59190. /**
  59191. * Create a new DiscardBlock
  59192. * @param name defines the block name
  59193. */
  59194. constructor(name: string);
  59195. /**
  59196. * Gets the current class name
  59197. * @returns the class name
  59198. */
  59199. getClassName(): string;
  59200. /**
  59201. * Gets the color input component
  59202. */
  59203. get value(): NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the cutoff input component
  59206. */
  59207. get cutoff(): NodeMaterialConnectionPoint;
  59208. protected _buildBlock(state: NodeMaterialBuildState): this;
  59209. }
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * Block used to test if the fragment shader is front facing
  59214. */
  59215. export class FrontFacingBlock extends NodeMaterialBlock {
  59216. /**
  59217. * Creates a new FrontFacingBlock
  59218. * @param name defines the block name
  59219. */
  59220. constructor(name: string);
  59221. /**
  59222. * Gets the current class name
  59223. * @returns the class name
  59224. */
  59225. getClassName(): string;
  59226. /**
  59227. * Gets the output component
  59228. */
  59229. get output(): NodeMaterialConnectionPoint;
  59230. protected _buildBlock(state: NodeMaterialBuildState): this;
  59231. }
  59232. }
  59233. declare module BABYLON {
  59234. /**
  59235. * Block used to get the derivative value on x and y of a given input
  59236. */
  59237. export class DerivativeBlock extends NodeMaterialBlock {
  59238. /**
  59239. * Create a new DerivativeBlock
  59240. * @param name defines the block name
  59241. */
  59242. constructor(name: string);
  59243. /**
  59244. * Gets the current class name
  59245. * @returns the class name
  59246. */
  59247. getClassName(): string;
  59248. /**
  59249. * Gets the input component
  59250. */
  59251. get input(): NodeMaterialConnectionPoint;
  59252. /**
  59253. * Gets the derivative output on x
  59254. */
  59255. get dx(): NodeMaterialConnectionPoint;
  59256. /**
  59257. * Gets the derivative output on y
  59258. */
  59259. get dy(): NodeMaterialConnectionPoint;
  59260. protected _buildBlock(state: NodeMaterialBuildState): this;
  59261. }
  59262. }
  59263. declare module BABYLON {
  59264. /**
  59265. * Block used to add support for scene fog
  59266. */
  59267. export class FogBlock extends NodeMaterialBlock {
  59268. private _fogDistanceName;
  59269. private _fogParameters;
  59270. /**
  59271. * Create a new FogBlock
  59272. * @param name defines the block name
  59273. */
  59274. constructor(name: string);
  59275. /**
  59276. * Gets the current class name
  59277. * @returns the class name
  59278. */
  59279. getClassName(): string;
  59280. /**
  59281. * Gets the world position input component
  59282. */
  59283. get worldPosition(): NodeMaterialConnectionPoint;
  59284. /**
  59285. * Gets the view input component
  59286. */
  59287. get view(): NodeMaterialConnectionPoint;
  59288. /**
  59289. * Gets the color input component
  59290. */
  59291. get input(): NodeMaterialConnectionPoint;
  59292. /**
  59293. * Gets the fog color input component
  59294. */
  59295. get fogColor(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the output component
  59298. */
  59299. get output(): NodeMaterialConnectionPoint;
  59300. autoConfigure(material: NodeMaterial): void;
  59301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59303. protected _buildBlock(state: NodeMaterialBuildState): this;
  59304. }
  59305. }
  59306. declare module BABYLON {
  59307. /**
  59308. * Block used to add light in the fragment shader
  59309. */
  59310. export class LightBlock extends NodeMaterialBlock {
  59311. private _lightId;
  59312. /**
  59313. * Gets or sets the light associated with this block
  59314. */
  59315. light: Nullable<Light>;
  59316. /**
  59317. * Create a new LightBlock
  59318. * @param name defines the block name
  59319. */
  59320. constructor(name: string);
  59321. /**
  59322. * Gets the current class name
  59323. * @returns the class name
  59324. */
  59325. getClassName(): string;
  59326. /**
  59327. * Gets the world position input component
  59328. */
  59329. get worldPosition(): NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the world normal input component
  59332. */
  59333. get worldNormal(): NodeMaterialConnectionPoint;
  59334. /**
  59335. * Gets the camera (or eye) position component
  59336. */
  59337. get cameraPosition(): NodeMaterialConnectionPoint;
  59338. /**
  59339. * Gets the glossiness component
  59340. */
  59341. get glossiness(): NodeMaterialConnectionPoint;
  59342. /**
  59343. * Gets the glossinness power component
  59344. */
  59345. get glossPower(): NodeMaterialConnectionPoint;
  59346. /**
  59347. * Gets the diffuse color component
  59348. */
  59349. get diffuseColor(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the specular color component
  59352. */
  59353. get specularColor(): NodeMaterialConnectionPoint;
  59354. /**
  59355. * Gets the diffuse output component
  59356. */
  59357. get diffuseOutput(): NodeMaterialConnectionPoint;
  59358. /**
  59359. * Gets the specular output component
  59360. */
  59361. get specularOutput(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the shadow output component
  59364. */
  59365. get shadow(): NodeMaterialConnectionPoint;
  59366. autoConfigure(material: NodeMaterial): void;
  59367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59368. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59370. private _injectVertexCode;
  59371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59372. serialize(): any;
  59373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59374. }
  59375. }
  59376. declare module BABYLON {
  59377. /**
  59378. * Block used to multiply 2 values
  59379. */
  59380. export class MultiplyBlock extends NodeMaterialBlock {
  59381. /**
  59382. * Creates a new MultiplyBlock
  59383. * @param name defines the block name
  59384. */
  59385. constructor(name: string);
  59386. /**
  59387. * Gets the current class name
  59388. * @returns the class name
  59389. */
  59390. getClassName(): string;
  59391. /**
  59392. * Gets the left operand input component
  59393. */
  59394. get left(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the right operand input component
  59397. */
  59398. get right(): NodeMaterialConnectionPoint;
  59399. /**
  59400. * Gets the output component
  59401. */
  59402. get output(): NodeMaterialConnectionPoint;
  59403. protected _buildBlock(state: NodeMaterialBuildState): this;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /**
  59408. * Block used to add 2 vectors
  59409. */
  59410. export class AddBlock extends NodeMaterialBlock {
  59411. /**
  59412. * Creates a new AddBlock
  59413. * @param name defines the block name
  59414. */
  59415. constructor(name: string);
  59416. /**
  59417. * Gets the current class name
  59418. * @returns the class name
  59419. */
  59420. getClassName(): string;
  59421. /**
  59422. * Gets the left operand input component
  59423. */
  59424. get left(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the right operand input component
  59427. */
  59428. get right(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the output component
  59431. */
  59432. get output(): NodeMaterialConnectionPoint;
  59433. protected _buildBlock(state: NodeMaterialBuildState): this;
  59434. }
  59435. }
  59436. declare module BABYLON {
  59437. /**
  59438. * Block used to scale a vector by a float
  59439. */
  59440. export class ScaleBlock extends NodeMaterialBlock {
  59441. /**
  59442. * Creates a new ScaleBlock
  59443. * @param name defines the block name
  59444. */
  59445. constructor(name: string);
  59446. /**
  59447. * Gets the current class name
  59448. * @returns the class name
  59449. */
  59450. getClassName(): string;
  59451. /**
  59452. * Gets the input component
  59453. */
  59454. get input(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the factor input component
  59457. */
  59458. get factor(): NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the output component
  59461. */
  59462. get output(): NodeMaterialConnectionPoint;
  59463. protected _buildBlock(state: NodeMaterialBuildState): this;
  59464. }
  59465. }
  59466. declare module BABYLON {
  59467. /**
  59468. * Block used to clamp a float
  59469. */
  59470. export class ClampBlock extends NodeMaterialBlock {
  59471. /** Gets or sets the minimum range */
  59472. minimum: number;
  59473. /** Gets or sets the maximum range */
  59474. maximum: number;
  59475. /**
  59476. * Creates a new ClampBlock
  59477. * @param name defines the block name
  59478. */
  59479. constructor(name: string);
  59480. /**
  59481. * Gets the current class name
  59482. * @returns the class name
  59483. */
  59484. getClassName(): string;
  59485. /**
  59486. * Gets the value input component
  59487. */
  59488. get value(): NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the output component
  59491. */
  59492. get output(): NodeMaterialConnectionPoint;
  59493. protected _buildBlock(state: NodeMaterialBuildState): this;
  59494. protected _dumpPropertiesCode(): string;
  59495. serialize(): any;
  59496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59497. }
  59498. }
  59499. declare module BABYLON {
  59500. /**
  59501. * Block used to apply a cross product between 2 vectors
  59502. */
  59503. export class CrossBlock extends NodeMaterialBlock {
  59504. /**
  59505. * Creates a new CrossBlock
  59506. * @param name defines the block name
  59507. */
  59508. constructor(name: string);
  59509. /**
  59510. * Gets the current class name
  59511. * @returns the class name
  59512. */
  59513. getClassName(): string;
  59514. /**
  59515. * Gets the left operand input component
  59516. */
  59517. get left(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the right operand input component
  59520. */
  59521. get right(): NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the output component
  59524. */
  59525. get output(): NodeMaterialConnectionPoint;
  59526. protected _buildBlock(state: NodeMaterialBuildState): this;
  59527. }
  59528. }
  59529. declare module BABYLON {
  59530. /**
  59531. * Block used to apply a dot product between 2 vectors
  59532. */
  59533. export class DotBlock extends NodeMaterialBlock {
  59534. /**
  59535. * Creates a new DotBlock
  59536. * @param name defines the block name
  59537. */
  59538. constructor(name: string);
  59539. /**
  59540. * Gets the current class name
  59541. * @returns the class name
  59542. */
  59543. getClassName(): string;
  59544. /**
  59545. * Gets the left operand input component
  59546. */
  59547. get left(): NodeMaterialConnectionPoint;
  59548. /**
  59549. * Gets the right operand input component
  59550. */
  59551. get right(): NodeMaterialConnectionPoint;
  59552. /**
  59553. * Gets the output component
  59554. */
  59555. get output(): NodeMaterialConnectionPoint;
  59556. protected _buildBlock(state: NodeMaterialBuildState): this;
  59557. }
  59558. }
  59559. declare module BABYLON {
  59560. /**
  59561. * Block used to remap a float from a range to a new one
  59562. */
  59563. export class RemapBlock extends NodeMaterialBlock {
  59564. /**
  59565. * Gets or sets the source range
  59566. */
  59567. sourceRange: Vector2;
  59568. /**
  59569. * Gets or sets the target range
  59570. */
  59571. targetRange: Vector2;
  59572. /**
  59573. * Creates a new RemapBlock
  59574. * @param name defines the block name
  59575. */
  59576. constructor(name: string);
  59577. /**
  59578. * Gets the current class name
  59579. * @returns the class name
  59580. */
  59581. getClassName(): string;
  59582. /**
  59583. * Gets the input component
  59584. */
  59585. get input(): NodeMaterialConnectionPoint;
  59586. /**
  59587. * Gets the source min input component
  59588. */
  59589. get sourceMin(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the source max input component
  59592. */
  59593. get sourceMax(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the target min input component
  59596. */
  59597. get targetMin(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the target max input component
  59600. */
  59601. get targetMax(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the output component
  59604. */
  59605. get output(): NodeMaterialConnectionPoint;
  59606. protected _buildBlock(state: NodeMaterialBuildState): this;
  59607. protected _dumpPropertiesCode(): string;
  59608. serialize(): any;
  59609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59610. }
  59611. }
  59612. declare module BABYLON {
  59613. /**
  59614. * Block used to normalize a vector
  59615. */
  59616. export class NormalizeBlock extends NodeMaterialBlock {
  59617. /**
  59618. * Creates a new NormalizeBlock
  59619. * @param name defines the block name
  59620. */
  59621. constructor(name: string);
  59622. /**
  59623. * Gets the current class name
  59624. * @returns the class name
  59625. */
  59626. getClassName(): string;
  59627. /**
  59628. * Gets the input component
  59629. */
  59630. get input(): NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the output component
  59633. */
  59634. get output(): NodeMaterialConnectionPoint;
  59635. protected _buildBlock(state: NodeMaterialBuildState): this;
  59636. }
  59637. }
  59638. declare module BABYLON {
  59639. /**
  59640. * Operations supported by the Trigonometry block
  59641. */
  59642. export enum TrigonometryBlockOperations {
  59643. /** Cos */
  59644. Cos = 0,
  59645. /** Sin */
  59646. Sin = 1,
  59647. /** Abs */
  59648. Abs = 2,
  59649. /** Exp */
  59650. Exp = 3,
  59651. /** Exp2 */
  59652. Exp2 = 4,
  59653. /** Round */
  59654. Round = 5,
  59655. /** Floor */
  59656. Floor = 6,
  59657. /** Ceiling */
  59658. Ceiling = 7,
  59659. /** Square root */
  59660. Sqrt = 8,
  59661. /** Log */
  59662. Log = 9,
  59663. /** Tangent */
  59664. Tan = 10,
  59665. /** Arc tangent */
  59666. ArcTan = 11,
  59667. /** Arc cosinus */
  59668. ArcCos = 12,
  59669. /** Arc sinus */
  59670. ArcSin = 13,
  59671. /** Fraction */
  59672. Fract = 14,
  59673. /** Sign */
  59674. Sign = 15,
  59675. /** To radians (from degrees) */
  59676. Radians = 16,
  59677. /** To degrees (from radians) */
  59678. Degrees = 17
  59679. }
  59680. /**
  59681. * Block used to apply trigonometry operation to floats
  59682. */
  59683. export class TrigonometryBlock extends NodeMaterialBlock {
  59684. /**
  59685. * Gets or sets the operation applied by the block
  59686. */
  59687. operation: TrigonometryBlockOperations;
  59688. /**
  59689. * Creates a new TrigonometryBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the input component
  59700. */
  59701. get input(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the output component
  59704. */
  59705. get output(): NodeMaterialConnectionPoint;
  59706. protected _buildBlock(state: NodeMaterialBuildState): this;
  59707. serialize(): any;
  59708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59709. protected _dumpPropertiesCode(): string;
  59710. }
  59711. }
  59712. declare module BABYLON {
  59713. /**
  59714. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59715. */
  59716. export class ColorMergerBlock extends NodeMaterialBlock {
  59717. /**
  59718. * Create a new ColorMergerBlock
  59719. * @param name defines the block name
  59720. */
  59721. constructor(name: string);
  59722. /**
  59723. * Gets the current class name
  59724. * @returns the class name
  59725. */
  59726. getClassName(): string;
  59727. /**
  59728. * Gets the rgb component (input)
  59729. */
  59730. get rgbIn(): NodeMaterialConnectionPoint;
  59731. /**
  59732. * Gets the r component (input)
  59733. */
  59734. get r(): NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the g component (input)
  59737. */
  59738. get g(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the b component (input)
  59741. */
  59742. get b(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the a component (input)
  59745. */
  59746. get a(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the rgba component (output)
  59749. */
  59750. get rgba(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the rgb component (output)
  59753. */
  59754. get rgbOut(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the rgb component (output)
  59757. * @deprecated Please use rgbOut instead.
  59758. */
  59759. get rgb(): NodeMaterialConnectionPoint;
  59760. protected _buildBlock(state: NodeMaterialBuildState): this;
  59761. }
  59762. }
  59763. declare module BABYLON {
  59764. /**
  59765. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59766. */
  59767. export class VectorMergerBlock extends NodeMaterialBlock {
  59768. /**
  59769. * Create a new VectorMergerBlock
  59770. * @param name defines the block name
  59771. */
  59772. constructor(name: string);
  59773. /**
  59774. * Gets the current class name
  59775. * @returns the class name
  59776. */
  59777. getClassName(): string;
  59778. /**
  59779. * Gets the xyz component (input)
  59780. */
  59781. get xyzIn(): NodeMaterialConnectionPoint;
  59782. /**
  59783. * Gets the xy component (input)
  59784. */
  59785. get xyIn(): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Gets the x component (input)
  59788. */
  59789. get x(): NodeMaterialConnectionPoint;
  59790. /**
  59791. * Gets the y component (input)
  59792. */
  59793. get y(): NodeMaterialConnectionPoint;
  59794. /**
  59795. * Gets the z component (input)
  59796. */
  59797. get z(): NodeMaterialConnectionPoint;
  59798. /**
  59799. * Gets the w component (input)
  59800. */
  59801. get w(): NodeMaterialConnectionPoint;
  59802. /**
  59803. * Gets the xyzw component (output)
  59804. */
  59805. get xyzw(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the xyz component (output)
  59808. */
  59809. get xyzOut(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the xy component (output)
  59812. */
  59813. get xyOut(): NodeMaterialConnectionPoint;
  59814. /**
  59815. * Gets the xy component (output)
  59816. * @deprecated Please use xyOut instead.
  59817. */
  59818. get xy(): NodeMaterialConnectionPoint;
  59819. /**
  59820. * Gets the xyz component (output)
  59821. * @deprecated Please use xyzOut instead.
  59822. */
  59823. get xyz(): NodeMaterialConnectionPoint;
  59824. protected _buildBlock(state: NodeMaterialBuildState): this;
  59825. }
  59826. }
  59827. declare module BABYLON {
  59828. /**
  59829. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59830. */
  59831. export class ColorSplitterBlock extends NodeMaterialBlock {
  59832. /**
  59833. * Create a new ColorSplitterBlock
  59834. * @param name defines the block name
  59835. */
  59836. constructor(name: string);
  59837. /**
  59838. * Gets the current class name
  59839. * @returns the class name
  59840. */
  59841. getClassName(): string;
  59842. /**
  59843. * Gets the rgba component (input)
  59844. */
  59845. get rgba(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the rgb component (input)
  59848. */
  59849. get rgbIn(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the rgb component (output)
  59852. */
  59853. get rgbOut(): NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the r component (output)
  59856. */
  59857. get r(): NodeMaterialConnectionPoint;
  59858. /**
  59859. * Gets the g component (output)
  59860. */
  59861. get g(): NodeMaterialConnectionPoint;
  59862. /**
  59863. * Gets the b component (output)
  59864. */
  59865. get b(): NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the a component (output)
  59868. */
  59869. get a(): NodeMaterialConnectionPoint;
  59870. protected _inputRename(name: string): string;
  59871. protected _outputRename(name: string): string;
  59872. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59873. }
  59874. }
  59875. declare module BABYLON {
  59876. /**
  59877. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59878. */
  59879. export class VectorSplitterBlock extends NodeMaterialBlock {
  59880. /**
  59881. * Create a new VectorSplitterBlock
  59882. * @param name defines the block name
  59883. */
  59884. constructor(name: string);
  59885. /**
  59886. * Gets the current class name
  59887. * @returns the class name
  59888. */
  59889. getClassName(): string;
  59890. /**
  59891. * Gets the xyzw component (input)
  59892. */
  59893. get xyzw(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the xyz component (input)
  59896. */
  59897. get xyzIn(): NodeMaterialConnectionPoint;
  59898. /**
  59899. * Gets the xy component (input)
  59900. */
  59901. get xyIn(): NodeMaterialConnectionPoint;
  59902. /**
  59903. * Gets the xyz component (output)
  59904. */
  59905. get xyzOut(): NodeMaterialConnectionPoint;
  59906. /**
  59907. * Gets the xy component (output)
  59908. */
  59909. get xyOut(): NodeMaterialConnectionPoint;
  59910. /**
  59911. * Gets the x component (output)
  59912. */
  59913. get x(): NodeMaterialConnectionPoint;
  59914. /**
  59915. * Gets the y component (output)
  59916. */
  59917. get y(): NodeMaterialConnectionPoint;
  59918. /**
  59919. * Gets the z component (output)
  59920. */
  59921. get z(): NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the w component (output)
  59924. */
  59925. get w(): NodeMaterialConnectionPoint;
  59926. protected _inputRename(name: string): string;
  59927. protected _outputRename(name: string): string;
  59928. protected _buildBlock(state: NodeMaterialBuildState): this;
  59929. }
  59930. }
  59931. declare module BABYLON {
  59932. /**
  59933. * Block used to lerp between 2 values
  59934. */
  59935. export class LerpBlock extends NodeMaterialBlock {
  59936. /**
  59937. * Creates a new LerpBlock
  59938. * @param name defines the block name
  59939. */
  59940. constructor(name: string);
  59941. /**
  59942. * Gets the current class name
  59943. * @returns the class name
  59944. */
  59945. getClassName(): string;
  59946. /**
  59947. * Gets the left operand input component
  59948. */
  59949. get left(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the right operand input component
  59952. */
  59953. get right(): NodeMaterialConnectionPoint;
  59954. /**
  59955. * Gets the gradient operand input component
  59956. */
  59957. get gradient(): NodeMaterialConnectionPoint;
  59958. /**
  59959. * Gets the output component
  59960. */
  59961. get output(): NodeMaterialConnectionPoint;
  59962. protected _buildBlock(state: NodeMaterialBuildState): this;
  59963. }
  59964. }
  59965. declare module BABYLON {
  59966. /**
  59967. * Block used to divide 2 vectors
  59968. */
  59969. export class DivideBlock extends NodeMaterialBlock {
  59970. /**
  59971. * Creates a new DivideBlock
  59972. * @param name defines the block name
  59973. */
  59974. constructor(name: string);
  59975. /**
  59976. * Gets the current class name
  59977. * @returns the class name
  59978. */
  59979. getClassName(): string;
  59980. /**
  59981. * Gets the left operand input component
  59982. */
  59983. get left(): NodeMaterialConnectionPoint;
  59984. /**
  59985. * Gets the right operand input component
  59986. */
  59987. get right(): NodeMaterialConnectionPoint;
  59988. /**
  59989. * Gets the output component
  59990. */
  59991. get output(): NodeMaterialConnectionPoint;
  59992. protected _buildBlock(state: NodeMaterialBuildState): this;
  59993. }
  59994. }
  59995. declare module BABYLON {
  59996. /**
  59997. * Block used to subtract 2 vectors
  59998. */
  59999. export class SubtractBlock extends NodeMaterialBlock {
  60000. /**
  60001. * Creates a new SubtractBlock
  60002. * @param name defines the block name
  60003. */
  60004. constructor(name: string);
  60005. /**
  60006. * Gets the current class name
  60007. * @returns the class name
  60008. */
  60009. getClassName(): string;
  60010. /**
  60011. * Gets the left operand input component
  60012. */
  60013. get left(): NodeMaterialConnectionPoint;
  60014. /**
  60015. * Gets the right operand input component
  60016. */
  60017. get right(): NodeMaterialConnectionPoint;
  60018. /**
  60019. * Gets the output component
  60020. */
  60021. get output(): NodeMaterialConnectionPoint;
  60022. protected _buildBlock(state: NodeMaterialBuildState): this;
  60023. }
  60024. }
  60025. declare module BABYLON {
  60026. /**
  60027. * Block used to step a value
  60028. */
  60029. export class StepBlock extends NodeMaterialBlock {
  60030. /**
  60031. * Creates a new StepBlock
  60032. * @param name defines the block name
  60033. */
  60034. constructor(name: string);
  60035. /**
  60036. * Gets the current class name
  60037. * @returns the class name
  60038. */
  60039. getClassName(): string;
  60040. /**
  60041. * Gets the value operand input component
  60042. */
  60043. get value(): NodeMaterialConnectionPoint;
  60044. /**
  60045. * Gets the edge operand input component
  60046. */
  60047. get edge(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the output component
  60050. */
  60051. get output(): NodeMaterialConnectionPoint;
  60052. protected _buildBlock(state: NodeMaterialBuildState): this;
  60053. }
  60054. }
  60055. declare module BABYLON {
  60056. /**
  60057. * Block used to get the opposite (1 - x) of a value
  60058. */
  60059. export class OneMinusBlock extends NodeMaterialBlock {
  60060. /**
  60061. * Creates a new OneMinusBlock
  60062. * @param name defines the block name
  60063. */
  60064. constructor(name: string);
  60065. /**
  60066. * Gets the current class name
  60067. * @returns the class name
  60068. */
  60069. getClassName(): string;
  60070. /**
  60071. * Gets the input component
  60072. */
  60073. get input(): NodeMaterialConnectionPoint;
  60074. /**
  60075. * Gets the output component
  60076. */
  60077. get output(): NodeMaterialConnectionPoint;
  60078. protected _buildBlock(state: NodeMaterialBuildState): this;
  60079. }
  60080. }
  60081. declare module BABYLON {
  60082. /**
  60083. * Block used to get the view direction
  60084. */
  60085. export class ViewDirectionBlock extends NodeMaterialBlock {
  60086. /**
  60087. * Creates a new ViewDirectionBlock
  60088. * @param name defines the block name
  60089. */
  60090. constructor(name: string);
  60091. /**
  60092. * Gets the current class name
  60093. * @returns the class name
  60094. */
  60095. getClassName(): string;
  60096. /**
  60097. * Gets the world position component
  60098. */
  60099. get worldPosition(): NodeMaterialConnectionPoint;
  60100. /**
  60101. * Gets the camera position component
  60102. */
  60103. get cameraPosition(): NodeMaterialConnectionPoint;
  60104. /**
  60105. * Gets the output component
  60106. */
  60107. get output(): NodeMaterialConnectionPoint;
  60108. autoConfigure(material: NodeMaterial): void;
  60109. protected _buildBlock(state: NodeMaterialBuildState): this;
  60110. }
  60111. }
  60112. declare module BABYLON {
  60113. /**
  60114. * Block used to compute fresnel value
  60115. */
  60116. export class FresnelBlock extends NodeMaterialBlock {
  60117. /**
  60118. * Create a new FresnelBlock
  60119. * @param name defines the block name
  60120. */
  60121. constructor(name: string);
  60122. /**
  60123. * Gets the current class name
  60124. * @returns the class name
  60125. */
  60126. getClassName(): string;
  60127. /**
  60128. * Gets the world normal input component
  60129. */
  60130. get worldNormal(): NodeMaterialConnectionPoint;
  60131. /**
  60132. * Gets the view direction input component
  60133. */
  60134. get viewDirection(): NodeMaterialConnectionPoint;
  60135. /**
  60136. * Gets the bias input component
  60137. */
  60138. get bias(): NodeMaterialConnectionPoint;
  60139. /**
  60140. * Gets the camera (or eye) position component
  60141. */
  60142. get power(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the fresnel output component
  60145. */
  60146. get fresnel(): NodeMaterialConnectionPoint;
  60147. autoConfigure(material: NodeMaterial): void;
  60148. protected _buildBlock(state: NodeMaterialBuildState): this;
  60149. }
  60150. }
  60151. declare module BABYLON {
  60152. /**
  60153. * Block used to get the max of 2 values
  60154. */
  60155. export class MaxBlock extends NodeMaterialBlock {
  60156. /**
  60157. * Creates a new MaxBlock
  60158. * @param name defines the block name
  60159. */
  60160. constructor(name: string);
  60161. /**
  60162. * Gets the current class name
  60163. * @returns the class name
  60164. */
  60165. getClassName(): string;
  60166. /**
  60167. * Gets the left operand input component
  60168. */
  60169. get left(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the right operand input component
  60172. */
  60173. get right(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the output component
  60176. */
  60177. get output(): NodeMaterialConnectionPoint;
  60178. protected _buildBlock(state: NodeMaterialBuildState): this;
  60179. }
  60180. }
  60181. declare module BABYLON {
  60182. /**
  60183. * Block used to get the min of 2 values
  60184. */
  60185. export class MinBlock extends NodeMaterialBlock {
  60186. /**
  60187. * Creates a new MinBlock
  60188. * @param name defines the block name
  60189. */
  60190. constructor(name: string);
  60191. /**
  60192. * Gets the current class name
  60193. * @returns the class name
  60194. */
  60195. getClassName(): string;
  60196. /**
  60197. * Gets the left operand input component
  60198. */
  60199. get left(): NodeMaterialConnectionPoint;
  60200. /**
  60201. * Gets the right operand input component
  60202. */
  60203. get right(): NodeMaterialConnectionPoint;
  60204. /**
  60205. * Gets the output component
  60206. */
  60207. get output(): NodeMaterialConnectionPoint;
  60208. protected _buildBlock(state: NodeMaterialBuildState): this;
  60209. }
  60210. }
  60211. declare module BABYLON {
  60212. /**
  60213. * Block used to get the distance between 2 values
  60214. */
  60215. export class DistanceBlock extends NodeMaterialBlock {
  60216. /**
  60217. * Creates a new DistanceBlock
  60218. * @param name defines the block name
  60219. */
  60220. constructor(name: string);
  60221. /**
  60222. * Gets the current class name
  60223. * @returns the class name
  60224. */
  60225. getClassName(): string;
  60226. /**
  60227. * Gets the left operand input component
  60228. */
  60229. get left(): NodeMaterialConnectionPoint;
  60230. /**
  60231. * Gets the right operand input component
  60232. */
  60233. get right(): NodeMaterialConnectionPoint;
  60234. /**
  60235. * Gets the output component
  60236. */
  60237. get output(): NodeMaterialConnectionPoint;
  60238. protected _buildBlock(state: NodeMaterialBuildState): this;
  60239. }
  60240. }
  60241. declare module BABYLON {
  60242. /**
  60243. * Block used to get the length of a vector
  60244. */
  60245. export class LengthBlock extends NodeMaterialBlock {
  60246. /**
  60247. * Creates a new LengthBlock
  60248. * @param name defines the block name
  60249. */
  60250. constructor(name: string);
  60251. /**
  60252. * Gets the current class name
  60253. * @returns the class name
  60254. */
  60255. getClassName(): string;
  60256. /**
  60257. * Gets the value input component
  60258. */
  60259. get value(): NodeMaterialConnectionPoint;
  60260. /**
  60261. * Gets the output component
  60262. */
  60263. get output(): NodeMaterialConnectionPoint;
  60264. protected _buildBlock(state: NodeMaterialBuildState): this;
  60265. }
  60266. }
  60267. declare module BABYLON {
  60268. /**
  60269. * Block used to get negative version of a value (i.e. x * -1)
  60270. */
  60271. export class NegateBlock extends NodeMaterialBlock {
  60272. /**
  60273. * Creates a new NegateBlock
  60274. * @param name defines the block name
  60275. */
  60276. constructor(name: string);
  60277. /**
  60278. * Gets the current class name
  60279. * @returns the class name
  60280. */
  60281. getClassName(): string;
  60282. /**
  60283. * Gets the value input component
  60284. */
  60285. get value(): NodeMaterialConnectionPoint;
  60286. /**
  60287. * Gets the output component
  60288. */
  60289. get output(): NodeMaterialConnectionPoint;
  60290. protected _buildBlock(state: NodeMaterialBuildState): this;
  60291. }
  60292. }
  60293. declare module BABYLON {
  60294. /**
  60295. * Block used to get the value of the first parameter raised to the power of the second
  60296. */
  60297. export class PowBlock extends NodeMaterialBlock {
  60298. /**
  60299. * Creates a new PowBlock
  60300. * @param name defines the block name
  60301. */
  60302. constructor(name: string);
  60303. /**
  60304. * Gets the current class name
  60305. * @returns the class name
  60306. */
  60307. getClassName(): string;
  60308. /**
  60309. * Gets the value operand input component
  60310. */
  60311. get value(): NodeMaterialConnectionPoint;
  60312. /**
  60313. * Gets the power operand input component
  60314. */
  60315. get power(): NodeMaterialConnectionPoint;
  60316. /**
  60317. * Gets the output component
  60318. */
  60319. get output(): NodeMaterialConnectionPoint;
  60320. protected _buildBlock(state: NodeMaterialBuildState): this;
  60321. }
  60322. }
  60323. declare module BABYLON {
  60324. /**
  60325. * Block used to get a random number
  60326. */
  60327. export class RandomNumberBlock extends NodeMaterialBlock {
  60328. /**
  60329. * Creates a new RandomNumberBlock
  60330. * @param name defines the block name
  60331. */
  60332. constructor(name: string);
  60333. /**
  60334. * Gets the current class name
  60335. * @returns the class name
  60336. */
  60337. getClassName(): string;
  60338. /**
  60339. * Gets the seed input component
  60340. */
  60341. get seed(): NodeMaterialConnectionPoint;
  60342. /**
  60343. * Gets the output component
  60344. */
  60345. get output(): NodeMaterialConnectionPoint;
  60346. protected _buildBlock(state: NodeMaterialBuildState): this;
  60347. }
  60348. }
  60349. declare module BABYLON {
  60350. /**
  60351. * Block used to compute arc tangent of 2 values
  60352. */
  60353. export class ArcTan2Block extends NodeMaterialBlock {
  60354. /**
  60355. * Creates a new ArcTan2Block
  60356. * @param name defines the block name
  60357. */
  60358. constructor(name: string);
  60359. /**
  60360. * Gets the current class name
  60361. * @returns the class name
  60362. */
  60363. getClassName(): string;
  60364. /**
  60365. * Gets the x operand input component
  60366. */
  60367. get x(): NodeMaterialConnectionPoint;
  60368. /**
  60369. * Gets the y operand input component
  60370. */
  60371. get y(): NodeMaterialConnectionPoint;
  60372. /**
  60373. * Gets the output component
  60374. */
  60375. get output(): NodeMaterialConnectionPoint;
  60376. protected _buildBlock(state: NodeMaterialBuildState): this;
  60377. }
  60378. }
  60379. declare module BABYLON {
  60380. /**
  60381. * Block used to smooth step a value
  60382. */
  60383. export class SmoothStepBlock extends NodeMaterialBlock {
  60384. /**
  60385. * Creates a new SmoothStepBlock
  60386. * @param name defines the block name
  60387. */
  60388. constructor(name: string);
  60389. /**
  60390. * Gets the current class name
  60391. * @returns the class name
  60392. */
  60393. getClassName(): string;
  60394. /**
  60395. * Gets the value operand input component
  60396. */
  60397. get value(): NodeMaterialConnectionPoint;
  60398. /**
  60399. * Gets the first edge operand input component
  60400. */
  60401. get edge0(): NodeMaterialConnectionPoint;
  60402. /**
  60403. * Gets the second edge operand input component
  60404. */
  60405. get edge1(): NodeMaterialConnectionPoint;
  60406. /**
  60407. * Gets the output component
  60408. */
  60409. get output(): NodeMaterialConnectionPoint;
  60410. protected _buildBlock(state: NodeMaterialBuildState): this;
  60411. }
  60412. }
  60413. declare module BABYLON {
  60414. /**
  60415. * Block used to get the reciprocal (1 / x) of a value
  60416. */
  60417. export class ReciprocalBlock extends NodeMaterialBlock {
  60418. /**
  60419. * Creates a new ReciprocalBlock
  60420. * @param name defines the block name
  60421. */
  60422. constructor(name: string);
  60423. /**
  60424. * Gets the current class name
  60425. * @returns the class name
  60426. */
  60427. getClassName(): string;
  60428. /**
  60429. * Gets the input component
  60430. */
  60431. get input(): NodeMaterialConnectionPoint;
  60432. /**
  60433. * Gets the output component
  60434. */
  60435. get output(): NodeMaterialConnectionPoint;
  60436. protected _buildBlock(state: NodeMaterialBuildState): this;
  60437. }
  60438. }
  60439. declare module BABYLON {
  60440. /**
  60441. * Block used to replace a color by another one
  60442. */
  60443. export class ReplaceColorBlock extends NodeMaterialBlock {
  60444. /**
  60445. * Creates a new ReplaceColorBlock
  60446. * @param name defines the block name
  60447. */
  60448. constructor(name: string);
  60449. /**
  60450. * Gets the current class name
  60451. * @returns the class name
  60452. */
  60453. getClassName(): string;
  60454. /**
  60455. * Gets the value input component
  60456. */
  60457. get value(): NodeMaterialConnectionPoint;
  60458. /**
  60459. * Gets the reference input component
  60460. */
  60461. get reference(): NodeMaterialConnectionPoint;
  60462. /**
  60463. * Gets the distance input component
  60464. */
  60465. get distance(): NodeMaterialConnectionPoint;
  60466. /**
  60467. * Gets the replacement input component
  60468. */
  60469. get replacement(): NodeMaterialConnectionPoint;
  60470. /**
  60471. * Gets the output component
  60472. */
  60473. get output(): NodeMaterialConnectionPoint;
  60474. protected _buildBlock(state: NodeMaterialBuildState): this;
  60475. }
  60476. }
  60477. declare module BABYLON {
  60478. /**
  60479. * Block used to posterize a value
  60480. * @see https://en.wikipedia.org/wiki/Posterization
  60481. */
  60482. export class PosterizeBlock extends NodeMaterialBlock {
  60483. /**
  60484. * Creates a new PosterizeBlock
  60485. * @param name defines the block name
  60486. */
  60487. constructor(name: string);
  60488. /**
  60489. * Gets the current class name
  60490. * @returns the class name
  60491. */
  60492. getClassName(): string;
  60493. /**
  60494. * Gets the value input component
  60495. */
  60496. get value(): NodeMaterialConnectionPoint;
  60497. /**
  60498. * Gets the steps input component
  60499. */
  60500. get steps(): NodeMaterialConnectionPoint;
  60501. /**
  60502. * Gets the output component
  60503. */
  60504. get output(): NodeMaterialConnectionPoint;
  60505. protected _buildBlock(state: NodeMaterialBuildState): this;
  60506. }
  60507. }
  60508. declare module BABYLON {
  60509. /**
  60510. * Operations supported by the Wave block
  60511. */
  60512. export enum WaveBlockKind {
  60513. /** SawTooth */
  60514. SawTooth = 0,
  60515. /** Square */
  60516. Square = 1,
  60517. /** Triangle */
  60518. Triangle = 2
  60519. }
  60520. /**
  60521. * Block used to apply wave operation to floats
  60522. */
  60523. export class WaveBlock extends NodeMaterialBlock {
  60524. /**
  60525. * Gets or sets the kibnd of wave to be applied by the block
  60526. */
  60527. kind: WaveBlockKind;
  60528. /**
  60529. * Creates a new WaveBlock
  60530. * @param name defines the block name
  60531. */
  60532. constructor(name: string);
  60533. /**
  60534. * Gets the current class name
  60535. * @returns the class name
  60536. */
  60537. getClassName(): string;
  60538. /**
  60539. * Gets the input component
  60540. */
  60541. get input(): NodeMaterialConnectionPoint;
  60542. /**
  60543. * Gets the output component
  60544. */
  60545. get output(): NodeMaterialConnectionPoint;
  60546. protected _buildBlock(state: NodeMaterialBuildState): this;
  60547. serialize(): any;
  60548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60549. }
  60550. }
  60551. declare module BABYLON {
  60552. /**
  60553. * Class used to store a color step for the GradientBlock
  60554. */
  60555. export class GradientBlockColorStep {
  60556. /**
  60557. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60558. */
  60559. step: number;
  60560. /**
  60561. * Gets or sets the color associated with this step
  60562. */
  60563. color: Color3;
  60564. /**
  60565. * Creates a new GradientBlockColorStep
  60566. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60567. * @param color defines the color associated with this step
  60568. */
  60569. constructor(
  60570. /**
  60571. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60572. */
  60573. step: number,
  60574. /**
  60575. * Gets or sets the color associated with this step
  60576. */
  60577. color: Color3);
  60578. }
  60579. /**
  60580. * Block used to return a color from a gradient based on an input value between 0 and 1
  60581. */
  60582. export class GradientBlock extends NodeMaterialBlock {
  60583. /**
  60584. * Gets or sets the list of color steps
  60585. */
  60586. colorSteps: GradientBlockColorStep[];
  60587. /**
  60588. * Creates a new GradientBlock
  60589. * @param name defines the block name
  60590. */
  60591. constructor(name: string);
  60592. /**
  60593. * Gets the current class name
  60594. * @returns the class name
  60595. */
  60596. getClassName(): string;
  60597. /**
  60598. * Gets the gradient input component
  60599. */
  60600. get gradient(): NodeMaterialConnectionPoint;
  60601. /**
  60602. * Gets the output component
  60603. */
  60604. get output(): NodeMaterialConnectionPoint;
  60605. private _writeColorConstant;
  60606. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60607. serialize(): any;
  60608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60609. protected _dumpPropertiesCode(): string;
  60610. }
  60611. }
  60612. declare module BABYLON {
  60613. /**
  60614. * Block used to normalize lerp between 2 values
  60615. */
  60616. export class NLerpBlock extends NodeMaterialBlock {
  60617. /**
  60618. * Creates a new NLerpBlock
  60619. * @param name defines the block name
  60620. */
  60621. constructor(name: string);
  60622. /**
  60623. * Gets the current class name
  60624. * @returns the class name
  60625. */
  60626. getClassName(): string;
  60627. /**
  60628. * Gets the left operand input component
  60629. */
  60630. get left(): NodeMaterialConnectionPoint;
  60631. /**
  60632. * Gets the right operand input component
  60633. */
  60634. get right(): NodeMaterialConnectionPoint;
  60635. /**
  60636. * Gets the gradient operand input component
  60637. */
  60638. get gradient(): NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the output component
  60641. */
  60642. get output(): NodeMaterialConnectionPoint;
  60643. protected _buildBlock(state: NodeMaterialBuildState): this;
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. /**
  60648. * block used to Generate a Worley Noise 3D Noise Pattern
  60649. */
  60650. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60651. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60652. manhattanDistance: boolean;
  60653. /**
  60654. * Creates a new WorleyNoise3DBlock
  60655. * @param name defines the block name
  60656. */
  60657. constructor(name: string);
  60658. /**
  60659. * Gets the current class name
  60660. * @returns the class name
  60661. */
  60662. getClassName(): string;
  60663. /**
  60664. * Gets the seed input component
  60665. */
  60666. get seed(): NodeMaterialConnectionPoint;
  60667. /**
  60668. * Gets the jitter input component
  60669. */
  60670. get jitter(): NodeMaterialConnectionPoint;
  60671. /**
  60672. * Gets the output component
  60673. */
  60674. get output(): NodeMaterialConnectionPoint;
  60675. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60676. /**
  60677. * Exposes the properties to the UI?
  60678. */
  60679. protected _dumpPropertiesCode(): string;
  60680. /**
  60681. * Exposes the properties to the Seralize?
  60682. */
  60683. serialize(): any;
  60684. /**
  60685. * Exposes the properties to the deseralize?
  60686. */
  60687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60688. }
  60689. }
  60690. declare module BABYLON {
  60691. /**
  60692. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60693. */
  60694. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60695. /**
  60696. * Creates a new SimplexPerlin3DBlock
  60697. * @param name defines the block name
  60698. */
  60699. constructor(name: string);
  60700. /**
  60701. * Gets the current class name
  60702. * @returns the class name
  60703. */
  60704. getClassName(): string;
  60705. /**
  60706. * Gets the seed operand input component
  60707. */
  60708. get seed(): NodeMaterialConnectionPoint;
  60709. /**
  60710. * Gets the output component
  60711. */
  60712. get output(): NodeMaterialConnectionPoint;
  60713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /**
  60718. * Block used to blend normals
  60719. */
  60720. export class NormalBlendBlock extends NodeMaterialBlock {
  60721. /**
  60722. * Creates a new NormalBlendBlock
  60723. * @param name defines the block name
  60724. */
  60725. constructor(name: string);
  60726. /**
  60727. * Gets the current class name
  60728. * @returns the class name
  60729. */
  60730. getClassName(): string;
  60731. /**
  60732. * Gets the first input component
  60733. */
  60734. get normalMap0(): NodeMaterialConnectionPoint;
  60735. /**
  60736. * Gets the second input component
  60737. */
  60738. get normalMap1(): NodeMaterialConnectionPoint;
  60739. /**
  60740. * Gets the output component
  60741. */
  60742. get output(): NodeMaterialConnectionPoint;
  60743. protected _buildBlock(state: NodeMaterialBuildState): this;
  60744. }
  60745. }
  60746. declare module BABYLON {
  60747. /**
  60748. * Block used to rotate a 2d vector by a given angle
  60749. */
  60750. export class Rotate2dBlock extends NodeMaterialBlock {
  60751. /**
  60752. * Creates a new Rotate2dBlock
  60753. * @param name defines the block name
  60754. */
  60755. constructor(name: string);
  60756. /**
  60757. * Gets the current class name
  60758. * @returns the class name
  60759. */
  60760. getClassName(): string;
  60761. /**
  60762. * Gets the input vector
  60763. */
  60764. get input(): NodeMaterialConnectionPoint;
  60765. /**
  60766. * Gets the input angle
  60767. */
  60768. get angle(): NodeMaterialConnectionPoint;
  60769. /**
  60770. * Gets the output component
  60771. */
  60772. get output(): NodeMaterialConnectionPoint;
  60773. autoConfigure(material: NodeMaterial): void;
  60774. protected _buildBlock(state: NodeMaterialBuildState): this;
  60775. }
  60776. }
  60777. declare module BABYLON {
  60778. /**
  60779. * Block used to get the reflected vector from a direction and a normal
  60780. */
  60781. export class ReflectBlock extends NodeMaterialBlock {
  60782. /**
  60783. * Creates a new ReflectBlock
  60784. * @param name defines the block name
  60785. */
  60786. constructor(name: string);
  60787. /**
  60788. * Gets the current class name
  60789. * @returns the class name
  60790. */
  60791. getClassName(): string;
  60792. /**
  60793. * Gets the incident component
  60794. */
  60795. get incident(): NodeMaterialConnectionPoint;
  60796. /**
  60797. * Gets the normal component
  60798. */
  60799. get normal(): NodeMaterialConnectionPoint;
  60800. /**
  60801. * Gets the output component
  60802. */
  60803. get output(): NodeMaterialConnectionPoint;
  60804. protected _buildBlock(state: NodeMaterialBuildState): this;
  60805. }
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * Block used to get the refracted vector from a direction and a normal
  60810. */
  60811. export class RefractBlock extends NodeMaterialBlock {
  60812. /**
  60813. * Creates a new RefractBlock
  60814. * @param name defines the block name
  60815. */
  60816. constructor(name: string);
  60817. /**
  60818. * Gets the current class name
  60819. * @returns the class name
  60820. */
  60821. getClassName(): string;
  60822. /**
  60823. * Gets the incident component
  60824. */
  60825. get incident(): NodeMaterialConnectionPoint;
  60826. /**
  60827. * Gets the normal component
  60828. */
  60829. get normal(): NodeMaterialConnectionPoint;
  60830. /**
  60831. * Gets the index of refraction component
  60832. */
  60833. get ior(): NodeMaterialConnectionPoint;
  60834. /**
  60835. * Gets the output component
  60836. */
  60837. get output(): NodeMaterialConnectionPoint;
  60838. protected _buildBlock(state: NodeMaterialBuildState): this;
  60839. }
  60840. }
  60841. declare module BABYLON {
  60842. /**
  60843. * Block used to desaturate a color
  60844. */
  60845. export class DesaturateBlock extends NodeMaterialBlock {
  60846. /**
  60847. * Creates a new DesaturateBlock
  60848. * @param name defines the block name
  60849. */
  60850. constructor(name: string);
  60851. /**
  60852. * Gets the current class name
  60853. * @returns the class name
  60854. */
  60855. getClassName(): string;
  60856. /**
  60857. * Gets the color operand input component
  60858. */
  60859. get color(): NodeMaterialConnectionPoint;
  60860. /**
  60861. * Gets the level operand input component
  60862. */
  60863. get level(): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Gets the output component
  60866. */
  60867. get output(): NodeMaterialConnectionPoint;
  60868. protected _buildBlock(state: NodeMaterialBuildState): this;
  60869. }
  60870. }
  60871. declare module BABYLON {
  60872. /**
  60873. * Effect Render Options
  60874. */
  60875. export interface IEffectRendererOptions {
  60876. /**
  60877. * Defines the vertices positions.
  60878. */
  60879. positions?: number[];
  60880. /**
  60881. * Defines the indices.
  60882. */
  60883. indices?: number[];
  60884. }
  60885. /**
  60886. * Helper class to render one or more effects.
  60887. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60888. */
  60889. export class EffectRenderer {
  60890. private engine;
  60891. private static _DefaultOptions;
  60892. private _vertexBuffers;
  60893. private _indexBuffer;
  60894. private _fullscreenViewport;
  60895. /**
  60896. * Creates an effect renderer
  60897. * @param engine the engine to use for rendering
  60898. * @param options defines the options of the effect renderer
  60899. */
  60900. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60901. /**
  60902. * Sets the current viewport in normalized coordinates 0-1
  60903. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60904. */
  60905. setViewport(viewport?: Viewport): void;
  60906. /**
  60907. * Binds the embedded attributes buffer to the effect.
  60908. * @param effect Defines the effect to bind the attributes for
  60909. */
  60910. bindBuffers(effect: Effect): void;
  60911. /**
  60912. * Sets the current effect wrapper to use during draw.
  60913. * The effect needs to be ready before calling this api.
  60914. * This also sets the default full screen position attribute.
  60915. * @param effectWrapper Defines the effect to draw with
  60916. */
  60917. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60918. /**
  60919. * Draws a full screen quad.
  60920. */
  60921. draw(): void;
  60922. private isRenderTargetTexture;
  60923. /**
  60924. * renders one or more effects to a specified texture
  60925. * @param effectWrapper the effect to renderer
  60926. * @param outputTexture texture to draw to, if null it will render to the screen.
  60927. */
  60928. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60929. /**
  60930. * Disposes of the effect renderer
  60931. */
  60932. dispose(): void;
  60933. }
  60934. /**
  60935. * Options to create an EffectWrapper
  60936. */
  60937. interface EffectWrapperCreationOptions {
  60938. /**
  60939. * Engine to use to create the effect
  60940. */
  60941. engine: ThinEngine;
  60942. /**
  60943. * Fragment shader for the effect
  60944. */
  60945. fragmentShader: string;
  60946. /**
  60947. * Vertex shader for the effect
  60948. */
  60949. vertexShader?: string;
  60950. /**
  60951. * Attributes to use in the shader
  60952. */
  60953. attributeNames?: Array<string>;
  60954. /**
  60955. * Uniforms to use in the shader
  60956. */
  60957. uniformNames?: Array<string>;
  60958. /**
  60959. * Texture sampler names to use in the shader
  60960. */
  60961. samplerNames?: Array<string>;
  60962. /**
  60963. * The friendly name of the effect displayed in Spector.
  60964. */
  60965. name?: string;
  60966. }
  60967. /**
  60968. * Wraps an effect to be used for rendering
  60969. */
  60970. export class EffectWrapper {
  60971. /**
  60972. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60973. */
  60974. onApplyObservable: Observable<{}>;
  60975. /**
  60976. * The underlying effect
  60977. */
  60978. effect: Effect;
  60979. /**
  60980. * Creates an effect to be renderer
  60981. * @param creationOptions options to create the effect
  60982. */
  60983. constructor(creationOptions: EffectWrapperCreationOptions);
  60984. /**
  60985. * Disposes of the effect wrapper
  60986. */
  60987. dispose(): void;
  60988. }
  60989. }
  60990. declare module BABYLON {
  60991. /**
  60992. * Helper class to push actions to a pool of workers.
  60993. */
  60994. export class WorkerPool implements IDisposable {
  60995. private _workerInfos;
  60996. private _pendingActions;
  60997. /**
  60998. * Constructor
  60999. * @param workers Array of workers to use for actions
  61000. */
  61001. constructor(workers: Array<Worker>);
  61002. /**
  61003. * Terminates all workers and clears any pending actions.
  61004. */
  61005. dispose(): void;
  61006. /**
  61007. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61008. * pended until a worker has completed its action.
  61009. * @param action The action to perform. Call onComplete when the action is complete.
  61010. */
  61011. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61012. private _execute;
  61013. }
  61014. }
  61015. declare module BABYLON {
  61016. /**
  61017. * Configuration for Draco compression
  61018. */
  61019. export interface IDracoCompressionConfiguration {
  61020. /**
  61021. * Configuration for the decoder.
  61022. */
  61023. decoder: {
  61024. /**
  61025. * The url to the WebAssembly module.
  61026. */
  61027. wasmUrl?: string;
  61028. /**
  61029. * The url to the WebAssembly binary.
  61030. */
  61031. wasmBinaryUrl?: string;
  61032. /**
  61033. * The url to the fallback JavaScript module.
  61034. */
  61035. fallbackUrl?: string;
  61036. };
  61037. }
  61038. /**
  61039. * Draco compression (https://google.github.io/draco/)
  61040. *
  61041. * This class wraps the Draco module.
  61042. *
  61043. * **Encoder**
  61044. *
  61045. * The encoder is not currently implemented.
  61046. *
  61047. * **Decoder**
  61048. *
  61049. * 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.
  61050. *
  61051. * To update the configuration, use the following code:
  61052. * ```javascript
  61053. * DracoCompression.Configuration = {
  61054. * decoder: {
  61055. * wasmUrl: "<url to the WebAssembly library>",
  61056. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61057. * fallbackUrl: "<url to the fallback JavaScript library>",
  61058. * }
  61059. * };
  61060. * ```
  61061. *
  61062. * 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.
  61063. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61064. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61065. *
  61066. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61067. * ```javascript
  61068. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61069. * ```
  61070. *
  61071. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61072. */
  61073. export class DracoCompression implements IDisposable {
  61074. private _workerPoolPromise?;
  61075. private _decoderModulePromise?;
  61076. /**
  61077. * The configuration. Defaults to the following urls:
  61078. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61079. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61080. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61081. */
  61082. static Configuration: IDracoCompressionConfiguration;
  61083. /**
  61084. * Returns true if the decoder configuration is available.
  61085. */
  61086. static get DecoderAvailable(): boolean;
  61087. /**
  61088. * Default number of workers to create when creating the draco compression object.
  61089. */
  61090. static DefaultNumWorkers: number;
  61091. private static GetDefaultNumWorkers;
  61092. private static _Default;
  61093. /**
  61094. * Default instance for the draco compression object.
  61095. */
  61096. static get Default(): DracoCompression;
  61097. /**
  61098. * Constructor
  61099. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61100. */
  61101. constructor(numWorkers?: number);
  61102. /**
  61103. * Stop all async operations and release resources.
  61104. */
  61105. dispose(): void;
  61106. /**
  61107. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61108. * @returns a promise that resolves when ready
  61109. */
  61110. whenReadyAsync(): Promise<void>;
  61111. /**
  61112. * Decode Draco compressed mesh data to vertex data.
  61113. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61114. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61115. * @returns A promise that resolves with the decoded vertex data
  61116. */
  61117. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61118. [kind: string]: number;
  61119. }): Promise<VertexData>;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Class for building Constructive Solid Geometry
  61125. */
  61126. export class CSG {
  61127. private polygons;
  61128. /**
  61129. * The world matrix
  61130. */
  61131. matrix: Matrix;
  61132. /**
  61133. * Stores the position
  61134. */
  61135. position: Vector3;
  61136. /**
  61137. * Stores the rotation
  61138. */
  61139. rotation: Vector3;
  61140. /**
  61141. * Stores the rotation quaternion
  61142. */
  61143. rotationQuaternion: Nullable<Quaternion>;
  61144. /**
  61145. * Stores the scaling vector
  61146. */
  61147. scaling: Vector3;
  61148. /**
  61149. * Convert the Mesh to CSG
  61150. * @param mesh The Mesh to convert to CSG
  61151. * @returns A new CSG from the Mesh
  61152. */
  61153. static FromMesh(mesh: Mesh): CSG;
  61154. /**
  61155. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61156. * @param polygons Polygons used to construct a CSG solid
  61157. */
  61158. private static FromPolygons;
  61159. /**
  61160. * Clones, or makes a deep copy, of the CSG
  61161. * @returns A new CSG
  61162. */
  61163. clone(): CSG;
  61164. /**
  61165. * Unions this CSG with another CSG
  61166. * @param csg The CSG to union against this CSG
  61167. * @returns The unioned CSG
  61168. */
  61169. union(csg: CSG): CSG;
  61170. /**
  61171. * Unions this CSG with another CSG in place
  61172. * @param csg The CSG to union against this CSG
  61173. */
  61174. unionInPlace(csg: CSG): void;
  61175. /**
  61176. * Subtracts this CSG with another CSG
  61177. * @param csg The CSG to subtract against this CSG
  61178. * @returns A new CSG
  61179. */
  61180. subtract(csg: CSG): CSG;
  61181. /**
  61182. * Subtracts this CSG with another CSG in place
  61183. * @param csg The CSG to subtact against this CSG
  61184. */
  61185. subtractInPlace(csg: CSG): void;
  61186. /**
  61187. * Intersect this CSG with another CSG
  61188. * @param csg The CSG to intersect against this CSG
  61189. * @returns A new CSG
  61190. */
  61191. intersect(csg: CSG): CSG;
  61192. /**
  61193. * Intersects this CSG with another CSG in place
  61194. * @param csg The CSG to intersect against this CSG
  61195. */
  61196. intersectInPlace(csg: CSG): void;
  61197. /**
  61198. * Return a new CSG solid with solid and empty space switched. This solid is
  61199. * not modified.
  61200. * @returns A new CSG solid with solid and empty space switched
  61201. */
  61202. inverse(): CSG;
  61203. /**
  61204. * Inverses the CSG in place
  61205. */
  61206. inverseInPlace(): void;
  61207. /**
  61208. * This is used to keep meshes transformations so they can be restored
  61209. * when we build back a Babylon Mesh
  61210. * NB : All CSG operations are performed in world coordinates
  61211. * @param csg The CSG to copy the transform attributes from
  61212. * @returns This CSG
  61213. */
  61214. copyTransformAttributes(csg: CSG): CSG;
  61215. /**
  61216. * Build Raw mesh from CSG
  61217. * Coordinates here are in world space
  61218. * @param name The name of the mesh geometry
  61219. * @param scene The Scene
  61220. * @param keepSubMeshes Specifies if the submeshes should be kept
  61221. * @returns A new Mesh
  61222. */
  61223. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61224. /**
  61225. * Build Mesh from CSG taking material and transforms into account
  61226. * @param name The name of the Mesh
  61227. * @param material The material of the Mesh
  61228. * @param scene The Scene
  61229. * @param keepSubMeshes Specifies if submeshes should be kept
  61230. * @returns The new Mesh
  61231. */
  61232. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61233. }
  61234. }
  61235. declare module BABYLON {
  61236. /**
  61237. * Class used to create a trail following a mesh
  61238. */
  61239. export class TrailMesh extends Mesh {
  61240. private _generator;
  61241. private _autoStart;
  61242. private _running;
  61243. private _diameter;
  61244. private _length;
  61245. private _sectionPolygonPointsCount;
  61246. private _sectionVectors;
  61247. private _sectionNormalVectors;
  61248. private _beforeRenderObserver;
  61249. /**
  61250. * @constructor
  61251. * @param name The value used by scene.getMeshByName() to do a lookup.
  61252. * @param generator The mesh or transform node to generate a trail.
  61253. * @param scene The scene to add this mesh to.
  61254. * @param diameter Diameter of trailing mesh. Default is 1.
  61255. * @param length Length of trailing mesh. Default is 60.
  61256. * @param autoStart Automatically start trailing mesh. Default true.
  61257. */
  61258. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61259. /**
  61260. * "TrailMesh"
  61261. * @returns "TrailMesh"
  61262. */
  61263. getClassName(): string;
  61264. private _createMesh;
  61265. /**
  61266. * Start trailing mesh.
  61267. */
  61268. start(): void;
  61269. /**
  61270. * Stop trailing mesh.
  61271. */
  61272. stop(): void;
  61273. /**
  61274. * Update trailing mesh geometry.
  61275. */
  61276. update(): void;
  61277. /**
  61278. * Returns a new TrailMesh object.
  61279. * @param name is a string, the name given to the new mesh
  61280. * @param newGenerator use new generator object for cloned trail mesh
  61281. * @returns a new mesh
  61282. */
  61283. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61284. /**
  61285. * Serializes this trail mesh
  61286. * @param serializationObject object to write serialization to
  61287. */
  61288. serialize(serializationObject: any): void;
  61289. /**
  61290. * Parses a serialized trail mesh
  61291. * @param parsedMesh the serialized mesh
  61292. * @param scene the scene to create the trail mesh in
  61293. * @returns the created trail mesh
  61294. */
  61295. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61296. }
  61297. }
  61298. declare module BABYLON {
  61299. /**
  61300. * Class containing static functions to help procedurally build meshes
  61301. */
  61302. export class TiledBoxBuilder {
  61303. /**
  61304. * Creates a box mesh
  61305. * 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)
  61306. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61308. * * 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
  61309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61310. * @param name defines the name of the mesh
  61311. * @param options defines the options used to create the mesh
  61312. * @param scene defines the hosting scene
  61313. * @returns the box mesh
  61314. */
  61315. static CreateTiledBox(name: string, options: {
  61316. pattern?: number;
  61317. width?: number;
  61318. height?: number;
  61319. depth?: number;
  61320. tileSize?: number;
  61321. tileWidth?: number;
  61322. tileHeight?: number;
  61323. alignHorizontal?: number;
  61324. alignVertical?: number;
  61325. faceUV?: Vector4[];
  61326. faceColors?: Color4[];
  61327. sideOrientation?: number;
  61328. updatable?: boolean;
  61329. }, scene?: Nullable<Scene>): Mesh;
  61330. }
  61331. }
  61332. declare module BABYLON {
  61333. /**
  61334. * Class containing static functions to help procedurally build meshes
  61335. */
  61336. export class TorusKnotBuilder {
  61337. /**
  61338. * Creates a torus knot mesh
  61339. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61340. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61341. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61342. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61344. * * 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
  61345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61346. * @param name defines the name of the mesh
  61347. * @param options defines the options used to create the mesh
  61348. * @param scene defines the hosting scene
  61349. * @returns the torus knot mesh
  61350. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61351. */
  61352. static CreateTorusKnot(name: string, options: {
  61353. radius?: number;
  61354. tube?: number;
  61355. radialSegments?: number;
  61356. tubularSegments?: number;
  61357. p?: number;
  61358. q?: number;
  61359. updatable?: boolean;
  61360. sideOrientation?: number;
  61361. frontUVs?: Vector4;
  61362. backUVs?: Vector4;
  61363. }, scene: any): Mesh;
  61364. }
  61365. }
  61366. declare module BABYLON {
  61367. /**
  61368. * Polygon
  61369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61370. */
  61371. export class Polygon {
  61372. /**
  61373. * Creates a rectangle
  61374. * @param xmin bottom X coord
  61375. * @param ymin bottom Y coord
  61376. * @param xmax top X coord
  61377. * @param ymax top Y coord
  61378. * @returns points that make the resulting rectation
  61379. */
  61380. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61381. /**
  61382. * Creates a circle
  61383. * @param radius radius of circle
  61384. * @param cx scale in x
  61385. * @param cy scale in y
  61386. * @param numberOfSides number of sides that make up the circle
  61387. * @returns points that make the resulting circle
  61388. */
  61389. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61390. /**
  61391. * Creates a polygon from input string
  61392. * @param input Input polygon data
  61393. * @returns the parsed points
  61394. */
  61395. static Parse(input: string): Vector2[];
  61396. /**
  61397. * Starts building a polygon from x and y coordinates
  61398. * @param x x coordinate
  61399. * @param y y coordinate
  61400. * @returns the started path2
  61401. */
  61402. static StartingAt(x: number, y: number): Path2;
  61403. }
  61404. /**
  61405. * Builds a polygon
  61406. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61407. */
  61408. export class PolygonMeshBuilder {
  61409. private _points;
  61410. private _outlinepoints;
  61411. private _holes;
  61412. private _name;
  61413. private _scene;
  61414. private _epoints;
  61415. private _eholes;
  61416. private _addToepoint;
  61417. /**
  61418. * Babylon reference to the earcut plugin.
  61419. */
  61420. bjsEarcut: any;
  61421. /**
  61422. * Creates a PolygonMeshBuilder
  61423. * @param name name of the builder
  61424. * @param contours Path of the polygon
  61425. * @param scene scene to add to when creating the mesh
  61426. * @param earcutInjection can be used to inject your own earcut reference
  61427. */
  61428. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61429. /**
  61430. * Adds a whole within the polygon
  61431. * @param hole Array of points defining the hole
  61432. * @returns this
  61433. */
  61434. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61435. /**
  61436. * Creates the polygon
  61437. * @param updatable If the mesh should be updatable
  61438. * @param depth The depth of the mesh created
  61439. * @returns the created mesh
  61440. */
  61441. build(updatable?: boolean, depth?: number): Mesh;
  61442. /**
  61443. * Creates the polygon
  61444. * @param depth The depth of the mesh created
  61445. * @returns the created VertexData
  61446. */
  61447. buildVertexData(depth?: number): VertexData;
  61448. /**
  61449. * Adds a side to the polygon
  61450. * @param positions points that make the polygon
  61451. * @param normals normals of the polygon
  61452. * @param uvs uvs of the polygon
  61453. * @param indices indices of the polygon
  61454. * @param bounds bounds of the polygon
  61455. * @param points points of the polygon
  61456. * @param depth depth of the polygon
  61457. * @param flip flip of the polygon
  61458. */
  61459. private addSide;
  61460. }
  61461. }
  61462. declare module BABYLON {
  61463. /**
  61464. * Class containing static functions to help procedurally build meshes
  61465. */
  61466. export class PolygonBuilder {
  61467. /**
  61468. * Creates a polygon mesh
  61469. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61470. * * 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
  61471. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61473. * * 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)
  61474. * * Remember you can only change the shape positions, not their number when updating a polygon
  61475. * @param name defines the name of the mesh
  61476. * @param options defines the options used to create the mesh
  61477. * @param scene defines the hosting scene
  61478. * @param earcutInjection can be used to inject your own earcut reference
  61479. * @returns the polygon mesh
  61480. */
  61481. static CreatePolygon(name: string, options: {
  61482. shape: Vector3[];
  61483. holes?: Vector3[][];
  61484. depth?: number;
  61485. faceUV?: Vector4[];
  61486. faceColors?: Color4[];
  61487. updatable?: boolean;
  61488. sideOrientation?: number;
  61489. frontUVs?: Vector4;
  61490. backUVs?: Vector4;
  61491. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61492. /**
  61493. * Creates an extruded polygon mesh, with depth in the Y direction.
  61494. * * 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)
  61495. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61496. * @param name defines the name of the mesh
  61497. * @param options defines the options used to create the mesh
  61498. * @param scene defines the hosting scene
  61499. * @param earcutInjection can be used to inject your own earcut reference
  61500. * @returns the polygon mesh
  61501. */
  61502. static ExtrudePolygon(name: string, options: {
  61503. shape: Vector3[];
  61504. holes?: Vector3[][];
  61505. depth?: number;
  61506. faceUV?: Vector4[];
  61507. faceColors?: Color4[];
  61508. updatable?: boolean;
  61509. sideOrientation?: number;
  61510. frontUVs?: Vector4;
  61511. backUVs?: Vector4;
  61512. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61513. }
  61514. }
  61515. declare module BABYLON {
  61516. /**
  61517. * Class containing static functions to help procedurally build meshes
  61518. */
  61519. export class LatheBuilder {
  61520. /**
  61521. * Creates lathe mesh.
  61522. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61523. * * 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
  61524. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61525. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61526. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61527. * * 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
  61528. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61529. * * 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
  61530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61531. * * 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
  61532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61534. * @param name defines the name of the mesh
  61535. * @param options defines the options used to create the mesh
  61536. * @param scene defines the hosting scene
  61537. * @returns the lathe mesh
  61538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61539. */
  61540. static CreateLathe(name: string, options: {
  61541. shape: Vector3[];
  61542. radius?: number;
  61543. tessellation?: number;
  61544. clip?: number;
  61545. arc?: number;
  61546. closed?: boolean;
  61547. updatable?: boolean;
  61548. sideOrientation?: number;
  61549. frontUVs?: Vector4;
  61550. backUVs?: Vector4;
  61551. cap?: number;
  61552. invertUV?: boolean;
  61553. }, scene?: Nullable<Scene>): Mesh;
  61554. }
  61555. }
  61556. declare module BABYLON {
  61557. /**
  61558. * Class containing static functions to help procedurally build meshes
  61559. */
  61560. export class TiledPlaneBuilder {
  61561. /**
  61562. * Creates a tiled plane mesh
  61563. * * The parameter `pattern` will, depending on value, do nothing or
  61564. * * * flip (reflect about central vertical) alternate tiles across and up
  61565. * * * flip every tile on alternate rows
  61566. * * * rotate (180 degs) alternate tiles across and up
  61567. * * * rotate every tile on alternate rows
  61568. * * * flip and rotate alternate tiles across and up
  61569. * * * flip and rotate every tile on alternate rows
  61570. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61571. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61572. * * 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
  61573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61574. * * 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)
  61575. * * 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)
  61576. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61577. * @param name defines the name of the mesh
  61578. * @param options defines the options used to create the mesh
  61579. * @param scene defines the hosting scene
  61580. * @returns the box mesh
  61581. */
  61582. static CreateTiledPlane(name: string, options: {
  61583. pattern?: number;
  61584. tileSize?: number;
  61585. tileWidth?: number;
  61586. tileHeight?: number;
  61587. size?: number;
  61588. width?: number;
  61589. height?: number;
  61590. alignHorizontal?: number;
  61591. alignVertical?: number;
  61592. sideOrientation?: number;
  61593. frontUVs?: Vector4;
  61594. backUVs?: Vector4;
  61595. updatable?: boolean;
  61596. }, scene?: Nullable<Scene>): Mesh;
  61597. }
  61598. }
  61599. declare module BABYLON {
  61600. /**
  61601. * Class containing static functions to help procedurally build meshes
  61602. */
  61603. export class TubeBuilder {
  61604. /**
  61605. * Creates a tube mesh.
  61606. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61607. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61608. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61609. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61610. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61611. * * 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)
  61612. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61613. * * 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
  61614. * * 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
  61615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61616. * * 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
  61617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61619. * @param name defines the name of the mesh
  61620. * @param options defines the options used to create the mesh
  61621. * @param scene defines the hosting scene
  61622. * @returns the tube mesh
  61623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61624. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61625. */
  61626. static CreateTube(name: string, options: {
  61627. path: Vector3[];
  61628. radius?: number;
  61629. tessellation?: number;
  61630. radiusFunction?: {
  61631. (i: number, distance: number): number;
  61632. };
  61633. cap?: number;
  61634. arc?: number;
  61635. updatable?: boolean;
  61636. sideOrientation?: number;
  61637. frontUVs?: Vector4;
  61638. backUVs?: Vector4;
  61639. instance?: Mesh;
  61640. invertUV?: boolean;
  61641. }, scene?: Nullable<Scene>): Mesh;
  61642. }
  61643. }
  61644. declare module BABYLON {
  61645. /**
  61646. * Class containing static functions to help procedurally build meshes
  61647. */
  61648. export class IcoSphereBuilder {
  61649. /**
  61650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61652. * * 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`)
  61653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61654. * * 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
  61655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61656. * * 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
  61657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61658. * @param name defines the name of the mesh
  61659. * @param options defines the options used to create the mesh
  61660. * @param scene defines the hosting scene
  61661. * @returns the icosahedron mesh
  61662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61663. */
  61664. static CreateIcoSphere(name: string, options: {
  61665. radius?: number;
  61666. radiusX?: number;
  61667. radiusY?: number;
  61668. radiusZ?: number;
  61669. flat?: boolean;
  61670. subdivisions?: number;
  61671. sideOrientation?: number;
  61672. frontUVs?: Vector4;
  61673. backUVs?: Vector4;
  61674. updatable?: boolean;
  61675. }, scene?: Nullable<Scene>): Mesh;
  61676. }
  61677. }
  61678. declare module BABYLON {
  61679. /**
  61680. * Class containing static functions to help procedurally build meshes
  61681. */
  61682. export class DecalBuilder {
  61683. /**
  61684. * Creates a decal mesh.
  61685. * 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
  61686. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61687. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61688. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61689. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61690. * @param name defines the name of the mesh
  61691. * @param sourceMesh defines the mesh where the decal must be applied
  61692. * @param options defines the options used to create the mesh
  61693. * @param scene defines the hosting scene
  61694. * @returns the decal mesh
  61695. * @see https://doc.babylonjs.com/how_to/decals
  61696. */
  61697. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61698. position?: Vector3;
  61699. normal?: Vector3;
  61700. size?: Vector3;
  61701. angle?: number;
  61702. }): Mesh;
  61703. }
  61704. }
  61705. declare module BABYLON {
  61706. /**
  61707. * Class containing static functions to help procedurally build meshes
  61708. */
  61709. export class MeshBuilder {
  61710. /**
  61711. * Creates a box mesh
  61712. * * The parameter `size` sets the size (float) of each box side (default 1)
  61713. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61714. * * 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)
  61715. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61717. * * 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
  61718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61719. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61720. * @param name defines the name of the mesh
  61721. * @param options defines the options used to create the mesh
  61722. * @param scene defines the hosting scene
  61723. * @returns the box mesh
  61724. */
  61725. static CreateBox(name: string, options: {
  61726. size?: number;
  61727. width?: number;
  61728. height?: number;
  61729. depth?: number;
  61730. faceUV?: Vector4[];
  61731. faceColors?: Color4[];
  61732. sideOrientation?: number;
  61733. frontUVs?: Vector4;
  61734. backUVs?: Vector4;
  61735. wrap?: boolean;
  61736. topBaseAt?: number;
  61737. bottomBaseAt?: number;
  61738. updatable?: boolean;
  61739. }, scene?: Nullable<Scene>): Mesh;
  61740. /**
  61741. * Creates a tiled box mesh
  61742. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61744. * @param name defines the name of the mesh
  61745. * @param options defines the options used to create the mesh
  61746. * @param scene defines the hosting scene
  61747. * @returns the tiled box mesh
  61748. */
  61749. static CreateTiledBox(name: string, options: {
  61750. pattern?: number;
  61751. size?: number;
  61752. width?: number;
  61753. height?: number;
  61754. depth: number;
  61755. tileSize?: number;
  61756. tileWidth?: number;
  61757. tileHeight?: number;
  61758. faceUV?: Vector4[];
  61759. faceColors?: Color4[];
  61760. alignHorizontal?: number;
  61761. alignVertical?: number;
  61762. sideOrientation?: number;
  61763. updatable?: boolean;
  61764. }, scene?: Nullable<Scene>): Mesh;
  61765. /**
  61766. * Creates a sphere mesh
  61767. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61768. * * 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`)
  61769. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61770. * * 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
  61771. * * 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)
  61772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61773. * * 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
  61774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61775. * @param name defines the name of the mesh
  61776. * @param options defines the options used to create the mesh
  61777. * @param scene defines the hosting scene
  61778. * @returns the sphere mesh
  61779. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61780. */
  61781. static CreateSphere(name: string, options: {
  61782. segments?: number;
  61783. diameter?: number;
  61784. diameterX?: number;
  61785. diameterY?: number;
  61786. diameterZ?: number;
  61787. arc?: number;
  61788. slice?: number;
  61789. sideOrientation?: number;
  61790. frontUVs?: Vector4;
  61791. backUVs?: Vector4;
  61792. updatable?: boolean;
  61793. }, scene?: Nullable<Scene>): Mesh;
  61794. /**
  61795. * Creates a plane polygonal mesh. By default, this is a disc
  61796. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61797. * * 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
  61798. * * 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
  61799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61800. * * 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
  61801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61802. * @param name defines the name of the mesh
  61803. * @param options defines the options used to create the mesh
  61804. * @param scene defines the hosting scene
  61805. * @returns the plane polygonal mesh
  61806. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61807. */
  61808. static CreateDisc(name: string, options: {
  61809. radius?: number;
  61810. tessellation?: number;
  61811. arc?: number;
  61812. updatable?: boolean;
  61813. sideOrientation?: number;
  61814. frontUVs?: Vector4;
  61815. backUVs?: Vector4;
  61816. }, scene?: Nullable<Scene>): Mesh;
  61817. /**
  61818. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61819. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61820. * * 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`)
  61821. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61822. * * 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
  61823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61824. * * 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
  61825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61826. * @param name defines the name of the mesh
  61827. * @param options defines the options used to create the mesh
  61828. * @param scene defines the hosting scene
  61829. * @returns the icosahedron mesh
  61830. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61831. */
  61832. static CreateIcoSphere(name: string, options: {
  61833. radius?: number;
  61834. radiusX?: number;
  61835. radiusY?: number;
  61836. radiusZ?: number;
  61837. flat?: boolean;
  61838. subdivisions?: number;
  61839. sideOrientation?: number;
  61840. frontUVs?: Vector4;
  61841. backUVs?: Vector4;
  61842. updatable?: boolean;
  61843. }, scene?: Nullable<Scene>): Mesh;
  61844. /**
  61845. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61846. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61847. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61848. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61849. * * 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
  61850. * * 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
  61851. * * 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
  61852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61853. * * 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
  61854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61855. * * 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
  61856. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61857. * * 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
  61858. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61860. * @param name defines the name of the mesh
  61861. * @param options defines the options used to create the mesh
  61862. * @param scene defines the hosting scene
  61863. * @returns the ribbon mesh
  61864. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61866. */
  61867. static CreateRibbon(name: string, options: {
  61868. pathArray: Vector3[][];
  61869. closeArray?: boolean;
  61870. closePath?: boolean;
  61871. offset?: number;
  61872. updatable?: boolean;
  61873. sideOrientation?: number;
  61874. frontUVs?: Vector4;
  61875. backUVs?: Vector4;
  61876. instance?: Mesh;
  61877. invertUV?: boolean;
  61878. uvs?: Vector2[];
  61879. colors?: Color4[];
  61880. }, scene?: Nullable<Scene>): Mesh;
  61881. /**
  61882. * Creates a cylinder or a cone mesh
  61883. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61884. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61885. * * 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.
  61886. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61887. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61888. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61889. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61890. * * 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).
  61891. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61892. * * 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).
  61893. * * 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
  61894. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61895. * * 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
  61896. * * 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.
  61897. * * If `enclose` is false, a ring surface is one element.
  61898. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61899. * * 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
  61900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61901. * * 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
  61902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61903. * @param name defines the name of the mesh
  61904. * @param options defines the options used to create the mesh
  61905. * @param scene defines the hosting scene
  61906. * @returns the cylinder mesh
  61907. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61908. */
  61909. static CreateCylinder(name: string, options: {
  61910. height?: number;
  61911. diameterTop?: number;
  61912. diameterBottom?: number;
  61913. diameter?: number;
  61914. tessellation?: number;
  61915. subdivisions?: number;
  61916. arc?: number;
  61917. faceColors?: Color4[];
  61918. faceUV?: Vector4[];
  61919. updatable?: boolean;
  61920. hasRings?: boolean;
  61921. enclose?: boolean;
  61922. cap?: number;
  61923. sideOrientation?: number;
  61924. frontUVs?: Vector4;
  61925. backUVs?: Vector4;
  61926. }, scene?: Nullable<Scene>): Mesh;
  61927. /**
  61928. * Creates a torus mesh
  61929. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61930. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61931. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61933. * * 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
  61934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61935. * @param name defines the name of the mesh
  61936. * @param options defines the options used to create the mesh
  61937. * @param scene defines the hosting scene
  61938. * @returns the torus mesh
  61939. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61940. */
  61941. static CreateTorus(name: string, options: {
  61942. diameter?: number;
  61943. thickness?: number;
  61944. tessellation?: number;
  61945. updatable?: boolean;
  61946. sideOrientation?: number;
  61947. frontUVs?: Vector4;
  61948. backUVs?: Vector4;
  61949. }, scene?: Nullable<Scene>): Mesh;
  61950. /**
  61951. * Creates a torus knot mesh
  61952. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61953. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61954. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61955. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61957. * * 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
  61958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61959. * @param name defines the name of the mesh
  61960. * @param options defines the options used to create the mesh
  61961. * @param scene defines the hosting scene
  61962. * @returns the torus knot mesh
  61963. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61964. */
  61965. static CreateTorusKnot(name: string, options: {
  61966. radius?: number;
  61967. tube?: number;
  61968. radialSegments?: number;
  61969. tubularSegments?: number;
  61970. p?: number;
  61971. q?: number;
  61972. updatable?: boolean;
  61973. sideOrientation?: number;
  61974. frontUVs?: Vector4;
  61975. backUVs?: Vector4;
  61976. }, scene?: Nullable<Scene>): Mesh;
  61977. /**
  61978. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61979. * * 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
  61980. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61981. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61982. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61983. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61984. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61985. * * 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
  61986. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61989. * @param name defines the name of the new line system
  61990. * @param options defines the options used to create the line system
  61991. * @param scene defines the hosting scene
  61992. * @returns a new line system mesh
  61993. */
  61994. static CreateLineSystem(name: string, options: {
  61995. lines: Vector3[][];
  61996. updatable?: boolean;
  61997. instance?: Nullable<LinesMesh>;
  61998. colors?: Nullable<Color4[][]>;
  61999. useVertexAlpha?: boolean;
  62000. }, scene: Nullable<Scene>): LinesMesh;
  62001. /**
  62002. * Creates a line mesh
  62003. * 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
  62004. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62005. * * The parameter `points` is an array successive Vector3
  62006. * * 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
  62007. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62008. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62009. * * When updating an instance, remember that only point positions can change, not the number of points
  62010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62012. * @param name defines the name of the new line system
  62013. * @param options defines the options used to create the line system
  62014. * @param scene defines the hosting scene
  62015. * @returns a new line mesh
  62016. */
  62017. static CreateLines(name: string, options: {
  62018. points: Vector3[];
  62019. updatable?: boolean;
  62020. instance?: Nullable<LinesMesh>;
  62021. colors?: Color4[];
  62022. useVertexAlpha?: boolean;
  62023. }, scene?: Nullable<Scene>): LinesMesh;
  62024. /**
  62025. * Creates a dashed line mesh
  62026. * * 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
  62027. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62028. * * The parameter `points` is an array successive Vector3
  62029. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62030. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62031. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62032. * * 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
  62033. * * When updating an instance, remember that only point positions can change, not the number of points
  62034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62035. * @param name defines the name of the mesh
  62036. * @param options defines the options used to create the mesh
  62037. * @param scene defines the hosting scene
  62038. * @returns the dashed line mesh
  62039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62040. */
  62041. static CreateDashedLines(name: string, options: {
  62042. points: Vector3[];
  62043. dashSize?: number;
  62044. gapSize?: number;
  62045. dashNb?: number;
  62046. updatable?: boolean;
  62047. instance?: LinesMesh;
  62048. }, scene?: Nullable<Scene>): LinesMesh;
  62049. /**
  62050. * 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.
  62051. * * 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.
  62052. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62053. * * 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.
  62054. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62055. * * 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
  62056. * * 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
  62057. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62059. * * 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
  62060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62062. * @param name defines the name of the mesh
  62063. * @param options defines the options used to create the mesh
  62064. * @param scene defines the hosting scene
  62065. * @returns the extruded shape mesh
  62066. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62068. */
  62069. static ExtrudeShape(name: string, options: {
  62070. shape: Vector3[];
  62071. path: Vector3[];
  62072. scale?: number;
  62073. rotation?: number;
  62074. cap?: number;
  62075. updatable?: boolean;
  62076. sideOrientation?: number;
  62077. frontUVs?: Vector4;
  62078. backUVs?: Vector4;
  62079. instance?: Mesh;
  62080. invertUV?: boolean;
  62081. }, scene?: Nullable<Scene>): Mesh;
  62082. /**
  62083. * Creates an custom extruded shape mesh.
  62084. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62085. * * 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.
  62086. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62087. * * 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
  62088. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62089. * * 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
  62090. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62091. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62092. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62093. * * 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
  62094. * * 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
  62095. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62097. * * 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
  62098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62100. * @param name defines the name of the mesh
  62101. * @param options defines the options used to create the mesh
  62102. * @param scene defines the hosting scene
  62103. * @returns the custom extruded shape mesh
  62104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62105. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62107. */
  62108. static ExtrudeShapeCustom(name: string, options: {
  62109. shape: Vector3[];
  62110. path: Vector3[];
  62111. scaleFunction?: any;
  62112. rotationFunction?: any;
  62113. ribbonCloseArray?: boolean;
  62114. ribbonClosePath?: boolean;
  62115. cap?: number;
  62116. updatable?: boolean;
  62117. sideOrientation?: number;
  62118. frontUVs?: Vector4;
  62119. backUVs?: Vector4;
  62120. instance?: Mesh;
  62121. invertUV?: boolean;
  62122. }, scene?: Nullable<Scene>): Mesh;
  62123. /**
  62124. * Creates lathe mesh.
  62125. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62126. * * 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
  62127. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62128. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62129. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62130. * * 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
  62131. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62132. * * 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
  62133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62134. * * 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
  62135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62137. * @param name defines the name of the mesh
  62138. * @param options defines the options used to create the mesh
  62139. * @param scene defines the hosting scene
  62140. * @returns the lathe mesh
  62141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62142. */
  62143. static CreateLathe(name: string, options: {
  62144. shape: Vector3[];
  62145. radius?: number;
  62146. tessellation?: number;
  62147. clip?: number;
  62148. arc?: number;
  62149. closed?: boolean;
  62150. updatable?: boolean;
  62151. sideOrientation?: number;
  62152. frontUVs?: Vector4;
  62153. backUVs?: Vector4;
  62154. cap?: number;
  62155. invertUV?: boolean;
  62156. }, scene?: Nullable<Scene>): Mesh;
  62157. /**
  62158. * Creates a tiled plane mesh
  62159. * * You can set a limited pattern arrangement with the tiles
  62160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62161. * * 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
  62162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62163. * @param name defines the name of the mesh
  62164. * @param options defines the options used to create the mesh
  62165. * @param scene defines the hosting scene
  62166. * @returns the plane mesh
  62167. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62168. */
  62169. static CreateTiledPlane(name: string, options: {
  62170. pattern?: number;
  62171. tileSize?: number;
  62172. tileWidth?: number;
  62173. tileHeight?: number;
  62174. size?: number;
  62175. width?: number;
  62176. height?: number;
  62177. alignHorizontal?: number;
  62178. alignVertical?: number;
  62179. sideOrientation?: number;
  62180. frontUVs?: Vector4;
  62181. backUVs?: Vector4;
  62182. updatable?: boolean;
  62183. }, scene?: Nullable<Scene>): Mesh;
  62184. /**
  62185. * Creates a plane mesh
  62186. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62187. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62188. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62190. * * 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
  62191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62192. * @param name defines the name of the mesh
  62193. * @param options defines the options used to create the mesh
  62194. * @param scene defines the hosting scene
  62195. * @returns the plane mesh
  62196. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62197. */
  62198. static CreatePlane(name: string, options: {
  62199. size?: number;
  62200. width?: number;
  62201. height?: number;
  62202. sideOrientation?: number;
  62203. frontUVs?: Vector4;
  62204. backUVs?: Vector4;
  62205. updatable?: boolean;
  62206. sourcePlane?: Plane;
  62207. }, scene?: Nullable<Scene>): Mesh;
  62208. /**
  62209. * Creates a ground mesh
  62210. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62211. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62213. * @param name defines the name of the mesh
  62214. * @param options defines the options used to create the mesh
  62215. * @param scene defines the hosting scene
  62216. * @returns the ground mesh
  62217. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62218. */
  62219. static CreateGround(name: string, options: {
  62220. width?: number;
  62221. height?: number;
  62222. subdivisions?: number;
  62223. subdivisionsX?: number;
  62224. subdivisionsY?: number;
  62225. updatable?: boolean;
  62226. }, scene?: Nullable<Scene>): Mesh;
  62227. /**
  62228. * Creates a tiled ground mesh
  62229. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62230. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62231. * * 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
  62232. * * 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
  62233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62234. * @param name defines the name of the mesh
  62235. * @param options defines the options used to create the mesh
  62236. * @param scene defines the hosting scene
  62237. * @returns the tiled ground mesh
  62238. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62239. */
  62240. static CreateTiledGround(name: string, options: {
  62241. xmin: number;
  62242. zmin: number;
  62243. xmax: number;
  62244. zmax: number;
  62245. subdivisions?: {
  62246. w: number;
  62247. h: number;
  62248. };
  62249. precision?: {
  62250. w: number;
  62251. h: number;
  62252. };
  62253. updatable?: boolean;
  62254. }, scene?: Nullable<Scene>): Mesh;
  62255. /**
  62256. * Creates a ground mesh from a height map
  62257. * * The parameter `url` sets the URL of the height map image resource.
  62258. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62259. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62260. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62261. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62262. * * 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.
  62263. * * 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).
  62264. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62266. * @param name defines the name of the mesh
  62267. * @param url defines the url to the height map
  62268. * @param options defines the options used to create the mesh
  62269. * @param scene defines the hosting scene
  62270. * @returns the ground mesh
  62271. * @see https://doc.babylonjs.com/babylon101/height_map
  62272. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62273. */
  62274. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62275. width?: number;
  62276. height?: number;
  62277. subdivisions?: number;
  62278. minHeight?: number;
  62279. maxHeight?: number;
  62280. colorFilter?: Color3;
  62281. alphaFilter?: number;
  62282. updatable?: boolean;
  62283. onReady?: (mesh: GroundMesh) => void;
  62284. }, scene?: Nullable<Scene>): GroundMesh;
  62285. /**
  62286. * Creates a polygon mesh
  62287. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62288. * * 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
  62289. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62291. * * 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)
  62292. * * Remember you can only change the shape positions, not their number when updating a polygon
  62293. * @param name defines the name of the mesh
  62294. * @param options defines the options used to create the mesh
  62295. * @param scene defines the hosting scene
  62296. * @param earcutInjection can be used to inject your own earcut reference
  62297. * @returns the polygon mesh
  62298. */
  62299. static CreatePolygon(name: string, options: {
  62300. shape: Vector3[];
  62301. holes?: Vector3[][];
  62302. depth?: number;
  62303. faceUV?: Vector4[];
  62304. faceColors?: Color4[];
  62305. updatable?: boolean;
  62306. sideOrientation?: number;
  62307. frontUVs?: Vector4;
  62308. backUVs?: Vector4;
  62309. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62310. /**
  62311. * Creates an extruded polygon mesh, with depth in the Y direction.
  62312. * * 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)
  62313. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62314. * @param name defines the name of the mesh
  62315. * @param options defines the options used to create the mesh
  62316. * @param scene defines the hosting scene
  62317. * @param earcutInjection can be used to inject your own earcut reference
  62318. * @returns the polygon mesh
  62319. */
  62320. static ExtrudePolygon(name: string, options: {
  62321. shape: Vector3[];
  62322. holes?: Vector3[][];
  62323. depth?: number;
  62324. faceUV?: Vector4[];
  62325. faceColors?: Color4[];
  62326. updatable?: boolean;
  62327. sideOrientation?: number;
  62328. frontUVs?: Vector4;
  62329. backUVs?: Vector4;
  62330. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62331. /**
  62332. * Creates a tube mesh.
  62333. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62334. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62335. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62336. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62337. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62338. * * 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)
  62339. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62340. * * 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
  62341. * * 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
  62342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62343. * * 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
  62344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62346. * @param name defines the name of the mesh
  62347. * @param options defines the options used to create the mesh
  62348. * @param scene defines the hosting scene
  62349. * @returns the tube mesh
  62350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62351. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62352. */
  62353. static CreateTube(name: string, options: {
  62354. path: Vector3[];
  62355. radius?: number;
  62356. tessellation?: number;
  62357. radiusFunction?: {
  62358. (i: number, distance: number): number;
  62359. };
  62360. cap?: number;
  62361. arc?: number;
  62362. updatable?: boolean;
  62363. sideOrientation?: number;
  62364. frontUVs?: Vector4;
  62365. backUVs?: Vector4;
  62366. instance?: Mesh;
  62367. invertUV?: boolean;
  62368. }, scene?: Nullable<Scene>): Mesh;
  62369. /**
  62370. * Creates a polyhedron mesh
  62371. * * 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
  62372. * * The parameter `size` (positive float, default 1) sets the polygon size
  62373. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62374. * * 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`
  62375. * * 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
  62376. * * 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)`)
  62377. * * 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
  62378. * * 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
  62379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62380. * * 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
  62381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62382. * @param name defines the name of the mesh
  62383. * @param options defines the options used to create the mesh
  62384. * @param scene defines the hosting scene
  62385. * @returns the polyhedron mesh
  62386. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62387. */
  62388. static CreatePolyhedron(name: string, options: {
  62389. type?: number;
  62390. size?: number;
  62391. sizeX?: number;
  62392. sizeY?: number;
  62393. sizeZ?: number;
  62394. custom?: any;
  62395. faceUV?: Vector4[];
  62396. faceColors?: Color4[];
  62397. flat?: boolean;
  62398. updatable?: boolean;
  62399. sideOrientation?: number;
  62400. frontUVs?: Vector4;
  62401. backUVs?: Vector4;
  62402. }, scene?: Nullable<Scene>): Mesh;
  62403. /**
  62404. * Creates a decal mesh.
  62405. * 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
  62406. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62407. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62408. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62409. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62410. * @param name defines the name of the mesh
  62411. * @param sourceMesh defines the mesh where the decal must be applied
  62412. * @param options defines the options used to create the mesh
  62413. * @param scene defines the hosting scene
  62414. * @returns the decal mesh
  62415. * @see https://doc.babylonjs.com/how_to/decals
  62416. */
  62417. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62418. position?: Vector3;
  62419. normal?: Vector3;
  62420. size?: Vector3;
  62421. angle?: number;
  62422. }): Mesh;
  62423. }
  62424. }
  62425. declare module BABYLON {
  62426. /**
  62427. * A simplifier interface for future simplification implementations
  62428. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62429. */
  62430. export interface ISimplifier {
  62431. /**
  62432. * Simplification of a given mesh according to the given settings.
  62433. * Since this requires computation, it is assumed that the function runs async.
  62434. * @param settings The settings of the simplification, including quality and distance
  62435. * @param successCallback A callback that will be called after the mesh was simplified.
  62436. * @param errorCallback in case of an error, this callback will be called. optional.
  62437. */
  62438. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62439. }
  62440. /**
  62441. * Expected simplification settings.
  62442. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62443. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62444. */
  62445. export interface ISimplificationSettings {
  62446. /**
  62447. * Gets or sets the expected quality
  62448. */
  62449. quality: number;
  62450. /**
  62451. * Gets or sets the distance when this optimized version should be used
  62452. */
  62453. distance: number;
  62454. /**
  62455. * Gets an already optimized mesh
  62456. */
  62457. optimizeMesh?: boolean;
  62458. }
  62459. /**
  62460. * Class used to specify simplification options
  62461. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62462. */
  62463. export class SimplificationSettings implements ISimplificationSettings {
  62464. /** expected quality */
  62465. quality: number;
  62466. /** distance when this optimized version should be used */
  62467. distance: number;
  62468. /** already optimized mesh */
  62469. optimizeMesh?: boolean | undefined;
  62470. /**
  62471. * Creates a SimplificationSettings
  62472. * @param quality expected quality
  62473. * @param distance distance when this optimized version should be used
  62474. * @param optimizeMesh already optimized mesh
  62475. */
  62476. constructor(
  62477. /** expected quality */
  62478. quality: number,
  62479. /** distance when this optimized version should be used */
  62480. distance: number,
  62481. /** already optimized mesh */
  62482. optimizeMesh?: boolean | undefined);
  62483. }
  62484. /**
  62485. * Interface used to define a simplification task
  62486. */
  62487. export interface ISimplificationTask {
  62488. /**
  62489. * Array of settings
  62490. */
  62491. settings: Array<ISimplificationSettings>;
  62492. /**
  62493. * Simplification type
  62494. */
  62495. simplificationType: SimplificationType;
  62496. /**
  62497. * Mesh to simplify
  62498. */
  62499. mesh: Mesh;
  62500. /**
  62501. * Callback called on success
  62502. */
  62503. successCallback?: () => void;
  62504. /**
  62505. * Defines if parallel processing can be used
  62506. */
  62507. parallelProcessing: boolean;
  62508. }
  62509. /**
  62510. * Queue used to order the simplification tasks
  62511. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62512. */
  62513. export class SimplificationQueue {
  62514. private _simplificationArray;
  62515. /**
  62516. * Gets a boolean indicating that the process is still running
  62517. */
  62518. running: boolean;
  62519. /**
  62520. * Creates a new queue
  62521. */
  62522. constructor();
  62523. /**
  62524. * Adds a new simplification task
  62525. * @param task defines a task to add
  62526. */
  62527. addTask(task: ISimplificationTask): void;
  62528. /**
  62529. * Execute next task
  62530. */
  62531. executeNext(): void;
  62532. /**
  62533. * Execute a simplification task
  62534. * @param task defines the task to run
  62535. */
  62536. runSimplification(task: ISimplificationTask): void;
  62537. private getSimplifier;
  62538. }
  62539. /**
  62540. * The implemented types of simplification
  62541. * At the moment only Quadratic Error Decimation is implemented
  62542. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62543. */
  62544. export enum SimplificationType {
  62545. /** Quadratic error decimation */
  62546. QUADRATIC = 0
  62547. }
  62548. /**
  62549. * An implementation of the Quadratic Error simplification algorithm.
  62550. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62551. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62552. * @author RaananW
  62553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62554. */
  62555. export class QuadraticErrorSimplification implements ISimplifier {
  62556. private _mesh;
  62557. private triangles;
  62558. private vertices;
  62559. private references;
  62560. private _reconstructedMesh;
  62561. /** Gets or sets the number pf sync interations */
  62562. syncIterations: number;
  62563. /** Gets or sets the aggressiveness of the simplifier */
  62564. aggressiveness: number;
  62565. /** Gets or sets the number of allowed iterations for decimation */
  62566. decimationIterations: number;
  62567. /** Gets or sets the espilon to use for bounding box computation */
  62568. boundingBoxEpsilon: number;
  62569. /**
  62570. * Creates a new QuadraticErrorSimplification
  62571. * @param _mesh defines the target mesh
  62572. */
  62573. constructor(_mesh: Mesh);
  62574. /**
  62575. * Simplification of a given mesh according to the given settings.
  62576. * Since this requires computation, it is assumed that the function runs async.
  62577. * @param settings The settings of the simplification, including quality and distance
  62578. * @param successCallback A callback that will be called after the mesh was simplified.
  62579. */
  62580. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62581. private runDecimation;
  62582. private initWithMesh;
  62583. private init;
  62584. private reconstructMesh;
  62585. private initDecimatedMesh;
  62586. private isFlipped;
  62587. private updateTriangles;
  62588. private identifyBorder;
  62589. private updateMesh;
  62590. private vertexError;
  62591. private calculateError;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. interface Scene {
  62596. /** @hidden (Backing field) */
  62597. _simplificationQueue: SimplificationQueue;
  62598. /**
  62599. * Gets or sets the simplification queue attached to the scene
  62600. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62601. */
  62602. simplificationQueue: SimplificationQueue;
  62603. }
  62604. interface Mesh {
  62605. /**
  62606. * Simplify the mesh according to the given array of settings.
  62607. * Function will return immediately and will simplify async
  62608. * @param settings a collection of simplification settings
  62609. * @param parallelProcessing should all levels calculate parallel or one after the other
  62610. * @param simplificationType the type of simplification to run
  62611. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62612. * @returns the current mesh
  62613. */
  62614. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62615. }
  62616. /**
  62617. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62618. * created in a scene
  62619. */
  62620. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62621. /**
  62622. * The component name helpfull to identify the component in the list of scene components.
  62623. */
  62624. readonly name: string;
  62625. /**
  62626. * The scene the component belongs to.
  62627. */
  62628. scene: Scene;
  62629. /**
  62630. * Creates a new instance of the component for the given scene
  62631. * @param scene Defines the scene to register the component in
  62632. */
  62633. constructor(scene: Scene);
  62634. /**
  62635. * Registers the component in a given scene
  62636. */
  62637. register(): void;
  62638. /**
  62639. * Rebuilds the elements related to this component in case of
  62640. * context lost for instance.
  62641. */
  62642. rebuild(): void;
  62643. /**
  62644. * Disposes the component and the associated ressources
  62645. */
  62646. dispose(): void;
  62647. private _beforeCameraUpdate;
  62648. }
  62649. }
  62650. declare module BABYLON {
  62651. /**
  62652. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62653. */
  62654. export interface INavigationEnginePlugin {
  62655. /**
  62656. * plugin name
  62657. */
  62658. name: string;
  62659. /**
  62660. * Creates a navigation mesh
  62661. * @param meshes array of all the geometry used to compute the navigatio mesh
  62662. * @param parameters bunch of parameters used to filter geometry
  62663. */
  62664. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62665. /**
  62666. * Create a navigation mesh debug mesh
  62667. * @param scene is where the mesh will be added
  62668. * @returns debug display mesh
  62669. */
  62670. createDebugNavMesh(scene: Scene): Mesh;
  62671. /**
  62672. * Get a navigation mesh constrained position, closest to the parameter position
  62673. * @param position world position
  62674. * @returns the closest point to position constrained by the navigation mesh
  62675. */
  62676. getClosestPoint(position: Vector3): Vector3;
  62677. /**
  62678. * Get a navigation mesh constrained position, closest to the parameter position
  62679. * @param position world position
  62680. * @param result output the closest point to position constrained by the navigation mesh
  62681. */
  62682. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62683. /**
  62684. * Get a navigation mesh constrained position, within a particular radius
  62685. * @param position world position
  62686. * @param maxRadius the maximum distance to the constrained world position
  62687. * @returns the closest point to position constrained by the navigation mesh
  62688. */
  62689. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62690. /**
  62691. * Get a navigation mesh constrained position, within a particular radius
  62692. * @param position world position
  62693. * @param maxRadius the maximum distance to the constrained world position
  62694. * @param result output the closest point to position constrained by the navigation mesh
  62695. */
  62696. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62697. /**
  62698. * Compute the final position from a segment made of destination-position
  62699. * @param position world position
  62700. * @param destination world position
  62701. * @returns the resulting point along the navmesh
  62702. */
  62703. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62704. /**
  62705. * Compute the final position from a segment made of destination-position
  62706. * @param position world position
  62707. * @param destination world position
  62708. * @param result output the resulting point along the navmesh
  62709. */
  62710. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62711. /**
  62712. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62713. * @param start world position
  62714. * @param end world position
  62715. * @returns array containing world position composing the path
  62716. */
  62717. computePath(start: Vector3, end: Vector3): Vector3[];
  62718. /**
  62719. * If this plugin is supported
  62720. * @returns true if plugin is supported
  62721. */
  62722. isSupported(): boolean;
  62723. /**
  62724. * Create a new Crowd so you can add agents
  62725. * @param maxAgents the maximum agent count in the crowd
  62726. * @param maxAgentRadius the maximum radius an agent can have
  62727. * @param scene to attach the crowd to
  62728. * @returns the crowd you can add agents to
  62729. */
  62730. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62731. /**
  62732. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62733. * The queries will try to find a solution within those bounds
  62734. * default is (1,1,1)
  62735. * @param extent x,y,z value that define the extent around the queries point of reference
  62736. */
  62737. setDefaultQueryExtent(extent: Vector3): void;
  62738. /**
  62739. * Get the Bounding box extent specified by setDefaultQueryExtent
  62740. * @returns the box extent values
  62741. */
  62742. getDefaultQueryExtent(): Vector3;
  62743. /**
  62744. * build the navmesh from a previously saved state using getNavmeshData
  62745. * @param data the Uint8Array returned by getNavmeshData
  62746. */
  62747. buildFromNavmeshData(data: Uint8Array): void;
  62748. /**
  62749. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62750. * @returns data the Uint8Array that can be saved and reused
  62751. */
  62752. getNavmeshData(): Uint8Array;
  62753. /**
  62754. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62755. * @param result output the box extent values
  62756. */
  62757. getDefaultQueryExtentToRef(result: Vector3): void;
  62758. /**
  62759. * Release all resources
  62760. */
  62761. dispose(): void;
  62762. }
  62763. /**
  62764. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62765. */
  62766. export interface ICrowd {
  62767. /**
  62768. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62769. * You can attach anything to that node. The node position is updated in the scene update tick.
  62770. * @param pos world position that will be constrained by the navigation mesh
  62771. * @param parameters agent parameters
  62772. * @param transform hooked to the agent that will be update by the scene
  62773. * @returns agent index
  62774. */
  62775. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62776. /**
  62777. * Returns the agent position in world space
  62778. * @param index agent index returned by addAgent
  62779. * @returns world space position
  62780. */
  62781. getAgentPosition(index: number): Vector3;
  62782. /**
  62783. * Gets the agent position result in world space
  62784. * @param index agent index returned by addAgent
  62785. * @param result output world space position
  62786. */
  62787. getAgentPositionToRef(index: number, result: Vector3): void;
  62788. /**
  62789. * Gets the agent velocity in world space
  62790. * @param index agent index returned by addAgent
  62791. * @returns world space velocity
  62792. */
  62793. getAgentVelocity(index: number): Vector3;
  62794. /**
  62795. * Gets the agent velocity result in world space
  62796. * @param index agent index returned by addAgent
  62797. * @param result output world space velocity
  62798. */
  62799. getAgentVelocityToRef(index: number, result: Vector3): void;
  62800. /**
  62801. * remove a particular agent previously created
  62802. * @param index agent index returned by addAgent
  62803. */
  62804. removeAgent(index: number): void;
  62805. /**
  62806. * get the list of all agents attached to this crowd
  62807. * @returns list of agent indices
  62808. */
  62809. getAgents(): number[];
  62810. /**
  62811. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62812. * @param deltaTime in seconds
  62813. */
  62814. update(deltaTime: number): void;
  62815. /**
  62816. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62817. * @param index agent index returned by addAgent
  62818. * @param destination targeted world position
  62819. */
  62820. agentGoto(index: number, destination: Vector3): void;
  62821. /**
  62822. * Teleport the agent to a new position
  62823. * @param index agent index returned by addAgent
  62824. * @param destination targeted world position
  62825. */
  62826. agentTeleport(index: number, destination: Vector3): void;
  62827. /**
  62828. * Update agent parameters
  62829. * @param index agent index returned by addAgent
  62830. * @param parameters agent parameters
  62831. */
  62832. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62833. /**
  62834. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62835. * The queries will try to find a solution within those bounds
  62836. * default is (1,1,1)
  62837. * @param extent x,y,z value that define the extent around the queries point of reference
  62838. */
  62839. setDefaultQueryExtent(extent: Vector3): void;
  62840. /**
  62841. * Get the Bounding box extent specified by setDefaultQueryExtent
  62842. * @returns the box extent values
  62843. */
  62844. getDefaultQueryExtent(): Vector3;
  62845. /**
  62846. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62847. * @param result output the box extent values
  62848. */
  62849. getDefaultQueryExtentToRef(result: Vector3): void;
  62850. /**
  62851. * Release all resources
  62852. */
  62853. dispose(): void;
  62854. }
  62855. /**
  62856. * Configures an agent
  62857. */
  62858. export interface IAgentParameters {
  62859. /**
  62860. * Agent radius. [Limit: >= 0]
  62861. */
  62862. radius: number;
  62863. /**
  62864. * Agent height. [Limit: > 0]
  62865. */
  62866. height: number;
  62867. /**
  62868. * Maximum allowed acceleration. [Limit: >= 0]
  62869. */
  62870. maxAcceleration: number;
  62871. /**
  62872. * Maximum allowed speed. [Limit: >= 0]
  62873. */
  62874. maxSpeed: number;
  62875. /**
  62876. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62877. */
  62878. collisionQueryRange: number;
  62879. /**
  62880. * The path visibility optimization range. [Limit: > 0]
  62881. */
  62882. pathOptimizationRange: number;
  62883. /**
  62884. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62885. */
  62886. separationWeight: number;
  62887. }
  62888. /**
  62889. * Configures the navigation mesh creation
  62890. */
  62891. export interface INavMeshParameters {
  62892. /**
  62893. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62894. */
  62895. cs: number;
  62896. /**
  62897. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62898. */
  62899. ch: number;
  62900. /**
  62901. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62902. */
  62903. walkableSlopeAngle: number;
  62904. /**
  62905. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62906. * be considered walkable. [Limit: >= 3] [Units: vx]
  62907. */
  62908. walkableHeight: number;
  62909. /**
  62910. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62911. */
  62912. walkableClimb: number;
  62913. /**
  62914. * The distance to erode/shrink the walkable area of the heightfield away from
  62915. * obstructions. [Limit: >=0] [Units: vx]
  62916. */
  62917. walkableRadius: number;
  62918. /**
  62919. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62920. */
  62921. maxEdgeLen: number;
  62922. /**
  62923. * The maximum distance a simplfied contour's border edges should deviate
  62924. * the original raw contour. [Limit: >=0] [Units: vx]
  62925. */
  62926. maxSimplificationError: number;
  62927. /**
  62928. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62929. */
  62930. minRegionArea: number;
  62931. /**
  62932. * Any regions with a span count smaller than this value will, if possible,
  62933. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62934. */
  62935. mergeRegionArea: number;
  62936. /**
  62937. * The maximum number of vertices allowed for polygons generated during the
  62938. * contour to polygon conversion process. [Limit: >= 3]
  62939. */
  62940. maxVertsPerPoly: number;
  62941. /**
  62942. * Sets the sampling distance to use when generating the detail mesh.
  62943. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62944. */
  62945. detailSampleDist: number;
  62946. /**
  62947. * The maximum distance the detail mesh surface should deviate from heightfield
  62948. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62949. */
  62950. detailSampleMaxError: number;
  62951. }
  62952. }
  62953. declare module BABYLON {
  62954. /**
  62955. * RecastJS navigation plugin
  62956. */
  62957. export class RecastJSPlugin implements INavigationEnginePlugin {
  62958. /**
  62959. * Reference to the Recast library
  62960. */
  62961. bjsRECAST: any;
  62962. /**
  62963. * plugin name
  62964. */
  62965. name: string;
  62966. /**
  62967. * the first navmesh created. We might extend this to support multiple navmeshes
  62968. */
  62969. navMesh: any;
  62970. /**
  62971. * Initializes the recastJS plugin
  62972. * @param recastInjection can be used to inject your own recast reference
  62973. */
  62974. constructor(recastInjection?: any);
  62975. /**
  62976. * Creates a navigation mesh
  62977. * @param meshes array of all the geometry used to compute the navigatio mesh
  62978. * @param parameters bunch of parameters used to filter geometry
  62979. */
  62980. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62981. /**
  62982. * Create a navigation mesh debug mesh
  62983. * @param scene is where the mesh will be added
  62984. * @returns debug display mesh
  62985. */
  62986. createDebugNavMesh(scene: Scene): Mesh;
  62987. /**
  62988. * Get a navigation mesh constrained position, closest to the parameter position
  62989. * @param position world position
  62990. * @returns the closest point to position constrained by the navigation mesh
  62991. */
  62992. getClosestPoint(position: Vector3): Vector3;
  62993. /**
  62994. * Get a navigation mesh constrained position, closest to the parameter position
  62995. * @param position world position
  62996. * @param result output the closest point to position constrained by the navigation mesh
  62997. */
  62998. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62999. /**
  63000. * Get a navigation mesh constrained position, within a particular radius
  63001. * @param position world position
  63002. * @param maxRadius the maximum distance to the constrained world position
  63003. * @returns the closest point to position constrained by the navigation mesh
  63004. */
  63005. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63006. /**
  63007. * Get a navigation mesh constrained position, within a particular radius
  63008. * @param position world position
  63009. * @param maxRadius the maximum distance to the constrained world position
  63010. * @param result output the closest point to position constrained by the navigation mesh
  63011. */
  63012. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63013. /**
  63014. * Compute the final position from a segment made of destination-position
  63015. * @param position world position
  63016. * @param destination world position
  63017. * @returns the resulting point along the navmesh
  63018. */
  63019. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63020. /**
  63021. * Compute the final position from a segment made of destination-position
  63022. * @param position world position
  63023. * @param destination world position
  63024. * @param result output the resulting point along the navmesh
  63025. */
  63026. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63027. /**
  63028. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63029. * @param start world position
  63030. * @param end world position
  63031. * @returns array containing world position composing the path
  63032. */
  63033. computePath(start: Vector3, end: Vector3): Vector3[];
  63034. /**
  63035. * Create a new Crowd so you can add agents
  63036. * @param maxAgents the maximum agent count in the crowd
  63037. * @param maxAgentRadius the maximum radius an agent can have
  63038. * @param scene to attach the crowd to
  63039. * @returns the crowd you can add agents to
  63040. */
  63041. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63042. /**
  63043. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63044. * The queries will try to find a solution within those bounds
  63045. * default is (1,1,1)
  63046. * @param extent x,y,z value that define the extent around the queries point of reference
  63047. */
  63048. setDefaultQueryExtent(extent: Vector3): void;
  63049. /**
  63050. * Get the Bounding box extent specified by setDefaultQueryExtent
  63051. * @returns the box extent values
  63052. */
  63053. getDefaultQueryExtent(): Vector3;
  63054. /**
  63055. * build the navmesh from a previously saved state using getNavmeshData
  63056. * @param data the Uint8Array returned by getNavmeshData
  63057. */
  63058. buildFromNavmeshData(data: Uint8Array): void;
  63059. /**
  63060. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63061. * @returns data the Uint8Array that can be saved and reused
  63062. */
  63063. getNavmeshData(): Uint8Array;
  63064. /**
  63065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63066. * @param result output the box extent values
  63067. */
  63068. getDefaultQueryExtentToRef(result: Vector3): void;
  63069. /**
  63070. * Disposes
  63071. */
  63072. dispose(): void;
  63073. /**
  63074. * If this plugin is supported
  63075. * @returns true if plugin is supported
  63076. */
  63077. isSupported(): boolean;
  63078. }
  63079. /**
  63080. * Recast detour crowd implementation
  63081. */
  63082. export class RecastJSCrowd implements ICrowd {
  63083. /**
  63084. * Recast/detour plugin
  63085. */
  63086. bjsRECASTPlugin: RecastJSPlugin;
  63087. /**
  63088. * Link to the detour crowd
  63089. */
  63090. recastCrowd: any;
  63091. /**
  63092. * One transform per agent
  63093. */
  63094. transforms: TransformNode[];
  63095. /**
  63096. * All agents created
  63097. */
  63098. agents: number[];
  63099. /**
  63100. * Link to the scene is kept to unregister the crowd from the scene
  63101. */
  63102. private _scene;
  63103. /**
  63104. * Observer for crowd updates
  63105. */
  63106. private _onBeforeAnimationsObserver;
  63107. /**
  63108. * Constructor
  63109. * @param plugin recastJS plugin
  63110. * @param maxAgents the maximum agent count in the crowd
  63111. * @param maxAgentRadius the maximum radius an agent can have
  63112. * @param scene to attach the crowd to
  63113. * @returns the crowd you can add agents to
  63114. */
  63115. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63116. /**
  63117. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63118. * You can attach anything to that node. The node position is updated in the scene update tick.
  63119. * @param pos world position that will be constrained by the navigation mesh
  63120. * @param parameters agent parameters
  63121. * @param transform hooked to the agent that will be update by the scene
  63122. * @returns agent index
  63123. */
  63124. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63125. /**
  63126. * Returns the agent position in world space
  63127. * @param index agent index returned by addAgent
  63128. * @returns world space position
  63129. */
  63130. getAgentPosition(index: number): Vector3;
  63131. /**
  63132. * Returns the agent position result in world space
  63133. * @param index agent index returned by addAgent
  63134. * @param result output world space position
  63135. */
  63136. getAgentPositionToRef(index: number, result: Vector3): void;
  63137. /**
  63138. * Returns the agent velocity in world space
  63139. * @param index agent index returned by addAgent
  63140. * @returns world space velocity
  63141. */
  63142. getAgentVelocity(index: number): Vector3;
  63143. /**
  63144. * Returns the agent velocity result in world space
  63145. * @param index agent index returned by addAgent
  63146. * @param result output world space velocity
  63147. */
  63148. getAgentVelocityToRef(index: number, result: Vector3): void;
  63149. /**
  63150. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63151. * @param index agent index returned by addAgent
  63152. * @param destination targeted world position
  63153. */
  63154. agentGoto(index: number, destination: Vector3): void;
  63155. /**
  63156. * Teleport the agent to a new position
  63157. * @param index agent index returned by addAgent
  63158. * @param destination targeted world position
  63159. */
  63160. agentTeleport(index: number, destination: Vector3): void;
  63161. /**
  63162. * Update agent parameters
  63163. * @param index agent index returned by addAgent
  63164. * @param parameters agent parameters
  63165. */
  63166. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63167. /**
  63168. * remove a particular agent previously created
  63169. * @param index agent index returned by addAgent
  63170. */
  63171. removeAgent(index: number): void;
  63172. /**
  63173. * get the list of all agents attached to this crowd
  63174. * @returns list of agent indices
  63175. */
  63176. getAgents(): number[];
  63177. /**
  63178. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63179. * @param deltaTime in seconds
  63180. */
  63181. update(deltaTime: number): void;
  63182. /**
  63183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63184. * The queries will try to find a solution within those bounds
  63185. * default is (1,1,1)
  63186. * @param extent x,y,z value that define the extent around the queries point of reference
  63187. */
  63188. setDefaultQueryExtent(extent: Vector3): void;
  63189. /**
  63190. * Get the Bounding box extent specified by setDefaultQueryExtent
  63191. * @returns the box extent values
  63192. */
  63193. getDefaultQueryExtent(): Vector3;
  63194. /**
  63195. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63196. * @param result output the box extent values
  63197. */
  63198. getDefaultQueryExtentToRef(result: Vector3): void;
  63199. /**
  63200. * Release all resources
  63201. */
  63202. dispose(): void;
  63203. }
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Class used to enable access to IndexedDB
  63208. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63209. */
  63210. export class Database implements IOfflineProvider {
  63211. private _callbackManifestChecked;
  63212. private _currentSceneUrl;
  63213. private _db;
  63214. private _enableSceneOffline;
  63215. private _enableTexturesOffline;
  63216. private _manifestVersionFound;
  63217. private _mustUpdateRessources;
  63218. private _hasReachedQuota;
  63219. private _isSupported;
  63220. private _idbFactory;
  63221. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63222. private static IsUASupportingBlobStorage;
  63223. /**
  63224. * Gets a boolean indicating if Database storate is enabled (off by default)
  63225. */
  63226. static IDBStorageEnabled: boolean;
  63227. /**
  63228. * Gets a boolean indicating if scene must be saved in the database
  63229. */
  63230. get enableSceneOffline(): boolean;
  63231. /**
  63232. * Gets a boolean indicating if textures must be saved in the database
  63233. */
  63234. get enableTexturesOffline(): boolean;
  63235. /**
  63236. * Creates a new Database
  63237. * @param urlToScene defines the url to load the scene
  63238. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63239. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63240. */
  63241. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63242. private static _ParseURL;
  63243. private static _ReturnFullUrlLocation;
  63244. private _checkManifestFile;
  63245. /**
  63246. * Open the database and make it available
  63247. * @param successCallback defines the callback to call on success
  63248. * @param errorCallback defines the callback to call on error
  63249. */
  63250. open(successCallback: () => void, errorCallback: () => void): void;
  63251. /**
  63252. * Loads an image from the database
  63253. * @param url defines the url to load from
  63254. * @param image defines the target DOM image
  63255. */
  63256. loadImage(url: string, image: HTMLImageElement): void;
  63257. private _loadImageFromDBAsync;
  63258. private _saveImageIntoDBAsync;
  63259. private _checkVersionFromDB;
  63260. private _loadVersionFromDBAsync;
  63261. private _saveVersionIntoDBAsync;
  63262. /**
  63263. * Loads a file from database
  63264. * @param url defines the URL to load from
  63265. * @param sceneLoaded defines a callback to call on success
  63266. * @param progressCallBack defines a callback to call when progress changed
  63267. * @param errorCallback defines a callback to call on error
  63268. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63269. */
  63270. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63271. private _loadFileAsync;
  63272. private _saveFileAsync;
  63273. /**
  63274. * Validates if xhr data is correct
  63275. * @param xhr defines the request to validate
  63276. * @param dataType defines the expected data type
  63277. * @returns true if data is correct
  63278. */
  63279. private static _ValidateXHRData;
  63280. }
  63281. }
  63282. declare module BABYLON {
  63283. /** @hidden */
  63284. export var gpuUpdateParticlesPixelShader: {
  63285. name: string;
  63286. shader: string;
  63287. };
  63288. }
  63289. declare module BABYLON {
  63290. /** @hidden */
  63291. export var gpuUpdateParticlesVertexShader: {
  63292. name: string;
  63293. shader: string;
  63294. };
  63295. }
  63296. declare module BABYLON {
  63297. /** @hidden */
  63298. export var clipPlaneFragmentDeclaration2: {
  63299. name: string;
  63300. shader: string;
  63301. };
  63302. }
  63303. declare module BABYLON {
  63304. /** @hidden */
  63305. export var gpuRenderParticlesPixelShader: {
  63306. name: string;
  63307. shader: string;
  63308. };
  63309. }
  63310. declare module BABYLON {
  63311. /** @hidden */
  63312. export var clipPlaneVertexDeclaration2: {
  63313. name: string;
  63314. shader: string;
  63315. };
  63316. }
  63317. declare module BABYLON {
  63318. /** @hidden */
  63319. export var gpuRenderParticlesVertexShader: {
  63320. name: string;
  63321. shader: string;
  63322. };
  63323. }
  63324. declare module BABYLON {
  63325. /**
  63326. * This represents a GPU particle system in Babylon
  63327. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63328. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63329. */
  63330. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63331. /**
  63332. * The layer mask we are rendering the particles through.
  63333. */
  63334. layerMask: number;
  63335. private _capacity;
  63336. private _activeCount;
  63337. private _currentActiveCount;
  63338. private _accumulatedCount;
  63339. private _renderEffect;
  63340. private _updateEffect;
  63341. private _buffer0;
  63342. private _buffer1;
  63343. private _spriteBuffer;
  63344. private _updateVAO;
  63345. private _renderVAO;
  63346. private _targetIndex;
  63347. private _sourceBuffer;
  63348. private _targetBuffer;
  63349. private _engine;
  63350. private _currentRenderId;
  63351. private _started;
  63352. private _stopped;
  63353. private _timeDelta;
  63354. private _randomTexture;
  63355. private _randomTexture2;
  63356. private _attributesStrideSize;
  63357. private _updateEffectOptions;
  63358. private _randomTextureSize;
  63359. private _actualFrame;
  63360. private readonly _rawTextureWidth;
  63361. /**
  63362. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63363. */
  63364. static get IsSupported(): boolean;
  63365. /**
  63366. * An event triggered when the system is disposed.
  63367. */
  63368. onDisposeObservable: Observable<GPUParticleSystem>;
  63369. /**
  63370. * Gets the maximum number of particles active at the same time.
  63371. * @returns The max number of active particles.
  63372. */
  63373. getCapacity(): number;
  63374. /**
  63375. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63376. * to override the particles.
  63377. */
  63378. forceDepthWrite: boolean;
  63379. /**
  63380. * Gets or set the number of active particles
  63381. */
  63382. get activeParticleCount(): number;
  63383. set activeParticleCount(value: number);
  63384. private _preWarmDone;
  63385. /**
  63386. * Specifies if the particles are updated in emitter local space or world space.
  63387. * This is always false for GPU particles
  63388. */
  63389. get isLocal(): boolean;
  63390. set isLocal(value: boolean);
  63391. /**
  63392. * Is this system ready to be used/rendered
  63393. * @return true if the system is ready
  63394. */
  63395. isReady(): boolean;
  63396. /**
  63397. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63398. * @returns True if it has been started, otherwise false.
  63399. */
  63400. isStarted(): boolean;
  63401. /**
  63402. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63403. * @returns True if it has been stopped, otherwise false.
  63404. */
  63405. isStopped(): boolean;
  63406. /**
  63407. * Gets a boolean indicating that the system is stopping
  63408. * @returns true if the system is currently stopping
  63409. */
  63410. isStopping(): boolean;
  63411. /**
  63412. * Gets the number of particles active at the same time.
  63413. * @returns The number of active particles.
  63414. */
  63415. getActiveCount(): number;
  63416. /**
  63417. * Starts the particle system and begins to emit
  63418. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63419. */
  63420. start(delay?: number): void;
  63421. /**
  63422. * Stops the particle system.
  63423. */
  63424. stop(): void;
  63425. /**
  63426. * Remove all active particles
  63427. */
  63428. reset(): void;
  63429. /**
  63430. * Returns the string "GPUParticleSystem"
  63431. * @returns a string containing the class name
  63432. */
  63433. getClassName(): string;
  63434. private _colorGradientsTexture;
  63435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63436. /**
  63437. * Adds a new color gradient
  63438. * @param gradient defines the gradient to use (between 0 and 1)
  63439. * @param color1 defines the color to affect to the specified gradient
  63440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63441. * @returns the current particle system
  63442. */
  63443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63444. private _refreshColorGradient;
  63445. /** Force the system to rebuild all gradients that need to be resync */
  63446. forceRefreshGradients(): void;
  63447. /**
  63448. * Remove a specific color gradient
  63449. * @param gradient defines the gradient to remove
  63450. * @returns the current particle system
  63451. */
  63452. removeColorGradient(gradient: number): GPUParticleSystem;
  63453. private _angularSpeedGradientsTexture;
  63454. private _sizeGradientsTexture;
  63455. private _velocityGradientsTexture;
  63456. private _limitVelocityGradientsTexture;
  63457. private _dragGradientsTexture;
  63458. private _addFactorGradient;
  63459. /**
  63460. * Adds a new size gradient
  63461. * @param gradient defines the gradient to use (between 0 and 1)
  63462. * @param factor defines the size factor to affect to the specified gradient
  63463. * @returns the current particle system
  63464. */
  63465. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63466. /**
  63467. * Remove a specific size gradient
  63468. * @param gradient defines the gradient to remove
  63469. * @returns the current particle system
  63470. */
  63471. removeSizeGradient(gradient: number): GPUParticleSystem;
  63472. private _refreshFactorGradient;
  63473. /**
  63474. * Adds a new angular speed gradient
  63475. * @param gradient defines the gradient to use (between 0 and 1)
  63476. * @param factor defines the angular speed to affect to the specified gradient
  63477. * @returns the current particle system
  63478. */
  63479. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63480. /**
  63481. * Remove a specific angular speed gradient
  63482. * @param gradient defines the gradient to remove
  63483. * @returns the current particle system
  63484. */
  63485. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63486. /**
  63487. * Adds a new velocity gradient
  63488. * @param gradient defines the gradient to use (between 0 and 1)
  63489. * @param factor defines the velocity to affect to the specified gradient
  63490. * @returns the current particle system
  63491. */
  63492. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63493. /**
  63494. * Remove a specific velocity gradient
  63495. * @param gradient defines the gradient to remove
  63496. * @returns the current particle system
  63497. */
  63498. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63499. /**
  63500. * Adds a new limit velocity gradient
  63501. * @param gradient defines the gradient to use (between 0 and 1)
  63502. * @param factor defines the limit velocity value to affect to the specified gradient
  63503. * @returns the current particle system
  63504. */
  63505. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63506. /**
  63507. * Remove a specific limit velocity gradient
  63508. * @param gradient defines the gradient to remove
  63509. * @returns the current particle system
  63510. */
  63511. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63512. /**
  63513. * Adds a new drag gradient
  63514. * @param gradient defines the gradient to use (between 0 and 1)
  63515. * @param factor defines the drag value to affect to the specified gradient
  63516. * @returns the current particle system
  63517. */
  63518. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63519. /**
  63520. * Remove a specific drag gradient
  63521. * @param gradient defines the gradient to remove
  63522. * @returns the current particle system
  63523. */
  63524. removeDragGradient(gradient: number): GPUParticleSystem;
  63525. /**
  63526. * Not supported by GPUParticleSystem
  63527. * @param gradient defines the gradient to use (between 0 and 1)
  63528. * @param factor defines the emit rate value to affect to the specified gradient
  63529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63530. * @returns the current particle system
  63531. */
  63532. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63533. /**
  63534. * Not supported by GPUParticleSystem
  63535. * @param gradient defines the gradient to remove
  63536. * @returns the current particle system
  63537. */
  63538. removeEmitRateGradient(gradient: number): IParticleSystem;
  63539. /**
  63540. * Not supported by GPUParticleSystem
  63541. * @param gradient defines the gradient to use (between 0 and 1)
  63542. * @param factor defines the start size value to affect to the specified gradient
  63543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63544. * @returns the current particle system
  63545. */
  63546. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63547. /**
  63548. * Not supported by GPUParticleSystem
  63549. * @param gradient defines the gradient to remove
  63550. * @returns the current particle system
  63551. */
  63552. removeStartSizeGradient(gradient: number): IParticleSystem;
  63553. /**
  63554. * Not supported by GPUParticleSystem
  63555. * @param gradient defines the gradient to use (between 0 and 1)
  63556. * @param min defines the color remap minimal range
  63557. * @param max defines the color remap maximal range
  63558. * @returns the current particle system
  63559. */
  63560. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63561. /**
  63562. * Not supported by GPUParticleSystem
  63563. * @param gradient defines the gradient to remove
  63564. * @returns the current particle system
  63565. */
  63566. removeColorRemapGradient(): IParticleSystem;
  63567. /**
  63568. * Not supported by GPUParticleSystem
  63569. * @param gradient defines the gradient to use (between 0 and 1)
  63570. * @param min defines the alpha remap minimal range
  63571. * @param max defines the alpha remap maximal range
  63572. * @returns the current particle system
  63573. */
  63574. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63575. /**
  63576. * Not supported by GPUParticleSystem
  63577. * @param gradient defines the gradient to remove
  63578. * @returns the current particle system
  63579. */
  63580. removeAlphaRemapGradient(): IParticleSystem;
  63581. /**
  63582. * Not supported by GPUParticleSystem
  63583. * @param gradient defines the gradient to use (between 0 and 1)
  63584. * @param color defines the color to affect to the specified gradient
  63585. * @returns the current particle system
  63586. */
  63587. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63588. /**
  63589. * Not supported by GPUParticleSystem
  63590. * @param gradient defines the gradient to remove
  63591. * @returns the current particle system
  63592. */
  63593. removeRampGradient(): IParticleSystem;
  63594. /**
  63595. * Not supported by GPUParticleSystem
  63596. * @returns the list of ramp gradients
  63597. */
  63598. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63599. /**
  63600. * Not supported by GPUParticleSystem
  63601. * Gets or sets a boolean indicating that ramp gradients must be used
  63602. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63603. */
  63604. get useRampGradients(): boolean;
  63605. set useRampGradients(value: boolean);
  63606. /**
  63607. * Not supported by GPUParticleSystem
  63608. * @param gradient defines the gradient to use (between 0 and 1)
  63609. * @param factor defines the life time factor to affect to the specified gradient
  63610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63611. * @returns the current particle system
  63612. */
  63613. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63614. /**
  63615. * Not supported by GPUParticleSystem
  63616. * @param gradient defines the gradient to remove
  63617. * @returns the current particle system
  63618. */
  63619. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63620. /**
  63621. * Instantiates a GPU particle system.
  63622. * 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.
  63623. * @param name The name of the particle system
  63624. * @param options The options used to create the system
  63625. * @param scene The scene the particle system belongs to
  63626. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63627. */
  63628. constructor(name: string, options: Partial<{
  63629. capacity: number;
  63630. randomTextureSize: number;
  63631. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63632. protected _reset(): void;
  63633. private _createUpdateVAO;
  63634. private _createRenderVAO;
  63635. private _initialize;
  63636. /** @hidden */
  63637. _recreateUpdateEffect(): void;
  63638. /** @hidden */
  63639. _recreateRenderEffect(): void;
  63640. /**
  63641. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63642. * @param preWarm defines if we are in the pre-warmimg phase
  63643. */
  63644. animate(preWarm?: boolean): void;
  63645. private _createFactorGradientTexture;
  63646. private _createSizeGradientTexture;
  63647. private _createAngularSpeedGradientTexture;
  63648. private _createVelocityGradientTexture;
  63649. private _createLimitVelocityGradientTexture;
  63650. private _createDragGradientTexture;
  63651. private _createColorGradientTexture;
  63652. /**
  63653. * Renders the particle system in its current state
  63654. * @param preWarm defines if the system should only update the particles but not render them
  63655. * @returns the current number of particles
  63656. */
  63657. render(preWarm?: boolean): number;
  63658. /**
  63659. * Rebuilds the particle system
  63660. */
  63661. rebuild(): void;
  63662. private _releaseBuffers;
  63663. private _releaseVAOs;
  63664. /**
  63665. * Disposes the particle system and free the associated resources
  63666. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63667. */
  63668. dispose(disposeTexture?: boolean): void;
  63669. /**
  63670. * Clones the particle system.
  63671. * @param name The name of the cloned object
  63672. * @param newEmitter The new emitter to use
  63673. * @returns the cloned particle system
  63674. */
  63675. clone(name: string, newEmitter: any): GPUParticleSystem;
  63676. /**
  63677. * Serializes the particle system to a JSON object
  63678. * @param serializeTexture defines if the texture must be serialized as well
  63679. * @returns the JSON object
  63680. */
  63681. serialize(serializeTexture?: boolean): any;
  63682. /**
  63683. * Parses a JSON object to create a GPU particle system.
  63684. * @param parsedParticleSystem The JSON object to parse
  63685. * @param scene The scene to create the particle system in
  63686. * @param rootUrl The root url to use to load external dependencies like texture
  63687. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63688. * @returns the parsed GPU particle system
  63689. */
  63690. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63691. }
  63692. }
  63693. declare module BABYLON {
  63694. /**
  63695. * Represents a set of particle systems working together to create a specific effect
  63696. */
  63697. export class ParticleSystemSet implements IDisposable {
  63698. /**
  63699. * Gets or sets base Assets URL
  63700. */
  63701. static BaseAssetsUrl: string;
  63702. private _emitterCreationOptions;
  63703. private _emitterNode;
  63704. /**
  63705. * Gets the particle system list
  63706. */
  63707. systems: IParticleSystem[];
  63708. /**
  63709. * Gets the emitter node used with this set
  63710. */
  63711. get emitterNode(): Nullable<TransformNode>;
  63712. /**
  63713. * Creates a new emitter mesh as a sphere
  63714. * @param options defines the options used to create the sphere
  63715. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63716. * @param scene defines the hosting scene
  63717. */
  63718. setEmitterAsSphere(options: {
  63719. diameter: number;
  63720. segments: number;
  63721. color: Color3;
  63722. }, renderingGroupId: number, scene: Scene): void;
  63723. /**
  63724. * Starts all particle systems of the set
  63725. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63726. */
  63727. start(emitter?: AbstractMesh): void;
  63728. /**
  63729. * Release all associated resources
  63730. */
  63731. dispose(): void;
  63732. /**
  63733. * Serialize the set into a JSON compatible object
  63734. * @param serializeTexture defines if the texture must be serialized as well
  63735. * @returns a JSON compatible representation of the set
  63736. */
  63737. serialize(serializeTexture?: boolean): any;
  63738. /**
  63739. * Parse a new ParticleSystemSet from a serialized source
  63740. * @param data defines a JSON compatible representation of the set
  63741. * @param scene defines the hosting scene
  63742. * @param gpu defines if we want GPU particles or CPU particles
  63743. * @returns a new ParticleSystemSet
  63744. */
  63745. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63746. }
  63747. }
  63748. declare module BABYLON {
  63749. /**
  63750. * This class is made for on one-liner static method to help creating particle system set.
  63751. */
  63752. export class ParticleHelper {
  63753. /**
  63754. * Gets or sets base Assets URL
  63755. */
  63756. static BaseAssetsUrl: string;
  63757. /** Define the Url to load snippets */
  63758. static SnippetUrl: string;
  63759. /**
  63760. * Create a default particle system that you can tweak
  63761. * @param emitter defines the emitter to use
  63762. * @param capacity defines the system capacity (default is 500 particles)
  63763. * @param scene defines the hosting scene
  63764. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63765. * @returns the new Particle system
  63766. */
  63767. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63768. /**
  63769. * This is the main static method (one-liner) of this helper to create different particle systems
  63770. * @param type This string represents the type to the particle system to create
  63771. * @param scene The scene where the particle system should live
  63772. * @param gpu If the system will use gpu
  63773. * @returns the ParticleSystemSet created
  63774. */
  63775. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63776. /**
  63777. * Static function used to export a particle system to a ParticleSystemSet variable.
  63778. * Please note that the emitter shape is not exported
  63779. * @param systems defines the particle systems to export
  63780. * @returns the created particle system set
  63781. */
  63782. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63783. /**
  63784. * Creates a particle system from a snippet saved in a remote file
  63785. * @param name defines the name of the particle system to create
  63786. * @param url defines the url to load from
  63787. * @param scene defines the hosting scene
  63788. * @param gpu If the system will use gpu
  63789. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63790. * @returns a promise that will resolve to the new particle system
  63791. */
  63792. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63793. /**
  63794. * Creates a particle system from a snippet saved by the particle system editor
  63795. * @param snippetId defines the snippet to load
  63796. * @param scene defines the hosting scene
  63797. * @param gpu If the system will use gpu
  63798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63799. * @returns a promise that will resolve to the new particle system
  63800. */
  63801. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63802. }
  63803. }
  63804. declare module BABYLON {
  63805. interface Engine {
  63806. /**
  63807. * Create an effect to use with particle systems.
  63808. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63809. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63810. * @param uniformsNames defines a list of attribute names
  63811. * @param samplers defines an array of string used to represent textures
  63812. * @param defines defines the string containing the defines to use to compile the shaders
  63813. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63814. * @param onCompiled defines a function to call when the effect creation is successful
  63815. * @param onError defines a function to call when the effect creation has failed
  63816. * @returns the new Effect
  63817. */
  63818. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63819. }
  63820. interface Mesh {
  63821. /**
  63822. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63823. * @returns an array of IParticleSystem
  63824. */
  63825. getEmittedParticleSystems(): IParticleSystem[];
  63826. /**
  63827. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63828. * @returns an array of IParticleSystem
  63829. */
  63830. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63831. }
  63832. /**
  63833. * @hidden
  63834. */
  63835. export var _IDoNeedToBeInTheBuild: number;
  63836. }
  63837. declare module BABYLON {
  63838. /** Defines the 4 color options */
  63839. export enum PointColor {
  63840. /** color value */
  63841. Color = 2,
  63842. /** uv value */
  63843. UV = 1,
  63844. /** random value */
  63845. Random = 0,
  63846. /** stated value */
  63847. Stated = 3
  63848. }
  63849. /**
  63850. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63851. * 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.
  63852. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63853. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63854. *
  63855. * Full documentation here : TO BE ENTERED
  63856. */
  63857. export class PointsCloudSystem implements IDisposable {
  63858. /**
  63859. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63860. * Example : var p = SPS.particles[i];
  63861. */
  63862. particles: CloudPoint[];
  63863. /**
  63864. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63865. */
  63866. nbParticles: number;
  63867. /**
  63868. * This a counter for your own usage. It's not set by any SPS functions.
  63869. */
  63870. counter: number;
  63871. /**
  63872. * The PCS name. This name is also given to the underlying mesh.
  63873. */
  63874. name: string;
  63875. /**
  63876. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63877. */
  63878. mesh: Mesh;
  63879. /**
  63880. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63881. * Please read :
  63882. */
  63883. vars: any;
  63884. /**
  63885. * @hidden
  63886. */
  63887. _size: number;
  63888. private _scene;
  63889. private _promises;
  63890. private _positions;
  63891. private _indices;
  63892. private _normals;
  63893. private _colors;
  63894. private _uvs;
  63895. private _indices32;
  63896. private _positions32;
  63897. private _colors32;
  63898. private _uvs32;
  63899. private _updatable;
  63900. private _isVisibilityBoxLocked;
  63901. private _alwaysVisible;
  63902. private _groups;
  63903. private _groupCounter;
  63904. private _computeParticleColor;
  63905. private _computeParticleTexture;
  63906. private _computeParticleRotation;
  63907. private _computeBoundingBox;
  63908. private _isReady;
  63909. /**
  63910. * Creates a PCS (Points Cloud System) object
  63911. * @param name (String) is the PCS name, this will be the underlying mesh name
  63912. * @param pointSize (number) is the size for each point
  63913. * @param scene (Scene) is the scene in which the PCS is added
  63914. * @param options defines the options of the PCS e.g.
  63915. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63916. */
  63917. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63918. updatable?: boolean;
  63919. });
  63920. /**
  63921. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63922. * If no points were added to the PCS, the returned mesh is just a single point.
  63923. * @returns a promise for the created mesh
  63924. */
  63925. buildMeshAsync(): Promise<Mesh>;
  63926. /**
  63927. * @hidden
  63928. */
  63929. private _buildMesh;
  63930. private _addParticle;
  63931. private _randomUnitVector;
  63932. private _getColorIndicesForCoord;
  63933. private _setPointsColorOrUV;
  63934. private _colorFromTexture;
  63935. private _calculateDensity;
  63936. /**
  63937. * Adds points to the PCS in random positions within a unit sphere
  63938. * @param nb (positive integer) the number of particles to be created from this model
  63939. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63940. * @returns the number of groups in the system
  63941. */
  63942. addPoints(nb: number, pointFunction?: any): number;
  63943. /**
  63944. * Adds points to the PCS from the surface of the model shape
  63945. * @param mesh is any Mesh object that will be used as a surface model for the points
  63946. * @param nb (positive integer) the number of particles to be created from this model
  63947. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63948. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63949. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63950. * @returns the number of groups in the system
  63951. */
  63952. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63953. /**
  63954. * Adds points to the PCS inside the model shape
  63955. * @param mesh is any Mesh object that will be used as a surface model for the points
  63956. * @param nb (positive integer) the number of particles to be created from this model
  63957. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63958. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63959. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63960. * @returns the number of groups in the system
  63961. */
  63962. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63963. /**
  63964. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63965. * This method calls `updateParticle()` for each particle of the SPS.
  63966. * For an animated SPS, it is usually called within the render loop.
  63967. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63968. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63969. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63970. * @returns the PCS.
  63971. */
  63972. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63973. /**
  63974. * Disposes the PCS.
  63975. */
  63976. dispose(): void;
  63977. /**
  63978. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63979. * doc :
  63980. * @returns the PCS.
  63981. */
  63982. refreshVisibleSize(): PointsCloudSystem;
  63983. /**
  63984. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63985. * @param size the size (float) of the visibility box
  63986. * note : this doesn't lock the PCS mesh bounding box.
  63987. * doc :
  63988. */
  63989. setVisibilityBox(size: number): void;
  63990. /**
  63991. * Gets whether the PCS is always visible or not
  63992. * doc :
  63993. */
  63994. get isAlwaysVisible(): boolean;
  63995. /**
  63996. * Sets the PCS as always visible or not
  63997. * doc :
  63998. */
  63999. set isAlwaysVisible(val: boolean);
  64000. /**
  64001. * Tells to `setParticles()` to compute the particle rotations or not
  64002. * Default value : false. The PCS is faster when it's set to false
  64003. * Note : particle rotations are only applied to parent particles
  64004. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64005. */
  64006. set computeParticleRotation(val: boolean);
  64007. /**
  64008. * Tells to `setParticles()` to compute the particle colors or not.
  64009. * Default value : true. The PCS is faster when it's set to false.
  64010. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64011. */
  64012. set computeParticleColor(val: boolean);
  64013. set computeParticleTexture(val: boolean);
  64014. /**
  64015. * Gets if `setParticles()` computes the particle colors or not.
  64016. * Default value : false. The PCS is faster when it's set to false.
  64017. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64018. */
  64019. get computeParticleColor(): boolean;
  64020. /**
  64021. * Gets if `setParticles()` computes the particle textures or not.
  64022. * Default value : false. The PCS is faster when it's set to false.
  64023. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64024. */
  64025. get computeParticleTexture(): boolean;
  64026. /**
  64027. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64028. */
  64029. set computeBoundingBox(val: boolean);
  64030. /**
  64031. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64032. */
  64033. get computeBoundingBox(): boolean;
  64034. /**
  64035. * This function does nothing. It may be overwritten to set all the particle first values.
  64036. * The PCS doesn't call this function, you may have to call it by your own.
  64037. * doc :
  64038. */
  64039. initParticles(): void;
  64040. /**
  64041. * This function does nothing. It may be overwritten to recycle a particle
  64042. * The PCS doesn't call this function, you can to call it
  64043. * doc :
  64044. * @param particle The particle to recycle
  64045. * @returns the recycled particle
  64046. */
  64047. recycleParticle(particle: CloudPoint): CloudPoint;
  64048. /**
  64049. * Updates a particle : this function should be overwritten by the user.
  64050. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64051. * doc :
  64052. * @example : just set a particle position or velocity and recycle conditions
  64053. * @param particle The particle to update
  64054. * @returns the updated particle
  64055. */
  64056. updateParticle(particle: CloudPoint): CloudPoint;
  64057. /**
  64058. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64059. * This does nothing and may be overwritten by the user.
  64060. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64061. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64062. * @param update the boolean update value actually passed to setParticles()
  64063. */
  64064. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64065. /**
  64066. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64067. * This will be passed three parameters.
  64068. * This does nothing and may be overwritten by the user.
  64069. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64070. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64071. * @param update the boolean update value actually passed to setParticles()
  64072. */
  64073. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * Represents one particle of a points cloud system.
  64079. */
  64080. export class CloudPoint {
  64081. /**
  64082. * particle global index
  64083. */
  64084. idx: number;
  64085. /**
  64086. * The color of the particle
  64087. */
  64088. color: Nullable<Color4>;
  64089. /**
  64090. * The world space position of the particle.
  64091. */
  64092. position: Vector3;
  64093. /**
  64094. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64095. */
  64096. rotation: Vector3;
  64097. /**
  64098. * The world space rotation quaternion of the particle.
  64099. */
  64100. rotationQuaternion: Nullable<Quaternion>;
  64101. /**
  64102. * The uv of the particle.
  64103. */
  64104. uv: Nullable<Vector2>;
  64105. /**
  64106. * The current speed of the particle.
  64107. */
  64108. velocity: Vector3;
  64109. /**
  64110. * The pivot point in the particle local space.
  64111. */
  64112. pivot: Vector3;
  64113. /**
  64114. * Must the particle be translated from its pivot point in its local space ?
  64115. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64116. * Default : false
  64117. */
  64118. translateFromPivot: boolean;
  64119. /**
  64120. * Index of this particle in the global "positions" array (Internal use)
  64121. * @hidden
  64122. */
  64123. _pos: number;
  64124. /**
  64125. * @hidden Index of this particle in the global "indices" array (Internal use)
  64126. */
  64127. _ind: number;
  64128. /**
  64129. * Group this particle belongs to
  64130. */
  64131. _group: PointsGroup;
  64132. /**
  64133. * Group id of this particle
  64134. */
  64135. groupId: number;
  64136. /**
  64137. * Index of the particle in its group id (Internal use)
  64138. */
  64139. idxInGroup: number;
  64140. /**
  64141. * @hidden Particle BoundingInfo object (Internal use)
  64142. */
  64143. _boundingInfo: BoundingInfo;
  64144. /**
  64145. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64146. */
  64147. _pcs: PointsCloudSystem;
  64148. /**
  64149. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64150. */
  64151. _stillInvisible: boolean;
  64152. /**
  64153. * @hidden Last computed particle rotation matrix
  64154. */
  64155. _rotationMatrix: number[];
  64156. /**
  64157. * Parent particle Id, if any.
  64158. * Default null.
  64159. */
  64160. parentId: Nullable<number>;
  64161. /**
  64162. * @hidden Internal global position in the PCS.
  64163. */
  64164. _globalPosition: Vector3;
  64165. /**
  64166. * Creates a Point Cloud object.
  64167. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64168. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64169. * @param group (PointsGroup) is the group the particle belongs to
  64170. * @param groupId (integer) is the group identifier in the PCS.
  64171. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64172. * @param pcs defines the PCS it is associated to
  64173. */
  64174. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64175. /**
  64176. * get point size
  64177. */
  64178. get size(): Vector3;
  64179. /**
  64180. * Set point size
  64181. */
  64182. set size(scale: Vector3);
  64183. /**
  64184. * Legacy support, changed quaternion to rotationQuaternion
  64185. */
  64186. get quaternion(): Nullable<Quaternion>;
  64187. /**
  64188. * Legacy support, changed quaternion to rotationQuaternion
  64189. */
  64190. set quaternion(q: Nullable<Quaternion>);
  64191. /**
  64192. * Returns a boolean. True if the particle intersects a mesh, else false
  64193. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64194. * @param target is the object (point or mesh) what the intersection is computed against
  64195. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64196. * @returns true if it intersects
  64197. */
  64198. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64199. /**
  64200. * get the rotation matrix of the particle
  64201. * @hidden
  64202. */
  64203. getRotationMatrix(m: Matrix): void;
  64204. }
  64205. /**
  64206. * Represents a group of points in a points cloud system
  64207. * * PCS internal tool, don't use it manually.
  64208. */
  64209. export class PointsGroup {
  64210. /**
  64211. * The group id
  64212. * @hidden
  64213. */
  64214. groupID: number;
  64215. /**
  64216. * image data for group (internal use)
  64217. * @hidden
  64218. */
  64219. _groupImageData: Nullable<ArrayBufferView>;
  64220. /**
  64221. * Image Width (internal use)
  64222. * @hidden
  64223. */
  64224. _groupImgWidth: number;
  64225. /**
  64226. * Image Height (internal use)
  64227. * @hidden
  64228. */
  64229. _groupImgHeight: number;
  64230. /**
  64231. * Custom position function (internal use)
  64232. * @hidden
  64233. */
  64234. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64235. /**
  64236. * density per facet for surface points
  64237. * @hidden
  64238. */
  64239. _groupDensity: number[];
  64240. /**
  64241. * Only when points are colored by texture carries pointer to texture list array
  64242. * @hidden
  64243. */
  64244. _textureNb: number;
  64245. /**
  64246. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64247. * PCS internal tool, don't use it manually.
  64248. * @hidden
  64249. */
  64250. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64251. }
  64252. }
  64253. declare module BABYLON {
  64254. interface Scene {
  64255. /** @hidden (Backing field) */
  64256. _physicsEngine: Nullable<IPhysicsEngine>;
  64257. /** @hidden */
  64258. _physicsTimeAccumulator: number;
  64259. /**
  64260. * Gets the current physics engine
  64261. * @returns a IPhysicsEngine or null if none attached
  64262. */
  64263. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64264. /**
  64265. * Enables physics to the current scene
  64266. * @param gravity defines the scene's gravity for the physics engine
  64267. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64268. * @return a boolean indicating if the physics engine was initialized
  64269. */
  64270. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64271. /**
  64272. * Disables and disposes the physics engine associated with the scene
  64273. */
  64274. disablePhysicsEngine(): void;
  64275. /**
  64276. * Gets a boolean indicating if there is an active physics engine
  64277. * @returns a boolean indicating if there is an active physics engine
  64278. */
  64279. isPhysicsEnabled(): boolean;
  64280. /**
  64281. * Deletes a physics compound impostor
  64282. * @param compound defines the compound to delete
  64283. */
  64284. deleteCompoundImpostor(compound: any): void;
  64285. /**
  64286. * An event triggered when physic simulation is about to be run
  64287. */
  64288. onBeforePhysicsObservable: Observable<Scene>;
  64289. /**
  64290. * An event triggered when physic simulation has been done
  64291. */
  64292. onAfterPhysicsObservable: Observable<Scene>;
  64293. }
  64294. interface AbstractMesh {
  64295. /** @hidden */
  64296. _physicsImpostor: Nullable<PhysicsImpostor>;
  64297. /**
  64298. * Gets or sets impostor used for physic simulation
  64299. * @see http://doc.babylonjs.com/features/physics_engine
  64300. */
  64301. physicsImpostor: Nullable<PhysicsImpostor>;
  64302. /**
  64303. * Gets the current physics impostor
  64304. * @see http://doc.babylonjs.com/features/physics_engine
  64305. * @returns a physics impostor or null
  64306. */
  64307. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64308. /** Apply a physic impulse to the mesh
  64309. * @param force defines the force to apply
  64310. * @param contactPoint defines where to apply the force
  64311. * @returns the current mesh
  64312. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64313. */
  64314. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64315. /**
  64316. * Creates a physic joint between two meshes
  64317. * @param otherMesh defines the other mesh to use
  64318. * @param pivot1 defines the pivot to use on this mesh
  64319. * @param pivot2 defines the pivot to use on the other mesh
  64320. * @param options defines additional options (can be plugin dependent)
  64321. * @returns the current mesh
  64322. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64323. */
  64324. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64325. /** @hidden */
  64326. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64327. }
  64328. /**
  64329. * Defines the physics engine scene component responsible to manage a physics engine
  64330. */
  64331. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64332. /**
  64333. * The component name helpful to identify the component in the list of scene components.
  64334. */
  64335. readonly name: string;
  64336. /**
  64337. * The scene the component belongs to.
  64338. */
  64339. scene: Scene;
  64340. /**
  64341. * Creates a new instance of the component for the given scene
  64342. * @param scene Defines the scene to register the component in
  64343. */
  64344. constructor(scene: Scene);
  64345. /**
  64346. * Registers the component in a given scene
  64347. */
  64348. register(): void;
  64349. /**
  64350. * Rebuilds the elements related to this component in case of
  64351. * context lost for instance.
  64352. */
  64353. rebuild(): void;
  64354. /**
  64355. * Disposes the component and the associated ressources
  64356. */
  64357. dispose(): void;
  64358. }
  64359. }
  64360. declare module BABYLON {
  64361. /**
  64362. * A helper for physics simulations
  64363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64364. */
  64365. export class PhysicsHelper {
  64366. private _scene;
  64367. private _physicsEngine;
  64368. /**
  64369. * Initializes the Physics helper
  64370. * @param scene Babylon.js scene
  64371. */
  64372. constructor(scene: Scene);
  64373. /**
  64374. * Applies a radial explosion impulse
  64375. * @param origin the origin of the explosion
  64376. * @param radiusOrEventOptions the radius or the options of radial explosion
  64377. * @param strength the explosion strength
  64378. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64379. * @returns A physics radial explosion event, or null
  64380. */
  64381. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64382. /**
  64383. * Applies a radial explosion force
  64384. * @param origin the origin of the explosion
  64385. * @param radiusOrEventOptions the radius or the options of radial explosion
  64386. * @param strength the explosion strength
  64387. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64388. * @returns A physics radial explosion event, or null
  64389. */
  64390. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64391. /**
  64392. * Creates a gravitational field
  64393. * @param origin the origin of the explosion
  64394. * @param radiusOrEventOptions the radius or the options of radial explosion
  64395. * @param strength the explosion strength
  64396. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64397. * @returns A physics gravitational field event, or null
  64398. */
  64399. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64400. /**
  64401. * Creates a physics updraft event
  64402. * @param origin the origin of the updraft
  64403. * @param radiusOrEventOptions the radius or the options of the updraft
  64404. * @param strength the strength of the updraft
  64405. * @param height the height of the updraft
  64406. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64407. * @returns A physics updraft event, or null
  64408. */
  64409. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64410. /**
  64411. * Creates a physics vortex event
  64412. * @param origin the of the vortex
  64413. * @param radiusOrEventOptions the radius or the options of the vortex
  64414. * @param strength the strength of the vortex
  64415. * @param height the height of the vortex
  64416. * @returns a Physics vortex event, or null
  64417. * A physics vortex event or null
  64418. */
  64419. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64420. }
  64421. /**
  64422. * Represents a physics radial explosion event
  64423. */
  64424. class PhysicsRadialExplosionEvent {
  64425. private _scene;
  64426. private _options;
  64427. private _sphere;
  64428. private _dataFetched;
  64429. /**
  64430. * Initializes a radial explosioin event
  64431. * @param _scene BabylonJS scene
  64432. * @param _options The options for the vortex event
  64433. */
  64434. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64435. /**
  64436. * Returns the data related to the radial explosion event (sphere).
  64437. * @returns The radial explosion event data
  64438. */
  64439. getData(): PhysicsRadialExplosionEventData;
  64440. /**
  64441. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64442. * @param impostor A physics imposter
  64443. * @param origin the origin of the explosion
  64444. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64445. */
  64446. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64447. /**
  64448. * Triggers affecterd impostors callbacks
  64449. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64450. */
  64451. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64452. /**
  64453. * Disposes the sphere.
  64454. * @param force Specifies if the sphere should be disposed by force
  64455. */
  64456. dispose(force?: boolean): void;
  64457. /*** Helpers ***/
  64458. private _prepareSphere;
  64459. private _intersectsWithSphere;
  64460. }
  64461. /**
  64462. * Represents a gravitational field event
  64463. */
  64464. class PhysicsGravitationalFieldEvent {
  64465. private _physicsHelper;
  64466. private _scene;
  64467. private _origin;
  64468. private _options;
  64469. private _tickCallback;
  64470. private _sphere;
  64471. private _dataFetched;
  64472. /**
  64473. * Initializes the physics gravitational field event
  64474. * @param _physicsHelper A physics helper
  64475. * @param _scene BabylonJS scene
  64476. * @param _origin The origin position of the gravitational field event
  64477. * @param _options The options for the vortex event
  64478. */
  64479. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64480. /**
  64481. * Returns the data related to the gravitational field event (sphere).
  64482. * @returns A gravitational field event
  64483. */
  64484. getData(): PhysicsGravitationalFieldEventData;
  64485. /**
  64486. * Enables the gravitational field.
  64487. */
  64488. enable(): void;
  64489. /**
  64490. * Disables the gravitational field.
  64491. */
  64492. disable(): void;
  64493. /**
  64494. * Disposes the sphere.
  64495. * @param force The force to dispose from the gravitational field event
  64496. */
  64497. dispose(force?: boolean): void;
  64498. private _tick;
  64499. }
  64500. /**
  64501. * Represents a physics updraft event
  64502. */
  64503. class PhysicsUpdraftEvent {
  64504. private _scene;
  64505. private _origin;
  64506. private _options;
  64507. private _physicsEngine;
  64508. private _originTop;
  64509. private _originDirection;
  64510. private _tickCallback;
  64511. private _cylinder;
  64512. private _cylinderPosition;
  64513. private _dataFetched;
  64514. /**
  64515. * Initializes the physics updraft event
  64516. * @param _scene BabylonJS scene
  64517. * @param _origin The origin position of the updraft
  64518. * @param _options The options for the updraft event
  64519. */
  64520. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64521. /**
  64522. * Returns the data related to the updraft event (cylinder).
  64523. * @returns A physics updraft event
  64524. */
  64525. getData(): PhysicsUpdraftEventData;
  64526. /**
  64527. * Enables the updraft.
  64528. */
  64529. enable(): void;
  64530. /**
  64531. * Disables the updraft.
  64532. */
  64533. disable(): void;
  64534. /**
  64535. * Disposes the cylinder.
  64536. * @param force Specifies if the updraft should be disposed by force
  64537. */
  64538. dispose(force?: boolean): void;
  64539. private getImpostorHitData;
  64540. private _tick;
  64541. /*** Helpers ***/
  64542. private _prepareCylinder;
  64543. private _intersectsWithCylinder;
  64544. }
  64545. /**
  64546. * Represents a physics vortex event
  64547. */
  64548. class PhysicsVortexEvent {
  64549. private _scene;
  64550. private _origin;
  64551. private _options;
  64552. private _physicsEngine;
  64553. private _originTop;
  64554. private _tickCallback;
  64555. private _cylinder;
  64556. private _cylinderPosition;
  64557. private _dataFetched;
  64558. /**
  64559. * Initializes the physics vortex event
  64560. * @param _scene The BabylonJS scene
  64561. * @param _origin The origin position of the vortex
  64562. * @param _options The options for the vortex event
  64563. */
  64564. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64565. /**
  64566. * Returns the data related to the vortex event (cylinder).
  64567. * @returns The physics vortex event data
  64568. */
  64569. getData(): PhysicsVortexEventData;
  64570. /**
  64571. * Enables the vortex.
  64572. */
  64573. enable(): void;
  64574. /**
  64575. * Disables the cortex.
  64576. */
  64577. disable(): void;
  64578. /**
  64579. * Disposes the sphere.
  64580. * @param force
  64581. */
  64582. dispose(force?: boolean): void;
  64583. private getImpostorHitData;
  64584. private _tick;
  64585. /*** Helpers ***/
  64586. private _prepareCylinder;
  64587. private _intersectsWithCylinder;
  64588. }
  64589. /**
  64590. * Options fot the radial explosion event
  64591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64592. */
  64593. export class PhysicsRadialExplosionEventOptions {
  64594. /**
  64595. * The radius of the sphere for the radial explosion.
  64596. */
  64597. radius: number;
  64598. /**
  64599. * The strenth of the explosion.
  64600. */
  64601. strength: number;
  64602. /**
  64603. * The strenght of the force in correspondence to the distance of the affected object
  64604. */
  64605. falloff: PhysicsRadialImpulseFalloff;
  64606. /**
  64607. * Sphere options for the radial explosion.
  64608. */
  64609. sphere: {
  64610. segments: number;
  64611. diameter: number;
  64612. };
  64613. /**
  64614. * Sphere options for the radial explosion.
  64615. */
  64616. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64617. }
  64618. /**
  64619. * Options fot the updraft event
  64620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64621. */
  64622. export class PhysicsUpdraftEventOptions {
  64623. /**
  64624. * The radius of the cylinder for the vortex
  64625. */
  64626. radius: number;
  64627. /**
  64628. * The strenth of the updraft.
  64629. */
  64630. strength: number;
  64631. /**
  64632. * The height of the cylinder for the updraft.
  64633. */
  64634. height: number;
  64635. /**
  64636. * The mode for the the updraft.
  64637. */
  64638. updraftMode: PhysicsUpdraftMode;
  64639. }
  64640. /**
  64641. * Options fot the vortex event
  64642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64643. */
  64644. export class PhysicsVortexEventOptions {
  64645. /**
  64646. * The radius of the cylinder for the vortex
  64647. */
  64648. radius: number;
  64649. /**
  64650. * The strenth of the vortex.
  64651. */
  64652. strength: number;
  64653. /**
  64654. * The height of the cylinder for the vortex.
  64655. */
  64656. height: number;
  64657. /**
  64658. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64659. */
  64660. centripetalForceThreshold: number;
  64661. /**
  64662. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64663. */
  64664. centripetalForceMultiplier: number;
  64665. /**
  64666. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64667. */
  64668. centrifugalForceMultiplier: number;
  64669. /**
  64670. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64671. */
  64672. updraftForceMultiplier: number;
  64673. }
  64674. /**
  64675. * The strenght of the force in correspondence to the distance of the affected object
  64676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64677. */
  64678. export enum PhysicsRadialImpulseFalloff {
  64679. /** Defines that impulse is constant in strength across it's whole radius */
  64680. Constant = 0,
  64681. /** Defines that impulse gets weaker if it's further from the origin */
  64682. Linear = 1
  64683. }
  64684. /**
  64685. * The strength of the force in correspondence to the distance of the affected object
  64686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64687. */
  64688. export enum PhysicsUpdraftMode {
  64689. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64690. Center = 0,
  64691. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64692. Perpendicular = 1
  64693. }
  64694. /**
  64695. * Interface for a physics hit data
  64696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64697. */
  64698. export interface PhysicsHitData {
  64699. /**
  64700. * The force applied at the contact point
  64701. */
  64702. force: Vector3;
  64703. /**
  64704. * The contact point
  64705. */
  64706. contactPoint: Vector3;
  64707. /**
  64708. * The distance from the origin to the contact point
  64709. */
  64710. distanceFromOrigin: number;
  64711. }
  64712. /**
  64713. * Interface for radial explosion event data
  64714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64715. */
  64716. export interface PhysicsRadialExplosionEventData {
  64717. /**
  64718. * A sphere used for the radial explosion event
  64719. */
  64720. sphere: Mesh;
  64721. }
  64722. /**
  64723. * Interface for gravitational field event data
  64724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64725. */
  64726. export interface PhysicsGravitationalFieldEventData {
  64727. /**
  64728. * A sphere mesh used for the gravitational field event
  64729. */
  64730. sphere: Mesh;
  64731. }
  64732. /**
  64733. * Interface for updraft event data
  64734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64735. */
  64736. export interface PhysicsUpdraftEventData {
  64737. /**
  64738. * A cylinder used for the updraft event
  64739. */
  64740. cylinder: Mesh;
  64741. }
  64742. /**
  64743. * Interface for vortex event data
  64744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64745. */
  64746. export interface PhysicsVortexEventData {
  64747. /**
  64748. * A cylinder used for the vortex event
  64749. */
  64750. cylinder: Mesh;
  64751. }
  64752. /**
  64753. * Interface for an affected physics impostor
  64754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64755. */
  64756. export interface PhysicsAffectedImpostorWithData {
  64757. /**
  64758. * The impostor affected by the effect
  64759. */
  64760. impostor: PhysicsImpostor;
  64761. /**
  64762. * The data about the hit/horce from the explosion
  64763. */
  64764. hitData: PhysicsHitData;
  64765. }
  64766. }
  64767. declare module BABYLON {
  64768. /** @hidden */
  64769. export var blackAndWhitePixelShader: {
  64770. name: string;
  64771. shader: string;
  64772. };
  64773. }
  64774. declare module BABYLON {
  64775. /**
  64776. * Post process used to render in black and white
  64777. */
  64778. export class BlackAndWhitePostProcess extends PostProcess {
  64779. /**
  64780. * Linear about to convert he result to black and white (default: 1)
  64781. */
  64782. degree: number;
  64783. /**
  64784. * Creates a black and white post process
  64785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64786. * @param name The name of the effect.
  64787. * @param options The required width/height ratio to downsize to before computing the render pass.
  64788. * @param camera The camera to apply the render pass to.
  64789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64790. * @param engine The engine which the post process will be applied. (default: current engine)
  64791. * @param reusable If the post process can be reused on the same frame. (default: false)
  64792. */
  64793. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64794. }
  64795. }
  64796. declare module BABYLON {
  64797. /**
  64798. * This represents a set of one or more post processes in Babylon.
  64799. * A post process can be used to apply a shader to a texture after it is rendered.
  64800. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64801. */
  64802. export class PostProcessRenderEffect {
  64803. private _postProcesses;
  64804. private _getPostProcesses;
  64805. private _singleInstance;
  64806. private _cameras;
  64807. private _indicesForCamera;
  64808. /**
  64809. * Name of the effect
  64810. * @hidden
  64811. */
  64812. _name: string;
  64813. /**
  64814. * Instantiates a post process render effect.
  64815. * A post process can be used to apply a shader to a texture after it is rendered.
  64816. * @param engine The engine the effect is tied to
  64817. * @param name The name of the effect
  64818. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64819. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64820. */
  64821. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64822. /**
  64823. * Checks if all the post processes in the effect are supported.
  64824. */
  64825. get isSupported(): boolean;
  64826. /**
  64827. * Updates the current state of the effect
  64828. * @hidden
  64829. */
  64830. _update(): void;
  64831. /**
  64832. * Attaches the effect on cameras
  64833. * @param cameras The camera to attach to.
  64834. * @hidden
  64835. */
  64836. _attachCameras(cameras: Camera): void;
  64837. /**
  64838. * Attaches the effect on cameras
  64839. * @param cameras The camera to attach to.
  64840. * @hidden
  64841. */
  64842. _attachCameras(cameras: Camera[]): void;
  64843. /**
  64844. * Detaches the effect on cameras
  64845. * @param cameras The camera to detatch from.
  64846. * @hidden
  64847. */
  64848. _detachCameras(cameras: Camera): void;
  64849. /**
  64850. * Detatches the effect on cameras
  64851. * @param cameras The camera to detatch from.
  64852. * @hidden
  64853. */
  64854. _detachCameras(cameras: Camera[]): void;
  64855. /**
  64856. * Enables the effect on given cameras
  64857. * @param cameras The camera to enable.
  64858. * @hidden
  64859. */
  64860. _enable(cameras: Camera): void;
  64861. /**
  64862. * Enables the effect on given cameras
  64863. * @param cameras The camera to enable.
  64864. * @hidden
  64865. */
  64866. _enable(cameras: Nullable<Camera[]>): void;
  64867. /**
  64868. * Disables the effect on the given cameras
  64869. * @param cameras The camera to disable.
  64870. * @hidden
  64871. */
  64872. _disable(cameras: Camera): void;
  64873. /**
  64874. * Disables the effect on the given cameras
  64875. * @param cameras The camera to disable.
  64876. * @hidden
  64877. */
  64878. _disable(cameras: Nullable<Camera[]>): void;
  64879. /**
  64880. * Gets a list of the post processes contained in the effect.
  64881. * @param camera The camera to get the post processes on.
  64882. * @returns The list of the post processes in the effect.
  64883. */
  64884. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64885. }
  64886. }
  64887. declare module BABYLON {
  64888. /** @hidden */
  64889. export var extractHighlightsPixelShader: {
  64890. name: string;
  64891. shader: string;
  64892. };
  64893. }
  64894. declare module BABYLON {
  64895. /**
  64896. * 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.
  64897. */
  64898. export class ExtractHighlightsPostProcess extends PostProcess {
  64899. /**
  64900. * The luminance threshold, pixels below this value will be set to black.
  64901. */
  64902. threshold: number;
  64903. /** @hidden */
  64904. _exposure: number;
  64905. /**
  64906. * Post process which has the input texture to be used when performing highlight extraction
  64907. * @hidden
  64908. */
  64909. _inputPostProcess: Nullable<PostProcess>;
  64910. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64911. }
  64912. }
  64913. declare module BABYLON {
  64914. /** @hidden */
  64915. export var bloomMergePixelShader: {
  64916. name: string;
  64917. shader: string;
  64918. };
  64919. }
  64920. declare module BABYLON {
  64921. /**
  64922. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64923. */
  64924. export class BloomMergePostProcess extends PostProcess {
  64925. /** Weight of the bloom to be added to the original input. */
  64926. weight: number;
  64927. /**
  64928. * Creates a new instance of @see BloomMergePostProcess
  64929. * @param name The name of the effect.
  64930. * @param originalFromInput Post process which's input will be used for the merge.
  64931. * @param blurred Blurred highlights post process which's output will be used.
  64932. * @param weight Weight of the bloom to be added to the original input.
  64933. * @param options The required width/height ratio to downsize to before computing the render pass.
  64934. * @param camera The camera to apply the render pass to.
  64935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64936. * @param engine The engine which the post process will be applied. (default: current engine)
  64937. * @param reusable If the post process can be reused on the same frame. (default: false)
  64938. * @param textureType Type of textures used when performing the post process. (default: 0)
  64939. * @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)
  64940. */
  64941. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64942. /** Weight of the bloom to be added to the original input. */
  64943. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64944. }
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64949. */
  64950. export class BloomEffect extends PostProcessRenderEffect {
  64951. private bloomScale;
  64952. /**
  64953. * @hidden Internal
  64954. */
  64955. _effects: Array<PostProcess>;
  64956. /**
  64957. * @hidden Internal
  64958. */
  64959. _downscale: ExtractHighlightsPostProcess;
  64960. private _blurX;
  64961. private _blurY;
  64962. private _merge;
  64963. /**
  64964. * The luminance threshold to find bright areas of the image to bloom.
  64965. */
  64966. get threshold(): number;
  64967. set threshold(value: number);
  64968. /**
  64969. * The strength of the bloom.
  64970. */
  64971. get weight(): number;
  64972. set weight(value: number);
  64973. /**
  64974. * Specifies the size of the bloom blur kernel, relative to the final output size
  64975. */
  64976. get kernel(): number;
  64977. set kernel(value: number);
  64978. /**
  64979. * Creates a new instance of @see BloomEffect
  64980. * @param scene The scene the effect belongs to.
  64981. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64982. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64983. * @param bloomWeight The the strength of bloom.
  64984. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64985. * @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)
  64986. */
  64987. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64988. /**
  64989. * Disposes each of the internal effects for a given camera.
  64990. * @param camera The camera to dispose the effect on.
  64991. */
  64992. disposeEffects(camera: Camera): void;
  64993. /**
  64994. * @hidden Internal
  64995. */
  64996. _updateEffects(): void;
  64997. /**
  64998. * Internal
  64999. * @returns if all the contained post processes are ready.
  65000. * @hidden
  65001. */
  65002. _isReady(): boolean;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /** @hidden */
  65007. export var chromaticAberrationPixelShader: {
  65008. name: string;
  65009. shader: string;
  65010. };
  65011. }
  65012. declare module BABYLON {
  65013. /**
  65014. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65015. */
  65016. export class ChromaticAberrationPostProcess extends PostProcess {
  65017. /**
  65018. * The amount of seperation of rgb channels (default: 30)
  65019. */
  65020. aberrationAmount: number;
  65021. /**
  65022. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65023. */
  65024. radialIntensity: number;
  65025. /**
  65026. * 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))
  65027. */
  65028. direction: Vector2;
  65029. /**
  65030. * 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))
  65031. */
  65032. centerPosition: Vector2;
  65033. /**
  65034. * Creates a new instance ChromaticAberrationPostProcess
  65035. * @param name The name of the effect.
  65036. * @param screenWidth The width of the screen to apply the effect on.
  65037. * @param screenHeight The height of the screen to apply the effect on.
  65038. * @param options The required width/height ratio to downsize to before computing the render pass.
  65039. * @param camera The camera to apply the render pass to.
  65040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65041. * @param engine The engine which the post process will be applied. (default: current engine)
  65042. * @param reusable If the post process can be reused on the same frame. (default: false)
  65043. * @param textureType Type of textures used when performing the post process. (default: 0)
  65044. * @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)
  65045. */
  65046. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65047. }
  65048. }
  65049. declare module BABYLON {
  65050. /** @hidden */
  65051. export var circleOfConfusionPixelShader: {
  65052. name: string;
  65053. shader: string;
  65054. };
  65055. }
  65056. declare module BABYLON {
  65057. /**
  65058. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65059. */
  65060. export class CircleOfConfusionPostProcess extends PostProcess {
  65061. /**
  65062. * 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.
  65063. */
  65064. lensSize: number;
  65065. /**
  65066. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65067. */
  65068. fStop: number;
  65069. /**
  65070. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65071. */
  65072. focusDistance: number;
  65073. /**
  65074. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65075. */
  65076. focalLength: number;
  65077. private _depthTexture;
  65078. /**
  65079. * Creates a new instance CircleOfConfusionPostProcess
  65080. * @param name The name of the effect.
  65081. * @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.
  65082. * @param options The required width/height ratio to downsize to before computing the render pass.
  65083. * @param camera The camera to apply the render pass to.
  65084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65085. * @param engine The engine which the post process will be applied. (default: current engine)
  65086. * @param reusable If the post process can be reused on the same frame. (default: false)
  65087. * @param textureType Type of textures used when performing the post process. (default: 0)
  65088. * @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)
  65089. */
  65090. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65091. /**
  65092. * 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.
  65093. */
  65094. set depthTexture(value: RenderTargetTexture);
  65095. }
  65096. }
  65097. declare module BABYLON {
  65098. /** @hidden */
  65099. export var colorCorrectionPixelShader: {
  65100. name: string;
  65101. shader: string;
  65102. };
  65103. }
  65104. declare module BABYLON {
  65105. /**
  65106. *
  65107. * This post-process allows the modification of rendered colors by using
  65108. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65109. *
  65110. * The object needs to be provided an url to a texture containing the color
  65111. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65112. * Use an image editing software to tweak the LUT to match your needs.
  65113. *
  65114. * For an example of a color LUT, see here:
  65115. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65116. * For explanations on color grading, see here:
  65117. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65118. *
  65119. */
  65120. export class ColorCorrectionPostProcess extends PostProcess {
  65121. private _colorTableTexture;
  65122. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65123. }
  65124. }
  65125. declare module BABYLON {
  65126. /** @hidden */
  65127. export var convolutionPixelShader: {
  65128. name: string;
  65129. shader: string;
  65130. };
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65135. * input texture to perform effects such as edge detection or sharpening
  65136. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65137. */
  65138. export class ConvolutionPostProcess extends PostProcess {
  65139. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65140. kernel: number[];
  65141. /**
  65142. * Creates a new instance ConvolutionPostProcess
  65143. * @param name The name of the effect.
  65144. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65145. * @param options The required width/height ratio to downsize to before computing the render pass.
  65146. * @param camera The camera to apply the render pass to.
  65147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65148. * @param engine The engine which the post process will be applied. (default: current engine)
  65149. * @param reusable If the post process can be reused on the same frame. (default: false)
  65150. * @param textureType Type of textures used when performing the post process. (default: 0)
  65151. */
  65152. constructor(name: string,
  65153. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65154. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65155. /**
  65156. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65157. */
  65158. static EdgeDetect0Kernel: number[];
  65159. /**
  65160. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65161. */
  65162. static EdgeDetect1Kernel: number[];
  65163. /**
  65164. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65165. */
  65166. static EdgeDetect2Kernel: number[];
  65167. /**
  65168. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65169. */
  65170. static SharpenKernel: number[];
  65171. /**
  65172. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65173. */
  65174. static EmbossKernel: number[];
  65175. /**
  65176. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65177. */
  65178. static GaussianKernel: number[];
  65179. }
  65180. }
  65181. declare module BABYLON {
  65182. /**
  65183. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65184. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65185. * based on samples that have a large difference in distance than the center pixel.
  65186. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65187. */
  65188. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65189. direction: Vector2;
  65190. /**
  65191. * Creates a new instance CircleOfConfusionPostProcess
  65192. * @param name The name of the effect.
  65193. * @param scene The scene the effect belongs to.
  65194. * @param direction The direction the blur should be applied.
  65195. * @param kernel The size of the kernel used to blur.
  65196. * @param options The required width/height ratio to downsize to before computing the render pass.
  65197. * @param camera The camera to apply the render pass to.
  65198. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65199. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65201. * @param engine The engine which the post process will be applied. (default: current engine)
  65202. * @param reusable If the post process can be reused on the same frame. (default: false)
  65203. * @param textureType Type of textures used when performing the post process. (default: 0)
  65204. * @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)
  65205. */
  65206. 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);
  65207. }
  65208. }
  65209. declare module BABYLON {
  65210. /** @hidden */
  65211. export var depthOfFieldMergePixelShader: {
  65212. name: string;
  65213. shader: string;
  65214. };
  65215. }
  65216. declare module BABYLON {
  65217. /**
  65218. * Options to be set when merging outputs from the default pipeline.
  65219. */
  65220. export class DepthOfFieldMergePostProcessOptions {
  65221. /**
  65222. * The original image to merge on top of
  65223. */
  65224. originalFromInput: PostProcess;
  65225. /**
  65226. * Parameters to perform the merge of the depth of field effect
  65227. */
  65228. depthOfField?: {
  65229. circleOfConfusion: PostProcess;
  65230. blurSteps: Array<PostProcess>;
  65231. };
  65232. /**
  65233. * Parameters to perform the merge of bloom effect
  65234. */
  65235. bloom?: {
  65236. blurred: PostProcess;
  65237. weight: number;
  65238. };
  65239. }
  65240. /**
  65241. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65242. */
  65243. export class DepthOfFieldMergePostProcess extends PostProcess {
  65244. private blurSteps;
  65245. /**
  65246. * Creates a new instance of DepthOfFieldMergePostProcess
  65247. * @param name The name of the effect.
  65248. * @param originalFromInput Post process which's input will be used for the merge.
  65249. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65250. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65251. * @param options The required width/height ratio to downsize to before computing the render pass.
  65252. * @param camera The camera to apply the render pass to.
  65253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65254. * @param engine The engine which the post process will be applied. (default: current engine)
  65255. * @param reusable If the post process can be reused on the same frame. (default: false)
  65256. * @param textureType Type of textures used when performing the post process. (default: 0)
  65257. * @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)
  65258. */
  65259. 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);
  65260. /**
  65261. * Updates the effect with the current post process compile time values and recompiles the shader.
  65262. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65263. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65264. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65265. * @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
  65266. * @param onCompiled Called when the shader has been compiled.
  65267. * @param onError Called if there is an error when compiling a shader.
  65268. */
  65269. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65270. }
  65271. }
  65272. declare module BABYLON {
  65273. /**
  65274. * Specifies the level of max blur that should be applied when using the depth of field effect
  65275. */
  65276. export enum DepthOfFieldEffectBlurLevel {
  65277. /**
  65278. * Subtle blur
  65279. */
  65280. Low = 0,
  65281. /**
  65282. * Medium blur
  65283. */
  65284. Medium = 1,
  65285. /**
  65286. * Large blur
  65287. */
  65288. High = 2
  65289. }
  65290. /**
  65291. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65292. */
  65293. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65294. private _circleOfConfusion;
  65295. /**
  65296. * @hidden Internal, blurs from high to low
  65297. */
  65298. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65299. private _depthOfFieldBlurY;
  65300. private _dofMerge;
  65301. /**
  65302. * @hidden Internal post processes in depth of field effect
  65303. */
  65304. _effects: Array<PostProcess>;
  65305. /**
  65306. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65307. */
  65308. set focalLength(value: number);
  65309. get focalLength(): number;
  65310. /**
  65311. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65312. */
  65313. set fStop(value: number);
  65314. get fStop(): number;
  65315. /**
  65316. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65317. */
  65318. set focusDistance(value: number);
  65319. get focusDistance(): number;
  65320. /**
  65321. * 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.
  65322. */
  65323. set lensSize(value: number);
  65324. get lensSize(): number;
  65325. /**
  65326. * Creates a new instance DepthOfFieldEffect
  65327. * @param scene The scene the effect belongs to.
  65328. * @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.
  65329. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65330. * @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)
  65331. */
  65332. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65333. /**
  65334. * Get the current class name of the current effet
  65335. * @returns "DepthOfFieldEffect"
  65336. */
  65337. getClassName(): string;
  65338. /**
  65339. * 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.
  65340. */
  65341. set depthTexture(value: RenderTargetTexture);
  65342. /**
  65343. * Disposes each of the internal effects for a given camera.
  65344. * @param camera The camera to dispose the effect on.
  65345. */
  65346. disposeEffects(camera: Camera): void;
  65347. /**
  65348. * @hidden Internal
  65349. */
  65350. _updateEffects(): void;
  65351. /**
  65352. * Internal
  65353. * @returns if all the contained post processes are ready.
  65354. * @hidden
  65355. */
  65356. _isReady(): boolean;
  65357. }
  65358. }
  65359. declare module BABYLON {
  65360. /** @hidden */
  65361. export var displayPassPixelShader: {
  65362. name: string;
  65363. shader: string;
  65364. };
  65365. }
  65366. declare module BABYLON {
  65367. /**
  65368. * DisplayPassPostProcess which produces an output the same as it's input
  65369. */
  65370. export class DisplayPassPostProcess extends PostProcess {
  65371. /**
  65372. * Creates the DisplayPassPostProcess
  65373. * @param name The name of the effect.
  65374. * @param options The required width/height ratio to downsize to before computing the render pass.
  65375. * @param camera The camera to apply the render pass to.
  65376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65377. * @param engine The engine which the post process will be applied. (default: current engine)
  65378. * @param reusable If the post process can be reused on the same frame. (default: false)
  65379. */
  65380. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65381. }
  65382. }
  65383. declare module BABYLON {
  65384. /** @hidden */
  65385. export var filterPixelShader: {
  65386. name: string;
  65387. shader: string;
  65388. };
  65389. }
  65390. declare module BABYLON {
  65391. /**
  65392. * Applies a kernel filter to the image
  65393. */
  65394. export class FilterPostProcess extends PostProcess {
  65395. /** The matrix to be applied to the image */
  65396. kernelMatrix: Matrix;
  65397. /**
  65398. *
  65399. * @param name The name of the effect.
  65400. * @param kernelMatrix The matrix to be applied to the image
  65401. * @param options The required width/height ratio to downsize to before computing the render pass.
  65402. * @param camera The camera to apply the render pass to.
  65403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65404. * @param engine The engine which the post process will be applied. (default: current engine)
  65405. * @param reusable If the post process can be reused on the same frame. (default: false)
  65406. */
  65407. constructor(name: string,
  65408. /** The matrix to be applied to the image */
  65409. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /** @hidden */
  65414. export var fxaaPixelShader: {
  65415. name: string;
  65416. shader: string;
  65417. };
  65418. }
  65419. declare module BABYLON {
  65420. /** @hidden */
  65421. export var fxaaVertexShader: {
  65422. name: string;
  65423. shader: string;
  65424. };
  65425. }
  65426. declare module BABYLON {
  65427. /**
  65428. * Fxaa post process
  65429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65430. */
  65431. export class FxaaPostProcess extends PostProcess {
  65432. /** @hidden */
  65433. texelWidth: number;
  65434. /** @hidden */
  65435. texelHeight: number;
  65436. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65437. private _getDefines;
  65438. }
  65439. }
  65440. declare module BABYLON {
  65441. /** @hidden */
  65442. export var grainPixelShader: {
  65443. name: string;
  65444. shader: string;
  65445. };
  65446. }
  65447. declare module BABYLON {
  65448. /**
  65449. * The GrainPostProcess adds noise to the image at mid luminance levels
  65450. */
  65451. export class GrainPostProcess extends PostProcess {
  65452. /**
  65453. * The intensity of the grain added (default: 30)
  65454. */
  65455. intensity: number;
  65456. /**
  65457. * If the grain should be randomized on every frame
  65458. */
  65459. animated: boolean;
  65460. /**
  65461. * Creates a new instance of @see GrainPostProcess
  65462. * @param name The name of the effect.
  65463. * @param options The required width/height ratio to downsize to before computing the render pass.
  65464. * @param camera The camera to apply the render pass to.
  65465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65466. * @param engine The engine which the post process will be applied. (default: current engine)
  65467. * @param reusable If the post process can be reused on the same frame. (default: false)
  65468. * @param textureType Type of textures used when performing the post process. (default: 0)
  65469. * @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)
  65470. */
  65471. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65472. }
  65473. }
  65474. declare module BABYLON {
  65475. /** @hidden */
  65476. export var highlightsPixelShader: {
  65477. name: string;
  65478. shader: string;
  65479. };
  65480. }
  65481. declare module BABYLON {
  65482. /**
  65483. * Extracts highlights from the image
  65484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65485. */
  65486. export class HighlightsPostProcess extends PostProcess {
  65487. /**
  65488. * Extracts highlights from the image
  65489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65490. * @param name The name of the effect.
  65491. * @param options The required width/height ratio to downsize to before computing the render pass.
  65492. * @param camera The camera to apply the render pass to.
  65493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65494. * @param engine The engine which the post process will be applied. (default: current engine)
  65495. * @param reusable If the post process can be reused on the same frame. (default: false)
  65496. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65497. */
  65498. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /** @hidden */
  65503. export var mrtFragmentDeclaration: {
  65504. name: string;
  65505. shader: string;
  65506. };
  65507. }
  65508. declare module BABYLON {
  65509. /** @hidden */
  65510. export var geometryPixelShader: {
  65511. name: string;
  65512. shader: string;
  65513. };
  65514. }
  65515. declare module BABYLON {
  65516. /** @hidden */
  65517. export var geometryVertexShader: {
  65518. name: string;
  65519. shader: string;
  65520. };
  65521. }
  65522. declare module BABYLON {
  65523. /** @hidden */
  65524. interface ISavedTransformationMatrix {
  65525. world: Matrix;
  65526. viewProjection: Matrix;
  65527. }
  65528. /**
  65529. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65530. */
  65531. export class GeometryBufferRenderer {
  65532. /**
  65533. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65534. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65535. */
  65536. static readonly POSITION_TEXTURE_TYPE: number;
  65537. /**
  65538. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65539. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65540. */
  65541. static readonly VELOCITY_TEXTURE_TYPE: number;
  65542. /**
  65543. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65544. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65545. */
  65546. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65547. /**
  65548. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65549. * in order to compute objects velocities when enableVelocity is set to "true"
  65550. * @hidden
  65551. */
  65552. _previousTransformationMatrices: {
  65553. [index: number]: ISavedTransformationMatrix;
  65554. };
  65555. /**
  65556. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65557. * in order to compute objects velocities when enableVelocity is set to "true"
  65558. * @hidden
  65559. */
  65560. _previousBonesTransformationMatrices: {
  65561. [index: number]: Float32Array;
  65562. };
  65563. /**
  65564. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65565. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65566. */
  65567. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65568. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65569. renderTransparentMeshes: boolean;
  65570. private _scene;
  65571. private _multiRenderTarget;
  65572. private _ratio;
  65573. private _enablePosition;
  65574. private _enableVelocity;
  65575. private _enableReflectivity;
  65576. private _positionIndex;
  65577. private _velocityIndex;
  65578. private _reflectivityIndex;
  65579. protected _effect: Effect;
  65580. protected _cachedDefines: string;
  65581. /**
  65582. * Set the render list (meshes to be rendered) used in the G buffer.
  65583. */
  65584. set renderList(meshes: Mesh[]);
  65585. /**
  65586. * Gets wether or not G buffer are supported by the running hardware.
  65587. * This requires draw buffer supports
  65588. */
  65589. get isSupported(): boolean;
  65590. /**
  65591. * Returns the index of the given texture type in the G-Buffer textures array
  65592. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65593. * @returns the index of the given texture type in the G-Buffer textures array
  65594. */
  65595. getTextureIndex(textureType: number): number;
  65596. /**
  65597. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65598. */
  65599. get enablePosition(): boolean;
  65600. /**
  65601. * Sets whether or not objects positions are enabled for the G buffer.
  65602. */
  65603. set enablePosition(enable: boolean);
  65604. /**
  65605. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65606. */
  65607. get enableVelocity(): boolean;
  65608. /**
  65609. * Sets wether or not objects velocities are enabled for the G buffer.
  65610. */
  65611. set enableVelocity(enable: boolean);
  65612. /**
  65613. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65614. */
  65615. get enableReflectivity(): boolean;
  65616. /**
  65617. * Sets wether or not objects roughness are enabled for the G buffer.
  65618. */
  65619. set enableReflectivity(enable: boolean);
  65620. /**
  65621. * Gets the scene associated with the buffer.
  65622. */
  65623. get scene(): Scene;
  65624. /**
  65625. * Gets the ratio used by the buffer during its creation.
  65626. * How big is the buffer related to the main canvas.
  65627. */
  65628. get ratio(): number;
  65629. /** @hidden */
  65630. static _SceneComponentInitialization: (scene: Scene) => void;
  65631. /**
  65632. * Creates a new G Buffer for the scene
  65633. * @param scene The scene the buffer belongs to
  65634. * @param ratio How big is the buffer related to the main canvas.
  65635. */
  65636. constructor(scene: Scene, ratio?: number);
  65637. /**
  65638. * Checks wether everything is ready to render a submesh to the G buffer.
  65639. * @param subMesh the submesh to check readiness for
  65640. * @param useInstances is the mesh drawn using instance or not
  65641. * @returns true if ready otherwise false
  65642. */
  65643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65644. /**
  65645. * Gets the current underlying G Buffer.
  65646. * @returns the buffer
  65647. */
  65648. getGBuffer(): MultiRenderTarget;
  65649. /**
  65650. * Gets the number of samples used to render the buffer (anti aliasing).
  65651. */
  65652. get samples(): number;
  65653. /**
  65654. * Sets the number of samples used to render the buffer (anti aliasing).
  65655. */
  65656. set samples(value: number);
  65657. /**
  65658. * Disposes the renderer and frees up associated resources.
  65659. */
  65660. dispose(): void;
  65661. protected _createRenderTargets(): void;
  65662. private _copyBonesTransformationMatrices;
  65663. }
  65664. }
  65665. declare module BABYLON {
  65666. interface Scene {
  65667. /** @hidden (Backing field) */
  65668. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65669. /**
  65670. * Gets or Sets the current geometry buffer associated to the scene.
  65671. */
  65672. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65673. /**
  65674. * Enables a GeometryBufferRender and associates it with the scene
  65675. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65676. * @returns the GeometryBufferRenderer
  65677. */
  65678. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65679. /**
  65680. * Disables the GeometryBufferRender associated with the scene
  65681. */
  65682. disableGeometryBufferRenderer(): void;
  65683. }
  65684. /**
  65685. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65686. * in several rendering techniques.
  65687. */
  65688. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65689. /**
  65690. * The component name helpful to identify the component in the list of scene components.
  65691. */
  65692. readonly name: string;
  65693. /**
  65694. * The scene the component belongs to.
  65695. */
  65696. scene: Scene;
  65697. /**
  65698. * Creates a new instance of the component for the given scene
  65699. * @param scene Defines the scene to register the component in
  65700. */
  65701. constructor(scene: Scene);
  65702. /**
  65703. * Registers the component in a given scene
  65704. */
  65705. register(): void;
  65706. /**
  65707. * Rebuilds the elements related to this component in case of
  65708. * context lost for instance.
  65709. */
  65710. rebuild(): void;
  65711. /**
  65712. * Disposes the component and the associated ressources
  65713. */
  65714. dispose(): void;
  65715. private _gatherRenderTargets;
  65716. }
  65717. }
  65718. declare module BABYLON {
  65719. /** @hidden */
  65720. export var motionBlurPixelShader: {
  65721. name: string;
  65722. shader: string;
  65723. };
  65724. }
  65725. declare module BABYLON {
  65726. /**
  65727. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65728. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65729. * As an example, all you have to do is to create the post-process:
  65730. * var mb = new BABYLON.MotionBlurPostProcess(
  65731. * 'mb', // The name of the effect.
  65732. * scene, // The scene containing the objects to blur according to their velocity.
  65733. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65734. * camera // The camera to apply the render pass to.
  65735. * );
  65736. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65737. */
  65738. export class MotionBlurPostProcess extends PostProcess {
  65739. /**
  65740. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65741. */
  65742. motionStrength: number;
  65743. /**
  65744. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65745. */
  65746. get motionBlurSamples(): number;
  65747. /**
  65748. * Sets the number of iterations to be used for motion blur quality
  65749. */
  65750. set motionBlurSamples(samples: number);
  65751. private _motionBlurSamples;
  65752. private _geometryBufferRenderer;
  65753. /**
  65754. * Creates a new instance MotionBlurPostProcess
  65755. * @param name The name of the effect.
  65756. * @param scene The scene containing the objects to blur according to their velocity.
  65757. * @param options The required width/height ratio to downsize to before computing the render pass.
  65758. * @param camera The camera to apply the render pass to.
  65759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65760. * @param engine The engine which the post process will be applied. (default: current engine)
  65761. * @param reusable If the post process can be reused on the same frame. (default: false)
  65762. * @param textureType Type of textures used when performing the post process. (default: 0)
  65763. * @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)
  65764. */
  65765. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65766. /**
  65767. * Excludes the given skinned mesh from computing bones velocities.
  65768. * 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.
  65769. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65770. */
  65771. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65772. /**
  65773. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65774. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65775. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65776. */
  65777. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65778. /**
  65779. * Disposes the post process.
  65780. * @param camera The camera to dispose the post process on.
  65781. */
  65782. dispose(camera?: Camera): void;
  65783. }
  65784. }
  65785. declare module BABYLON {
  65786. /** @hidden */
  65787. export var refractionPixelShader: {
  65788. name: string;
  65789. shader: string;
  65790. };
  65791. }
  65792. declare module BABYLON {
  65793. /**
  65794. * Post process which applies a refractin texture
  65795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65796. */
  65797. export class RefractionPostProcess extends PostProcess {
  65798. /** the base color of the refraction (used to taint the rendering) */
  65799. color: Color3;
  65800. /** simulated refraction depth */
  65801. depth: number;
  65802. /** the coefficient of the base color (0 to remove base color tainting) */
  65803. colorLevel: number;
  65804. private _refTexture;
  65805. private _ownRefractionTexture;
  65806. /**
  65807. * Gets or sets the refraction texture
  65808. * Please note that you are responsible for disposing the texture if you set it manually
  65809. */
  65810. get refractionTexture(): Texture;
  65811. set refractionTexture(value: Texture);
  65812. /**
  65813. * Initializes the RefractionPostProcess
  65814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65815. * @param name The name of the effect.
  65816. * @param refractionTextureUrl Url of the refraction texture to use
  65817. * @param color the base color of the refraction (used to taint the rendering)
  65818. * @param depth simulated refraction depth
  65819. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65820. * @param camera The camera to apply the render pass to.
  65821. * @param options The required width/height ratio to downsize to before computing the render pass.
  65822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65823. * @param engine The engine which the post process will be applied. (default: current engine)
  65824. * @param reusable If the post process can be reused on the same frame. (default: false)
  65825. */
  65826. constructor(name: string, refractionTextureUrl: string,
  65827. /** the base color of the refraction (used to taint the rendering) */
  65828. color: Color3,
  65829. /** simulated refraction depth */
  65830. depth: number,
  65831. /** the coefficient of the base color (0 to remove base color tainting) */
  65832. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65833. /**
  65834. * Disposes of the post process
  65835. * @param camera Camera to dispose post process on
  65836. */
  65837. dispose(camera: Camera): void;
  65838. }
  65839. }
  65840. declare module BABYLON {
  65841. /** @hidden */
  65842. export var sharpenPixelShader: {
  65843. name: string;
  65844. shader: string;
  65845. };
  65846. }
  65847. declare module BABYLON {
  65848. /**
  65849. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65850. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65851. */
  65852. export class SharpenPostProcess extends PostProcess {
  65853. /**
  65854. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65855. */
  65856. colorAmount: number;
  65857. /**
  65858. * How much sharpness should be applied (default: 0.3)
  65859. */
  65860. edgeAmount: number;
  65861. /**
  65862. * Creates a new instance ConvolutionPostProcess
  65863. * @param name The name of the effect.
  65864. * @param options The required width/height ratio to downsize to before computing the render pass.
  65865. * @param camera The camera to apply the render pass to.
  65866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65867. * @param engine The engine which the post process will be applied. (default: current engine)
  65868. * @param reusable If the post process can be reused on the same frame. (default: false)
  65869. * @param textureType Type of textures used when performing the post process. (default: 0)
  65870. * @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)
  65871. */
  65872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65873. }
  65874. }
  65875. declare module BABYLON {
  65876. /**
  65877. * PostProcessRenderPipeline
  65878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65879. */
  65880. export class PostProcessRenderPipeline {
  65881. private engine;
  65882. private _renderEffects;
  65883. private _renderEffectsForIsolatedPass;
  65884. /**
  65885. * List of inspectable custom properties (used by the Inspector)
  65886. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65887. */
  65888. inspectableCustomProperties: IInspectable[];
  65889. /**
  65890. * @hidden
  65891. */
  65892. protected _cameras: Camera[];
  65893. /** @hidden */
  65894. _name: string;
  65895. /**
  65896. * Gets pipeline name
  65897. */
  65898. get name(): string;
  65899. /** Gets the list of attached cameras */
  65900. get cameras(): Camera[];
  65901. /**
  65902. * Initializes a PostProcessRenderPipeline
  65903. * @param engine engine to add the pipeline to
  65904. * @param name name of the pipeline
  65905. */
  65906. constructor(engine: Engine, name: string);
  65907. /**
  65908. * Gets the class name
  65909. * @returns "PostProcessRenderPipeline"
  65910. */
  65911. getClassName(): string;
  65912. /**
  65913. * If all the render effects in the pipeline are supported
  65914. */
  65915. get isSupported(): boolean;
  65916. /**
  65917. * Adds an effect to the pipeline
  65918. * @param renderEffect the effect to add
  65919. */
  65920. addEffect(renderEffect: PostProcessRenderEffect): void;
  65921. /** @hidden */
  65922. _rebuild(): void;
  65923. /** @hidden */
  65924. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65925. /** @hidden */
  65926. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65927. /** @hidden */
  65928. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65929. /** @hidden */
  65930. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65931. /** @hidden */
  65932. _attachCameras(cameras: Camera, unique: boolean): void;
  65933. /** @hidden */
  65934. _attachCameras(cameras: Camera[], unique: boolean): void;
  65935. /** @hidden */
  65936. _detachCameras(cameras: Camera): void;
  65937. /** @hidden */
  65938. _detachCameras(cameras: Nullable<Camera[]>): void;
  65939. /** @hidden */
  65940. _update(): void;
  65941. /** @hidden */
  65942. _reset(): void;
  65943. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65944. /**
  65945. * Disposes of the pipeline
  65946. */
  65947. dispose(): void;
  65948. }
  65949. }
  65950. declare module BABYLON {
  65951. /**
  65952. * PostProcessRenderPipelineManager class
  65953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65954. */
  65955. export class PostProcessRenderPipelineManager {
  65956. private _renderPipelines;
  65957. /**
  65958. * Initializes a PostProcessRenderPipelineManager
  65959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65960. */
  65961. constructor();
  65962. /**
  65963. * Gets the list of supported render pipelines
  65964. */
  65965. get supportedPipelines(): PostProcessRenderPipeline[];
  65966. /**
  65967. * Adds a pipeline to the manager
  65968. * @param renderPipeline The pipeline to add
  65969. */
  65970. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65971. /**
  65972. * Attaches a camera to the pipeline
  65973. * @param renderPipelineName The name of the pipeline to attach to
  65974. * @param cameras the camera to attach
  65975. * @param unique if the camera can be attached multiple times to the pipeline
  65976. */
  65977. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65978. /**
  65979. * Detaches a camera from the pipeline
  65980. * @param renderPipelineName The name of the pipeline to detach from
  65981. * @param cameras the camera to detach
  65982. */
  65983. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65984. /**
  65985. * Enables an effect by name on a pipeline
  65986. * @param renderPipelineName the name of the pipeline to enable the effect in
  65987. * @param renderEffectName the name of the effect to enable
  65988. * @param cameras the cameras that the effect should be enabled on
  65989. */
  65990. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65991. /**
  65992. * Disables an effect by name on a pipeline
  65993. * @param renderPipelineName the name of the pipeline to disable the effect in
  65994. * @param renderEffectName the name of the effect to disable
  65995. * @param cameras the cameras that the effect should be disabled on
  65996. */
  65997. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65998. /**
  65999. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66000. */
  66001. update(): void;
  66002. /** @hidden */
  66003. _rebuild(): void;
  66004. /**
  66005. * Disposes of the manager and pipelines
  66006. */
  66007. dispose(): void;
  66008. }
  66009. }
  66010. declare module BABYLON {
  66011. interface Scene {
  66012. /** @hidden (Backing field) */
  66013. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66014. /**
  66015. * Gets the postprocess render pipeline manager
  66016. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66017. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66018. */
  66019. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66020. }
  66021. /**
  66022. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66023. */
  66024. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66025. /**
  66026. * The component name helpfull to identify the component in the list of scene components.
  66027. */
  66028. readonly name: string;
  66029. /**
  66030. * The scene the component belongs to.
  66031. */
  66032. scene: Scene;
  66033. /**
  66034. * Creates a new instance of the component for the given scene
  66035. * @param scene Defines the scene to register the component in
  66036. */
  66037. constructor(scene: Scene);
  66038. /**
  66039. * Registers the component in a given scene
  66040. */
  66041. register(): void;
  66042. /**
  66043. * Rebuilds the elements related to this component in case of
  66044. * context lost for instance.
  66045. */
  66046. rebuild(): void;
  66047. /**
  66048. * Disposes the component and the associated ressources
  66049. */
  66050. dispose(): void;
  66051. private _gatherRenderTargets;
  66052. }
  66053. }
  66054. declare module BABYLON {
  66055. /**
  66056. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66057. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66058. */
  66059. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66060. private _scene;
  66061. private _camerasToBeAttached;
  66062. /**
  66063. * ID of the sharpen post process,
  66064. */
  66065. private readonly SharpenPostProcessId;
  66066. /**
  66067. * @ignore
  66068. * ID of the image processing post process;
  66069. */
  66070. readonly ImageProcessingPostProcessId: string;
  66071. /**
  66072. * @ignore
  66073. * ID of the Fast Approximate Anti-Aliasing post process;
  66074. */
  66075. readonly FxaaPostProcessId: string;
  66076. /**
  66077. * ID of the chromatic aberration post process,
  66078. */
  66079. private readonly ChromaticAberrationPostProcessId;
  66080. /**
  66081. * ID of the grain post process
  66082. */
  66083. private readonly GrainPostProcessId;
  66084. /**
  66085. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66086. */
  66087. sharpen: SharpenPostProcess;
  66088. private _sharpenEffect;
  66089. private bloom;
  66090. /**
  66091. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66092. */
  66093. depthOfField: DepthOfFieldEffect;
  66094. /**
  66095. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66096. */
  66097. fxaa: FxaaPostProcess;
  66098. /**
  66099. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66100. */
  66101. imageProcessing: ImageProcessingPostProcess;
  66102. /**
  66103. * Chromatic aberration post process which will shift rgb colors in the image
  66104. */
  66105. chromaticAberration: ChromaticAberrationPostProcess;
  66106. private _chromaticAberrationEffect;
  66107. /**
  66108. * Grain post process which add noise to the image
  66109. */
  66110. grain: GrainPostProcess;
  66111. private _grainEffect;
  66112. /**
  66113. * Glow post process which adds a glow to emissive areas of the image
  66114. */
  66115. private _glowLayer;
  66116. /**
  66117. * Animations which can be used to tweak settings over a period of time
  66118. */
  66119. animations: Animation[];
  66120. private _imageProcessingConfigurationObserver;
  66121. private _sharpenEnabled;
  66122. private _bloomEnabled;
  66123. private _depthOfFieldEnabled;
  66124. private _depthOfFieldBlurLevel;
  66125. private _fxaaEnabled;
  66126. private _imageProcessingEnabled;
  66127. private _defaultPipelineTextureType;
  66128. private _bloomScale;
  66129. private _chromaticAberrationEnabled;
  66130. private _grainEnabled;
  66131. private _buildAllowed;
  66132. /**
  66133. * Gets active scene
  66134. */
  66135. get scene(): Scene;
  66136. /**
  66137. * Enable or disable the sharpen process from the pipeline
  66138. */
  66139. set sharpenEnabled(enabled: boolean);
  66140. get sharpenEnabled(): boolean;
  66141. private _resizeObserver;
  66142. private _hardwareScaleLevel;
  66143. private _bloomKernel;
  66144. /**
  66145. * Specifies the size of the bloom blur kernel, relative to the final output size
  66146. */
  66147. get bloomKernel(): number;
  66148. set bloomKernel(value: number);
  66149. /**
  66150. * Specifies the weight of the bloom in the final rendering
  66151. */
  66152. private _bloomWeight;
  66153. /**
  66154. * Specifies the luma threshold for the area that will be blurred by the bloom
  66155. */
  66156. private _bloomThreshold;
  66157. private _hdr;
  66158. /**
  66159. * The strength of the bloom.
  66160. */
  66161. set bloomWeight(value: number);
  66162. get bloomWeight(): number;
  66163. /**
  66164. * The strength of the bloom.
  66165. */
  66166. set bloomThreshold(value: number);
  66167. get bloomThreshold(): number;
  66168. /**
  66169. * The scale of the bloom, lower value will provide better performance.
  66170. */
  66171. set bloomScale(value: number);
  66172. get bloomScale(): number;
  66173. /**
  66174. * Enable or disable the bloom from the pipeline
  66175. */
  66176. set bloomEnabled(enabled: boolean);
  66177. get bloomEnabled(): boolean;
  66178. private _rebuildBloom;
  66179. /**
  66180. * If the depth of field is enabled.
  66181. */
  66182. get depthOfFieldEnabled(): boolean;
  66183. set depthOfFieldEnabled(enabled: boolean);
  66184. /**
  66185. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66186. */
  66187. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66188. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66189. /**
  66190. * If the anti aliasing is enabled.
  66191. */
  66192. set fxaaEnabled(enabled: boolean);
  66193. get fxaaEnabled(): boolean;
  66194. private _samples;
  66195. /**
  66196. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66197. */
  66198. set samples(sampleCount: number);
  66199. get samples(): number;
  66200. /**
  66201. * If image processing is enabled.
  66202. */
  66203. set imageProcessingEnabled(enabled: boolean);
  66204. get imageProcessingEnabled(): boolean;
  66205. /**
  66206. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66207. */
  66208. set glowLayerEnabled(enabled: boolean);
  66209. get glowLayerEnabled(): boolean;
  66210. /**
  66211. * Gets the glow layer (or null if not defined)
  66212. */
  66213. get glowLayer(): Nullable<GlowLayer>;
  66214. /**
  66215. * Enable or disable the chromaticAberration process from the pipeline
  66216. */
  66217. set chromaticAberrationEnabled(enabled: boolean);
  66218. get chromaticAberrationEnabled(): boolean;
  66219. /**
  66220. * Enable or disable the grain process from the pipeline
  66221. */
  66222. set grainEnabled(enabled: boolean);
  66223. get grainEnabled(): boolean;
  66224. /**
  66225. * @constructor
  66226. * @param name - The rendering pipeline name (default: "")
  66227. * @param hdr - If high dynamic range textures should be used (default: true)
  66228. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66229. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66230. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66231. */
  66232. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66233. /**
  66234. * Get the class name
  66235. * @returns "DefaultRenderingPipeline"
  66236. */
  66237. getClassName(): string;
  66238. /**
  66239. * Force the compilation of the entire pipeline.
  66240. */
  66241. prepare(): void;
  66242. private _hasCleared;
  66243. private _prevPostProcess;
  66244. private _prevPrevPostProcess;
  66245. private _setAutoClearAndTextureSharing;
  66246. private _depthOfFieldSceneObserver;
  66247. private _buildPipeline;
  66248. private _disposePostProcesses;
  66249. /**
  66250. * Adds a camera to the pipeline
  66251. * @param camera the camera to be added
  66252. */
  66253. addCamera(camera: Camera): void;
  66254. /**
  66255. * Removes a camera from the pipeline
  66256. * @param camera the camera to remove
  66257. */
  66258. removeCamera(camera: Camera): void;
  66259. /**
  66260. * Dispose of the pipeline and stop all post processes
  66261. */
  66262. dispose(): void;
  66263. /**
  66264. * Serialize the rendering pipeline (Used when exporting)
  66265. * @returns the serialized object
  66266. */
  66267. serialize(): any;
  66268. /**
  66269. * Parse the serialized pipeline
  66270. * @param source Source pipeline.
  66271. * @param scene The scene to load the pipeline to.
  66272. * @param rootUrl The URL of the serialized pipeline.
  66273. * @returns An instantiated pipeline from the serialized object.
  66274. */
  66275. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66276. }
  66277. }
  66278. declare module BABYLON {
  66279. /** @hidden */
  66280. export var lensHighlightsPixelShader: {
  66281. name: string;
  66282. shader: string;
  66283. };
  66284. }
  66285. declare module BABYLON {
  66286. /** @hidden */
  66287. export var depthOfFieldPixelShader: {
  66288. name: string;
  66289. shader: string;
  66290. };
  66291. }
  66292. declare module BABYLON {
  66293. /**
  66294. * BABYLON.JS Chromatic Aberration GLSL Shader
  66295. * Author: Olivier Guyot
  66296. * Separates very slightly R, G and B colors on the edges of the screen
  66297. * Inspired by Francois Tarlier & Martins Upitis
  66298. */
  66299. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66300. /**
  66301. * @ignore
  66302. * The chromatic aberration PostProcess id in the pipeline
  66303. */
  66304. LensChromaticAberrationEffect: string;
  66305. /**
  66306. * @ignore
  66307. * The highlights enhancing PostProcess id in the pipeline
  66308. */
  66309. HighlightsEnhancingEffect: string;
  66310. /**
  66311. * @ignore
  66312. * The depth-of-field PostProcess id in the pipeline
  66313. */
  66314. LensDepthOfFieldEffect: string;
  66315. private _scene;
  66316. private _depthTexture;
  66317. private _grainTexture;
  66318. private _chromaticAberrationPostProcess;
  66319. private _highlightsPostProcess;
  66320. private _depthOfFieldPostProcess;
  66321. private _edgeBlur;
  66322. private _grainAmount;
  66323. private _chromaticAberration;
  66324. private _distortion;
  66325. private _highlightsGain;
  66326. private _highlightsThreshold;
  66327. private _dofDistance;
  66328. private _dofAperture;
  66329. private _dofDarken;
  66330. private _dofPentagon;
  66331. private _blurNoise;
  66332. /**
  66333. * @constructor
  66334. *
  66335. * Effect parameters are as follow:
  66336. * {
  66337. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66338. * edge_blur: number; // from 0 to x (1 for realism)
  66339. * distortion: number; // from 0 to x (1 for realism)
  66340. * grain_amount: number; // from 0 to 1
  66341. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66342. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66343. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66344. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66345. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66346. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66347. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66348. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66349. * }
  66350. * Note: if an effect parameter is unset, effect is disabled
  66351. *
  66352. * @param name The rendering pipeline name
  66353. * @param parameters - An object containing all parameters (see above)
  66354. * @param scene The scene linked to this pipeline
  66355. * @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)
  66356. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66357. */
  66358. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66359. /**
  66360. * Get the class name
  66361. * @returns "LensRenderingPipeline"
  66362. */
  66363. getClassName(): string;
  66364. /**
  66365. * Gets associated scene
  66366. */
  66367. get scene(): Scene;
  66368. /**
  66369. * Gets or sets the edge blur
  66370. */
  66371. get edgeBlur(): number;
  66372. set edgeBlur(value: number);
  66373. /**
  66374. * Gets or sets the grain amount
  66375. */
  66376. get grainAmount(): number;
  66377. set grainAmount(value: number);
  66378. /**
  66379. * Gets or sets the chromatic aberration amount
  66380. */
  66381. get chromaticAberration(): number;
  66382. set chromaticAberration(value: number);
  66383. /**
  66384. * Gets or sets the depth of field aperture
  66385. */
  66386. get dofAperture(): number;
  66387. set dofAperture(value: number);
  66388. /**
  66389. * Gets or sets the edge distortion
  66390. */
  66391. get edgeDistortion(): number;
  66392. set edgeDistortion(value: number);
  66393. /**
  66394. * Gets or sets the depth of field distortion
  66395. */
  66396. get dofDistortion(): number;
  66397. set dofDistortion(value: number);
  66398. /**
  66399. * Gets or sets the darken out of focus amount
  66400. */
  66401. get darkenOutOfFocus(): number;
  66402. set darkenOutOfFocus(value: number);
  66403. /**
  66404. * Gets or sets a boolean indicating if blur noise is enabled
  66405. */
  66406. get blurNoise(): boolean;
  66407. set blurNoise(value: boolean);
  66408. /**
  66409. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66410. */
  66411. get pentagonBokeh(): boolean;
  66412. set pentagonBokeh(value: boolean);
  66413. /**
  66414. * Gets or sets the highlight grain amount
  66415. */
  66416. get highlightsGain(): number;
  66417. set highlightsGain(value: number);
  66418. /**
  66419. * Gets or sets the highlight threshold
  66420. */
  66421. get highlightsThreshold(): number;
  66422. set highlightsThreshold(value: number);
  66423. /**
  66424. * Sets the amount of blur at the edges
  66425. * @param amount blur amount
  66426. */
  66427. setEdgeBlur(amount: number): void;
  66428. /**
  66429. * Sets edge blur to 0
  66430. */
  66431. disableEdgeBlur(): void;
  66432. /**
  66433. * Sets the amout of grain
  66434. * @param amount Amount of grain
  66435. */
  66436. setGrainAmount(amount: number): void;
  66437. /**
  66438. * Set grain amount to 0
  66439. */
  66440. disableGrain(): void;
  66441. /**
  66442. * Sets the chromatic aberration amount
  66443. * @param amount amount of chromatic aberration
  66444. */
  66445. setChromaticAberration(amount: number): void;
  66446. /**
  66447. * Sets chromatic aberration amount to 0
  66448. */
  66449. disableChromaticAberration(): void;
  66450. /**
  66451. * Sets the EdgeDistortion amount
  66452. * @param amount amount of EdgeDistortion
  66453. */
  66454. setEdgeDistortion(amount: number): void;
  66455. /**
  66456. * Sets edge distortion to 0
  66457. */
  66458. disableEdgeDistortion(): void;
  66459. /**
  66460. * Sets the FocusDistance amount
  66461. * @param amount amount of FocusDistance
  66462. */
  66463. setFocusDistance(amount: number): void;
  66464. /**
  66465. * Disables depth of field
  66466. */
  66467. disableDepthOfField(): void;
  66468. /**
  66469. * Sets the Aperture amount
  66470. * @param amount amount of Aperture
  66471. */
  66472. setAperture(amount: number): void;
  66473. /**
  66474. * Sets the DarkenOutOfFocus amount
  66475. * @param amount amount of DarkenOutOfFocus
  66476. */
  66477. setDarkenOutOfFocus(amount: number): void;
  66478. private _pentagonBokehIsEnabled;
  66479. /**
  66480. * Creates a pentagon bokeh effect
  66481. */
  66482. enablePentagonBokeh(): void;
  66483. /**
  66484. * Disables the pentagon bokeh effect
  66485. */
  66486. disablePentagonBokeh(): void;
  66487. /**
  66488. * Enables noise blur
  66489. */
  66490. enableNoiseBlur(): void;
  66491. /**
  66492. * Disables noise blur
  66493. */
  66494. disableNoiseBlur(): void;
  66495. /**
  66496. * Sets the HighlightsGain amount
  66497. * @param amount amount of HighlightsGain
  66498. */
  66499. setHighlightsGain(amount: number): void;
  66500. /**
  66501. * Sets the HighlightsThreshold amount
  66502. * @param amount amount of HighlightsThreshold
  66503. */
  66504. setHighlightsThreshold(amount: number): void;
  66505. /**
  66506. * Disables highlights
  66507. */
  66508. disableHighlights(): void;
  66509. /**
  66510. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66511. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66512. */
  66513. dispose(disableDepthRender?: boolean): void;
  66514. private _createChromaticAberrationPostProcess;
  66515. private _createHighlightsPostProcess;
  66516. private _createDepthOfFieldPostProcess;
  66517. private _createGrainTexture;
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. /** @hidden */
  66522. export var ssao2PixelShader: {
  66523. name: string;
  66524. shader: string;
  66525. };
  66526. }
  66527. declare module BABYLON {
  66528. /** @hidden */
  66529. export var ssaoCombinePixelShader: {
  66530. name: string;
  66531. shader: string;
  66532. };
  66533. }
  66534. declare module BABYLON {
  66535. /**
  66536. * Render pipeline to produce ssao effect
  66537. */
  66538. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66539. /**
  66540. * @ignore
  66541. * The PassPostProcess id in the pipeline that contains the original scene color
  66542. */
  66543. SSAOOriginalSceneColorEffect: string;
  66544. /**
  66545. * @ignore
  66546. * The SSAO PostProcess id in the pipeline
  66547. */
  66548. SSAORenderEffect: string;
  66549. /**
  66550. * @ignore
  66551. * The horizontal blur PostProcess id in the pipeline
  66552. */
  66553. SSAOBlurHRenderEffect: string;
  66554. /**
  66555. * @ignore
  66556. * The vertical blur PostProcess id in the pipeline
  66557. */
  66558. SSAOBlurVRenderEffect: string;
  66559. /**
  66560. * @ignore
  66561. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66562. */
  66563. SSAOCombineRenderEffect: string;
  66564. /**
  66565. * The output strength of the SSAO post-process. Default value is 1.0.
  66566. */
  66567. totalStrength: number;
  66568. /**
  66569. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66570. */
  66571. maxZ: number;
  66572. /**
  66573. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66574. */
  66575. minZAspect: number;
  66576. private _samples;
  66577. /**
  66578. * Number of samples used for the SSAO calculations. Default value is 8
  66579. */
  66580. set samples(n: number);
  66581. get samples(): number;
  66582. private _textureSamples;
  66583. /**
  66584. * Number of samples to use for antialiasing
  66585. */
  66586. set textureSamples(n: number);
  66587. get textureSamples(): number;
  66588. /**
  66589. * Ratio object used for SSAO ratio and blur ratio
  66590. */
  66591. private _ratio;
  66592. /**
  66593. * Dynamically generated sphere sampler.
  66594. */
  66595. private _sampleSphere;
  66596. /**
  66597. * Blur filter offsets
  66598. */
  66599. private _samplerOffsets;
  66600. private _expensiveBlur;
  66601. /**
  66602. * If bilateral blur should be used
  66603. */
  66604. set expensiveBlur(b: boolean);
  66605. get expensiveBlur(): boolean;
  66606. /**
  66607. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66608. */
  66609. radius: number;
  66610. /**
  66611. * The base color of the SSAO post-process
  66612. * The final result is "base + ssao" between [0, 1]
  66613. */
  66614. base: number;
  66615. /**
  66616. * Support test.
  66617. */
  66618. static get IsSupported(): boolean;
  66619. private _scene;
  66620. private _depthTexture;
  66621. private _normalTexture;
  66622. private _randomTexture;
  66623. private _originalColorPostProcess;
  66624. private _ssaoPostProcess;
  66625. private _blurHPostProcess;
  66626. private _blurVPostProcess;
  66627. private _ssaoCombinePostProcess;
  66628. /**
  66629. * Gets active scene
  66630. */
  66631. get scene(): Scene;
  66632. /**
  66633. * @constructor
  66634. * @param name The rendering pipeline name
  66635. * @param scene The scene linked to this pipeline
  66636. * @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 }
  66637. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66638. */
  66639. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66640. /**
  66641. * Get the class name
  66642. * @returns "SSAO2RenderingPipeline"
  66643. */
  66644. getClassName(): string;
  66645. /**
  66646. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66647. */
  66648. dispose(disableGeometryBufferRenderer?: boolean): void;
  66649. private _createBlurPostProcess;
  66650. /** @hidden */
  66651. _rebuild(): void;
  66652. private _bits;
  66653. private _radicalInverse_VdC;
  66654. private _hammersley;
  66655. private _hemisphereSample_uniform;
  66656. private _generateHemisphere;
  66657. private _createSSAOPostProcess;
  66658. private _createSSAOCombinePostProcess;
  66659. private _createRandomTexture;
  66660. /**
  66661. * Serialize the rendering pipeline (Used when exporting)
  66662. * @returns the serialized object
  66663. */
  66664. serialize(): any;
  66665. /**
  66666. * Parse the serialized pipeline
  66667. * @param source Source pipeline.
  66668. * @param scene The scene to load the pipeline to.
  66669. * @param rootUrl The URL of the serialized pipeline.
  66670. * @returns An instantiated pipeline from the serialized object.
  66671. */
  66672. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66673. }
  66674. }
  66675. declare module BABYLON {
  66676. /** @hidden */
  66677. export var ssaoPixelShader: {
  66678. name: string;
  66679. shader: string;
  66680. };
  66681. }
  66682. declare module BABYLON {
  66683. /**
  66684. * Render pipeline to produce ssao effect
  66685. */
  66686. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66687. /**
  66688. * @ignore
  66689. * The PassPostProcess id in the pipeline that contains the original scene color
  66690. */
  66691. SSAOOriginalSceneColorEffect: string;
  66692. /**
  66693. * @ignore
  66694. * The SSAO PostProcess id in the pipeline
  66695. */
  66696. SSAORenderEffect: string;
  66697. /**
  66698. * @ignore
  66699. * The horizontal blur PostProcess id in the pipeline
  66700. */
  66701. SSAOBlurHRenderEffect: string;
  66702. /**
  66703. * @ignore
  66704. * The vertical blur PostProcess id in the pipeline
  66705. */
  66706. SSAOBlurVRenderEffect: string;
  66707. /**
  66708. * @ignore
  66709. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66710. */
  66711. SSAOCombineRenderEffect: string;
  66712. /**
  66713. * The output strength of the SSAO post-process. Default value is 1.0.
  66714. */
  66715. totalStrength: number;
  66716. /**
  66717. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66718. */
  66719. radius: number;
  66720. /**
  66721. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66722. * Must not be equal to fallOff and superior to fallOff.
  66723. * Default value is 0.0075
  66724. */
  66725. area: number;
  66726. /**
  66727. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66728. * Must not be equal to area and inferior to area.
  66729. * Default value is 0.000001
  66730. */
  66731. fallOff: number;
  66732. /**
  66733. * The base color of the SSAO post-process
  66734. * The final result is "base + ssao" between [0, 1]
  66735. */
  66736. base: number;
  66737. private _scene;
  66738. private _depthTexture;
  66739. private _randomTexture;
  66740. private _originalColorPostProcess;
  66741. private _ssaoPostProcess;
  66742. private _blurHPostProcess;
  66743. private _blurVPostProcess;
  66744. private _ssaoCombinePostProcess;
  66745. private _firstUpdate;
  66746. /**
  66747. * Gets active scene
  66748. */
  66749. get scene(): Scene;
  66750. /**
  66751. * @constructor
  66752. * @param name - The rendering pipeline name
  66753. * @param scene - The scene linked to this pipeline
  66754. * @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 }
  66755. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66756. */
  66757. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66758. /**
  66759. * Get the class name
  66760. * @returns "SSAORenderingPipeline"
  66761. */
  66762. getClassName(): string;
  66763. /**
  66764. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66765. */
  66766. dispose(disableDepthRender?: boolean): void;
  66767. private _createBlurPostProcess;
  66768. /** @hidden */
  66769. _rebuild(): void;
  66770. private _createSSAOPostProcess;
  66771. private _createSSAOCombinePostProcess;
  66772. private _createRandomTexture;
  66773. }
  66774. }
  66775. declare module BABYLON {
  66776. /** @hidden */
  66777. export var screenSpaceReflectionPixelShader: {
  66778. name: string;
  66779. shader: string;
  66780. };
  66781. }
  66782. declare module BABYLON {
  66783. /**
  66784. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66785. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66786. */
  66787. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66788. /**
  66789. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66790. */
  66791. threshold: number;
  66792. /**
  66793. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66794. */
  66795. strength: number;
  66796. /**
  66797. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66798. */
  66799. reflectionSpecularFalloffExponent: number;
  66800. /**
  66801. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  66802. */
  66803. step: number;
  66804. /**
  66805. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66806. */
  66807. roughnessFactor: number;
  66808. private _geometryBufferRenderer;
  66809. private _enableSmoothReflections;
  66810. private _reflectionSamples;
  66811. private _smoothSteps;
  66812. /**
  66813. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66814. * @param name The name of the effect.
  66815. * @param scene The scene containing the objects to calculate reflections.
  66816. * @param options The required width/height ratio to downsize to before computing the render pass.
  66817. * @param camera The camera to apply the render pass to.
  66818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66819. * @param engine The engine which the post process will be applied. (default: current engine)
  66820. * @param reusable If the post process can be reused on the same frame. (default: false)
  66821. * @param textureType Type of textures used when performing the post process. (default: 0)
  66822. * @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)
  66823. */
  66824. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66825. /**
  66826. * Gets wether or not smoothing reflections is enabled.
  66827. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66828. */
  66829. get enableSmoothReflections(): boolean;
  66830. /**
  66831. * Sets wether or not smoothing reflections is enabled.
  66832. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66833. */
  66834. set enableSmoothReflections(enabled: boolean);
  66835. /**
  66836. * Gets the number of samples taken while computing reflections. More samples count is high,
  66837. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66838. */
  66839. get reflectionSamples(): number;
  66840. /**
  66841. * Sets the number of samples taken while computing reflections. More samples count is high,
  66842. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66843. */
  66844. set reflectionSamples(samples: number);
  66845. /**
  66846. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66847. * more the post-process will require GPU power and can generate a drop in FPS.
  66848. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66849. */
  66850. get smoothSteps(): number;
  66851. set smoothSteps(steps: number);
  66852. private _updateEffectDefines;
  66853. }
  66854. }
  66855. declare module BABYLON {
  66856. /** @hidden */
  66857. export var standardPixelShader: {
  66858. name: string;
  66859. shader: string;
  66860. };
  66861. }
  66862. declare module BABYLON {
  66863. /**
  66864. * Standard rendering pipeline
  66865. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66866. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66867. */
  66868. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66869. /**
  66870. * Public members
  66871. */
  66872. /**
  66873. * Post-process which contains the original scene color before the pipeline applies all the effects
  66874. */
  66875. originalPostProcess: Nullable<PostProcess>;
  66876. /**
  66877. * Post-process used to down scale an image x4
  66878. */
  66879. downSampleX4PostProcess: Nullable<PostProcess>;
  66880. /**
  66881. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66882. */
  66883. brightPassPostProcess: Nullable<PostProcess>;
  66884. /**
  66885. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66886. */
  66887. blurHPostProcesses: PostProcess[];
  66888. /**
  66889. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66890. */
  66891. blurVPostProcesses: PostProcess[];
  66892. /**
  66893. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66894. */
  66895. textureAdderPostProcess: Nullable<PostProcess>;
  66896. /**
  66897. * Post-process used to create volumetric lighting effect
  66898. */
  66899. volumetricLightPostProcess: Nullable<PostProcess>;
  66900. /**
  66901. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66902. */
  66903. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66904. /**
  66905. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66906. */
  66907. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66908. /**
  66909. * Post-process used to merge the volumetric light effect and the real scene color
  66910. */
  66911. volumetricLightMergePostProces: Nullable<PostProcess>;
  66912. /**
  66913. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66914. */
  66915. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66916. /**
  66917. * Base post-process used to calculate the average luminance of the final image for HDR
  66918. */
  66919. luminancePostProcess: Nullable<PostProcess>;
  66920. /**
  66921. * Post-processes used to create down sample post-processes in order to get
  66922. * the average luminance of the final image for HDR
  66923. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66924. */
  66925. luminanceDownSamplePostProcesses: PostProcess[];
  66926. /**
  66927. * Post-process used to create a HDR effect (light adaptation)
  66928. */
  66929. hdrPostProcess: Nullable<PostProcess>;
  66930. /**
  66931. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66932. */
  66933. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66934. /**
  66935. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66936. */
  66937. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66938. /**
  66939. * Post-process used to merge the final HDR post-process and the real scene color
  66940. */
  66941. hdrFinalPostProcess: Nullable<PostProcess>;
  66942. /**
  66943. * Post-process used to create a lens flare effect
  66944. */
  66945. lensFlarePostProcess: Nullable<PostProcess>;
  66946. /**
  66947. * Post-process that merges the result of the lens flare post-process and the real scene color
  66948. */
  66949. lensFlareComposePostProcess: Nullable<PostProcess>;
  66950. /**
  66951. * Post-process used to create a motion blur effect
  66952. */
  66953. motionBlurPostProcess: Nullable<PostProcess>;
  66954. /**
  66955. * Post-process used to create a depth of field effect
  66956. */
  66957. depthOfFieldPostProcess: Nullable<PostProcess>;
  66958. /**
  66959. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66960. */
  66961. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66962. /**
  66963. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66964. */
  66965. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66966. /**
  66967. * Represents the brightness threshold in order to configure the illuminated surfaces
  66968. */
  66969. brightThreshold: number;
  66970. /**
  66971. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66972. */
  66973. blurWidth: number;
  66974. /**
  66975. * Sets if the blur for highlighted surfaces must be only horizontal
  66976. */
  66977. horizontalBlur: boolean;
  66978. /**
  66979. * Gets the overall exposure used by the pipeline
  66980. */
  66981. get exposure(): number;
  66982. /**
  66983. * Sets the overall exposure used by the pipeline
  66984. */
  66985. set exposure(value: number);
  66986. /**
  66987. * Texture used typically to simulate "dirty" on camera lens
  66988. */
  66989. lensTexture: Nullable<Texture>;
  66990. /**
  66991. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66992. */
  66993. volumetricLightCoefficient: number;
  66994. /**
  66995. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66996. */
  66997. volumetricLightPower: number;
  66998. /**
  66999. * Used the set the blur intensity to smooth the volumetric lights
  67000. */
  67001. volumetricLightBlurScale: number;
  67002. /**
  67003. * Light (spot or directional) used to generate the volumetric lights rays
  67004. * The source light must have a shadow generate so the pipeline can get its
  67005. * depth map
  67006. */
  67007. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67008. /**
  67009. * For eye adaptation, represents the minimum luminance the eye can see
  67010. */
  67011. hdrMinimumLuminance: number;
  67012. /**
  67013. * For eye adaptation, represents the decrease luminance speed
  67014. */
  67015. hdrDecreaseRate: number;
  67016. /**
  67017. * For eye adaptation, represents the increase luminance speed
  67018. */
  67019. hdrIncreaseRate: number;
  67020. /**
  67021. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67022. */
  67023. get hdrAutoExposure(): boolean;
  67024. /**
  67025. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67026. */
  67027. set hdrAutoExposure(value: boolean);
  67028. /**
  67029. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67030. */
  67031. lensColorTexture: Nullable<Texture>;
  67032. /**
  67033. * The overall strengh for the lens flare effect
  67034. */
  67035. lensFlareStrength: number;
  67036. /**
  67037. * Dispersion coefficient for lens flare ghosts
  67038. */
  67039. lensFlareGhostDispersal: number;
  67040. /**
  67041. * Main lens flare halo width
  67042. */
  67043. lensFlareHaloWidth: number;
  67044. /**
  67045. * Based on the lens distortion effect, defines how much the lens flare result
  67046. * is distorted
  67047. */
  67048. lensFlareDistortionStrength: number;
  67049. /**
  67050. * Configures the blur intensity used for for lens flare (halo)
  67051. */
  67052. lensFlareBlurWidth: number;
  67053. /**
  67054. * Lens star texture must be used to simulate rays on the flares and is available
  67055. * in the documentation
  67056. */
  67057. lensStarTexture: Nullable<Texture>;
  67058. /**
  67059. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67060. * flare effect by taking account of the dirt texture
  67061. */
  67062. lensFlareDirtTexture: Nullable<Texture>;
  67063. /**
  67064. * Represents the focal length for the depth of field effect
  67065. */
  67066. depthOfFieldDistance: number;
  67067. /**
  67068. * Represents the blur intensity for the blurred part of the depth of field effect
  67069. */
  67070. depthOfFieldBlurWidth: number;
  67071. /**
  67072. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67073. */
  67074. get motionStrength(): number;
  67075. /**
  67076. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67077. */
  67078. set motionStrength(strength: number);
  67079. /**
  67080. * Gets wether or not the motion blur post-process is object based or screen based.
  67081. */
  67082. get objectBasedMotionBlur(): boolean;
  67083. /**
  67084. * Sets wether or not the motion blur post-process should be object based or screen based
  67085. */
  67086. set objectBasedMotionBlur(value: boolean);
  67087. /**
  67088. * List of animations for the pipeline (IAnimatable implementation)
  67089. */
  67090. animations: Animation[];
  67091. /**
  67092. * Private members
  67093. */
  67094. private _scene;
  67095. private _currentDepthOfFieldSource;
  67096. private _basePostProcess;
  67097. private _fixedExposure;
  67098. private _currentExposure;
  67099. private _hdrAutoExposure;
  67100. private _hdrCurrentLuminance;
  67101. private _motionStrength;
  67102. private _isObjectBasedMotionBlur;
  67103. private _floatTextureType;
  67104. private _camerasToBeAttached;
  67105. private _ratio;
  67106. private _bloomEnabled;
  67107. private _depthOfFieldEnabled;
  67108. private _vlsEnabled;
  67109. private _lensFlareEnabled;
  67110. private _hdrEnabled;
  67111. private _motionBlurEnabled;
  67112. private _fxaaEnabled;
  67113. private _screenSpaceReflectionsEnabled;
  67114. private _motionBlurSamples;
  67115. private _volumetricLightStepsCount;
  67116. private _samples;
  67117. /**
  67118. * @ignore
  67119. * Specifies if the bloom pipeline is enabled
  67120. */
  67121. get BloomEnabled(): boolean;
  67122. set BloomEnabled(enabled: boolean);
  67123. /**
  67124. * @ignore
  67125. * Specifies if the depth of field pipeline is enabed
  67126. */
  67127. get DepthOfFieldEnabled(): boolean;
  67128. set DepthOfFieldEnabled(enabled: boolean);
  67129. /**
  67130. * @ignore
  67131. * Specifies if the lens flare pipeline is enabed
  67132. */
  67133. get LensFlareEnabled(): boolean;
  67134. set LensFlareEnabled(enabled: boolean);
  67135. /**
  67136. * @ignore
  67137. * Specifies if the HDR pipeline is enabled
  67138. */
  67139. get HDREnabled(): boolean;
  67140. set HDREnabled(enabled: boolean);
  67141. /**
  67142. * @ignore
  67143. * Specifies if the volumetric lights scattering effect is enabled
  67144. */
  67145. get VLSEnabled(): boolean;
  67146. set VLSEnabled(enabled: boolean);
  67147. /**
  67148. * @ignore
  67149. * Specifies if the motion blur effect is enabled
  67150. */
  67151. get MotionBlurEnabled(): boolean;
  67152. set MotionBlurEnabled(enabled: boolean);
  67153. /**
  67154. * Specifies if anti-aliasing is enabled
  67155. */
  67156. get fxaaEnabled(): boolean;
  67157. set fxaaEnabled(enabled: boolean);
  67158. /**
  67159. * Specifies if screen space reflections are enabled.
  67160. */
  67161. get screenSpaceReflectionsEnabled(): boolean;
  67162. set screenSpaceReflectionsEnabled(enabled: boolean);
  67163. /**
  67164. * Specifies the number of steps used to calculate the volumetric lights
  67165. * Typically in interval [50, 200]
  67166. */
  67167. get volumetricLightStepsCount(): number;
  67168. set volumetricLightStepsCount(count: number);
  67169. /**
  67170. * Specifies the number of samples used for the motion blur effect
  67171. * Typically in interval [16, 64]
  67172. */
  67173. get motionBlurSamples(): number;
  67174. set motionBlurSamples(samples: number);
  67175. /**
  67176. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67177. */
  67178. get samples(): number;
  67179. set samples(sampleCount: number);
  67180. /**
  67181. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67182. * @constructor
  67183. * @param name The rendering pipeline name
  67184. * @param scene The scene linked to this pipeline
  67185. * @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)
  67186. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67188. */
  67189. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67190. private _buildPipeline;
  67191. private _createDownSampleX4PostProcess;
  67192. private _createBrightPassPostProcess;
  67193. private _createBlurPostProcesses;
  67194. private _createTextureAdderPostProcess;
  67195. private _createVolumetricLightPostProcess;
  67196. private _createLuminancePostProcesses;
  67197. private _createHdrPostProcess;
  67198. private _createLensFlarePostProcess;
  67199. private _createDepthOfFieldPostProcess;
  67200. private _createMotionBlurPostProcess;
  67201. private _getDepthTexture;
  67202. private _disposePostProcesses;
  67203. /**
  67204. * Dispose of the pipeline and stop all post processes
  67205. */
  67206. dispose(): void;
  67207. /**
  67208. * Serialize the rendering pipeline (Used when exporting)
  67209. * @returns the serialized object
  67210. */
  67211. serialize(): any;
  67212. /**
  67213. * Parse the serialized pipeline
  67214. * @param source Source pipeline.
  67215. * @param scene The scene to load the pipeline to.
  67216. * @param rootUrl The URL of the serialized pipeline.
  67217. * @returns An instantiated pipeline from the serialized object.
  67218. */
  67219. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67220. /**
  67221. * Luminance steps
  67222. */
  67223. static LuminanceSteps: number;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /** @hidden */
  67228. export var stereoscopicInterlacePixelShader: {
  67229. name: string;
  67230. shader: string;
  67231. };
  67232. }
  67233. declare module BABYLON {
  67234. /**
  67235. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  67236. */
  67237. export class StereoscopicInterlacePostProcessI extends PostProcess {
  67238. private _stepSize;
  67239. private _passedProcess;
  67240. /**
  67241. * Initializes a StereoscopicInterlacePostProcessI
  67242. * @param name The name of the effect.
  67243. * @param rigCameras The rig cameras to be appled to the post process
  67244. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  67245. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  67246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67247. * @param engine The engine which the post process will be applied. (default: current engine)
  67248. * @param reusable If the post process can be reused on the same frame. (default: false)
  67249. */
  67250. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67251. }
  67252. /**
  67253. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  67254. */
  67255. export class StereoscopicInterlacePostProcess extends PostProcess {
  67256. private _stepSize;
  67257. private _passedProcess;
  67258. /**
  67259. * Initializes a StereoscopicInterlacePostProcess
  67260. * @param name The name of the effect.
  67261. * @param rigCameras The rig cameras to be appled to the post process
  67262. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  67263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67264. * @param engine The engine which the post process will be applied. (default: current engine)
  67265. * @param reusable If the post process can be reused on the same frame. (default: false)
  67266. */
  67267. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /** @hidden */
  67272. export var tonemapPixelShader: {
  67273. name: string;
  67274. shader: string;
  67275. };
  67276. }
  67277. declare module BABYLON {
  67278. /** Defines operator used for tonemapping */
  67279. export enum TonemappingOperator {
  67280. /** Hable */
  67281. Hable = 0,
  67282. /** Reinhard */
  67283. Reinhard = 1,
  67284. /** HejiDawson */
  67285. HejiDawson = 2,
  67286. /** Photographic */
  67287. Photographic = 3
  67288. }
  67289. /**
  67290. * Defines a post process to apply tone mapping
  67291. */
  67292. export class TonemapPostProcess extends PostProcess {
  67293. private _operator;
  67294. /** Defines the required exposure adjustement */
  67295. exposureAdjustment: number;
  67296. /**
  67297. * Creates a new TonemapPostProcess
  67298. * @param name defines the name of the postprocess
  67299. * @param _operator defines the operator to use
  67300. * @param exposureAdjustment defines the required exposure adjustement
  67301. * @param camera defines the camera to use (can be null)
  67302. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67303. * @param engine defines the hosting engine (can be ignore if camera is set)
  67304. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67305. */
  67306. constructor(name: string, _operator: TonemappingOperator,
  67307. /** Defines the required exposure adjustement */
  67308. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67309. }
  67310. }
  67311. declare module BABYLON {
  67312. /** @hidden */
  67313. export var volumetricLightScatteringPixelShader: {
  67314. name: string;
  67315. shader: string;
  67316. };
  67317. }
  67318. declare module BABYLON {
  67319. /** @hidden */
  67320. export var volumetricLightScatteringPassVertexShader: {
  67321. name: string;
  67322. shader: string;
  67323. };
  67324. }
  67325. declare module BABYLON {
  67326. /** @hidden */
  67327. export var volumetricLightScatteringPassPixelShader: {
  67328. name: string;
  67329. shader: string;
  67330. };
  67331. }
  67332. declare module BABYLON {
  67333. /**
  67334. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67335. */
  67336. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67337. private _volumetricLightScatteringPass;
  67338. private _volumetricLightScatteringRTT;
  67339. private _viewPort;
  67340. private _screenCoordinates;
  67341. private _cachedDefines;
  67342. /**
  67343. * If not undefined, the mesh position is computed from the attached node position
  67344. */
  67345. attachedNode: {
  67346. position: Vector3;
  67347. };
  67348. /**
  67349. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67350. */
  67351. customMeshPosition: Vector3;
  67352. /**
  67353. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67354. */
  67355. useCustomMeshPosition: boolean;
  67356. /**
  67357. * If the post-process should inverse the light scattering direction
  67358. */
  67359. invert: boolean;
  67360. /**
  67361. * The internal mesh used by the post-process
  67362. */
  67363. mesh: Mesh;
  67364. /**
  67365. * @hidden
  67366. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67367. */
  67368. get useDiffuseColor(): boolean;
  67369. set useDiffuseColor(useDiffuseColor: boolean);
  67370. /**
  67371. * Array containing the excluded meshes not rendered in the internal pass
  67372. */
  67373. excludedMeshes: AbstractMesh[];
  67374. /**
  67375. * Controls the overall intensity of the post-process
  67376. */
  67377. exposure: number;
  67378. /**
  67379. * Dissipates each sample's contribution in range [0, 1]
  67380. */
  67381. decay: number;
  67382. /**
  67383. * Controls the overall intensity of each sample
  67384. */
  67385. weight: number;
  67386. /**
  67387. * Controls the density of each sample
  67388. */
  67389. density: number;
  67390. /**
  67391. * @constructor
  67392. * @param name The post-process name
  67393. * @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)
  67394. * @param camera The camera that the post-process will be attached to
  67395. * @param mesh The mesh used to create the light scattering
  67396. * @param samples The post-process quality, default 100
  67397. * @param samplingModeThe post-process filtering mode
  67398. * @param engine The babylon engine
  67399. * @param reusable If the post-process is reusable
  67400. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67401. */
  67402. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67403. /**
  67404. * Returns the string "VolumetricLightScatteringPostProcess"
  67405. * @returns "VolumetricLightScatteringPostProcess"
  67406. */
  67407. getClassName(): string;
  67408. private _isReady;
  67409. /**
  67410. * Sets the new light position for light scattering effect
  67411. * @param position The new custom light position
  67412. */
  67413. setCustomMeshPosition(position: Vector3): void;
  67414. /**
  67415. * Returns the light position for light scattering effect
  67416. * @return Vector3 The custom light position
  67417. */
  67418. getCustomMeshPosition(): Vector3;
  67419. /**
  67420. * Disposes the internal assets and detaches the post-process from the camera
  67421. */
  67422. dispose(camera: Camera): void;
  67423. /**
  67424. * Returns the render target texture used by the post-process
  67425. * @return the render target texture used by the post-process
  67426. */
  67427. getPass(): RenderTargetTexture;
  67428. private _meshExcluded;
  67429. private _createPass;
  67430. private _updateMeshScreenCoordinates;
  67431. /**
  67432. * Creates a default mesh for the Volumeric Light Scattering post-process
  67433. * @param name The mesh name
  67434. * @param scene The scene where to create the mesh
  67435. * @return the default mesh
  67436. */
  67437. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67438. }
  67439. }
  67440. declare module BABYLON {
  67441. interface Scene {
  67442. /** @hidden (Backing field) */
  67443. _boundingBoxRenderer: BoundingBoxRenderer;
  67444. /** @hidden (Backing field) */
  67445. _forceShowBoundingBoxes: boolean;
  67446. /**
  67447. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67448. */
  67449. forceShowBoundingBoxes: boolean;
  67450. /**
  67451. * Gets the bounding box renderer associated with the scene
  67452. * @returns a BoundingBoxRenderer
  67453. */
  67454. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67455. }
  67456. interface AbstractMesh {
  67457. /** @hidden (Backing field) */
  67458. _showBoundingBox: boolean;
  67459. /**
  67460. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67461. */
  67462. showBoundingBox: boolean;
  67463. }
  67464. /**
  67465. * Component responsible of rendering the bounding box of the meshes in a scene.
  67466. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67467. */
  67468. export class BoundingBoxRenderer implements ISceneComponent {
  67469. /**
  67470. * The component name helpfull to identify the component in the list of scene components.
  67471. */
  67472. readonly name: string;
  67473. /**
  67474. * The scene the component belongs to.
  67475. */
  67476. scene: Scene;
  67477. /**
  67478. * Color of the bounding box lines placed in front of an object
  67479. */
  67480. frontColor: Color3;
  67481. /**
  67482. * Color of the bounding box lines placed behind an object
  67483. */
  67484. backColor: Color3;
  67485. /**
  67486. * Defines if the renderer should show the back lines or not
  67487. */
  67488. showBackLines: boolean;
  67489. /**
  67490. * @hidden
  67491. */
  67492. renderList: SmartArray<BoundingBox>;
  67493. private _colorShader;
  67494. private _vertexBuffers;
  67495. private _indexBuffer;
  67496. private _fillIndexBuffer;
  67497. private _fillIndexData;
  67498. /**
  67499. * Instantiates a new bounding box renderer in a scene.
  67500. * @param scene the scene the renderer renders in
  67501. */
  67502. constructor(scene: Scene);
  67503. /**
  67504. * Registers the component in a given scene
  67505. */
  67506. register(): void;
  67507. private _evaluateSubMesh;
  67508. private _activeMesh;
  67509. private _prepareRessources;
  67510. private _createIndexBuffer;
  67511. /**
  67512. * Rebuilds the elements related to this component in case of
  67513. * context lost for instance.
  67514. */
  67515. rebuild(): void;
  67516. /**
  67517. * @hidden
  67518. */
  67519. reset(): void;
  67520. /**
  67521. * Render the bounding boxes of a specific rendering group
  67522. * @param renderingGroupId defines the rendering group to render
  67523. */
  67524. render(renderingGroupId: number): void;
  67525. /**
  67526. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67527. * @param mesh Define the mesh to render the occlusion bounding box for
  67528. */
  67529. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67530. /**
  67531. * Dispose and release the resources attached to this renderer.
  67532. */
  67533. dispose(): void;
  67534. }
  67535. }
  67536. declare module BABYLON {
  67537. interface Scene {
  67538. /** @hidden (Backing field) */
  67539. _depthRenderer: {
  67540. [id: string]: DepthRenderer;
  67541. };
  67542. /**
  67543. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67544. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67545. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67546. * @returns the created depth renderer
  67547. */
  67548. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67549. /**
  67550. * Disables a depth renderer for a given camera
  67551. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67552. */
  67553. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67554. }
  67555. /**
  67556. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67557. * in several rendering techniques.
  67558. */
  67559. export class DepthRendererSceneComponent implements ISceneComponent {
  67560. /**
  67561. * The component name helpfull to identify the component in the list of scene components.
  67562. */
  67563. readonly name: string;
  67564. /**
  67565. * The scene the component belongs to.
  67566. */
  67567. scene: Scene;
  67568. /**
  67569. * Creates a new instance of the component for the given scene
  67570. * @param scene Defines the scene to register the component in
  67571. */
  67572. constructor(scene: Scene);
  67573. /**
  67574. * Registers the component in a given scene
  67575. */
  67576. register(): void;
  67577. /**
  67578. * Rebuilds the elements related to this component in case of
  67579. * context lost for instance.
  67580. */
  67581. rebuild(): void;
  67582. /**
  67583. * Disposes the component and the associated ressources
  67584. */
  67585. dispose(): void;
  67586. private _gatherRenderTargets;
  67587. private _gatherActiveCameraRenderTargets;
  67588. }
  67589. }
  67590. declare module BABYLON {
  67591. /** @hidden */
  67592. export var outlinePixelShader: {
  67593. name: string;
  67594. shader: string;
  67595. };
  67596. }
  67597. declare module BABYLON {
  67598. /** @hidden */
  67599. export var outlineVertexShader: {
  67600. name: string;
  67601. shader: string;
  67602. };
  67603. }
  67604. declare module BABYLON {
  67605. interface Scene {
  67606. /** @hidden */
  67607. _outlineRenderer: OutlineRenderer;
  67608. /**
  67609. * Gets the outline renderer associated with the scene
  67610. * @returns a OutlineRenderer
  67611. */
  67612. getOutlineRenderer(): OutlineRenderer;
  67613. }
  67614. interface AbstractMesh {
  67615. /** @hidden (Backing field) */
  67616. _renderOutline: boolean;
  67617. /**
  67618. * Gets or sets a boolean indicating if the outline must be rendered as well
  67619. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67620. */
  67621. renderOutline: boolean;
  67622. /** @hidden (Backing field) */
  67623. _renderOverlay: boolean;
  67624. /**
  67625. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67626. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67627. */
  67628. renderOverlay: boolean;
  67629. }
  67630. /**
  67631. * This class is responsible to draw bothe outline/overlay of meshes.
  67632. * It should not be used directly but through the available method on mesh.
  67633. */
  67634. export class OutlineRenderer implements ISceneComponent {
  67635. /**
  67636. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67637. */
  67638. private static _StencilReference;
  67639. /**
  67640. * The name of the component. Each component must have a unique name.
  67641. */
  67642. name: string;
  67643. /**
  67644. * The scene the component belongs to.
  67645. */
  67646. scene: Scene;
  67647. /**
  67648. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67649. */
  67650. zOffset: number;
  67651. private _engine;
  67652. private _effect;
  67653. private _cachedDefines;
  67654. private _savedDepthWrite;
  67655. /**
  67656. * Instantiates a new outline renderer. (There could be only one per scene).
  67657. * @param scene Defines the scene it belongs to
  67658. */
  67659. constructor(scene: Scene);
  67660. /**
  67661. * Register the component to one instance of a scene.
  67662. */
  67663. register(): void;
  67664. /**
  67665. * Rebuilds the elements related to this component in case of
  67666. * context lost for instance.
  67667. */
  67668. rebuild(): void;
  67669. /**
  67670. * Disposes the component and the associated ressources.
  67671. */
  67672. dispose(): void;
  67673. /**
  67674. * Renders the outline in the canvas.
  67675. * @param subMesh Defines the sumesh to render
  67676. * @param batch Defines the batch of meshes in case of instances
  67677. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67678. */
  67679. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67680. /**
  67681. * Returns whether or not the outline renderer is ready for a given submesh.
  67682. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67683. * @param subMesh Defines the submesh to check readyness for
  67684. * @param useInstances Defines wheter wee are trying to render instances or not
  67685. * @returns true if ready otherwise false
  67686. */
  67687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67688. private _beforeRenderingMesh;
  67689. private _afterRenderingMesh;
  67690. }
  67691. }
  67692. declare module BABYLON {
  67693. /**
  67694. * Defines the basic options interface of a Sprite Frame Source Size.
  67695. */
  67696. export interface ISpriteJSONSpriteSourceSize {
  67697. /**
  67698. * number of the original width of the Frame
  67699. */
  67700. w: number;
  67701. /**
  67702. * number of the original height of the Frame
  67703. */
  67704. h: number;
  67705. }
  67706. /**
  67707. * Defines the basic options interface of a Sprite Frame Data.
  67708. */
  67709. export interface ISpriteJSONSpriteFrameData {
  67710. /**
  67711. * number of the x offset of the Frame
  67712. */
  67713. x: number;
  67714. /**
  67715. * number of the y offset of the Frame
  67716. */
  67717. y: number;
  67718. /**
  67719. * number of the width of the Frame
  67720. */
  67721. w: number;
  67722. /**
  67723. * number of the height of the Frame
  67724. */
  67725. h: number;
  67726. }
  67727. /**
  67728. * Defines the basic options interface of a JSON Sprite.
  67729. */
  67730. export interface ISpriteJSONSprite {
  67731. /**
  67732. * string name of the Frame
  67733. */
  67734. filename: string;
  67735. /**
  67736. * ISpriteJSONSpriteFrame basic object of the frame data
  67737. */
  67738. frame: ISpriteJSONSpriteFrameData;
  67739. /**
  67740. * boolean to flag is the frame was rotated.
  67741. */
  67742. rotated: boolean;
  67743. /**
  67744. * boolean to flag is the frame was trimmed.
  67745. */
  67746. trimmed: boolean;
  67747. /**
  67748. * ISpriteJSONSpriteFrame basic object of the source data
  67749. */
  67750. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67751. /**
  67752. * ISpriteJSONSpriteFrame basic object of the source data
  67753. */
  67754. sourceSize: ISpriteJSONSpriteSourceSize;
  67755. }
  67756. /**
  67757. * Defines the basic options interface of a JSON atlas.
  67758. */
  67759. export interface ISpriteJSONAtlas {
  67760. /**
  67761. * Array of objects that contain the frame data.
  67762. */
  67763. frames: Array<ISpriteJSONSprite>;
  67764. /**
  67765. * object basic object containing the sprite meta data.
  67766. */
  67767. meta?: object;
  67768. }
  67769. }
  67770. declare module BABYLON {
  67771. /** @hidden */
  67772. export var spriteMapPixelShader: {
  67773. name: string;
  67774. shader: string;
  67775. };
  67776. }
  67777. declare module BABYLON {
  67778. /** @hidden */
  67779. export var spriteMapVertexShader: {
  67780. name: string;
  67781. shader: string;
  67782. };
  67783. }
  67784. declare module BABYLON {
  67785. /**
  67786. * Defines the basic options interface of a SpriteMap
  67787. */
  67788. export interface ISpriteMapOptions {
  67789. /**
  67790. * Vector2 of the number of cells in the grid.
  67791. */
  67792. stageSize?: Vector2;
  67793. /**
  67794. * Vector2 of the size of the output plane in World Units.
  67795. */
  67796. outputSize?: Vector2;
  67797. /**
  67798. * Vector3 of the position of the output plane in World Units.
  67799. */
  67800. outputPosition?: Vector3;
  67801. /**
  67802. * Vector3 of the rotation of the output plane.
  67803. */
  67804. outputRotation?: Vector3;
  67805. /**
  67806. * number of layers that the system will reserve in resources.
  67807. */
  67808. layerCount?: number;
  67809. /**
  67810. * number of max animation frames a single cell will reserve in resources.
  67811. */
  67812. maxAnimationFrames?: number;
  67813. /**
  67814. * number cell index of the base tile when the system compiles.
  67815. */
  67816. baseTile?: number;
  67817. /**
  67818. * boolean flip the sprite after its been repositioned by the framing data.
  67819. */
  67820. flipU?: boolean;
  67821. /**
  67822. * Vector3 scalar of the global RGB values of the SpriteMap.
  67823. */
  67824. colorMultiply?: Vector3;
  67825. }
  67826. /**
  67827. * Defines the IDisposable interface in order to be cleanable from resources.
  67828. */
  67829. export interface ISpriteMap extends IDisposable {
  67830. /**
  67831. * String name of the SpriteMap.
  67832. */
  67833. name: string;
  67834. /**
  67835. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67836. */
  67837. atlasJSON: ISpriteJSONAtlas;
  67838. /**
  67839. * Texture of the SpriteMap.
  67840. */
  67841. spriteSheet: Texture;
  67842. /**
  67843. * The parameters to initialize the SpriteMap with.
  67844. */
  67845. options: ISpriteMapOptions;
  67846. }
  67847. /**
  67848. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67849. */
  67850. export class SpriteMap implements ISpriteMap {
  67851. /** The Name of the spriteMap */
  67852. name: string;
  67853. /** The JSON file with the frame and meta data */
  67854. atlasJSON: ISpriteJSONAtlas;
  67855. /** The systems Sprite Sheet Texture */
  67856. spriteSheet: Texture;
  67857. /** Arguments passed with the Constructor */
  67858. options: ISpriteMapOptions;
  67859. /** Public Sprite Storage array, parsed from atlasJSON */
  67860. sprites: Array<ISpriteJSONSprite>;
  67861. /** Returns the Number of Sprites in the System */
  67862. get spriteCount(): number;
  67863. /** Returns the Position of Output Plane*/
  67864. get position(): Vector3;
  67865. /** Returns the Position of Output Plane*/
  67866. set position(v: Vector3);
  67867. /** Returns the Rotation of Output Plane*/
  67868. get rotation(): Vector3;
  67869. /** Returns the Rotation of Output Plane*/
  67870. set rotation(v: Vector3);
  67871. /** Sets the AnimationMap*/
  67872. get animationMap(): RawTexture;
  67873. /** Sets the AnimationMap*/
  67874. set animationMap(v: RawTexture);
  67875. /** Scene that the SpriteMap was created in */
  67876. private _scene;
  67877. /** Texture Buffer of Float32 that holds tile frame data*/
  67878. private _frameMap;
  67879. /** Texture Buffers of Float32 that holds tileMap data*/
  67880. private _tileMaps;
  67881. /** Texture Buffer of Float32 that holds Animation Data*/
  67882. private _animationMap;
  67883. /** Custom ShaderMaterial Central to the System*/
  67884. private _material;
  67885. /** Custom ShaderMaterial Central to the System*/
  67886. private _output;
  67887. /** Systems Time Ticker*/
  67888. private _time;
  67889. /**
  67890. * Creates a new SpriteMap
  67891. * @param name defines the SpriteMaps Name
  67892. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67893. * @param spriteSheet is the Texture that the Sprites are on.
  67894. * @param options a basic deployment configuration
  67895. * @param scene The Scene that the map is deployed on
  67896. */
  67897. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67898. /**
  67899. * Returns tileID location
  67900. * @returns Vector2 the cell position ID
  67901. */
  67902. getTileID(): Vector2;
  67903. /**
  67904. * Gets the UV location of the mouse over the SpriteMap.
  67905. * @returns Vector2 the UV position of the mouse interaction
  67906. */
  67907. getMousePosition(): Vector2;
  67908. /**
  67909. * Creates the "frame" texture Buffer
  67910. * -------------------------------------
  67911. * Structure of frames
  67912. * "filename": "Falling-Water-2.png",
  67913. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67914. * "rotated": true,
  67915. * "trimmed": true,
  67916. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67917. * "sourceSize": {"w":32,"h":32}
  67918. * @returns RawTexture of the frameMap
  67919. */
  67920. private _createFrameBuffer;
  67921. /**
  67922. * Creates the tileMap texture Buffer
  67923. * @param buffer normally and array of numbers, or a false to generate from scratch
  67924. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67925. * @returns RawTexture of the tileMap
  67926. */
  67927. private _createTileBuffer;
  67928. /**
  67929. * Modifies the data of the tileMaps
  67930. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67931. * @param pos is the iVector2 Coordinates of the Tile
  67932. * @param tile The SpriteIndex of the new Tile
  67933. */
  67934. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67935. /**
  67936. * Creates the animationMap texture Buffer
  67937. * @param buffer normally and array of numbers, or a false to generate from scratch
  67938. * @returns RawTexture of the animationMap
  67939. */
  67940. private _createTileAnimationBuffer;
  67941. /**
  67942. * Modifies the data of the animationMap
  67943. * @param cellID is the Index of the Sprite
  67944. * @param _frame is the target Animation frame
  67945. * @param toCell is the Target Index of the next frame of the animation
  67946. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67947. * @param speed is a global scalar of the time variable on the map.
  67948. */
  67949. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67950. /**
  67951. * Exports the .tilemaps file
  67952. */
  67953. saveTileMaps(): void;
  67954. /**
  67955. * Imports the .tilemaps file
  67956. * @param url of the .tilemaps file
  67957. */
  67958. loadTileMaps(url: string): void;
  67959. /**
  67960. * Release associated resources
  67961. */
  67962. dispose(): void;
  67963. }
  67964. }
  67965. declare module BABYLON {
  67966. /**
  67967. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67968. * @see http://doc.babylonjs.com/babylon101/sprites
  67969. */
  67970. export class SpritePackedManager extends SpriteManager {
  67971. /** defines the packed manager's name */
  67972. name: string;
  67973. /**
  67974. * Creates a new sprite manager from a packed sprite sheet
  67975. * @param name defines the manager's name
  67976. * @param imgUrl defines the sprite sheet url
  67977. * @param capacity defines the maximum allowed number of sprites
  67978. * @param scene defines the hosting scene
  67979. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67980. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67981. * @param samplingMode defines the smapling mode to use with spritesheet
  67982. * @param fromPacked set to true; do not alter
  67983. */
  67984. constructor(
  67985. /** defines the packed manager's name */
  67986. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67987. }
  67988. }
  67989. declare module BABYLON {
  67990. /**
  67991. * Defines the list of states available for a task inside a AssetsManager
  67992. */
  67993. export enum AssetTaskState {
  67994. /**
  67995. * Initialization
  67996. */
  67997. INIT = 0,
  67998. /**
  67999. * Running
  68000. */
  68001. RUNNING = 1,
  68002. /**
  68003. * Done
  68004. */
  68005. DONE = 2,
  68006. /**
  68007. * Error
  68008. */
  68009. ERROR = 3
  68010. }
  68011. /**
  68012. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68013. */
  68014. export abstract class AbstractAssetTask {
  68015. /**
  68016. * Task name
  68017. */ name: string;
  68018. /**
  68019. * Callback called when the task is successful
  68020. */
  68021. onSuccess: (task: any) => void;
  68022. /**
  68023. * Callback called when the task is not successful
  68024. */
  68025. onError: (task: any, message?: string, exception?: any) => void;
  68026. /**
  68027. * Creates a new AssetsManager
  68028. * @param name defines the name of the task
  68029. */
  68030. constructor(
  68031. /**
  68032. * Task name
  68033. */ name: string);
  68034. private _isCompleted;
  68035. private _taskState;
  68036. private _errorObject;
  68037. /**
  68038. * Get if the task is completed
  68039. */
  68040. get isCompleted(): boolean;
  68041. /**
  68042. * Gets the current state of the task
  68043. */
  68044. get taskState(): AssetTaskState;
  68045. /**
  68046. * Gets the current error object (if task is in error)
  68047. */
  68048. get errorObject(): {
  68049. message?: string;
  68050. exception?: any;
  68051. };
  68052. /**
  68053. * Internal only
  68054. * @hidden
  68055. */
  68056. _setErrorObject(message?: string, exception?: any): void;
  68057. /**
  68058. * Execute the current task
  68059. * @param scene defines the scene where you want your assets to be loaded
  68060. * @param onSuccess is a callback called when the task is successfully executed
  68061. * @param onError is a callback called if an error occurs
  68062. */
  68063. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68064. /**
  68065. * Execute the current task
  68066. * @param scene defines the scene where you want your assets to be loaded
  68067. * @param onSuccess is a callback called when the task is successfully executed
  68068. * @param onError is a callback called if an error occurs
  68069. */
  68070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68071. /**
  68072. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68073. * This can be used with failed tasks that have the reason for failure fixed.
  68074. */
  68075. reset(): void;
  68076. private onErrorCallback;
  68077. private onDoneCallback;
  68078. }
  68079. /**
  68080. * Define the interface used by progress events raised during assets loading
  68081. */
  68082. export interface IAssetsProgressEvent {
  68083. /**
  68084. * Defines the number of remaining tasks to process
  68085. */
  68086. remainingCount: number;
  68087. /**
  68088. * Defines the total number of tasks
  68089. */
  68090. totalCount: number;
  68091. /**
  68092. * Defines the task that was just processed
  68093. */
  68094. task: AbstractAssetTask;
  68095. }
  68096. /**
  68097. * Class used to share progress information about assets loading
  68098. */
  68099. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68100. /**
  68101. * Defines the number of remaining tasks to process
  68102. */
  68103. remainingCount: number;
  68104. /**
  68105. * Defines the total number of tasks
  68106. */
  68107. totalCount: number;
  68108. /**
  68109. * Defines the task that was just processed
  68110. */
  68111. task: AbstractAssetTask;
  68112. /**
  68113. * Creates a AssetsProgressEvent
  68114. * @param remainingCount defines the number of remaining tasks to process
  68115. * @param totalCount defines the total number of tasks
  68116. * @param task defines the task that was just processed
  68117. */
  68118. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68119. }
  68120. /**
  68121. * Define a task used by AssetsManager to load meshes
  68122. */
  68123. export class MeshAssetTask extends AbstractAssetTask {
  68124. /**
  68125. * Defines the name of the task
  68126. */
  68127. name: string;
  68128. /**
  68129. * Defines the list of mesh's names you want to load
  68130. */
  68131. meshesNames: any;
  68132. /**
  68133. * Defines the root url to use as a base to load your meshes and associated resources
  68134. */
  68135. rootUrl: string;
  68136. /**
  68137. * Defines the filename of the scene to load from
  68138. */
  68139. sceneFilename: string;
  68140. /**
  68141. * Gets the list of loaded meshes
  68142. */
  68143. loadedMeshes: Array<AbstractMesh>;
  68144. /**
  68145. * Gets the list of loaded particle systems
  68146. */
  68147. loadedParticleSystems: Array<IParticleSystem>;
  68148. /**
  68149. * Gets the list of loaded skeletons
  68150. */
  68151. loadedSkeletons: Array<Skeleton>;
  68152. /**
  68153. * Gets the list of loaded animation groups
  68154. */
  68155. loadedAnimationGroups: Array<AnimationGroup>;
  68156. /**
  68157. * Callback called when the task is successful
  68158. */
  68159. onSuccess: (task: MeshAssetTask) => void;
  68160. /**
  68161. * Callback called when the task is successful
  68162. */
  68163. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68164. /**
  68165. * Creates a new MeshAssetTask
  68166. * @param name defines the name of the task
  68167. * @param meshesNames defines the list of mesh's names you want to load
  68168. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68169. * @param sceneFilename defines the filename of the scene to load from
  68170. */
  68171. constructor(
  68172. /**
  68173. * Defines the name of the task
  68174. */
  68175. name: string,
  68176. /**
  68177. * Defines the list of mesh's names you want to load
  68178. */
  68179. meshesNames: any,
  68180. /**
  68181. * Defines the root url to use as a base to load your meshes and associated resources
  68182. */
  68183. rootUrl: string,
  68184. /**
  68185. * Defines the filename of the scene to load from
  68186. */
  68187. sceneFilename: string);
  68188. /**
  68189. * Execute the current task
  68190. * @param scene defines the scene where you want your assets to be loaded
  68191. * @param onSuccess is a callback called when the task is successfully executed
  68192. * @param onError is a callback called if an error occurs
  68193. */
  68194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68195. }
  68196. /**
  68197. * Define a task used by AssetsManager to load text content
  68198. */
  68199. export class TextFileAssetTask extends AbstractAssetTask {
  68200. /**
  68201. * Defines the name of the task
  68202. */
  68203. name: string;
  68204. /**
  68205. * Defines the location of the file to load
  68206. */
  68207. url: string;
  68208. /**
  68209. * Gets the loaded text string
  68210. */
  68211. text: string;
  68212. /**
  68213. * Callback called when the task is successful
  68214. */
  68215. onSuccess: (task: TextFileAssetTask) => void;
  68216. /**
  68217. * Callback called when the task is successful
  68218. */
  68219. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68220. /**
  68221. * Creates a new TextFileAssetTask object
  68222. * @param name defines the name of the task
  68223. * @param url defines the location of the file to load
  68224. */
  68225. constructor(
  68226. /**
  68227. * Defines the name of the task
  68228. */
  68229. name: string,
  68230. /**
  68231. * Defines the location of the file to load
  68232. */
  68233. url: string);
  68234. /**
  68235. * Execute the current task
  68236. * @param scene defines the scene where you want your assets to be loaded
  68237. * @param onSuccess is a callback called when the task is successfully executed
  68238. * @param onError is a callback called if an error occurs
  68239. */
  68240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68241. }
  68242. /**
  68243. * Define a task used by AssetsManager to load binary data
  68244. */
  68245. export class BinaryFileAssetTask extends AbstractAssetTask {
  68246. /**
  68247. * Defines the name of the task
  68248. */
  68249. name: string;
  68250. /**
  68251. * Defines the location of the file to load
  68252. */
  68253. url: string;
  68254. /**
  68255. * Gets the lodaded data (as an array buffer)
  68256. */
  68257. data: ArrayBuffer;
  68258. /**
  68259. * Callback called when the task is successful
  68260. */
  68261. onSuccess: (task: BinaryFileAssetTask) => void;
  68262. /**
  68263. * Callback called when the task is successful
  68264. */
  68265. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68266. /**
  68267. * Creates a new BinaryFileAssetTask object
  68268. * @param name defines the name of the new task
  68269. * @param url defines the location of the file to load
  68270. */
  68271. constructor(
  68272. /**
  68273. * Defines the name of the task
  68274. */
  68275. name: string,
  68276. /**
  68277. * Defines the location of the file to load
  68278. */
  68279. url: string);
  68280. /**
  68281. * Execute the current task
  68282. * @param scene defines the scene where you want your assets to be loaded
  68283. * @param onSuccess is a callback called when the task is successfully executed
  68284. * @param onError is a callback called if an error occurs
  68285. */
  68286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68287. }
  68288. /**
  68289. * Define a task used by AssetsManager to load images
  68290. */
  68291. export class ImageAssetTask extends AbstractAssetTask {
  68292. /**
  68293. * Defines the name of the task
  68294. */
  68295. name: string;
  68296. /**
  68297. * Defines the location of the image to load
  68298. */
  68299. url: string;
  68300. /**
  68301. * Gets the loaded images
  68302. */
  68303. image: HTMLImageElement;
  68304. /**
  68305. * Callback called when the task is successful
  68306. */
  68307. onSuccess: (task: ImageAssetTask) => void;
  68308. /**
  68309. * Callback called when the task is successful
  68310. */
  68311. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68312. /**
  68313. * Creates a new ImageAssetTask
  68314. * @param name defines the name of the task
  68315. * @param url defines the location of the image to load
  68316. */
  68317. constructor(
  68318. /**
  68319. * Defines the name of the task
  68320. */
  68321. name: string,
  68322. /**
  68323. * Defines the location of the image to load
  68324. */
  68325. url: string);
  68326. /**
  68327. * Execute the current task
  68328. * @param scene defines the scene where you want your assets to be loaded
  68329. * @param onSuccess is a callback called when the task is successfully executed
  68330. * @param onError is a callback called if an error occurs
  68331. */
  68332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68333. }
  68334. /**
  68335. * Defines the interface used by texture loading tasks
  68336. */
  68337. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68338. /**
  68339. * Gets the loaded texture
  68340. */
  68341. texture: TEX;
  68342. }
  68343. /**
  68344. * Define a task used by AssetsManager to load 2D textures
  68345. */
  68346. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68347. /**
  68348. * Defines the name of the task
  68349. */
  68350. name: string;
  68351. /**
  68352. * Defines the location of the file to load
  68353. */
  68354. url: string;
  68355. /**
  68356. * Defines if mipmap should not be generated (default is false)
  68357. */
  68358. noMipmap?: boolean | undefined;
  68359. /**
  68360. * Defines if texture must be inverted on Y axis (default is true)
  68361. */
  68362. invertY: boolean;
  68363. /**
  68364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68365. */
  68366. samplingMode: number;
  68367. /**
  68368. * Gets the loaded texture
  68369. */
  68370. texture: Texture;
  68371. /**
  68372. * Callback called when the task is successful
  68373. */
  68374. onSuccess: (task: TextureAssetTask) => void;
  68375. /**
  68376. * Callback called when the task is successful
  68377. */
  68378. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68379. /**
  68380. * Creates a new TextureAssetTask object
  68381. * @param name defines the name of the task
  68382. * @param url defines the location of the file to load
  68383. * @param noMipmap defines if mipmap should not be generated (default is false)
  68384. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68385. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68386. */
  68387. constructor(
  68388. /**
  68389. * Defines the name of the task
  68390. */
  68391. name: string,
  68392. /**
  68393. * Defines the location of the file to load
  68394. */
  68395. url: string,
  68396. /**
  68397. * Defines if mipmap should not be generated (default is false)
  68398. */
  68399. noMipmap?: boolean | undefined,
  68400. /**
  68401. * Defines if texture must be inverted on Y axis (default is true)
  68402. */
  68403. invertY?: boolean,
  68404. /**
  68405. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68406. */
  68407. samplingMode?: number);
  68408. /**
  68409. * Execute the current task
  68410. * @param scene defines the scene where you want your assets to be loaded
  68411. * @param onSuccess is a callback called when the task is successfully executed
  68412. * @param onError is a callback called if an error occurs
  68413. */
  68414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68415. }
  68416. /**
  68417. * Define a task used by AssetsManager to load cube textures
  68418. */
  68419. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68420. /**
  68421. * Defines the name of the task
  68422. */
  68423. name: string;
  68424. /**
  68425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68426. */
  68427. url: string;
  68428. /**
  68429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68430. */
  68431. extensions?: string[] | undefined;
  68432. /**
  68433. * Defines if mipmaps should not be generated (default is false)
  68434. */
  68435. noMipmap?: boolean | undefined;
  68436. /**
  68437. * Defines the explicit list of files (undefined by default)
  68438. */
  68439. files?: string[] | undefined;
  68440. /**
  68441. * Gets the loaded texture
  68442. */
  68443. texture: CubeTexture;
  68444. /**
  68445. * Callback called when the task is successful
  68446. */
  68447. onSuccess: (task: CubeTextureAssetTask) => void;
  68448. /**
  68449. * Callback called when the task is successful
  68450. */
  68451. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68452. /**
  68453. * Creates a new CubeTextureAssetTask
  68454. * @param name defines the name of the task
  68455. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68456. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68457. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68458. * @param files defines the explicit list of files (undefined by default)
  68459. */
  68460. constructor(
  68461. /**
  68462. * Defines the name of the task
  68463. */
  68464. name: string,
  68465. /**
  68466. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68467. */
  68468. url: string,
  68469. /**
  68470. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68471. */
  68472. extensions?: string[] | undefined,
  68473. /**
  68474. * Defines if mipmaps should not be generated (default is false)
  68475. */
  68476. noMipmap?: boolean | undefined,
  68477. /**
  68478. * Defines the explicit list of files (undefined by default)
  68479. */
  68480. files?: string[] | undefined);
  68481. /**
  68482. * Execute the current task
  68483. * @param scene defines the scene where you want your assets to be loaded
  68484. * @param onSuccess is a callback called when the task is successfully executed
  68485. * @param onError is a callback called if an error occurs
  68486. */
  68487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68488. }
  68489. /**
  68490. * Define a task used by AssetsManager to load HDR cube textures
  68491. */
  68492. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68493. /**
  68494. * Defines the name of the task
  68495. */
  68496. name: string;
  68497. /**
  68498. * Defines the location of the file to load
  68499. */
  68500. url: string;
  68501. /**
  68502. * Defines the desired size (the more it increases the longer the generation will be)
  68503. */
  68504. size: number;
  68505. /**
  68506. * Defines if mipmaps should not be generated (default is false)
  68507. */
  68508. noMipmap: boolean;
  68509. /**
  68510. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68511. */
  68512. generateHarmonics: boolean;
  68513. /**
  68514. * 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)
  68515. */
  68516. gammaSpace: boolean;
  68517. /**
  68518. * Internal Use Only
  68519. */
  68520. reserved: boolean;
  68521. /**
  68522. * Gets the loaded texture
  68523. */
  68524. texture: HDRCubeTexture;
  68525. /**
  68526. * Callback called when the task is successful
  68527. */
  68528. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68529. /**
  68530. * Callback called when the task is successful
  68531. */
  68532. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68533. /**
  68534. * Creates a new HDRCubeTextureAssetTask object
  68535. * @param name defines the name of the task
  68536. * @param url defines the location of the file to load
  68537. * @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.
  68538. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68539. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68540. * @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)
  68541. * @param reserved Internal use only
  68542. */
  68543. constructor(
  68544. /**
  68545. * Defines the name of the task
  68546. */
  68547. name: string,
  68548. /**
  68549. * Defines the location of the file to load
  68550. */
  68551. url: string,
  68552. /**
  68553. * Defines the desired size (the more it increases the longer the generation will be)
  68554. */
  68555. size: number,
  68556. /**
  68557. * Defines if mipmaps should not be generated (default is false)
  68558. */
  68559. noMipmap?: boolean,
  68560. /**
  68561. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68562. */
  68563. generateHarmonics?: boolean,
  68564. /**
  68565. * 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)
  68566. */
  68567. gammaSpace?: boolean,
  68568. /**
  68569. * Internal Use Only
  68570. */
  68571. reserved?: boolean);
  68572. /**
  68573. * Execute the current task
  68574. * @param scene defines the scene where you want your assets to be loaded
  68575. * @param onSuccess is a callback called when the task is successfully executed
  68576. * @param onError is a callback called if an error occurs
  68577. */
  68578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68579. }
  68580. /**
  68581. * Define a task used by AssetsManager to load Equirectangular cube textures
  68582. */
  68583. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68584. /**
  68585. * Defines the name of the task
  68586. */
  68587. name: string;
  68588. /**
  68589. * Defines the location of the file to load
  68590. */
  68591. url: string;
  68592. /**
  68593. * Defines the desired size (the more it increases the longer the generation will be)
  68594. */
  68595. size: number;
  68596. /**
  68597. * Defines if mipmaps should not be generated (default is false)
  68598. */
  68599. noMipmap: boolean;
  68600. /**
  68601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68602. * but the standard material would require them in Gamma space) (default is true)
  68603. */
  68604. gammaSpace: boolean;
  68605. /**
  68606. * Gets the loaded texture
  68607. */
  68608. texture: EquiRectangularCubeTexture;
  68609. /**
  68610. * Callback called when the task is successful
  68611. */
  68612. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68613. /**
  68614. * Callback called when the task is successful
  68615. */
  68616. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68617. /**
  68618. * Creates a new EquiRectangularCubeTextureAssetTask object
  68619. * @param name defines the name of the task
  68620. * @param url defines the location of the file to load
  68621. * @param size defines the desired size (the more it increases the longer the generation will be)
  68622. * If the size is omitted this implies you are using a preprocessed cubemap.
  68623. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68624. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68625. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68626. * (default is true)
  68627. */
  68628. constructor(
  68629. /**
  68630. * Defines the name of the task
  68631. */
  68632. name: string,
  68633. /**
  68634. * Defines the location of the file to load
  68635. */
  68636. url: string,
  68637. /**
  68638. * Defines the desired size (the more it increases the longer the generation will be)
  68639. */
  68640. size: number,
  68641. /**
  68642. * Defines if mipmaps should not be generated (default is false)
  68643. */
  68644. noMipmap?: boolean,
  68645. /**
  68646. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68647. * but the standard material would require them in Gamma space) (default is true)
  68648. */
  68649. gammaSpace?: boolean);
  68650. /**
  68651. * Execute the current task
  68652. * @param scene defines the scene where you want your assets to be loaded
  68653. * @param onSuccess is a callback called when the task is successfully executed
  68654. * @param onError is a callback called if an error occurs
  68655. */
  68656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68657. }
  68658. /**
  68659. * This class can be used to easily import assets into a scene
  68660. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68661. */
  68662. export class AssetsManager {
  68663. private _scene;
  68664. private _isLoading;
  68665. protected _tasks: AbstractAssetTask[];
  68666. protected _waitingTasksCount: number;
  68667. protected _totalTasksCount: number;
  68668. /**
  68669. * Callback called when all tasks are processed
  68670. */
  68671. onFinish: (tasks: AbstractAssetTask[]) => void;
  68672. /**
  68673. * Callback called when a task is successful
  68674. */
  68675. onTaskSuccess: (task: AbstractAssetTask) => void;
  68676. /**
  68677. * Callback called when a task had an error
  68678. */
  68679. onTaskError: (task: AbstractAssetTask) => void;
  68680. /**
  68681. * Callback called when a task is done (whatever the result is)
  68682. */
  68683. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68684. /**
  68685. * Observable called when all tasks are processed
  68686. */
  68687. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68688. /**
  68689. * Observable called when a task had an error
  68690. */
  68691. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68692. /**
  68693. * Observable called when all tasks were executed
  68694. */
  68695. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68696. /**
  68697. * Observable called when a task is done (whatever the result is)
  68698. */
  68699. onProgressObservable: Observable<IAssetsProgressEvent>;
  68700. /**
  68701. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68703. */
  68704. useDefaultLoadingScreen: boolean;
  68705. /**
  68706. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68707. * when all assets have been downloaded.
  68708. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68709. */
  68710. autoHideLoadingUI: boolean;
  68711. /**
  68712. * Creates a new AssetsManager
  68713. * @param scene defines the scene to work on
  68714. */
  68715. constructor(scene: Scene);
  68716. /**
  68717. * Add a MeshAssetTask to the list of active tasks
  68718. * @param taskName defines the name of the new task
  68719. * @param meshesNames defines the name of meshes to load
  68720. * @param rootUrl defines the root url to use to locate files
  68721. * @param sceneFilename defines the filename of the scene file
  68722. * @returns a new MeshAssetTask object
  68723. */
  68724. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68725. /**
  68726. * Add a TextFileAssetTask to the list of active tasks
  68727. * @param taskName defines the name of the new task
  68728. * @param url defines the url of the file to load
  68729. * @returns a new TextFileAssetTask object
  68730. */
  68731. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68732. /**
  68733. * Add a BinaryFileAssetTask to the list of active tasks
  68734. * @param taskName defines the name of the new task
  68735. * @param url defines the url of the file to load
  68736. * @returns a new BinaryFileAssetTask object
  68737. */
  68738. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68739. /**
  68740. * Add a ImageAssetTask to the list of active tasks
  68741. * @param taskName defines the name of the new task
  68742. * @param url defines the url of the file to load
  68743. * @returns a new ImageAssetTask object
  68744. */
  68745. addImageTask(taskName: string, url: string): ImageAssetTask;
  68746. /**
  68747. * Add a TextureAssetTask to the list of active tasks
  68748. * @param taskName defines the name of the new task
  68749. * @param url defines the url of the file to load
  68750. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68751. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68752. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68753. * @returns a new TextureAssetTask object
  68754. */
  68755. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68756. /**
  68757. * Add a CubeTextureAssetTask to the list of active tasks
  68758. * @param taskName defines the name of the new task
  68759. * @param url defines the url of the file to load
  68760. * @param extensions defines the extension to use to load the cube map (can be null)
  68761. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68762. * @param files defines the list of files to load (can be null)
  68763. * @returns a new CubeTextureAssetTask object
  68764. */
  68765. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68766. /**
  68767. *
  68768. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68769. * @param taskName defines the name of the new task
  68770. * @param url defines the url of the file to load
  68771. * @param size defines the size you want for the cubemap (can be null)
  68772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68773. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68774. * @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)
  68775. * @param reserved Internal use only
  68776. * @returns a new HDRCubeTextureAssetTask object
  68777. */
  68778. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68779. /**
  68780. *
  68781. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68782. * @param taskName defines the name of the new task
  68783. * @param url defines the url of the file to load
  68784. * @param size defines the size you want for the cubemap (can be null)
  68785. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68786. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68787. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68788. * @returns a new EquiRectangularCubeTextureAssetTask object
  68789. */
  68790. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68791. /**
  68792. * Remove a task from the assets manager.
  68793. * @param task the task to remove
  68794. */
  68795. removeTask(task: AbstractAssetTask): void;
  68796. private _decreaseWaitingTasksCount;
  68797. private _runTask;
  68798. /**
  68799. * Reset the AssetsManager and remove all tasks
  68800. * @return the current instance of the AssetsManager
  68801. */
  68802. reset(): AssetsManager;
  68803. /**
  68804. * Start the loading process
  68805. * @return the current instance of the AssetsManager
  68806. */
  68807. load(): AssetsManager;
  68808. /**
  68809. * Start the loading process as an async operation
  68810. * @return a promise returning the list of failed tasks
  68811. */
  68812. loadAsync(): Promise<void>;
  68813. }
  68814. }
  68815. declare module BABYLON {
  68816. /**
  68817. * Wrapper class for promise with external resolve and reject.
  68818. */
  68819. export class Deferred<T> {
  68820. /**
  68821. * The promise associated with this deferred object.
  68822. */
  68823. readonly promise: Promise<T>;
  68824. private _resolve;
  68825. private _reject;
  68826. /**
  68827. * The resolve method of the promise associated with this deferred object.
  68828. */
  68829. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68830. /**
  68831. * The reject method of the promise associated with this deferred object.
  68832. */
  68833. get reject(): (reason?: any) => void;
  68834. /**
  68835. * Constructor for this deferred object.
  68836. */
  68837. constructor();
  68838. }
  68839. }
  68840. declare module BABYLON {
  68841. /**
  68842. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68843. */
  68844. export class MeshExploder {
  68845. private _centerMesh;
  68846. private _meshes;
  68847. private _meshesOrigins;
  68848. private _toCenterVectors;
  68849. private _scaledDirection;
  68850. private _newPosition;
  68851. private _centerPosition;
  68852. /**
  68853. * Explodes meshes from a center mesh.
  68854. * @param meshes The meshes to explode.
  68855. * @param centerMesh The mesh to be center of explosion.
  68856. */
  68857. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68858. private _setCenterMesh;
  68859. /**
  68860. * Get class name
  68861. * @returns "MeshExploder"
  68862. */
  68863. getClassName(): string;
  68864. /**
  68865. * "Exploded meshes"
  68866. * @returns Array of meshes with the centerMesh at index 0.
  68867. */
  68868. getMeshes(): Array<Mesh>;
  68869. /**
  68870. * Explodes meshes giving a specific direction
  68871. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68872. */
  68873. explode(direction?: number): void;
  68874. }
  68875. }
  68876. declare module BABYLON {
  68877. /**
  68878. * Class used to help managing file picking and drag'n'drop
  68879. */
  68880. export class FilesInput {
  68881. /**
  68882. * List of files ready to be loaded
  68883. */
  68884. static get FilesToLoad(): {
  68885. [key: string]: File;
  68886. };
  68887. /**
  68888. * Callback called when a file is processed
  68889. */
  68890. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68891. private _engine;
  68892. private _currentScene;
  68893. private _sceneLoadedCallback;
  68894. private _progressCallback;
  68895. private _additionalRenderLoopLogicCallback;
  68896. private _textureLoadingCallback;
  68897. private _startingProcessingFilesCallback;
  68898. private _onReloadCallback;
  68899. private _errorCallback;
  68900. private _elementToMonitor;
  68901. private _sceneFileToLoad;
  68902. private _filesToLoad;
  68903. /**
  68904. * Creates a new FilesInput
  68905. * @param engine defines the rendering engine
  68906. * @param scene defines the hosting scene
  68907. * @param sceneLoadedCallback callback called when scene is loaded
  68908. * @param progressCallback callback called to track progress
  68909. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68910. * @param textureLoadingCallback callback called when a texture is loading
  68911. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68912. * @param onReloadCallback callback called when a reload is requested
  68913. * @param errorCallback callback call if an error occurs
  68914. */
  68915. 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);
  68916. private _dragEnterHandler;
  68917. private _dragOverHandler;
  68918. private _dropHandler;
  68919. /**
  68920. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68921. * @param elementToMonitor defines the DOM element to track
  68922. */
  68923. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68924. /**
  68925. * Release all associated resources
  68926. */
  68927. dispose(): void;
  68928. private renderFunction;
  68929. private drag;
  68930. private drop;
  68931. private _traverseFolder;
  68932. private _processFiles;
  68933. /**
  68934. * Load files from a drop event
  68935. * @param event defines the drop event to use as source
  68936. */
  68937. loadFiles(event: any): void;
  68938. private _processReload;
  68939. /**
  68940. * Reload the current scene from the loaded files
  68941. */
  68942. reload(): void;
  68943. }
  68944. }
  68945. declare module BABYLON {
  68946. /**
  68947. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68949. */
  68950. export class SceneOptimization {
  68951. /**
  68952. * Defines the priority of this optimization (0 by default which means first in the list)
  68953. */
  68954. priority: number;
  68955. /**
  68956. * Gets a string describing the action executed by the current optimization
  68957. * @returns description string
  68958. */
  68959. getDescription(): string;
  68960. /**
  68961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68962. * @param scene defines the current scene where to apply this optimization
  68963. * @param optimizer defines the current optimizer
  68964. * @returns true if everything that can be done was applied
  68965. */
  68966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68967. /**
  68968. * Creates the SceneOptimization object
  68969. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68970. * @param desc defines the description associated with the optimization
  68971. */
  68972. constructor(
  68973. /**
  68974. * Defines the priority of this optimization (0 by default which means first in the list)
  68975. */
  68976. priority?: number);
  68977. }
  68978. /**
  68979. * Defines an optimization used to reduce the size of render target textures
  68980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68981. */
  68982. export class TextureOptimization extends SceneOptimization {
  68983. /**
  68984. * Defines the priority of this optimization (0 by default which means first in the list)
  68985. */
  68986. priority: number;
  68987. /**
  68988. * 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
  68989. */
  68990. maximumSize: number;
  68991. /**
  68992. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68993. */
  68994. step: number;
  68995. /**
  68996. * Gets a string describing the action executed by the current optimization
  68997. * @returns description string
  68998. */
  68999. getDescription(): string;
  69000. /**
  69001. * Creates the TextureOptimization object
  69002. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69003. * @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
  69004. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69005. */
  69006. constructor(
  69007. /**
  69008. * Defines the priority of this optimization (0 by default which means first in the list)
  69009. */
  69010. priority?: number,
  69011. /**
  69012. * 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
  69013. */
  69014. maximumSize?: number,
  69015. /**
  69016. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69017. */
  69018. step?: number);
  69019. /**
  69020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69021. * @param scene defines the current scene where to apply this optimization
  69022. * @param optimizer defines the current optimizer
  69023. * @returns true if everything that can be done was applied
  69024. */
  69025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69026. }
  69027. /**
  69028. * Defines an optimization used to increase or decrease the rendering resolution
  69029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69030. */
  69031. export class HardwareScalingOptimization extends SceneOptimization {
  69032. /**
  69033. * Defines the priority of this optimization (0 by default which means first in the list)
  69034. */
  69035. priority: number;
  69036. /**
  69037. * Defines the maximum scale to use (2 by default)
  69038. */
  69039. maximumScale: number;
  69040. /**
  69041. * Defines the step to use between two passes (0.5 by default)
  69042. */
  69043. step: number;
  69044. private _currentScale;
  69045. private _directionOffset;
  69046. /**
  69047. * Gets a string describing the action executed by the current optimization
  69048. * @return description string
  69049. */
  69050. getDescription(): string;
  69051. /**
  69052. * Creates the HardwareScalingOptimization object
  69053. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69054. * @param maximumScale defines the maximum scale to use (2 by default)
  69055. * @param step defines the step to use between two passes (0.5 by default)
  69056. */
  69057. constructor(
  69058. /**
  69059. * Defines the priority of this optimization (0 by default which means first in the list)
  69060. */
  69061. priority?: number,
  69062. /**
  69063. * Defines the maximum scale to use (2 by default)
  69064. */
  69065. maximumScale?: number,
  69066. /**
  69067. * Defines the step to use between two passes (0.5 by default)
  69068. */
  69069. step?: number);
  69070. /**
  69071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69072. * @param scene defines the current scene where to apply this optimization
  69073. * @param optimizer defines the current optimizer
  69074. * @returns true if everything that can be done was applied
  69075. */
  69076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69077. }
  69078. /**
  69079. * Defines an optimization used to remove shadows
  69080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69081. */
  69082. export class ShadowsOptimization extends SceneOptimization {
  69083. /**
  69084. * Gets a string describing the action executed by the current optimization
  69085. * @return description string
  69086. */
  69087. getDescription(): string;
  69088. /**
  69089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69090. * @param scene defines the current scene where to apply this optimization
  69091. * @param optimizer defines the current optimizer
  69092. * @returns true if everything that can be done was applied
  69093. */
  69094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69095. }
  69096. /**
  69097. * Defines an optimization used to turn post-processes off
  69098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69099. */
  69100. export class PostProcessesOptimization extends SceneOptimization {
  69101. /**
  69102. * Gets a string describing the action executed by the current optimization
  69103. * @return description string
  69104. */
  69105. getDescription(): string;
  69106. /**
  69107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69108. * @param scene defines the current scene where to apply this optimization
  69109. * @param optimizer defines the current optimizer
  69110. * @returns true if everything that can be done was applied
  69111. */
  69112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69113. }
  69114. /**
  69115. * Defines an optimization used to turn lens flares off
  69116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69117. */
  69118. export class LensFlaresOptimization extends SceneOptimization {
  69119. /**
  69120. * Gets a string describing the action executed by the current optimization
  69121. * @return description string
  69122. */
  69123. getDescription(): string;
  69124. /**
  69125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69126. * @param scene defines the current scene where to apply this optimization
  69127. * @param optimizer defines the current optimizer
  69128. * @returns true if everything that can be done was applied
  69129. */
  69130. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69131. }
  69132. /**
  69133. * Defines an optimization based on user defined callback.
  69134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69135. */
  69136. export class CustomOptimization extends SceneOptimization {
  69137. /**
  69138. * Callback called to apply the custom optimization.
  69139. */
  69140. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69141. /**
  69142. * Callback called to get custom description
  69143. */
  69144. onGetDescription: () => string;
  69145. /**
  69146. * Gets a string describing the action executed by the current optimization
  69147. * @returns description string
  69148. */
  69149. getDescription(): string;
  69150. /**
  69151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69152. * @param scene defines the current scene where to apply this optimization
  69153. * @param optimizer defines the current optimizer
  69154. * @returns true if everything that can be done was applied
  69155. */
  69156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69157. }
  69158. /**
  69159. * Defines an optimization used to turn particles off
  69160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69161. */
  69162. export class ParticlesOptimization extends SceneOptimization {
  69163. /**
  69164. * Gets a string describing the action executed by the current optimization
  69165. * @return description string
  69166. */
  69167. getDescription(): string;
  69168. /**
  69169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69170. * @param scene defines the current scene where to apply this optimization
  69171. * @param optimizer defines the current optimizer
  69172. * @returns true if everything that can be done was applied
  69173. */
  69174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69175. }
  69176. /**
  69177. * Defines an optimization used to turn render targets off
  69178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69179. */
  69180. export class RenderTargetsOptimization extends SceneOptimization {
  69181. /**
  69182. * Gets a string describing the action executed by the current optimization
  69183. * @return description string
  69184. */
  69185. getDescription(): string;
  69186. /**
  69187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69188. * @param scene defines the current scene where to apply this optimization
  69189. * @param optimizer defines the current optimizer
  69190. * @returns true if everything that can be done was applied
  69191. */
  69192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69193. }
  69194. /**
  69195. * Defines an optimization used to merge meshes with compatible materials
  69196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69197. */
  69198. export class MergeMeshesOptimization extends SceneOptimization {
  69199. private static _UpdateSelectionTree;
  69200. /**
  69201. * Gets or sets a boolean which defines if optimization octree has to be updated
  69202. */
  69203. static get UpdateSelectionTree(): boolean;
  69204. /**
  69205. * Gets or sets a boolean which defines if optimization octree has to be updated
  69206. */
  69207. static set UpdateSelectionTree(value: boolean);
  69208. /**
  69209. * Gets a string describing the action executed by the current optimization
  69210. * @return description string
  69211. */
  69212. getDescription(): string;
  69213. private _canBeMerged;
  69214. /**
  69215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69216. * @param scene defines the current scene where to apply this optimization
  69217. * @param optimizer defines the current optimizer
  69218. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69219. * @returns true if everything that can be done was applied
  69220. */
  69221. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69222. }
  69223. /**
  69224. * Defines a list of options used by SceneOptimizer
  69225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69226. */
  69227. export class SceneOptimizerOptions {
  69228. /**
  69229. * Defines the target frame rate to reach (60 by default)
  69230. */
  69231. targetFrameRate: number;
  69232. /**
  69233. * Defines the interval between two checkes (2000ms by default)
  69234. */
  69235. trackerDuration: number;
  69236. /**
  69237. * Gets the list of optimizations to apply
  69238. */
  69239. optimizations: SceneOptimization[];
  69240. /**
  69241. * Creates a new list of options used by SceneOptimizer
  69242. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69243. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69244. */
  69245. constructor(
  69246. /**
  69247. * Defines the target frame rate to reach (60 by default)
  69248. */
  69249. targetFrameRate?: number,
  69250. /**
  69251. * Defines the interval between two checkes (2000ms by default)
  69252. */
  69253. trackerDuration?: number);
  69254. /**
  69255. * Add a new optimization
  69256. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69257. * @returns the current SceneOptimizerOptions
  69258. */
  69259. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69260. /**
  69261. * Add a new custom optimization
  69262. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69263. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69264. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69265. * @returns the current SceneOptimizerOptions
  69266. */
  69267. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69268. /**
  69269. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69270. * @param targetFrameRate defines the target frame rate (60 by default)
  69271. * @returns a SceneOptimizerOptions object
  69272. */
  69273. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69274. /**
  69275. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69276. * @param targetFrameRate defines the target frame rate (60 by default)
  69277. * @returns a SceneOptimizerOptions object
  69278. */
  69279. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69280. /**
  69281. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69282. * @param targetFrameRate defines the target frame rate (60 by default)
  69283. * @returns a SceneOptimizerOptions object
  69284. */
  69285. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69286. }
  69287. /**
  69288. * Class used to run optimizations in order to reach a target frame rate
  69289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69290. */
  69291. export class SceneOptimizer implements IDisposable {
  69292. private _isRunning;
  69293. private _options;
  69294. private _scene;
  69295. private _currentPriorityLevel;
  69296. private _targetFrameRate;
  69297. private _trackerDuration;
  69298. private _currentFrameRate;
  69299. private _sceneDisposeObserver;
  69300. private _improvementMode;
  69301. /**
  69302. * Defines an observable called when the optimizer reaches the target frame rate
  69303. */
  69304. onSuccessObservable: Observable<SceneOptimizer>;
  69305. /**
  69306. * Defines an observable called when the optimizer enables an optimization
  69307. */
  69308. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69309. /**
  69310. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69311. */
  69312. onFailureObservable: Observable<SceneOptimizer>;
  69313. /**
  69314. * Gets a boolean indicating if the optimizer is in improvement mode
  69315. */
  69316. get isInImprovementMode(): boolean;
  69317. /**
  69318. * Gets the current priority level (0 at start)
  69319. */
  69320. get currentPriorityLevel(): number;
  69321. /**
  69322. * Gets the current frame rate checked by the SceneOptimizer
  69323. */
  69324. get currentFrameRate(): number;
  69325. /**
  69326. * Gets or sets the current target frame rate (60 by default)
  69327. */
  69328. get targetFrameRate(): number;
  69329. /**
  69330. * Gets or sets the current target frame rate (60 by default)
  69331. */
  69332. set targetFrameRate(value: number);
  69333. /**
  69334. * Gets or sets the current interval between two checks (every 2000ms by default)
  69335. */
  69336. get trackerDuration(): number;
  69337. /**
  69338. * Gets or sets the current interval between two checks (every 2000ms by default)
  69339. */
  69340. set trackerDuration(value: number);
  69341. /**
  69342. * Gets the list of active optimizations
  69343. */
  69344. get optimizations(): SceneOptimization[];
  69345. /**
  69346. * Creates a new SceneOptimizer
  69347. * @param scene defines the scene to work on
  69348. * @param options defines the options to use with the SceneOptimizer
  69349. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69350. * @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)
  69351. */
  69352. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69353. /**
  69354. * Stops the current optimizer
  69355. */
  69356. stop(): void;
  69357. /**
  69358. * Reset the optimizer to initial step (current priority level = 0)
  69359. */
  69360. reset(): void;
  69361. /**
  69362. * Start the optimizer. By default it will try to reach a specific framerate
  69363. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69364. */
  69365. start(): void;
  69366. private _checkCurrentState;
  69367. /**
  69368. * Release all resources
  69369. */
  69370. dispose(): void;
  69371. /**
  69372. * Helper function to create a SceneOptimizer with one single line of code
  69373. * @param scene defines the scene to work on
  69374. * @param options defines the options to use with the SceneOptimizer
  69375. * @param onSuccess defines a callback to call on success
  69376. * @param onFailure defines a callback to call on failure
  69377. * @returns the new SceneOptimizer object
  69378. */
  69379. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69380. }
  69381. }
  69382. declare module BABYLON {
  69383. /**
  69384. * Class used to serialize a scene into a string
  69385. */
  69386. export class SceneSerializer {
  69387. /**
  69388. * Clear cache used by a previous serialization
  69389. */
  69390. static ClearCache(): void;
  69391. /**
  69392. * Serialize a scene into a JSON compatible object
  69393. * @param scene defines the scene to serialize
  69394. * @returns a JSON compatible object
  69395. */
  69396. static Serialize(scene: Scene): any;
  69397. /**
  69398. * Serialize a mesh into a JSON compatible object
  69399. * @param toSerialize defines the mesh to serialize
  69400. * @param withParents defines if parents must be serialized as well
  69401. * @param withChildren defines if children must be serialized as well
  69402. * @returns a JSON compatible object
  69403. */
  69404. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. /**
  69409. * Class used to host texture specific utilities
  69410. */
  69411. export class TextureTools {
  69412. /**
  69413. * Uses the GPU to create a copy texture rescaled at a given size
  69414. * @param texture Texture to copy from
  69415. * @param width defines the desired width
  69416. * @param height defines the desired height
  69417. * @param useBilinearMode defines if bilinear mode has to be used
  69418. * @return the generated texture
  69419. */
  69420. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * This represents the different options available for the video capture.
  69426. */
  69427. export interface VideoRecorderOptions {
  69428. /** Defines the mime type of the video. */
  69429. mimeType: string;
  69430. /** Defines the FPS the video should be recorded at. */
  69431. fps: number;
  69432. /** Defines the chunk size for the recording data. */
  69433. recordChunckSize: number;
  69434. /** The audio tracks to attach to the recording. */
  69435. audioTracks?: MediaStreamTrack[];
  69436. }
  69437. /**
  69438. * This can help with recording videos from BabylonJS.
  69439. * This is based on the available WebRTC functionalities of the browser.
  69440. *
  69441. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69442. */
  69443. export class VideoRecorder {
  69444. private static readonly _defaultOptions;
  69445. /**
  69446. * Returns whether or not the VideoRecorder is available in your browser.
  69447. * @param engine Defines the Babylon Engine.
  69448. * @returns true if supported otherwise false.
  69449. */
  69450. static IsSupported(engine: Engine): boolean;
  69451. private readonly _options;
  69452. private _canvas;
  69453. private _mediaRecorder;
  69454. private _recordedChunks;
  69455. private _fileName;
  69456. private _resolve;
  69457. private _reject;
  69458. /**
  69459. * True when a recording is already in progress.
  69460. */
  69461. get isRecording(): boolean;
  69462. /**
  69463. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69464. * @param engine Defines the BabylonJS Engine you wish to record.
  69465. * @param options Defines options that can be used to customize the capture.
  69466. */
  69467. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69468. /**
  69469. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69470. */
  69471. stopRecording(): void;
  69472. /**
  69473. * Starts recording the canvas for a max duration specified in parameters.
  69474. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69475. * If null no automatic download will start and you can rely on the promise to get the data back.
  69476. * @param maxDuration Defines the maximum recording time in seconds.
  69477. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69478. * @return A promise callback at the end of the recording with the video data in Blob.
  69479. */
  69480. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69481. /**
  69482. * Releases internal resources used during the recording.
  69483. */
  69484. dispose(): void;
  69485. private _handleDataAvailable;
  69486. private _handleError;
  69487. private _handleStop;
  69488. }
  69489. }
  69490. declare module BABYLON {
  69491. /**
  69492. * Class containing a set of static utilities functions for screenshots
  69493. */
  69494. export class ScreenshotTools {
  69495. /**
  69496. * Captures a screenshot of the current rendering
  69497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69498. * @param engine defines the rendering engine
  69499. * @param camera defines the source camera
  69500. * @param size This parameter can be set to a single number or to an object with the
  69501. * following (optional) properties: precision, width, height. If a single number is passed,
  69502. * it will be used for both width and height. If an object is passed, the screenshot size
  69503. * will be derived from the parameters. The precision property is a multiplier allowing
  69504. * rendering at a higher or lower resolution
  69505. * @param successCallback defines the callback receives a single parameter which contains the
  69506. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69507. * src parameter of an <img> to display it
  69508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69509. * Check your browser for supported MIME types
  69510. */
  69511. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69512. /**
  69513. * Captures a screenshot of the current rendering
  69514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69515. * @param engine defines the rendering engine
  69516. * @param camera defines the source camera
  69517. * @param size This parameter can be set to a single number or to an object with the
  69518. * following (optional) properties: precision, width, height. If a single number is passed,
  69519. * it will be used for both width and height. If an object is passed, the screenshot size
  69520. * will be derived from the parameters. The precision property is a multiplier allowing
  69521. * rendering at a higher or lower resolution
  69522. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69523. * Check your browser for supported MIME types
  69524. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69525. * to the src parameter of an <img> to display it
  69526. */
  69527. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69528. /**
  69529. * Generates an image screenshot from the specified camera.
  69530. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69531. * @param engine The engine to use for rendering
  69532. * @param camera The camera to use for rendering
  69533. * @param size This parameter can be set to a single number or to an object with the
  69534. * following (optional) properties: precision, width, height. If a single number is passed,
  69535. * it will be used for both width and height. If an object is passed, the screenshot size
  69536. * will be derived from the parameters. The precision property is a multiplier allowing
  69537. * rendering at a higher or lower resolution
  69538. * @param successCallback The callback receives a single parameter which contains the
  69539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69540. * src parameter of an <img> to display it
  69541. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69542. * Check your browser for supported MIME types
  69543. * @param samples Texture samples (default: 1)
  69544. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69545. * @param fileName A name for for the downloaded file.
  69546. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69547. */
  69548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69549. /**
  69550. * Generates an image screenshot from the specified camera.
  69551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69552. * @param engine The engine to use for rendering
  69553. * @param camera The camera to use for rendering
  69554. * @param size This parameter can be set to a single number or to an object with the
  69555. * following (optional) properties: precision, width, height. If a single number is passed,
  69556. * it will be used for both width and height. If an object is passed, the screenshot size
  69557. * will be derived from the parameters. The precision property is a multiplier allowing
  69558. * rendering at a higher or lower resolution
  69559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69560. * Check your browser for supported MIME types
  69561. * @param samples Texture samples (default: 1)
  69562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69563. * @param fileName A name for for the downloaded file.
  69564. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69566. * to the src parameter of an <img> to display it
  69567. */
  69568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69569. /**
  69570. * Gets height and width for screenshot size
  69571. * @private
  69572. */
  69573. private static _getScreenshotSize;
  69574. }
  69575. }
  69576. declare module BABYLON {
  69577. /**
  69578. * Interface for a data buffer
  69579. */
  69580. export interface IDataBuffer {
  69581. /**
  69582. * Reads bytes from the data buffer.
  69583. * @param byteOffset The byte offset to read
  69584. * @param byteLength The byte length to read
  69585. * @returns A promise that resolves when the bytes are read
  69586. */
  69587. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69588. /**
  69589. * The byte length of the buffer.
  69590. */
  69591. readonly byteLength: number;
  69592. }
  69593. /**
  69594. * Utility class for reading from a data buffer
  69595. */
  69596. export class DataReader {
  69597. /**
  69598. * The data buffer associated with this data reader.
  69599. */
  69600. readonly buffer: IDataBuffer;
  69601. /**
  69602. * The current byte offset from the beginning of the data buffer.
  69603. */
  69604. byteOffset: number;
  69605. private _dataView;
  69606. private _dataByteOffset;
  69607. /**
  69608. * Constructor
  69609. * @param buffer The buffer to read
  69610. */
  69611. constructor(buffer: IDataBuffer);
  69612. /**
  69613. * Loads the given byte length.
  69614. * @param byteLength The byte length to load
  69615. * @returns A promise that resolves when the load is complete
  69616. */
  69617. loadAsync(byteLength: number): Promise<void>;
  69618. /**
  69619. * Read a unsigned 32-bit integer from the currently loaded data range.
  69620. * @returns The 32-bit integer read
  69621. */
  69622. readUint32(): number;
  69623. /**
  69624. * Read a byte array from the currently loaded data range.
  69625. * @param byteLength The byte length to read
  69626. * @returns The byte array read
  69627. */
  69628. readUint8Array(byteLength: number): Uint8Array;
  69629. /**
  69630. * Read a string from the currently loaded data range.
  69631. * @param byteLength The byte length to read
  69632. * @returns The string read
  69633. */
  69634. readString(byteLength: number): string;
  69635. /**
  69636. * Skips the given byte length the currently loaded data range.
  69637. * @param byteLength The byte length to skip
  69638. */
  69639. skipBytes(byteLength: number): void;
  69640. }
  69641. }
  69642. declare module BABYLON {
  69643. /**
  69644. * Class for storing data to local storage if available or in-memory storage otherwise
  69645. */
  69646. export class DataStorage {
  69647. private static _Storage;
  69648. private static _GetStorage;
  69649. /**
  69650. * Reads a string from the data storage
  69651. * @param key The key to read
  69652. * @param defaultValue The value if the key doesn't exist
  69653. * @returns The string value
  69654. */
  69655. static ReadString(key: string, defaultValue: string): string;
  69656. /**
  69657. * Writes a string to the data storage
  69658. * @param key The key to write
  69659. * @param value The value to write
  69660. */
  69661. static WriteString(key: string, value: string): void;
  69662. /**
  69663. * Reads a boolean from the data storage
  69664. * @param key The key to read
  69665. * @param defaultValue The value if the key doesn't exist
  69666. * @returns The boolean value
  69667. */
  69668. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69669. /**
  69670. * Writes a boolean to the data storage
  69671. * @param key The key to write
  69672. * @param value The value to write
  69673. */
  69674. static WriteBoolean(key: string, value: boolean): void;
  69675. /**
  69676. * Reads a number from the data storage
  69677. * @param key The key to read
  69678. * @param defaultValue The value if the key doesn't exist
  69679. * @returns The number value
  69680. */
  69681. static ReadNumber(key: string, defaultValue: number): number;
  69682. /**
  69683. * Writes a number to the data storage
  69684. * @param key The key to write
  69685. * @param value The value to write
  69686. */
  69687. static WriteNumber(key: string, value: number): void;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /**
  69692. * Options used for hit testing
  69693. */
  69694. export interface IWebXRLegacyHitTestOptions {
  69695. /**
  69696. * Only test when user interacted with the scene. Default - hit test every frame
  69697. */
  69698. testOnPointerDownOnly?: boolean;
  69699. /**
  69700. * The node to use to transform the local results to world coordinates
  69701. */
  69702. worldParentNode?: TransformNode;
  69703. }
  69704. /**
  69705. * Interface defining the babylon result of raycasting/hit-test
  69706. */
  69707. export interface IWebXRLegacyHitResult {
  69708. /**
  69709. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69710. */
  69711. transformationMatrix: Matrix;
  69712. /**
  69713. * The native hit test result
  69714. */
  69715. xrHitResult: XRHitResult | XRHitTestResult;
  69716. }
  69717. /**
  69718. * The currently-working hit-test module.
  69719. * Hit test (or Ray-casting) is used to interact with the real world.
  69720. * For further information read here - https://github.com/immersive-web/hit-test
  69721. */
  69722. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69723. /**
  69724. * options to use when constructing this feature
  69725. */
  69726. readonly options: IWebXRLegacyHitTestOptions;
  69727. private _direction;
  69728. private _mat;
  69729. private _onSelectEnabled;
  69730. private _origin;
  69731. /**
  69732. * The module's name
  69733. */
  69734. static readonly Name: string;
  69735. /**
  69736. * The (Babylon) version of this module.
  69737. * This is an integer representing the implementation version.
  69738. * This number does not correspond to the WebXR specs version
  69739. */
  69740. static readonly Version: number;
  69741. /**
  69742. * Populated with the last native XR Hit Results
  69743. */
  69744. lastNativeXRHitResults: XRHitResult[];
  69745. /**
  69746. * Triggered when new babylon (transformed) hit test results are available
  69747. */
  69748. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69749. /**
  69750. * Creates a new instance of the (legacy version) hit test feature
  69751. * @param _xrSessionManager an instance of WebXRSessionManager
  69752. * @param options options to use when constructing this feature
  69753. */
  69754. constructor(_xrSessionManager: WebXRSessionManager,
  69755. /**
  69756. * options to use when constructing this feature
  69757. */
  69758. options?: IWebXRLegacyHitTestOptions);
  69759. /**
  69760. * execute a hit test with an XR Ray
  69761. *
  69762. * @param xrSession a native xrSession that will execute this hit test
  69763. * @param xrRay the ray (position and direction) to use for ray-casting
  69764. * @param referenceSpace native XR reference space to use for the hit-test
  69765. * @param filter filter function that will filter the results
  69766. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69767. */
  69768. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69769. /**
  69770. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69771. * @param event the (select) event to use to select with
  69772. * @param referenceSpace the reference space to use for this hit test
  69773. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69774. */
  69775. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69776. /**
  69777. * attach this feature
  69778. * Will usually be called by the features manager
  69779. *
  69780. * @returns true if successful.
  69781. */
  69782. attach(): boolean;
  69783. /**
  69784. * detach this feature.
  69785. * Will usually be called by the features manager
  69786. *
  69787. * @returns true if successful.
  69788. */
  69789. detach(): boolean;
  69790. /**
  69791. * Dispose this feature and all of the resources attached
  69792. */
  69793. dispose(): void;
  69794. protected _onXRFrame(frame: XRFrame): void;
  69795. private _onHitTestResults;
  69796. private _onSelect;
  69797. }
  69798. }
  69799. declare module BABYLON {
  69800. /**
  69801. * Options used in the plane detector module
  69802. */
  69803. export interface IWebXRPlaneDetectorOptions {
  69804. /**
  69805. * The node to use to transform the local results to world coordinates
  69806. */
  69807. worldParentNode?: TransformNode;
  69808. }
  69809. /**
  69810. * A babylon interface for a WebXR plane.
  69811. * A Plane is actually a polygon, built from N points in space
  69812. *
  69813. * Supported in chrome 79, not supported in canary 81 ATM
  69814. */
  69815. export interface IWebXRPlane {
  69816. /**
  69817. * a babylon-assigned ID for this polygon
  69818. */
  69819. id: number;
  69820. /**
  69821. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69822. */
  69823. polygonDefinition: Array<Vector3>;
  69824. /**
  69825. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69826. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69827. */
  69828. transformationMatrix: Matrix;
  69829. /**
  69830. * the native xr-plane object
  69831. */
  69832. xrPlane: XRPlane;
  69833. }
  69834. /**
  69835. * The plane detector is used to detect planes in the real world when in AR
  69836. * For more information see https://github.com/immersive-web/real-world-geometry/
  69837. */
  69838. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69839. private _options;
  69840. private _detectedPlanes;
  69841. private _enabled;
  69842. private _lastFrameDetected;
  69843. /**
  69844. * The module's name
  69845. */
  69846. static readonly Name: string;
  69847. /**
  69848. * The (Babylon) version of this module.
  69849. * This is an integer representing the implementation version.
  69850. * This number does not correspond to the WebXR specs version
  69851. */
  69852. static readonly Version: number;
  69853. /**
  69854. * Observers registered here will be executed when a new plane was added to the session
  69855. */
  69856. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69857. /**
  69858. * Observers registered here will be executed when a plane is no longer detected in the session
  69859. */
  69860. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69861. /**
  69862. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69863. * This can execute N times every frame
  69864. */
  69865. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69866. /**
  69867. * construct a new Plane Detector
  69868. * @param _xrSessionManager an instance of xr Session manager
  69869. * @param _options configuration to use when constructing this feature
  69870. */
  69871. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69872. /**
  69873. * Dispose this feature and all of the resources attached
  69874. */
  69875. dispose(): void;
  69876. protected _onXRFrame(frame: XRFrame): void;
  69877. private _init;
  69878. private _updatePlaneWithXRPlane;
  69879. /**
  69880. * avoiding using Array.find for global support.
  69881. * @param xrPlane the plane to find in the array
  69882. */
  69883. private findIndexInPlaneArray;
  69884. }
  69885. }
  69886. declare module BABYLON {
  69887. /**
  69888. * Configuration options of the anchor system
  69889. */
  69890. export interface IWebXRAnchorSystemOptions {
  69891. /**
  69892. * Should a new anchor be added every time a select event is triggered
  69893. */
  69894. addAnchorOnSelect?: boolean;
  69895. /**
  69896. * should the anchor system use plane detection.
  69897. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69898. */
  69899. usePlaneDetection?: boolean;
  69900. /**
  69901. * a node that will be used to convert local to world coordinates
  69902. */
  69903. worldParentNode?: TransformNode;
  69904. }
  69905. /**
  69906. * A babylon container for an XR Anchor
  69907. */
  69908. export interface IWebXRAnchor {
  69909. /**
  69910. * A babylon-assigned ID for this anchor
  69911. */
  69912. id: number;
  69913. /**
  69914. * Transformation matrix to apply to an object attached to this anchor
  69915. */
  69916. transformationMatrix: Matrix;
  69917. /**
  69918. * The native anchor object
  69919. */
  69920. xrAnchor: XRAnchor;
  69921. }
  69922. /**
  69923. * An implementation of the anchor system of WebXR.
  69924. * Note that the current documented implementation is not available in any browser. Future implementations
  69925. * will use the frame to create an anchor and not the session or a detected plane
  69926. * For further information see https://github.com/immersive-web/anchors/
  69927. */
  69928. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69929. private _options;
  69930. private _enabled;
  69931. private _hitTestModule;
  69932. private _lastFrameDetected;
  69933. private _onSelect;
  69934. private _planeDetector;
  69935. private _trackedAnchors;
  69936. /**
  69937. * The module's name
  69938. */
  69939. static readonly Name: string;
  69940. /**
  69941. * The (Babylon) version of this module.
  69942. * This is an integer representing the implementation version.
  69943. * This number does not correspond to the WebXR specs version
  69944. */
  69945. static readonly Version: number;
  69946. /**
  69947. * Observers registered here will be executed when a new anchor was added to the session
  69948. */
  69949. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69950. /**
  69951. * Observers registered here will be executed when an anchor was removed from the session
  69952. */
  69953. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69954. /**
  69955. * Observers registered here will be executed when an existing anchor updates
  69956. * This can execute N times every frame
  69957. */
  69958. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69959. /**
  69960. * constructs a new anchor system
  69961. * @param _xrSessionManager an instance of WebXRSessionManager
  69962. * @param _options configuration object for this feature
  69963. */
  69964. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69965. /**
  69966. * Add anchor at a specific XR point.
  69967. *
  69968. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69969. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69970. * @returns a promise the fulfills when the anchor was created
  69971. */
  69972. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69973. /**
  69974. * attach this feature
  69975. * Will usually be called by the features manager
  69976. *
  69977. * @returns true if successful.
  69978. */
  69979. attach(): boolean;
  69980. /**
  69981. * detach this feature.
  69982. * Will usually be called by the features manager
  69983. *
  69984. * @returns true if successful.
  69985. */
  69986. detach(): boolean;
  69987. /**
  69988. * Dispose this feature and all of the resources attached
  69989. */
  69990. dispose(): void;
  69991. /**
  69992. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69993. * @param hitTestModule the hit-test module to use.
  69994. */
  69995. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69996. /**
  69997. * set the plane detector to use in order to create anchors from frames
  69998. * @param planeDetector the plane-detector module to use
  69999. * @param enable enable plane-anchors. default is true
  70000. */
  70001. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  70002. protected _onXRFrame(frame: XRFrame): void;
  70003. /**
  70004. * avoiding using Array.find for global support.
  70005. * @param xrAnchor the plane to find in the array
  70006. */
  70007. private _findIndexInAnchorArray;
  70008. private _updateAnchorWithXRFrame;
  70009. }
  70010. }
  70011. declare module BABYLON {
  70012. /**
  70013. * Options interface for the background remover plugin
  70014. */
  70015. export interface IWebXRBackgroundRemoverOptions {
  70016. /**
  70017. * Further background meshes to disable when entering AR
  70018. */
  70019. backgroundMeshes?: AbstractMesh[];
  70020. /**
  70021. * flags to configure the removal of the environment helper.
  70022. * If not set, the entire background will be removed. If set, flags should be set as well.
  70023. */
  70024. environmentHelperRemovalFlags?: {
  70025. /**
  70026. * Should the skybox be removed (default false)
  70027. */
  70028. skyBox?: boolean;
  70029. /**
  70030. * Should the ground be removed (default false)
  70031. */
  70032. ground?: boolean;
  70033. };
  70034. /**
  70035. * don't disable the environment helper
  70036. */
  70037. ignoreEnvironmentHelper?: boolean;
  70038. }
  70039. /**
  70040. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  70041. */
  70042. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  70043. /**
  70044. * read-only options to be used in this module
  70045. */
  70046. readonly options: IWebXRBackgroundRemoverOptions;
  70047. /**
  70048. * The module's name
  70049. */
  70050. static readonly Name: string;
  70051. /**
  70052. * The (Babylon) version of this module.
  70053. * This is an integer representing the implementation version.
  70054. * This number does not correspond to the WebXR specs version
  70055. */
  70056. static readonly Version: number;
  70057. /**
  70058. * registered observers will be triggered when the background state changes
  70059. */
  70060. onBackgroundStateChangedObservable: Observable<boolean>;
  70061. /**
  70062. * constructs a new background remover module
  70063. * @param _xrSessionManager the session manager for this module
  70064. * @param options read-only options to be used in this module
  70065. */
  70066. constructor(_xrSessionManager: WebXRSessionManager,
  70067. /**
  70068. * read-only options to be used in this module
  70069. */
  70070. options?: IWebXRBackgroundRemoverOptions);
  70071. /**
  70072. * attach this feature
  70073. * Will usually be called by the features manager
  70074. *
  70075. * @returns true if successful.
  70076. */
  70077. attach(): boolean;
  70078. /**
  70079. * detach this feature.
  70080. * Will usually be called by the features manager
  70081. *
  70082. * @returns true if successful.
  70083. */
  70084. detach(): boolean;
  70085. /**
  70086. * Dispose this feature and all of the resources attached
  70087. */
  70088. dispose(): void;
  70089. protected _onXRFrame(_xrFrame: XRFrame): void;
  70090. private _setBackgroundState;
  70091. }
  70092. }
  70093. declare module BABYLON {
  70094. /**
  70095. * Options for the controller physics feature
  70096. */
  70097. export class IWebXRControllerPhysicsOptions {
  70098. /**
  70099. * Should the headset get its own impostor
  70100. */
  70101. enableHeadsetImpostor?: boolean;
  70102. /**
  70103. * Optional parameters for the headset impostor
  70104. */
  70105. headsetImpostorParams?: {
  70106. /**
  70107. * The type of impostor to create. Default is sphere
  70108. */
  70109. impostorType: number;
  70110. /**
  70111. * the size of the impostor. Defaults to 10cm
  70112. */
  70113. impostorSize?: number | {
  70114. width: number;
  70115. height: number;
  70116. depth: number;
  70117. };
  70118. /**
  70119. * Friction definitions
  70120. */
  70121. friction?: number;
  70122. /**
  70123. * Restitution
  70124. */
  70125. restitution?: number;
  70126. };
  70127. /**
  70128. * The physics properties of the future impostors
  70129. */
  70130. physicsProperties?: {
  70131. /**
  70132. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70133. * Note that this requires a physics engine that supports mesh impostors!
  70134. */
  70135. useControllerMesh?: boolean;
  70136. /**
  70137. * The type of impostor to create. Default is sphere
  70138. */
  70139. impostorType?: number;
  70140. /**
  70141. * the size of the impostor. Defaults to 10cm
  70142. */
  70143. impostorSize?: number | {
  70144. width: number;
  70145. height: number;
  70146. depth: number;
  70147. };
  70148. /**
  70149. * Friction definitions
  70150. */
  70151. friction?: number;
  70152. /**
  70153. * Restitution
  70154. */
  70155. restitution?: number;
  70156. };
  70157. /**
  70158. * the xr input to use with this pointer selection
  70159. */
  70160. xrInput: WebXRInput;
  70161. }
  70162. /**
  70163. * Add physics impostor to your webxr controllers,
  70164. * including naive calculation of their linear and angular velocity
  70165. */
  70166. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70167. private readonly _options;
  70168. private _attachController;
  70169. private _controllers;
  70170. private _debugMode;
  70171. private _delta;
  70172. private _headsetImpostor?;
  70173. private _headsetMesh?;
  70174. private _lastTimestamp;
  70175. private _tmpQuaternion;
  70176. private _tmpVector;
  70177. /**
  70178. * The module's name
  70179. */
  70180. static readonly Name: string;
  70181. /**
  70182. * The (Babylon) version of this module.
  70183. * This is an integer representing the implementation version.
  70184. * This number does not correspond to the webxr specs version
  70185. */
  70186. static readonly Version: number;
  70187. /**
  70188. * Construct a new Controller Physics Feature
  70189. * @param _xrSessionManager the corresponding xr session manager
  70190. * @param _options options to create this feature with
  70191. */
  70192. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70193. /**
  70194. * @hidden
  70195. * enable debugging - will show console outputs and the impostor mesh
  70196. */
  70197. _enablePhysicsDebug(): void;
  70198. /**
  70199. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70200. * @param xrController the controller to add
  70201. */
  70202. addController(xrController: WebXRInputSource): void;
  70203. /**
  70204. * attach this feature
  70205. * Will usually be called by the features manager
  70206. *
  70207. * @returns true if successful.
  70208. */
  70209. attach(): boolean;
  70210. /**
  70211. * detach this feature.
  70212. * Will usually be called by the features manager
  70213. *
  70214. * @returns true if successful.
  70215. */
  70216. detach(): boolean;
  70217. /**
  70218. * Get the headset impostor, if enabled
  70219. * @returns the impostor
  70220. */
  70221. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70222. /**
  70223. * Get the physics impostor of a specific controller.
  70224. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70225. * @param controller the controller or the controller id of which to get the impostor
  70226. * @returns the impostor or null
  70227. */
  70228. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70229. /**
  70230. * Update the physics properties provided in the constructor
  70231. * @param newProperties the new properties object
  70232. */
  70233. setPhysicsProperties(newProperties: {
  70234. impostorType?: number;
  70235. impostorSize?: number | {
  70236. width: number;
  70237. height: number;
  70238. depth: number;
  70239. };
  70240. friction?: number;
  70241. restitution?: number;
  70242. }): void;
  70243. protected _onXRFrame(_xrFrame: any): void;
  70244. private _detachController;
  70245. }
  70246. }
  70247. declare module BABYLON {
  70248. /**
  70249. * Options used for hit testing (version 2)
  70250. */
  70251. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70252. /**
  70253. * Do not create a permanent hit test. Will usually be used when only
  70254. * transient inputs are needed.
  70255. */
  70256. disablePermanentHitTest?: boolean;
  70257. /**
  70258. * Enable transient (for example touch-based) hit test inspections
  70259. */
  70260. enableTransientHitTest?: boolean;
  70261. /**
  70262. * Offset ray for the permanent hit test
  70263. */
  70264. offsetRay?: Vector3;
  70265. /**
  70266. * Offset ray for the transient hit test
  70267. */
  70268. transientOffsetRay?: Vector3;
  70269. /**
  70270. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70271. */
  70272. useReferenceSpace?: boolean;
  70273. }
  70274. /**
  70275. * Interface defining the babylon result of hit-test
  70276. */
  70277. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70278. /**
  70279. * The input source that generated this hit test (if transient)
  70280. */
  70281. inputSource?: XRInputSource;
  70282. /**
  70283. * Is this a transient hit test
  70284. */
  70285. isTransient?: boolean;
  70286. /**
  70287. * Position of the hit test result
  70288. */
  70289. position: Vector3;
  70290. /**
  70291. * Rotation of the hit test result
  70292. */
  70293. rotationQuaternion: Quaternion;
  70294. }
  70295. /**
  70296. * The currently-working hit-test module.
  70297. * Hit test (or Ray-casting) is used to interact with the real world.
  70298. * For further information read here - https://github.com/immersive-web/hit-test
  70299. *
  70300. * Tested on chrome (mobile) 80.
  70301. */
  70302. export class WebXRHitTest extends WebXRAbstractFeature {
  70303. /**
  70304. * options to use when constructing this feature
  70305. */
  70306. readonly options: IWebXRHitTestOptions;
  70307. private _tmpMat;
  70308. private _tmpPos;
  70309. private _tmpQuat;
  70310. private _transientXrHitTestSource;
  70311. private _xrHitTestSource;
  70312. private initHitTestSource;
  70313. /**
  70314. * The module's name
  70315. */
  70316. static readonly Name: string;
  70317. /**
  70318. * The (Babylon) version of this module.
  70319. * This is an integer representing the implementation version.
  70320. * This number does not correspond to the WebXR specs version
  70321. */
  70322. static readonly Version: number;
  70323. /**
  70324. * When set to true, each hit test will have its own position/rotation objects
  70325. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70326. * the developers will clone them or copy them as they see fit.
  70327. */
  70328. autoCloneTransformation: boolean;
  70329. /**
  70330. * Populated with the last native XR Hit Results
  70331. */
  70332. lastNativeXRHitResults: XRHitResult[];
  70333. /**
  70334. * Triggered when new babylon (transformed) hit test results are available
  70335. */
  70336. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70337. /**
  70338. * Use this to temporarily pause hit test checks.
  70339. */
  70340. paused: boolean;
  70341. /**
  70342. * Creates a new instance of the hit test feature
  70343. * @param _xrSessionManager an instance of WebXRSessionManager
  70344. * @param options options to use when constructing this feature
  70345. */
  70346. constructor(_xrSessionManager: WebXRSessionManager,
  70347. /**
  70348. * options to use when constructing this feature
  70349. */
  70350. options?: IWebXRHitTestOptions);
  70351. /**
  70352. * attach this feature
  70353. * Will usually be called by the features manager
  70354. *
  70355. * @returns true if successful.
  70356. */
  70357. attach(): boolean;
  70358. /**
  70359. * detach this feature.
  70360. * Will usually be called by the features manager
  70361. *
  70362. * @returns true if successful.
  70363. */
  70364. detach(): boolean;
  70365. /**
  70366. * Dispose this feature and all of the resources attached
  70367. */
  70368. dispose(): void;
  70369. protected _onXRFrame(frame: XRFrame): void;
  70370. private _processWebXRHitTestResult;
  70371. }
  70372. }
  70373. declare module BABYLON {
  70374. /**
  70375. * The motion controller class for all microsoft mixed reality controllers
  70376. */
  70377. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70378. protected readonly _mapping: {
  70379. defaultButton: {
  70380. valueNodeName: string;
  70381. unpressedNodeName: string;
  70382. pressedNodeName: string;
  70383. };
  70384. defaultAxis: {
  70385. valueNodeName: string;
  70386. minNodeName: string;
  70387. maxNodeName: string;
  70388. };
  70389. buttons: {
  70390. "xr-standard-trigger": {
  70391. rootNodeName: string;
  70392. componentProperty: string;
  70393. states: string[];
  70394. };
  70395. "xr-standard-squeeze": {
  70396. rootNodeName: string;
  70397. componentProperty: string;
  70398. states: string[];
  70399. };
  70400. "xr-standard-touchpad": {
  70401. rootNodeName: string;
  70402. labelAnchorNodeName: string;
  70403. touchPointNodeName: string;
  70404. };
  70405. "xr-standard-thumbstick": {
  70406. rootNodeName: string;
  70407. componentProperty: string;
  70408. states: string[];
  70409. };
  70410. };
  70411. axes: {
  70412. "xr-standard-touchpad": {
  70413. "x-axis": {
  70414. rootNodeName: string;
  70415. };
  70416. "y-axis": {
  70417. rootNodeName: string;
  70418. };
  70419. };
  70420. "xr-standard-thumbstick": {
  70421. "x-axis": {
  70422. rootNodeName: string;
  70423. };
  70424. "y-axis": {
  70425. rootNodeName: string;
  70426. };
  70427. };
  70428. };
  70429. };
  70430. /**
  70431. * The base url used to load the left and right controller models
  70432. */
  70433. static MODEL_BASE_URL: string;
  70434. /**
  70435. * The name of the left controller model file
  70436. */
  70437. static MODEL_LEFT_FILENAME: string;
  70438. /**
  70439. * The name of the right controller model file
  70440. */
  70441. static MODEL_RIGHT_FILENAME: string;
  70442. profileId: string;
  70443. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70444. protected _getFilenameAndPath(): {
  70445. filename: string;
  70446. path: string;
  70447. };
  70448. protected _getModelLoadingConstraints(): boolean;
  70449. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70450. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70451. protected _updateModel(): void;
  70452. }
  70453. }
  70454. declare module BABYLON {
  70455. /**
  70456. * The motion controller class for oculus touch (quest, rift).
  70457. * This class supports legacy mapping as well the standard xr mapping
  70458. */
  70459. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70460. private _forceLegacyControllers;
  70461. private _modelRootNode;
  70462. /**
  70463. * The base url used to load the left and right controller models
  70464. */
  70465. static MODEL_BASE_URL: string;
  70466. /**
  70467. * The name of the left controller model file
  70468. */
  70469. static MODEL_LEFT_FILENAME: string;
  70470. /**
  70471. * The name of the right controller model file
  70472. */
  70473. static MODEL_RIGHT_FILENAME: string;
  70474. /**
  70475. * Base Url for the Quest controller model.
  70476. */
  70477. static QUEST_MODEL_BASE_URL: string;
  70478. profileId: string;
  70479. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70480. protected _getFilenameAndPath(): {
  70481. filename: string;
  70482. path: string;
  70483. };
  70484. protected _getModelLoadingConstraints(): boolean;
  70485. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70486. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70487. protected _updateModel(): void;
  70488. /**
  70489. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70490. * between the touch and touch 2.
  70491. */
  70492. private _isQuest;
  70493. }
  70494. }
  70495. declare module BABYLON {
  70496. /**
  70497. * The motion controller class for the standard HTC-Vive controllers
  70498. */
  70499. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70500. private _modelRootNode;
  70501. /**
  70502. * The base url used to load the left and right controller models
  70503. */
  70504. static MODEL_BASE_URL: string;
  70505. /**
  70506. * File name for the controller model.
  70507. */
  70508. static MODEL_FILENAME: string;
  70509. profileId: string;
  70510. /**
  70511. * Create a new Vive motion controller object
  70512. * @param scene the scene to use to create this controller
  70513. * @param gamepadObject the corresponding gamepad object
  70514. * @param handness the handness of the controller
  70515. */
  70516. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70517. protected _getFilenameAndPath(): {
  70518. filename: string;
  70519. path: string;
  70520. };
  70521. protected _getModelLoadingConstraints(): boolean;
  70522. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70523. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70524. protected _updateModel(): void;
  70525. }
  70526. }
  70527. declare module BABYLON {
  70528. /**
  70529. * A cursor which tracks a point on a path
  70530. */
  70531. export class PathCursor {
  70532. private path;
  70533. /**
  70534. * Stores path cursor callbacks for when an onchange event is triggered
  70535. */
  70536. private _onchange;
  70537. /**
  70538. * The value of the path cursor
  70539. */
  70540. value: number;
  70541. /**
  70542. * The animation array of the path cursor
  70543. */
  70544. animations: Animation[];
  70545. /**
  70546. * Initializes the path cursor
  70547. * @param path The path to track
  70548. */
  70549. constructor(path: Path2);
  70550. /**
  70551. * Gets the cursor point on the path
  70552. * @returns A point on the path cursor at the cursor location
  70553. */
  70554. getPoint(): Vector3;
  70555. /**
  70556. * Moves the cursor ahead by the step amount
  70557. * @param step The amount to move the cursor forward
  70558. * @returns This path cursor
  70559. */
  70560. moveAhead(step?: number): PathCursor;
  70561. /**
  70562. * Moves the cursor behind by the step amount
  70563. * @param step The amount to move the cursor back
  70564. * @returns This path cursor
  70565. */
  70566. moveBack(step?: number): PathCursor;
  70567. /**
  70568. * Moves the cursor by the step amount
  70569. * If the step amount is greater than one, an exception is thrown
  70570. * @param step The amount to move the cursor
  70571. * @returns This path cursor
  70572. */
  70573. move(step: number): PathCursor;
  70574. /**
  70575. * Ensures that the value is limited between zero and one
  70576. * @returns This path cursor
  70577. */
  70578. private ensureLimits;
  70579. /**
  70580. * Runs onchange callbacks on change (used by the animation engine)
  70581. * @returns This path cursor
  70582. */
  70583. private raiseOnChange;
  70584. /**
  70585. * Executes a function on change
  70586. * @param f A path cursor onchange callback
  70587. * @returns This path cursor
  70588. */
  70589. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /** @hidden */
  70594. export var blurPixelShader: {
  70595. name: string;
  70596. shader: string;
  70597. };
  70598. }
  70599. declare module BABYLON {
  70600. /** @hidden */
  70601. export var pointCloudVertexDeclaration: {
  70602. name: string;
  70603. shader: string;
  70604. };
  70605. }
  70606. // Mixins
  70607. interface Window {
  70608. mozIndexedDB: IDBFactory;
  70609. webkitIndexedDB: IDBFactory;
  70610. msIndexedDB: IDBFactory;
  70611. webkitURL: typeof URL;
  70612. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70613. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70614. WebGLRenderingContext: WebGLRenderingContext;
  70615. MSGesture: MSGesture;
  70616. CANNON: any;
  70617. AudioContext: AudioContext;
  70618. webkitAudioContext: AudioContext;
  70619. PointerEvent: any;
  70620. Math: Math;
  70621. Uint8Array: Uint8ArrayConstructor;
  70622. Float32Array: Float32ArrayConstructor;
  70623. mozURL: typeof URL;
  70624. msURL: typeof URL;
  70625. VRFrameData: any; // WebVR, from specs 1.1
  70626. DracoDecoderModule: any;
  70627. setImmediate(handler: (...args: any[]) => void): number;
  70628. }
  70629. interface HTMLCanvasElement {
  70630. requestPointerLock(): void;
  70631. msRequestPointerLock?(): void;
  70632. mozRequestPointerLock?(): void;
  70633. webkitRequestPointerLock?(): void;
  70634. /** Track wether a record is in progress */
  70635. isRecording: boolean;
  70636. /** Capture Stream method defined by some browsers */
  70637. captureStream(fps?: number): MediaStream;
  70638. }
  70639. interface CanvasRenderingContext2D {
  70640. msImageSmoothingEnabled: boolean;
  70641. }
  70642. interface MouseEvent {
  70643. mozMovementX: number;
  70644. mozMovementY: number;
  70645. webkitMovementX: number;
  70646. webkitMovementY: number;
  70647. msMovementX: number;
  70648. msMovementY: number;
  70649. }
  70650. interface Navigator {
  70651. mozGetVRDevices: (any: any) => any;
  70652. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70653. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70654. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70655. webkitGetGamepads(): Gamepad[];
  70656. msGetGamepads(): Gamepad[];
  70657. webkitGamepads(): Gamepad[];
  70658. }
  70659. interface HTMLVideoElement {
  70660. mozSrcObject: any;
  70661. }
  70662. interface Math {
  70663. fround(x: number): number;
  70664. imul(a: number, b: number): number;
  70665. }
  70666. interface WebGLRenderingContext {
  70667. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70668. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70669. vertexAttribDivisor(index: number, divisor: number): void;
  70670. createVertexArray(): any;
  70671. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70672. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70673. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70674. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70675. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70676. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70677. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70678. // Queries
  70679. createQuery(): WebGLQuery;
  70680. deleteQuery(query: WebGLQuery): void;
  70681. beginQuery(target: number, query: WebGLQuery): void;
  70682. endQuery(target: number): void;
  70683. getQueryParameter(query: WebGLQuery, pname: number): any;
  70684. getQuery(target: number, pname: number): any;
  70685. MAX_SAMPLES: number;
  70686. RGBA8: number;
  70687. READ_FRAMEBUFFER: number;
  70688. DRAW_FRAMEBUFFER: number;
  70689. UNIFORM_BUFFER: number;
  70690. HALF_FLOAT_OES: number;
  70691. RGBA16F: number;
  70692. RGBA32F: number;
  70693. R32F: number;
  70694. RG32F: number;
  70695. RGB32F: number;
  70696. R16F: number;
  70697. RG16F: number;
  70698. RGB16F: number;
  70699. RED: number;
  70700. RG: number;
  70701. R8: number;
  70702. RG8: number;
  70703. UNSIGNED_INT_24_8: number;
  70704. DEPTH24_STENCIL8: number;
  70705. MIN: number;
  70706. MAX: number;
  70707. /* Multiple Render Targets */
  70708. drawBuffers(buffers: number[]): void;
  70709. readBuffer(src: number): void;
  70710. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70711. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70712. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70713. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70714. // Occlusion Query
  70715. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70716. ANY_SAMPLES_PASSED: number;
  70717. QUERY_RESULT_AVAILABLE: number;
  70718. QUERY_RESULT: number;
  70719. }
  70720. interface WebGLProgram {
  70721. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70722. }
  70723. interface EXT_disjoint_timer_query {
  70724. QUERY_COUNTER_BITS_EXT: number;
  70725. TIME_ELAPSED_EXT: number;
  70726. TIMESTAMP_EXT: number;
  70727. GPU_DISJOINT_EXT: number;
  70728. QUERY_RESULT_EXT: number;
  70729. QUERY_RESULT_AVAILABLE_EXT: number;
  70730. queryCounterEXT(query: WebGLQuery, target: number): void;
  70731. createQueryEXT(): WebGLQuery;
  70732. beginQueryEXT(target: number, query: WebGLQuery): void;
  70733. endQueryEXT(target: number): void;
  70734. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70735. deleteQueryEXT(query: WebGLQuery): void;
  70736. }
  70737. interface WebGLUniformLocation {
  70738. _currentState: any;
  70739. }
  70740. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70741. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70742. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70743. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70744. interface WebGLRenderingContext {
  70745. readonly RASTERIZER_DISCARD: number;
  70746. readonly DEPTH_COMPONENT24: number;
  70747. readonly TEXTURE_3D: number;
  70748. readonly TEXTURE_2D_ARRAY: number;
  70749. readonly TEXTURE_COMPARE_FUNC: number;
  70750. readonly TEXTURE_COMPARE_MODE: number;
  70751. readonly COMPARE_REF_TO_TEXTURE: number;
  70752. readonly TEXTURE_WRAP_R: number;
  70753. readonly HALF_FLOAT: number;
  70754. readonly RGB8: number;
  70755. readonly RED_INTEGER: number;
  70756. readonly RG_INTEGER: number;
  70757. readonly RGB_INTEGER: number;
  70758. readonly RGBA_INTEGER: number;
  70759. readonly R8_SNORM: number;
  70760. readonly RG8_SNORM: number;
  70761. readonly RGB8_SNORM: number;
  70762. readonly RGBA8_SNORM: number;
  70763. readonly R8I: number;
  70764. readonly RG8I: number;
  70765. readonly RGB8I: number;
  70766. readonly RGBA8I: number;
  70767. readonly R8UI: number;
  70768. readonly RG8UI: number;
  70769. readonly RGB8UI: number;
  70770. readonly RGBA8UI: number;
  70771. readonly R16I: number;
  70772. readonly RG16I: number;
  70773. readonly RGB16I: number;
  70774. readonly RGBA16I: number;
  70775. readonly R16UI: number;
  70776. readonly RG16UI: number;
  70777. readonly RGB16UI: number;
  70778. readonly RGBA16UI: number;
  70779. readonly R32I: number;
  70780. readonly RG32I: number;
  70781. readonly RGB32I: number;
  70782. readonly RGBA32I: number;
  70783. readonly R32UI: number;
  70784. readonly RG32UI: number;
  70785. readonly RGB32UI: number;
  70786. readonly RGBA32UI: number;
  70787. readonly RGB10_A2UI: number;
  70788. readonly R11F_G11F_B10F: number;
  70789. readonly RGB9_E5: number;
  70790. readonly RGB10_A2: number;
  70791. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70792. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70793. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70794. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70795. readonly DEPTH_COMPONENT32F: number;
  70796. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70797. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70798. 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;
  70799. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70800. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70801. readonly TRANSFORM_FEEDBACK: number;
  70802. readonly INTERLEAVED_ATTRIBS: number;
  70803. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70804. createTransformFeedback(): WebGLTransformFeedback;
  70805. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70806. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70807. beginTransformFeedback(primitiveMode: number): void;
  70808. endTransformFeedback(): void;
  70809. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70810. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70811. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70812. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70813. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70814. }
  70815. interface ImageBitmap {
  70816. readonly width: number;
  70817. readonly height: number;
  70818. close(): void;
  70819. }
  70820. interface WebGLQuery extends WebGLObject {
  70821. }
  70822. declare var WebGLQuery: {
  70823. prototype: WebGLQuery;
  70824. new(): WebGLQuery;
  70825. };
  70826. interface WebGLSampler extends WebGLObject {
  70827. }
  70828. declare var WebGLSampler: {
  70829. prototype: WebGLSampler;
  70830. new(): WebGLSampler;
  70831. };
  70832. interface WebGLSync extends WebGLObject {
  70833. }
  70834. declare var WebGLSync: {
  70835. prototype: WebGLSync;
  70836. new(): WebGLSync;
  70837. };
  70838. interface WebGLTransformFeedback extends WebGLObject {
  70839. }
  70840. declare var WebGLTransformFeedback: {
  70841. prototype: WebGLTransformFeedback;
  70842. new(): WebGLTransformFeedback;
  70843. };
  70844. interface WebGLVertexArrayObject extends WebGLObject {
  70845. }
  70846. declare var WebGLVertexArrayObject: {
  70847. prototype: WebGLVertexArrayObject;
  70848. new(): WebGLVertexArrayObject;
  70849. };
  70850. // Type definitions for WebVR API
  70851. // Project: https://w3c.github.io/webvr/
  70852. // Definitions by: six a <https://github.com/lostfictions>
  70853. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70854. interface VRDisplay extends EventTarget {
  70855. /**
  70856. * Dictionary of capabilities describing the VRDisplay.
  70857. */
  70858. readonly capabilities: VRDisplayCapabilities;
  70859. /**
  70860. * z-depth defining the far plane of the eye view frustum
  70861. * enables mapping of values in the render target depth
  70862. * attachment to scene coordinates. Initially set to 10000.0.
  70863. */
  70864. depthFar: number;
  70865. /**
  70866. * z-depth defining the near plane of the eye view frustum
  70867. * enables mapping of values in the render target depth
  70868. * attachment to scene coordinates. Initially set to 0.01.
  70869. */
  70870. depthNear: number;
  70871. /**
  70872. * An identifier for this distinct VRDisplay. Used as an
  70873. * association point in the Gamepad API.
  70874. */
  70875. readonly displayId: number;
  70876. /**
  70877. * A display name, a user-readable name identifying it.
  70878. */
  70879. readonly displayName: string;
  70880. readonly isConnected: boolean;
  70881. readonly isPresenting: boolean;
  70882. /**
  70883. * If this VRDisplay supports room-scale experiences, the optional
  70884. * stage attribute contains details on the room-scale parameters.
  70885. */
  70886. readonly stageParameters: VRStageParameters | null;
  70887. /**
  70888. * Passing the value returned by `requestAnimationFrame` to
  70889. * `cancelAnimationFrame` will unregister the callback.
  70890. * @param handle Define the hanle of the request to cancel
  70891. */
  70892. cancelAnimationFrame(handle: number): void;
  70893. /**
  70894. * Stops presenting to the VRDisplay.
  70895. * @returns a promise to know when it stopped
  70896. */
  70897. exitPresent(): Promise<void>;
  70898. /**
  70899. * Return the current VREyeParameters for the given eye.
  70900. * @param whichEye Define the eye we want the parameter for
  70901. * @returns the eye parameters
  70902. */
  70903. getEyeParameters(whichEye: string): VREyeParameters;
  70904. /**
  70905. * Populates the passed VRFrameData with the information required to render
  70906. * the current frame.
  70907. * @param frameData Define the data structure to populate
  70908. * @returns true if ok otherwise false
  70909. */
  70910. getFrameData(frameData: VRFrameData): boolean;
  70911. /**
  70912. * Get the layers currently being presented.
  70913. * @returns the list of VR layers
  70914. */
  70915. getLayers(): VRLayer[];
  70916. /**
  70917. * Return a VRPose containing the future predicted pose of the VRDisplay
  70918. * when the current frame will be presented. The value returned will not
  70919. * change until JavaScript has returned control to the browser.
  70920. *
  70921. * The VRPose will contain the position, orientation, velocity,
  70922. * and acceleration of each of these properties.
  70923. * @returns the pose object
  70924. */
  70925. getPose(): VRPose;
  70926. /**
  70927. * Return the current instantaneous pose of the VRDisplay, with no
  70928. * prediction applied.
  70929. * @returns the current instantaneous pose
  70930. */
  70931. getImmediatePose(): VRPose;
  70932. /**
  70933. * The callback passed to `requestAnimationFrame` will be called
  70934. * any time a new frame should be rendered. When the VRDisplay is
  70935. * presenting the callback will be called at the native refresh
  70936. * rate of the HMD. When not presenting this function acts
  70937. * identically to how window.requestAnimationFrame acts. Content should
  70938. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70939. * asynchronously from other displays and at differing refresh rates.
  70940. * @param callback Define the eaction to run next frame
  70941. * @returns the request handle it
  70942. */
  70943. requestAnimationFrame(callback: FrameRequestCallback): number;
  70944. /**
  70945. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70946. * Repeat calls while already presenting will update the VRLayers being displayed.
  70947. * @param layers Define the list of layer to present
  70948. * @returns a promise to know when the request has been fulfilled
  70949. */
  70950. requestPresent(layers: VRLayer[]): Promise<void>;
  70951. /**
  70952. * Reset the pose for this display, treating its current position and
  70953. * orientation as the "origin/zero" values. VRPose.position,
  70954. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70955. * updated when calling resetPose(). This should be called in only
  70956. * sitting-space experiences.
  70957. */
  70958. resetPose(): void;
  70959. /**
  70960. * The VRLayer provided to the VRDisplay will be captured and presented
  70961. * in the HMD. Calling this function has the same effect on the source
  70962. * canvas as any other operation that uses its source image, and canvases
  70963. * created without preserveDrawingBuffer set to true will be cleared.
  70964. * @param pose Define the pose to submit
  70965. */
  70966. submitFrame(pose?: VRPose): void;
  70967. }
  70968. declare var VRDisplay: {
  70969. prototype: VRDisplay;
  70970. new(): VRDisplay;
  70971. };
  70972. interface VRLayer {
  70973. leftBounds?: number[] | Float32Array | null;
  70974. rightBounds?: number[] | Float32Array | null;
  70975. source?: HTMLCanvasElement | null;
  70976. }
  70977. interface VRDisplayCapabilities {
  70978. readonly canPresent: boolean;
  70979. readonly hasExternalDisplay: boolean;
  70980. readonly hasOrientation: boolean;
  70981. readonly hasPosition: boolean;
  70982. readonly maxLayers: number;
  70983. }
  70984. interface VREyeParameters {
  70985. /** @deprecated */
  70986. readonly fieldOfView: VRFieldOfView;
  70987. readonly offset: Float32Array;
  70988. readonly renderHeight: number;
  70989. readonly renderWidth: number;
  70990. }
  70991. interface VRFieldOfView {
  70992. readonly downDegrees: number;
  70993. readonly leftDegrees: number;
  70994. readonly rightDegrees: number;
  70995. readonly upDegrees: number;
  70996. }
  70997. interface VRFrameData {
  70998. readonly leftProjectionMatrix: Float32Array;
  70999. readonly leftViewMatrix: Float32Array;
  71000. readonly pose: VRPose;
  71001. readonly rightProjectionMatrix: Float32Array;
  71002. readonly rightViewMatrix: Float32Array;
  71003. readonly timestamp: number;
  71004. }
  71005. interface VRPose {
  71006. readonly angularAcceleration: Float32Array | null;
  71007. readonly angularVelocity: Float32Array | null;
  71008. readonly linearAcceleration: Float32Array | null;
  71009. readonly linearVelocity: Float32Array | null;
  71010. readonly orientation: Float32Array | null;
  71011. readonly position: Float32Array | null;
  71012. readonly timestamp: number;
  71013. }
  71014. interface VRStageParameters {
  71015. sittingToStandingTransform?: Float32Array;
  71016. sizeX?: number;
  71017. sizeY?: number;
  71018. }
  71019. interface Navigator {
  71020. getVRDisplays(): Promise<VRDisplay[]>;
  71021. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  71022. }
  71023. interface Window {
  71024. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  71025. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  71026. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  71027. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71028. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71029. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  71030. }
  71031. interface Gamepad {
  71032. readonly displayId: number;
  71033. }
  71034. type XRSessionMode =
  71035. | "inline"
  71036. | "immersive-vr"
  71037. | "immersive-ar";
  71038. type XRReferenceSpaceType =
  71039. | "viewer"
  71040. | "local"
  71041. | "local-floor"
  71042. | "bounded-floor"
  71043. | "unbounded";
  71044. type XREnvironmentBlendMode =
  71045. | "opaque"
  71046. | "additive"
  71047. | "alpha-blend";
  71048. type XRVisibilityState =
  71049. | "visible"
  71050. | "visible-blurred"
  71051. | "hidden";
  71052. type XRHandedness =
  71053. | "none"
  71054. | "left"
  71055. | "right";
  71056. type XRTargetRayMode =
  71057. | "gaze"
  71058. | "tracked-pointer"
  71059. | "screen";
  71060. type XREye =
  71061. | "none"
  71062. | "left"
  71063. | "right";
  71064. type XREventType =
  71065. | "devicechange"
  71066. | "visibilitychange"
  71067. | "end"
  71068. | "inputsourceschange"
  71069. | "select"
  71070. | "selectstart"
  71071. | "selectend"
  71072. | "squeeze"
  71073. | "squeezestart"
  71074. | "squeezeend"
  71075. | "reset";
  71076. interface XRSpace extends EventTarget {
  71077. }
  71078. interface XRRenderState {
  71079. depthNear?: number;
  71080. depthFar?: number;
  71081. inlineVerticalFieldOfView?: number;
  71082. baseLayer?: XRWebGLLayer;
  71083. }
  71084. interface XRInputSource {
  71085. handedness: XRHandedness;
  71086. targetRayMode: XRTargetRayMode;
  71087. targetRaySpace: XRSpace;
  71088. gripSpace: XRSpace | undefined;
  71089. gamepad: Gamepad | undefined;
  71090. profiles: Array<string>;
  71091. }
  71092. interface XRSessionInit {
  71093. optionalFeatures?: XRReferenceSpaceType[];
  71094. requiredFeatures?: XRReferenceSpaceType[];
  71095. }
  71096. interface XRSession extends XRAnchorCreator {
  71097. addEventListener: Function;
  71098. removeEventListener: Function;
  71099. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71100. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71101. requestAnimationFrame: Function;
  71102. end(): Promise<void>;
  71103. renderState: XRRenderState;
  71104. inputSources: Array<XRInputSource>;
  71105. // hit test
  71106. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71107. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71108. // legacy AR hit test
  71109. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71110. // legacy plane detection
  71111. updateWorldTrackingState(options: {
  71112. planeDetectionState?: { enabled: boolean; }
  71113. }): void;
  71114. }
  71115. interface XRReferenceSpace extends XRSpace {
  71116. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71117. onreset: any;
  71118. }
  71119. type XRPlaneSet = Set<XRPlane>;
  71120. type XRAnchorSet = Set<XRAnchor>;
  71121. interface XRFrame {
  71122. session: XRSession;
  71123. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71124. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71125. // AR
  71126. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71127. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71128. // Anchors
  71129. trackedAnchors?: XRAnchorSet;
  71130. // Planes
  71131. worldInformation: {
  71132. detectedPlanes?: XRPlaneSet;
  71133. };
  71134. }
  71135. interface XRViewerPose extends XRPose {
  71136. views: Array<XRView>;
  71137. }
  71138. interface XRPose {
  71139. transform: XRRigidTransform;
  71140. emulatedPosition: boolean;
  71141. }
  71142. interface XRWebGLLayerOptions {
  71143. antialias?: boolean;
  71144. depth?: boolean;
  71145. stencil?: boolean;
  71146. alpha?: boolean;
  71147. multiview?: boolean;
  71148. framebufferScaleFactor?: number;
  71149. }
  71150. declare var XRWebGLLayer: {
  71151. prototype: XRWebGLLayer;
  71152. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71153. };
  71154. interface XRWebGLLayer {
  71155. framebuffer: WebGLFramebuffer;
  71156. framebufferWidth: number;
  71157. framebufferHeight: number;
  71158. getViewport: Function;
  71159. }
  71160. declare class XRRigidTransform {
  71161. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71162. position: DOMPointReadOnly;
  71163. orientation: DOMPointReadOnly;
  71164. matrix: Float32Array;
  71165. inverse: XRRigidTransform;
  71166. }
  71167. interface XRView {
  71168. eye: XREye;
  71169. projectionMatrix: Float32Array;
  71170. transform: XRRigidTransform;
  71171. }
  71172. interface XRInputSourceChangeEvent {
  71173. session: XRSession;
  71174. removed: Array<XRInputSource>;
  71175. added: Array<XRInputSource>;
  71176. }
  71177. interface XRInputSourceEvent extends Event {
  71178. readonly frame: XRFrame;
  71179. readonly inputSource: XRInputSource;
  71180. }
  71181. // Experimental(er) features
  71182. declare class XRRay {
  71183. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71184. origin: DOMPointReadOnly;
  71185. direction: DOMPointReadOnly;
  71186. matrix: Float32Array;
  71187. }
  71188. declare enum XRHitTestTrackableType {
  71189. "point",
  71190. "plane"
  71191. }
  71192. interface XRHitResult {
  71193. hitMatrix: Float32Array;
  71194. }
  71195. interface XRTransientInputHitTestResult {
  71196. readonly inputSource: XRInputSource;
  71197. readonly results: Array<XRHitTestResult>;
  71198. }
  71199. interface XRHitTestResult {
  71200. getPose(baseSpace: XRSpace): XRPose | undefined;
  71201. }
  71202. interface XRHitTestSource {
  71203. cancel(): void;
  71204. }
  71205. interface XRTransientInputHitTestSource {
  71206. cancel(): void;
  71207. }
  71208. interface XRHitTestOptionsInit {
  71209. space: XRSpace;
  71210. entityTypes?: Array<XRHitTestTrackableType>;
  71211. offsetRay?: XRRay;
  71212. }
  71213. interface XRTransientInputHitTestOptionsInit {
  71214. profile: string;
  71215. entityTypes?: Array<XRHitTestTrackableType>;
  71216. offsetRay?: XRRay;
  71217. }
  71218. interface XRAnchor {
  71219. // remove?
  71220. id?: string;
  71221. anchorSpace: XRSpace;
  71222. lastChangedTime: number;
  71223. detach(): void;
  71224. }
  71225. interface XRPlane extends XRAnchorCreator {
  71226. orientation: "Horizontal" | "Vertical";
  71227. planeSpace: XRSpace;
  71228. polygon: Array<DOMPointReadOnly>;
  71229. lastChangedTime: number;
  71230. }
  71231. interface XRAnchorCreator {
  71232. // AR Anchors
  71233. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71234. }
  71235. /**
  71236. * @ignore
  71237. */
  71238. declare module BABYLON.GLTF2.Exporter {
  71239. }
  71240. /**
  71241. * @ignore
  71242. */
  71243. declare module BABYLON.GLTF1 {
  71244. }
  71245. declare module BABYLON.GUI {
  71246. /**
  71247. * Class used to specific a value and its associated unit
  71248. */
  71249. export class ValueAndUnit {
  71250. /** defines the unit to store */
  71251. unit: number;
  71252. /** defines a boolean indicating if the value can be negative */
  71253. negativeValueAllowed: boolean;
  71254. private _value;
  71255. private _originalUnit;
  71256. /**
  71257. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71258. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71259. */
  71260. ignoreAdaptiveScaling: boolean;
  71261. /**
  71262. * Creates a new ValueAndUnit
  71263. * @param value defines the value to store
  71264. * @param unit defines the unit to store
  71265. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71266. */
  71267. constructor(value: number,
  71268. /** defines the unit to store */
  71269. unit?: number,
  71270. /** defines a boolean indicating if the value can be negative */
  71271. negativeValueAllowed?: boolean);
  71272. /** Gets a boolean indicating if the value is a percentage */
  71273. get isPercentage(): boolean;
  71274. /** Gets a boolean indicating if the value is store as pixel */
  71275. get isPixel(): boolean;
  71276. /** Gets direct internal value */
  71277. get internalValue(): number;
  71278. /**
  71279. * Gets value as pixel
  71280. * @param host defines the root host
  71281. * @param refValue defines the reference value for percentages
  71282. * @returns the value as pixel
  71283. */
  71284. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71285. /**
  71286. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71287. * @param value defines the value to store
  71288. * @param unit defines the unit to store
  71289. * @returns the current ValueAndUnit
  71290. */
  71291. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71292. /**
  71293. * Gets the value accordingly to its unit
  71294. * @param host defines the root host
  71295. * @returns the value
  71296. */
  71297. getValue(host: AdvancedDynamicTexture): number;
  71298. /**
  71299. * Gets a string representation of the value
  71300. * @param host defines the root host
  71301. * @param decimals defines an optional number of decimals to display
  71302. * @returns a string
  71303. */
  71304. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71305. /**
  71306. * Store a value parsed from a string
  71307. * @param source defines the source string
  71308. * @returns true if the value was successfully parsed
  71309. */
  71310. fromString(source: string | number): boolean;
  71311. private static _Regex;
  71312. private static _UNITMODE_PERCENTAGE;
  71313. private static _UNITMODE_PIXEL;
  71314. /** UNITMODE_PERCENTAGE */
  71315. static get UNITMODE_PERCENTAGE(): number;
  71316. /** UNITMODE_PIXEL */
  71317. static get UNITMODE_PIXEL(): number;
  71318. }
  71319. }
  71320. declare module BABYLON.GUI {
  71321. /**
  71322. * Define a style used by control to automatically setup properties based on a template.
  71323. * Only support font related properties so far
  71324. */
  71325. export class Style implements BABYLON.IDisposable {
  71326. private _fontFamily;
  71327. private _fontStyle;
  71328. private _fontWeight;
  71329. /** @hidden */
  71330. _host: AdvancedDynamicTexture;
  71331. /** @hidden */
  71332. _fontSize: ValueAndUnit;
  71333. /**
  71334. * BABYLON.Observable raised when the style values are changed
  71335. */
  71336. onChangedObservable: BABYLON.Observable<Style>;
  71337. /**
  71338. * Creates a new style object
  71339. * @param host defines the AdvancedDynamicTexture which hosts this style
  71340. */
  71341. constructor(host: AdvancedDynamicTexture);
  71342. /**
  71343. * Gets or sets the font size
  71344. */
  71345. get fontSize(): string | number;
  71346. set fontSize(value: string | number);
  71347. /**
  71348. * Gets or sets the font family
  71349. */
  71350. get fontFamily(): string;
  71351. set fontFamily(value: string);
  71352. /**
  71353. * Gets or sets the font style
  71354. */
  71355. get fontStyle(): string;
  71356. set fontStyle(value: string);
  71357. /** Gets or sets font weight */
  71358. get fontWeight(): string;
  71359. set fontWeight(value: string);
  71360. /** Dispose all associated resources */
  71361. dispose(): void;
  71362. }
  71363. }
  71364. declare module BABYLON.GUI {
  71365. /**
  71366. * Class used to transport BABYLON.Vector2 information for pointer events
  71367. */
  71368. export class Vector2WithInfo extends BABYLON.Vector2 {
  71369. /** defines the current mouse button index */
  71370. buttonIndex: number;
  71371. /**
  71372. * Creates a new Vector2WithInfo
  71373. * @param source defines the vector2 data to transport
  71374. * @param buttonIndex defines the current mouse button index
  71375. */
  71376. constructor(source: BABYLON.Vector2,
  71377. /** defines the current mouse button index */
  71378. buttonIndex?: number);
  71379. }
  71380. /** Class used to provide 2D matrix features */
  71381. export class Matrix2D {
  71382. /** Gets the internal array of 6 floats used to store matrix data */
  71383. m: Float32Array;
  71384. /**
  71385. * Creates a new matrix
  71386. * @param m00 defines value for (0, 0)
  71387. * @param m01 defines value for (0, 1)
  71388. * @param m10 defines value for (1, 0)
  71389. * @param m11 defines value for (1, 1)
  71390. * @param m20 defines value for (2, 0)
  71391. * @param m21 defines value for (2, 1)
  71392. */
  71393. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71394. /**
  71395. * Fills the matrix from direct values
  71396. * @param m00 defines value for (0, 0)
  71397. * @param m01 defines value for (0, 1)
  71398. * @param m10 defines value for (1, 0)
  71399. * @param m11 defines value for (1, 1)
  71400. * @param m20 defines value for (2, 0)
  71401. * @param m21 defines value for (2, 1)
  71402. * @returns the current modified matrix
  71403. */
  71404. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71405. /**
  71406. * Gets matrix determinant
  71407. * @returns the determinant
  71408. */
  71409. determinant(): number;
  71410. /**
  71411. * Inverses the matrix and stores it in a target matrix
  71412. * @param result defines the target matrix
  71413. * @returns the current matrix
  71414. */
  71415. invertToRef(result: Matrix2D): Matrix2D;
  71416. /**
  71417. * Multiplies the current matrix with another one
  71418. * @param other defines the second operand
  71419. * @param result defines the target matrix
  71420. * @returns the current matrix
  71421. */
  71422. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71423. /**
  71424. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71425. * @param x defines the x coordinate to transform
  71426. * @param y defines the x coordinate to transform
  71427. * @param result defines the target vector2
  71428. * @returns the current matrix
  71429. */
  71430. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71431. /**
  71432. * Creates an identity matrix
  71433. * @returns a new matrix
  71434. */
  71435. static Identity(): Matrix2D;
  71436. /**
  71437. * Creates a translation matrix and stores it in a target matrix
  71438. * @param x defines the x coordinate of the translation
  71439. * @param y defines the y coordinate of the translation
  71440. * @param result defines the target matrix
  71441. */
  71442. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71443. /**
  71444. * Creates a scaling matrix and stores it in a target matrix
  71445. * @param x defines the x coordinate of the scaling
  71446. * @param y defines the y coordinate of the scaling
  71447. * @param result defines the target matrix
  71448. */
  71449. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71450. /**
  71451. * Creates a rotation matrix and stores it in a target matrix
  71452. * @param angle defines the rotation angle
  71453. * @param result defines the target matrix
  71454. */
  71455. static RotationToRef(angle: number, result: Matrix2D): void;
  71456. private static _TempPreTranslationMatrix;
  71457. private static _TempPostTranslationMatrix;
  71458. private static _TempRotationMatrix;
  71459. private static _TempScalingMatrix;
  71460. private static _TempCompose0;
  71461. private static _TempCompose1;
  71462. private static _TempCompose2;
  71463. /**
  71464. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71465. * @param tx defines the x coordinate of the translation
  71466. * @param ty defines the y coordinate of the translation
  71467. * @param angle defines the rotation angle
  71468. * @param scaleX defines the x coordinate of the scaling
  71469. * @param scaleY defines the y coordinate of the scaling
  71470. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71471. * @param result defines the target matrix
  71472. */
  71473. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71474. }
  71475. }
  71476. declare module BABYLON.GUI {
  71477. /**
  71478. * Class used to store 2D control sizes
  71479. */
  71480. export class Measure {
  71481. /** defines left coordinate */
  71482. left: number;
  71483. /** defines top coordinate */
  71484. top: number;
  71485. /** defines width dimension */
  71486. width: number;
  71487. /** defines height dimension */
  71488. height: number;
  71489. /**
  71490. * Creates a new measure
  71491. * @param left defines left coordinate
  71492. * @param top defines top coordinate
  71493. * @param width defines width dimension
  71494. * @param height defines height dimension
  71495. */
  71496. constructor(
  71497. /** defines left coordinate */
  71498. left: number,
  71499. /** defines top coordinate */
  71500. top: number,
  71501. /** defines width dimension */
  71502. width: number,
  71503. /** defines height dimension */
  71504. height: number);
  71505. /**
  71506. * Copy from another measure
  71507. * @param other defines the other measure to copy from
  71508. */
  71509. copyFrom(other: Measure): void;
  71510. /**
  71511. * Copy from a group of 4 floats
  71512. * @param left defines left coordinate
  71513. * @param top defines top coordinate
  71514. * @param width defines width dimension
  71515. * @param height defines height dimension
  71516. */
  71517. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71518. /**
  71519. * Computes the axis aligned bounding box measure for two given measures
  71520. * @param a Input measure
  71521. * @param b Input measure
  71522. * @param result the resulting bounding measure
  71523. */
  71524. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71525. /**
  71526. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71527. * @param transform the matrix to transform the measure before computing the AABB
  71528. * @param result the resulting AABB
  71529. */
  71530. transformToRef(transform: Matrix2D, result: Measure): void;
  71531. /**
  71532. * Check equality between this measure and another one
  71533. * @param other defines the other measures
  71534. * @returns true if both measures are equals
  71535. */
  71536. isEqualsTo(other: Measure): boolean;
  71537. /**
  71538. * Creates an empty measure
  71539. * @returns a new measure
  71540. */
  71541. static Empty(): Measure;
  71542. }
  71543. }
  71544. declare module BABYLON.GUI {
  71545. /**
  71546. * Interface used to define a control that can receive focus
  71547. */
  71548. export interface IFocusableControl {
  71549. /**
  71550. * Function called when the control receives the focus
  71551. */
  71552. onFocus(): void;
  71553. /**
  71554. * Function called when the control loses the focus
  71555. */
  71556. onBlur(): void;
  71557. /**
  71558. * Function called to let the control handle keyboard events
  71559. * @param evt defines the current keyboard event
  71560. */
  71561. processKeyboard(evt: KeyboardEvent): void;
  71562. /**
  71563. * Function called to get the list of controls that should not steal the focus from this control
  71564. * @returns an array of controls
  71565. */
  71566. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71567. }
  71568. /**
  71569. * Class used to create texture to support 2D GUI elements
  71570. * @see http://doc.babylonjs.com/how_to/gui
  71571. */
  71572. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71573. private _isDirty;
  71574. private _renderObserver;
  71575. private _resizeObserver;
  71576. private _preKeyboardObserver;
  71577. private _pointerMoveObserver;
  71578. private _pointerObserver;
  71579. private _canvasPointerOutObserver;
  71580. private _background;
  71581. /** @hidden */
  71582. _rootContainer: Container;
  71583. /** @hidden */
  71584. _lastPickedControl: Control;
  71585. /** @hidden */
  71586. _lastControlOver: {
  71587. [pointerId: number]: Control;
  71588. };
  71589. /** @hidden */
  71590. _lastControlDown: {
  71591. [pointerId: number]: Control;
  71592. };
  71593. /** @hidden */
  71594. _capturingControl: {
  71595. [pointerId: number]: Control;
  71596. };
  71597. /** @hidden */
  71598. _shouldBlockPointer: boolean;
  71599. /** @hidden */
  71600. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71601. /** @hidden */
  71602. _linkedControls: Control[];
  71603. private _isFullscreen;
  71604. private _fullscreenViewport;
  71605. private _idealWidth;
  71606. private _idealHeight;
  71607. private _useSmallestIdeal;
  71608. private _renderAtIdealSize;
  71609. private _focusedControl;
  71610. private _blockNextFocusCheck;
  71611. private _renderScale;
  71612. private _rootElement;
  71613. private _cursorChanged;
  71614. private _defaultMousePointerId;
  71615. /** @hidden */
  71616. _numLayoutCalls: number;
  71617. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71618. get numLayoutCalls(): number;
  71619. /** @hidden */
  71620. _numRenderCalls: number;
  71621. /** Gets the number of render calls made the last time the ADT has been rendered */
  71622. get numRenderCalls(): number;
  71623. /**
  71624. * Define type to string to ensure compatibility across browsers
  71625. * Safari doesn't support DataTransfer constructor
  71626. */
  71627. private _clipboardData;
  71628. /**
  71629. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71630. */
  71631. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71632. /**
  71633. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71634. */
  71635. onControlPickedObservable: BABYLON.Observable<Control>;
  71636. /**
  71637. * BABYLON.Observable event triggered before layout is evaluated
  71638. */
  71639. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71640. /**
  71641. * BABYLON.Observable event triggered after the layout was evaluated
  71642. */
  71643. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71644. /**
  71645. * BABYLON.Observable event triggered before the texture is rendered
  71646. */
  71647. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71648. /**
  71649. * BABYLON.Observable event triggered after the texture was rendered
  71650. */
  71651. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71652. /**
  71653. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71654. */
  71655. premulAlpha: boolean;
  71656. /**
  71657. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71658. * Useful when you want more antialiasing
  71659. */
  71660. get renderScale(): number;
  71661. set renderScale(value: number);
  71662. /** Gets or sets the background color */
  71663. get background(): string;
  71664. set background(value: string);
  71665. /**
  71666. * Gets or sets the ideal width used to design controls.
  71667. * The GUI will then rescale everything accordingly
  71668. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71669. */
  71670. get idealWidth(): number;
  71671. set idealWidth(value: number);
  71672. /**
  71673. * Gets or sets the ideal height used to design controls.
  71674. * The GUI will then rescale everything accordingly
  71675. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71676. */
  71677. get idealHeight(): number;
  71678. set idealHeight(value: number);
  71679. /**
  71680. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71682. */
  71683. get useSmallestIdeal(): boolean;
  71684. set useSmallestIdeal(value: boolean);
  71685. /**
  71686. * Gets or sets a boolean indicating if adaptive scaling must be used
  71687. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71688. */
  71689. get renderAtIdealSize(): boolean;
  71690. set renderAtIdealSize(value: boolean);
  71691. /**
  71692. * Gets the ratio used when in "ideal mode"
  71693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71694. * */
  71695. get idealRatio(): number;
  71696. /**
  71697. * Gets the underlying layer used to render the texture when in fullscreen mode
  71698. */
  71699. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71700. /**
  71701. * Gets the root container control
  71702. */
  71703. get rootContainer(): Container;
  71704. /**
  71705. * Returns an array containing the root container.
  71706. * This is mostly used to let the Inspector introspects the ADT
  71707. * @returns an array containing the rootContainer
  71708. */
  71709. getChildren(): Array<Container>;
  71710. /**
  71711. * Will return all controls that are inside this texture
  71712. * @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
  71713. * @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
  71714. * @return all child controls
  71715. */
  71716. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71717. /**
  71718. * Gets or sets the current focused control
  71719. */
  71720. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71721. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71722. /**
  71723. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71724. */
  71725. get isForeground(): boolean;
  71726. set isForeground(value: boolean);
  71727. /**
  71728. * Gets or set information about clipboardData
  71729. */
  71730. get clipboardData(): string;
  71731. set clipboardData(value: string);
  71732. /**
  71733. * Creates a new AdvancedDynamicTexture
  71734. * @param name defines the name of the texture
  71735. * @param width defines the width of the texture
  71736. * @param height defines the height of the texture
  71737. * @param scene defines the hosting scene
  71738. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71739. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71740. */
  71741. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71742. /**
  71743. * Get the current class name of the texture useful for serialization or dynamic coding.
  71744. * @returns "AdvancedDynamicTexture"
  71745. */
  71746. getClassName(): string;
  71747. /**
  71748. * Function used to execute a function on all controls
  71749. * @param func defines the function to execute
  71750. * @param container defines the container where controls belong. If null the root container will be used
  71751. */
  71752. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71753. private _useInvalidateRectOptimization;
  71754. /**
  71755. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71756. */
  71757. get useInvalidateRectOptimization(): boolean;
  71758. set useInvalidateRectOptimization(value: boolean);
  71759. private _invalidatedRectangle;
  71760. /**
  71761. * Invalidates a rectangle area on the gui texture
  71762. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71763. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71764. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71765. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71766. */
  71767. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71768. /**
  71769. * Marks the texture as dirty forcing a complete update
  71770. */
  71771. markAsDirty(): void;
  71772. /**
  71773. * Helper function used to create a new style
  71774. * @returns a new style
  71775. * @see http://doc.babylonjs.com/how_to/gui#styles
  71776. */
  71777. createStyle(): Style;
  71778. /**
  71779. * Adds a new control to the root container
  71780. * @param control defines the control to add
  71781. * @returns the current texture
  71782. */
  71783. addControl(control: Control): AdvancedDynamicTexture;
  71784. /**
  71785. * Removes a control from the root container
  71786. * @param control defines the control to remove
  71787. * @returns the current texture
  71788. */
  71789. removeControl(control: Control): AdvancedDynamicTexture;
  71790. /**
  71791. * Release all resources
  71792. */
  71793. dispose(): void;
  71794. private _onResize;
  71795. /** @hidden */
  71796. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71797. /**
  71798. * Get screen coordinates for a vector3
  71799. * @param position defines the position to project
  71800. * @param worldMatrix defines the world matrix to use
  71801. * @returns the projected position
  71802. */
  71803. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71804. private _checkUpdate;
  71805. private _clearMeasure;
  71806. private _render;
  71807. /** @hidden */
  71808. _changeCursor(cursor: string): void;
  71809. /** @hidden */
  71810. _registerLastControlDown(control: Control, pointerId: number): void;
  71811. private _doPicking;
  71812. /** @hidden */
  71813. _cleanControlAfterRemovalFromList(list: {
  71814. [pointerId: number]: Control;
  71815. }, control: Control): void;
  71816. /** @hidden */
  71817. _cleanControlAfterRemoval(control: Control): void;
  71818. /** Attach to all scene events required to support pointer events */
  71819. attach(): void;
  71820. /** @hidden */
  71821. private onClipboardCopy;
  71822. /** @hidden */
  71823. private onClipboardCut;
  71824. /** @hidden */
  71825. private onClipboardPaste;
  71826. /**
  71827. * Register the clipboard Events onto the canvas
  71828. */
  71829. registerClipboardEvents(): void;
  71830. /**
  71831. * Unregister the clipboard Events from the canvas
  71832. */
  71833. unRegisterClipboardEvents(): void;
  71834. /**
  71835. * Connect the texture to a hosting mesh to enable interactions
  71836. * @param mesh defines the mesh to attach to
  71837. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71838. */
  71839. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71840. /**
  71841. * Move the focus to a specific control
  71842. * @param control defines the control which will receive the focus
  71843. */
  71844. moveFocusToControl(control: IFocusableControl): void;
  71845. private _manageFocus;
  71846. private _attachToOnPointerOut;
  71847. /**
  71848. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71849. * @param mesh defines the mesh which will receive the texture
  71850. * @param width defines the texture width (1024 by default)
  71851. * @param height defines the texture height (1024 by default)
  71852. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71853. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71854. * @returns a new AdvancedDynamicTexture
  71855. */
  71856. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71857. /**
  71858. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71859. * In this mode the texture will rely on a layer for its rendering.
  71860. * This allows it to be treated like any other layer.
  71861. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71862. * LayerMask is set through advancedTexture.layer.layerMask
  71863. * @param name defines name for the texture
  71864. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71865. * @param scene defines the hsoting scene
  71866. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71867. * @returns a new AdvancedDynamicTexture
  71868. */
  71869. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71870. }
  71871. }
  71872. declare module BABYLON.GUI {
  71873. /**
  71874. * Root class used for all 2D controls
  71875. * @see http://doc.babylonjs.com/how_to/gui#controls
  71876. */
  71877. export class Control {
  71878. /** defines the name of the control */
  71879. name?: string | undefined;
  71880. /**
  71881. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71882. */
  71883. static AllowAlphaInheritance: boolean;
  71884. private _alpha;
  71885. private _alphaSet;
  71886. private _zIndex;
  71887. /** @hidden */
  71888. _host: AdvancedDynamicTexture;
  71889. /** Gets or sets the control parent */
  71890. parent: BABYLON.Nullable<Container>;
  71891. /** @hidden */
  71892. _currentMeasure: Measure;
  71893. private _fontFamily;
  71894. private _fontStyle;
  71895. private _fontWeight;
  71896. private _fontSize;
  71897. private _font;
  71898. /** @hidden */
  71899. _width: ValueAndUnit;
  71900. /** @hidden */
  71901. _height: ValueAndUnit;
  71902. /** @hidden */
  71903. protected _fontOffset: {
  71904. ascent: number;
  71905. height: number;
  71906. descent: number;
  71907. };
  71908. private _color;
  71909. private _style;
  71910. private _styleObserver;
  71911. /** @hidden */
  71912. protected _horizontalAlignment: number;
  71913. /** @hidden */
  71914. protected _verticalAlignment: number;
  71915. /** @hidden */
  71916. protected _isDirty: boolean;
  71917. /** @hidden */
  71918. protected _wasDirty: boolean;
  71919. /** @hidden */
  71920. _tempParentMeasure: Measure;
  71921. /** @hidden */
  71922. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71923. /** @hidden */
  71924. protected _cachedParentMeasure: Measure;
  71925. private _paddingLeft;
  71926. private _paddingRight;
  71927. private _paddingTop;
  71928. private _paddingBottom;
  71929. /** @hidden */
  71930. _left: ValueAndUnit;
  71931. /** @hidden */
  71932. _top: ValueAndUnit;
  71933. private _scaleX;
  71934. private _scaleY;
  71935. private _rotation;
  71936. private _transformCenterX;
  71937. private _transformCenterY;
  71938. /** @hidden */
  71939. _transformMatrix: Matrix2D;
  71940. /** @hidden */
  71941. protected _invertTransformMatrix: Matrix2D;
  71942. /** @hidden */
  71943. protected _transformedPosition: BABYLON.Vector2;
  71944. private _isMatrixDirty;
  71945. private _cachedOffsetX;
  71946. private _cachedOffsetY;
  71947. private _isVisible;
  71948. private _isHighlighted;
  71949. /** @hidden */
  71950. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71951. private _fontSet;
  71952. private _dummyVector2;
  71953. private _downCount;
  71954. private _enterCount;
  71955. private _doNotRender;
  71956. private _downPointerIds;
  71957. protected _isEnabled: boolean;
  71958. protected _disabledColor: string;
  71959. protected _disabledColorItem: string;
  71960. /** @hidden */
  71961. protected _rebuildLayout: boolean;
  71962. /** @hidden */
  71963. _customData: any;
  71964. /** @hidden */
  71965. _isClipped: boolean;
  71966. /** @hidden */
  71967. _automaticSize: boolean;
  71968. /** @hidden */
  71969. _tag: any;
  71970. /**
  71971. * 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
  71972. */
  71973. uniqueId: number;
  71974. /**
  71975. * Gets or sets an object used to store user defined information for the node
  71976. */
  71977. metadata: any;
  71978. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71979. isHitTestVisible: boolean;
  71980. /** Gets or sets a boolean indicating if the control can block pointer events */
  71981. isPointerBlocker: boolean;
  71982. /** Gets or sets a boolean indicating if the control can be focusable */
  71983. isFocusInvisible: boolean;
  71984. /**
  71985. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71986. * 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
  71987. */
  71988. clipChildren: boolean;
  71989. /**
  71990. * Gets or sets a boolean indicating that control content must be clipped
  71991. * 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
  71992. */
  71993. clipContent: boolean;
  71994. /**
  71995. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71996. */
  71997. useBitmapCache: boolean;
  71998. private _cacheData;
  71999. private _shadowOffsetX;
  72000. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  72001. get shadowOffsetX(): number;
  72002. set shadowOffsetX(value: number);
  72003. private _shadowOffsetY;
  72004. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  72005. get shadowOffsetY(): number;
  72006. set shadowOffsetY(value: number);
  72007. private _shadowBlur;
  72008. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  72009. get shadowBlur(): number;
  72010. set shadowBlur(value: number);
  72011. private _shadowColor;
  72012. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  72013. get shadowColor(): string;
  72014. set shadowColor(value: string);
  72015. /** Gets or sets the cursor to use when the control is hovered */
  72016. hoverCursor: string;
  72017. /** @hidden */
  72018. protected _linkOffsetX: ValueAndUnit;
  72019. /** @hidden */
  72020. protected _linkOffsetY: ValueAndUnit;
  72021. /** Gets the control type name */
  72022. get typeName(): string;
  72023. /**
  72024. * Get the current class name of the control.
  72025. * @returns current class name
  72026. */
  72027. getClassName(): string;
  72028. /**
  72029. * An event triggered when pointer wheel is scrolled
  72030. */
  72031. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  72032. /**
  72033. * An event triggered when the pointer move over the control.
  72034. */
  72035. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  72036. /**
  72037. * An event triggered when the pointer move out of the control.
  72038. */
  72039. onPointerOutObservable: BABYLON.Observable<Control>;
  72040. /**
  72041. * An event triggered when the pointer taps the control
  72042. */
  72043. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  72044. /**
  72045. * An event triggered when pointer up
  72046. */
  72047. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  72048. /**
  72049. * An event triggered when a control is clicked on
  72050. */
  72051. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  72052. /**
  72053. * An event triggered when pointer enters the control
  72054. */
  72055. onPointerEnterObservable: BABYLON.Observable<Control>;
  72056. /**
  72057. * An event triggered when the control is marked as dirty
  72058. */
  72059. onDirtyObservable: BABYLON.Observable<Control>;
  72060. /**
  72061. * An event triggered before drawing the control
  72062. */
  72063. onBeforeDrawObservable: BABYLON.Observable<Control>;
  72064. /**
  72065. * An event triggered after the control was drawn
  72066. */
  72067. onAfterDrawObservable: BABYLON.Observable<Control>;
  72068. /**
  72069. * Get the hosting AdvancedDynamicTexture
  72070. */
  72071. get host(): AdvancedDynamicTexture;
  72072. /** Gets or set information about font offsets (used to render and align text) */
  72073. get fontOffset(): {
  72074. ascent: number;
  72075. height: number;
  72076. descent: number;
  72077. };
  72078. set fontOffset(offset: {
  72079. ascent: number;
  72080. height: number;
  72081. descent: number;
  72082. });
  72083. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72084. get alpha(): number;
  72085. set alpha(value: number);
  72086. /**
  72087. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72088. */
  72089. get isHighlighted(): boolean;
  72090. set isHighlighted(value: boolean);
  72091. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72092. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72093. */
  72094. get scaleX(): number;
  72095. set scaleX(value: number);
  72096. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72097. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72098. */
  72099. get scaleY(): number;
  72100. set scaleY(value: number);
  72101. /** Gets or sets the rotation angle (0 by default)
  72102. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72103. */
  72104. get rotation(): number;
  72105. set rotation(value: number);
  72106. /** Gets or sets the transformation center on Y axis (0 by default)
  72107. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72108. */
  72109. get transformCenterY(): number;
  72110. set transformCenterY(value: number);
  72111. /** Gets or sets the transformation center on X axis (0 by default)
  72112. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72113. */
  72114. get transformCenterX(): number;
  72115. set transformCenterX(value: number);
  72116. /**
  72117. * Gets or sets the horizontal alignment
  72118. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72119. */
  72120. get horizontalAlignment(): number;
  72121. set horizontalAlignment(value: number);
  72122. /**
  72123. * Gets or sets the vertical alignment
  72124. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72125. */
  72126. get verticalAlignment(): number;
  72127. set verticalAlignment(value: number);
  72128. /**
  72129. * Gets or sets control width
  72130. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72131. */
  72132. get width(): string | number;
  72133. set width(value: string | number);
  72134. /**
  72135. * Gets or sets the control width in pixel
  72136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72137. */
  72138. get widthInPixels(): number;
  72139. set widthInPixels(value: number);
  72140. /**
  72141. * Gets or sets control height
  72142. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72143. */
  72144. get height(): string | number;
  72145. set height(value: string | number);
  72146. /**
  72147. * Gets or sets control height in pixel
  72148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72149. */
  72150. get heightInPixels(): number;
  72151. set heightInPixels(value: number);
  72152. /** Gets or set font family */
  72153. get fontFamily(): string;
  72154. set fontFamily(value: string);
  72155. /** Gets or sets font style */
  72156. get fontStyle(): string;
  72157. set fontStyle(value: string);
  72158. /** Gets or sets font weight */
  72159. get fontWeight(): string;
  72160. set fontWeight(value: string);
  72161. /**
  72162. * Gets or sets style
  72163. * @see http://doc.babylonjs.com/how_to/gui#styles
  72164. */
  72165. get style(): BABYLON.Nullable<Style>;
  72166. set style(value: BABYLON.Nullable<Style>);
  72167. /** @hidden */
  72168. get _isFontSizeInPercentage(): boolean;
  72169. /** Gets or sets font size in pixels */
  72170. get fontSizeInPixels(): number;
  72171. set fontSizeInPixels(value: number);
  72172. /** Gets or sets font size */
  72173. get fontSize(): string | number;
  72174. set fontSize(value: string | number);
  72175. /** Gets or sets foreground color */
  72176. get color(): string;
  72177. set color(value: string);
  72178. /** Gets or sets z index which is used to reorder controls on the z axis */
  72179. get zIndex(): number;
  72180. set zIndex(value: number);
  72181. /** Gets or sets a boolean indicating if the control can be rendered */
  72182. get notRenderable(): boolean;
  72183. set notRenderable(value: boolean);
  72184. /** Gets or sets a boolean indicating if the control is visible */
  72185. get isVisible(): boolean;
  72186. set isVisible(value: boolean);
  72187. /** Gets a boolean indicating that the control needs to update its rendering */
  72188. get isDirty(): boolean;
  72189. /**
  72190. * Gets the current linked mesh (or null if none)
  72191. */
  72192. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72193. /**
  72194. * Gets or sets a value indicating the padding to use on the left of the control
  72195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72196. */
  72197. get paddingLeft(): string | number;
  72198. set paddingLeft(value: string | number);
  72199. /**
  72200. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72201. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72202. */
  72203. get paddingLeftInPixels(): number;
  72204. set paddingLeftInPixels(value: number);
  72205. /**
  72206. * Gets or sets a value indicating the padding to use on the right of the control
  72207. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72208. */
  72209. get paddingRight(): string | number;
  72210. set paddingRight(value: string | number);
  72211. /**
  72212. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72213. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72214. */
  72215. get paddingRightInPixels(): number;
  72216. set paddingRightInPixels(value: number);
  72217. /**
  72218. * Gets or sets a value indicating the padding to use on the top of the control
  72219. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72220. */
  72221. get paddingTop(): string | number;
  72222. set paddingTop(value: string | number);
  72223. /**
  72224. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72225. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72226. */
  72227. get paddingTopInPixels(): number;
  72228. set paddingTopInPixels(value: number);
  72229. /**
  72230. * Gets or sets a value indicating the padding to use on the bottom of the control
  72231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72232. */
  72233. get paddingBottom(): string | number;
  72234. set paddingBottom(value: string | number);
  72235. /**
  72236. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72237. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72238. */
  72239. get paddingBottomInPixels(): number;
  72240. set paddingBottomInPixels(value: number);
  72241. /**
  72242. * Gets or sets a value indicating the left coordinate of the control
  72243. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72244. */
  72245. get left(): string | number;
  72246. set left(value: string | number);
  72247. /**
  72248. * Gets or sets a value indicating the left coordinate in pixels of the control
  72249. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72250. */
  72251. get leftInPixels(): number;
  72252. set leftInPixels(value: number);
  72253. /**
  72254. * Gets or sets a value indicating the top coordinate of the control
  72255. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72256. */
  72257. get top(): string | number;
  72258. set top(value: string | number);
  72259. /**
  72260. * Gets or sets a value indicating the top coordinate in pixels of the control
  72261. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72262. */
  72263. get topInPixels(): number;
  72264. set topInPixels(value: number);
  72265. /**
  72266. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72267. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72268. */
  72269. get linkOffsetX(): string | number;
  72270. set linkOffsetX(value: string | number);
  72271. /**
  72272. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72273. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72274. */
  72275. get linkOffsetXInPixels(): number;
  72276. set linkOffsetXInPixels(value: number);
  72277. /**
  72278. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72279. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72280. */
  72281. get linkOffsetY(): string | number;
  72282. set linkOffsetY(value: string | number);
  72283. /**
  72284. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72285. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72286. */
  72287. get linkOffsetYInPixels(): number;
  72288. set linkOffsetYInPixels(value: number);
  72289. /** Gets the center coordinate on X axis */
  72290. get centerX(): number;
  72291. /** Gets the center coordinate on Y axis */
  72292. get centerY(): number;
  72293. /** Gets or sets if control is Enabled*/
  72294. get isEnabled(): boolean;
  72295. set isEnabled(value: boolean);
  72296. /** Gets or sets background color of control if it's disabled*/
  72297. get disabledColor(): string;
  72298. set disabledColor(value: string);
  72299. /** Gets or sets front color of control if it's disabled*/
  72300. get disabledColorItem(): string;
  72301. set disabledColorItem(value: string);
  72302. /**
  72303. * Creates a new control
  72304. * @param name defines the name of the control
  72305. */
  72306. constructor(
  72307. /** defines the name of the control */
  72308. name?: string | undefined);
  72309. /** @hidden */
  72310. protected _getTypeName(): string;
  72311. /**
  72312. * Gets the first ascendant in the hierarchy of the given type
  72313. * @param className defines the required type
  72314. * @returns the ascendant or null if not found
  72315. */
  72316. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72317. /** @hidden */
  72318. _resetFontCache(): void;
  72319. /**
  72320. * Determines if a container is an ascendant of the current control
  72321. * @param container defines the container to look for
  72322. * @returns true if the container is one of the ascendant of the control
  72323. */
  72324. isAscendant(container: Control): boolean;
  72325. /**
  72326. * Gets coordinates in local control space
  72327. * @param globalCoordinates defines the coordinates to transform
  72328. * @returns the new coordinates in local space
  72329. */
  72330. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72331. /**
  72332. * Gets coordinates in local control space
  72333. * @param globalCoordinates defines the coordinates to transform
  72334. * @param result defines the target vector2 where to store the result
  72335. * @returns the current control
  72336. */
  72337. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72338. /**
  72339. * Gets coordinates in parent local control space
  72340. * @param globalCoordinates defines the coordinates to transform
  72341. * @returns the new coordinates in parent local space
  72342. */
  72343. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72344. /**
  72345. * Move the current control to a vector3 position projected onto the screen.
  72346. * @param position defines the target position
  72347. * @param scene defines the hosting scene
  72348. */
  72349. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72350. /**
  72351. * Will store all controls that have this control as ascendant in a given array
  72352. * @param results defines the array where to store the descendants
  72353. * @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
  72354. * @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
  72355. */
  72356. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72357. /**
  72358. * Will return all controls that have this control as ascendant
  72359. * @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
  72360. * @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
  72361. * @return all child controls
  72362. */
  72363. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72364. /**
  72365. * Link current control with a target mesh
  72366. * @param mesh defines the mesh to link with
  72367. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72368. */
  72369. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72370. /** @hidden */
  72371. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72372. /** @hidden */
  72373. _offsetLeft(offset: number): void;
  72374. /** @hidden */
  72375. _offsetTop(offset: number): void;
  72376. /** @hidden */
  72377. _markMatrixAsDirty(): void;
  72378. /** @hidden */
  72379. _flagDescendantsAsMatrixDirty(): void;
  72380. /** @hidden */
  72381. _intersectsRect(rect: Measure): boolean;
  72382. /** @hidden */
  72383. protected invalidateRect(): void;
  72384. /** @hidden */
  72385. _markAsDirty(force?: boolean): void;
  72386. /** @hidden */
  72387. _markAllAsDirty(): void;
  72388. /** @hidden */
  72389. _link(host: AdvancedDynamicTexture): void;
  72390. /** @hidden */
  72391. protected _transform(context?: CanvasRenderingContext2D): void;
  72392. /** @hidden */
  72393. _renderHighlight(context: CanvasRenderingContext2D): void;
  72394. /** @hidden */
  72395. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72396. /** @hidden */
  72397. protected _applyStates(context: CanvasRenderingContext2D): void;
  72398. /** @hidden */
  72399. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72400. /** @hidden */
  72401. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72402. protected _evaluateClippingState(parentMeasure: Measure): void;
  72403. /** @hidden */
  72404. _measure(): void;
  72405. /** @hidden */
  72406. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72407. /** @hidden */
  72408. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72409. /** @hidden */
  72410. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72411. /** @hidden */
  72412. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72413. private static _ClipMeasure;
  72414. private _tmpMeasureA;
  72415. private _clip;
  72416. /** @hidden */
  72417. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72418. /** @hidden */
  72419. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72420. /**
  72421. * Tests if a given coordinates belong to the current control
  72422. * @param x defines x coordinate to test
  72423. * @param y defines y coordinate to test
  72424. * @returns true if the coordinates are inside the control
  72425. */
  72426. contains(x: number, y: number): boolean;
  72427. /** @hidden */
  72428. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72429. /** @hidden */
  72430. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72431. /** @hidden */
  72432. _onPointerEnter(target: Control): boolean;
  72433. /** @hidden */
  72434. _onPointerOut(target: Control, force?: boolean): void;
  72435. /** @hidden */
  72436. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72437. /** @hidden */
  72438. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72439. /** @hidden */
  72440. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72441. /** @hidden */
  72442. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72443. /** @hidden */
  72444. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72445. private _prepareFont;
  72446. /** Releases associated resources */
  72447. dispose(): void;
  72448. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72449. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72450. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72451. private static _VERTICAL_ALIGNMENT_TOP;
  72452. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72453. private static _VERTICAL_ALIGNMENT_CENTER;
  72454. /** HORIZONTAL_ALIGNMENT_LEFT */
  72455. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72456. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72457. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72458. /** HORIZONTAL_ALIGNMENT_CENTER */
  72459. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72460. /** VERTICAL_ALIGNMENT_TOP */
  72461. static get VERTICAL_ALIGNMENT_TOP(): number;
  72462. /** VERTICAL_ALIGNMENT_BOTTOM */
  72463. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72464. /** VERTICAL_ALIGNMENT_CENTER */
  72465. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72466. private static _FontHeightSizes;
  72467. /** @hidden */
  72468. static _GetFontOffset(font: string): {
  72469. ascent: number;
  72470. height: number;
  72471. descent: number;
  72472. };
  72473. /**
  72474. * Creates a stack panel that can be used to render headers
  72475. * @param control defines the control to associate with the header
  72476. * @param text defines the text of the header
  72477. * @param size defines the size of the header
  72478. * @param options defines options used to configure the header
  72479. * @returns a new StackPanel
  72480. * @ignore
  72481. * @hidden
  72482. */
  72483. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72484. isHorizontal: boolean;
  72485. controlFirst: boolean;
  72486. }) => any;
  72487. /** @hidden */
  72488. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72489. }
  72490. }
  72491. declare module BABYLON.GUI {
  72492. /**
  72493. * Root class for 2D containers
  72494. * @see http://doc.babylonjs.com/how_to/gui#containers
  72495. */
  72496. export class Container extends Control {
  72497. name?: string | undefined;
  72498. /** @hidden */
  72499. _children: Control[];
  72500. /** @hidden */
  72501. protected _measureForChildren: Measure;
  72502. /** @hidden */
  72503. protected _background: string;
  72504. /** @hidden */
  72505. protected _adaptWidthToChildren: boolean;
  72506. /** @hidden */
  72507. protected _adaptHeightToChildren: boolean;
  72508. /**
  72509. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72510. */
  72511. logLayoutCycleErrors: boolean;
  72512. /**
  72513. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72514. */
  72515. maxLayoutCycle: number;
  72516. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72517. get adaptHeightToChildren(): boolean;
  72518. set adaptHeightToChildren(value: boolean);
  72519. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72520. get adaptWidthToChildren(): boolean;
  72521. set adaptWidthToChildren(value: boolean);
  72522. /** Gets or sets background color */
  72523. get background(): string;
  72524. set background(value: string);
  72525. /** Gets the list of children */
  72526. get children(): Control[];
  72527. /**
  72528. * Creates a new Container
  72529. * @param name defines the name of the container
  72530. */
  72531. constructor(name?: string | undefined);
  72532. protected _getTypeName(): string;
  72533. _flagDescendantsAsMatrixDirty(): void;
  72534. /**
  72535. * Gets a child using its name
  72536. * @param name defines the child name to look for
  72537. * @returns the child control if found
  72538. */
  72539. getChildByName(name: string): BABYLON.Nullable<Control>;
  72540. /**
  72541. * Gets a child using its type and its name
  72542. * @param name defines the child name to look for
  72543. * @param type defines the child type to look for
  72544. * @returns the child control if found
  72545. */
  72546. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72547. /**
  72548. * Search for a specific control in children
  72549. * @param control defines the control to look for
  72550. * @returns true if the control is in child list
  72551. */
  72552. containsControl(control: Control): boolean;
  72553. /**
  72554. * Adds a new control to the current container
  72555. * @param control defines the control to add
  72556. * @returns the current container
  72557. */
  72558. addControl(control: BABYLON.Nullable<Control>): Container;
  72559. /**
  72560. * Removes all controls from the current container
  72561. * @returns the current container
  72562. */
  72563. clearControls(): Container;
  72564. /**
  72565. * Removes a control from the current container
  72566. * @param control defines the control to remove
  72567. * @returns the current container
  72568. */
  72569. removeControl(control: Control): Container;
  72570. /** @hidden */
  72571. _reOrderControl(control: Control): void;
  72572. /** @hidden */
  72573. _offsetLeft(offset: number): void;
  72574. /** @hidden */
  72575. _offsetTop(offset: number): void;
  72576. /** @hidden */
  72577. _markAllAsDirty(): void;
  72578. /** @hidden */
  72579. protected _localDraw(context: CanvasRenderingContext2D): void;
  72580. /** @hidden */
  72581. _link(host: AdvancedDynamicTexture): void;
  72582. /** @hidden */
  72583. protected _beforeLayout(): void;
  72584. /** @hidden */
  72585. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72586. /** @hidden */
  72587. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72588. protected _postMeasure(): void;
  72589. /** @hidden */
  72590. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72591. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72592. /** @hidden */
  72593. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72594. /** @hidden */
  72595. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72596. /** Releases associated resources */
  72597. dispose(): void;
  72598. }
  72599. }
  72600. declare module BABYLON.GUI {
  72601. /** Class used to create rectangle container */
  72602. export class Rectangle extends Container {
  72603. name?: string | undefined;
  72604. private _thickness;
  72605. private _cornerRadius;
  72606. /** Gets or sets border thickness */
  72607. get thickness(): number;
  72608. set thickness(value: number);
  72609. /** Gets or sets the corner radius angle */
  72610. get cornerRadius(): number;
  72611. set cornerRadius(value: number);
  72612. /**
  72613. * Creates a new Rectangle
  72614. * @param name defines the control name
  72615. */
  72616. constructor(name?: string | undefined);
  72617. protected _getTypeName(): string;
  72618. protected _localDraw(context: CanvasRenderingContext2D): void;
  72619. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72620. private _drawRoundedRect;
  72621. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72622. }
  72623. }
  72624. declare module BABYLON.GUI {
  72625. /**
  72626. * Enum that determines the text-wrapping mode to use.
  72627. */
  72628. export enum TextWrapping {
  72629. /**
  72630. * Clip the text when it's larger than Control.width; this is the default mode.
  72631. */
  72632. Clip = 0,
  72633. /**
  72634. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72635. */
  72636. WordWrap = 1,
  72637. /**
  72638. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72639. */
  72640. Ellipsis = 2
  72641. }
  72642. /**
  72643. * Class used to create text block control
  72644. */
  72645. export class TextBlock extends Control {
  72646. /**
  72647. * Defines the name of the control
  72648. */
  72649. name?: string | undefined;
  72650. private _text;
  72651. private _textWrapping;
  72652. private _textHorizontalAlignment;
  72653. private _textVerticalAlignment;
  72654. private _lines;
  72655. private _resizeToFit;
  72656. private _lineSpacing;
  72657. private _outlineWidth;
  72658. private _outlineColor;
  72659. /**
  72660. * An event triggered after the text is changed
  72661. */
  72662. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72663. /**
  72664. * An event triggered after the text was broken up into lines
  72665. */
  72666. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72667. /**
  72668. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72669. */
  72670. get lines(): any[];
  72671. /**
  72672. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72673. */
  72674. get resizeToFit(): boolean;
  72675. /**
  72676. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72677. */
  72678. set resizeToFit(value: boolean);
  72679. /**
  72680. * Gets or sets a boolean indicating if text must be wrapped
  72681. */
  72682. get textWrapping(): TextWrapping | boolean;
  72683. /**
  72684. * Gets or sets a boolean indicating if text must be wrapped
  72685. */
  72686. set textWrapping(value: TextWrapping | boolean);
  72687. /**
  72688. * Gets or sets text to display
  72689. */
  72690. get text(): string;
  72691. /**
  72692. * Gets or sets text to display
  72693. */
  72694. set text(value: string);
  72695. /**
  72696. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72697. */
  72698. get textHorizontalAlignment(): number;
  72699. /**
  72700. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72701. */
  72702. set textHorizontalAlignment(value: number);
  72703. /**
  72704. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72705. */
  72706. get textVerticalAlignment(): number;
  72707. /**
  72708. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72709. */
  72710. set textVerticalAlignment(value: number);
  72711. /**
  72712. * Gets or sets line spacing value
  72713. */
  72714. set lineSpacing(value: string | number);
  72715. /**
  72716. * Gets or sets line spacing value
  72717. */
  72718. get lineSpacing(): string | number;
  72719. /**
  72720. * Gets or sets outlineWidth of the text to display
  72721. */
  72722. get outlineWidth(): number;
  72723. /**
  72724. * Gets or sets outlineWidth of the text to display
  72725. */
  72726. set outlineWidth(value: number);
  72727. /**
  72728. * Gets or sets outlineColor of the text to display
  72729. */
  72730. get outlineColor(): string;
  72731. /**
  72732. * Gets or sets outlineColor of the text to display
  72733. */
  72734. set outlineColor(value: string);
  72735. /**
  72736. * Creates a new TextBlock object
  72737. * @param name defines the name of the control
  72738. * @param text defines the text to display (emptry string by default)
  72739. */
  72740. constructor(
  72741. /**
  72742. * Defines the name of the control
  72743. */
  72744. name?: string | undefined, text?: string);
  72745. protected _getTypeName(): string;
  72746. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72747. private _drawText;
  72748. /** @hidden */
  72749. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72750. protected _applyStates(context: CanvasRenderingContext2D): void;
  72751. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72752. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72753. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72754. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72755. protected _renderLines(context: CanvasRenderingContext2D): void;
  72756. /**
  72757. * Given a width constraint applied on the text block, find the expected height
  72758. * @returns expected height
  72759. */
  72760. computeExpectedHeight(): number;
  72761. dispose(): void;
  72762. }
  72763. }
  72764. declare module BABYLON.GUI {
  72765. /**
  72766. * Class used to create 2D images
  72767. */
  72768. export class Image extends Control {
  72769. name?: string | undefined;
  72770. private _workingCanvas;
  72771. private _domImage;
  72772. private _imageWidth;
  72773. private _imageHeight;
  72774. private _loaded;
  72775. private _stretch;
  72776. private _source;
  72777. private _autoScale;
  72778. private _sourceLeft;
  72779. private _sourceTop;
  72780. private _sourceWidth;
  72781. private _sourceHeight;
  72782. private _svgAttributesComputationCompleted;
  72783. private _isSVG;
  72784. private _cellWidth;
  72785. private _cellHeight;
  72786. private _cellId;
  72787. private _populateNinePatchSlicesFromImage;
  72788. private _sliceLeft;
  72789. private _sliceRight;
  72790. private _sliceTop;
  72791. private _sliceBottom;
  72792. private _detectPointerOnOpaqueOnly;
  72793. /**
  72794. * BABYLON.Observable notified when the content is loaded
  72795. */
  72796. onImageLoadedObservable: BABYLON.Observable<Image>;
  72797. /**
  72798. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72799. */
  72800. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72801. /**
  72802. * Gets a boolean indicating that the content is loaded
  72803. */
  72804. get isLoaded(): boolean;
  72805. /**
  72806. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72807. */
  72808. get populateNinePatchSlicesFromImage(): boolean;
  72809. set populateNinePatchSlicesFromImage(value: boolean);
  72810. /**
  72811. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72812. * Beware using this as this will comsume more memory as the image has to be stored twice
  72813. */
  72814. get detectPointerOnOpaqueOnly(): boolean;
  72815. set detectPointerOnOpaqueOnly(value: boolean);
  72816. /**
  72817. * Gets or sets the left value for slicing (9-patch)
  72818. */
  72819. get sliceLeft(): number;
  72820. set sliceLeft(value: number);
  72821. /**
  72822. * Gets or sets the right value for slicing (9-patch)
  72823. */
  72824. get sliceRight(): number;
  72825. set sliceRight(value: number);
  72826. /**
  72827. * Gets or sets the top value for slicing (9-patch)
  72828. */
  72829. get sliceTop(): number;
  72830. set sliceTop(value: number);
  72831. /**
  72832. * Gets or sets the bottom value for slicing (9-patch)
  72833. */
  72834. get sliceBottom(): number;
  72835. set sliceBottom(value: number);
  72836. /**
  72837. * Gets or sets the left coordinate in the source image
  72838. */
  72839. get sourceLeft(): number;
  72840. set sourceLeft(value: number);
  72841. /**
  72842. * Gets or sets the top coordinate in the source image
  72843. */
  72844. get sourceTop(): number;
  72845. set sourceTop(value: number);
  72846. /**
  72847. * Gets or sets the width to capture in the source image
  72848. */
  72849. get sourceWidth(): number;
  72850. set sourceWidth(value: number);
  72851. /**
  72852. * Gets or sets the height to capture in the source image
  72853. */
  72854. get sourceHeight(): number;
  72855. set sourceHeight(value: number);
  72856. /** Indicates if the format of the image is SVG */
  72857. get isSVG(): boolean;
  72858. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72859. get svgAttributesComputationCompleted(): boolean;
  72860. /**
  72861. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72862. * @see http://doc.babylonjs.com/how_to/gui#image
  72863. */
  72864. get autoScale(): boolean;
  72865. set autoScale(value: boolean);
  72866. /** Gets or sets the streching mode used by the image */
  72867. get stretch(): number;
  72868. set stretch(value: number);
  72869. /** @hidden */
  72870. _rotate90(n: number, preserveProperties?: boolean): Image;
  72871. private _handleRotationForSVGImage;
  72872. private _rotate90SourceProperties;
  72873. /**
  72874. * Gets or sets the internal DOM image used to render the control
  72875. */
  72876. set domImage(value: HTMLImageElement);
  72877. get domImage(): HTMLImageElement;
  72878. private _onImageLoaded;
  72879. private _extractNinePatchSliceDataFromImage;
  72880. /**
  72881. * Gets or sets image source url
  72882. */
  72883. set source(value: BABYLON.Nullable<string>);
  72884. /**
  72885. * Checks for svg document with icon id present
  72886. */
  72887. private _svgCheck;
  72888. /**
  72889. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72890. * given external svg file and icon id
  72891. */
  72892. private _getSVGAttribs;
  72893. /**
  72894. * Gets or sets the cell width to use when animation sheet is enabled
  72895. * @see http://doc.babylonjs.com/how_to/gui#image
  72896. */
  72897. get cellWidth(): number;
  72898. set cellWidth(value: number);
  72899. /**
  72900. * Gets or sets the cell height to use when animation sheet is enabled
  72901. * @see http://doc.babylonjs.com/how_to/gui#image
  72902. */
  72903. get cellHeight(): number;
  72904. set cellHeight(value: number);
  72905. /**
  72906. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72907. * @see http://doc.babylonjs.com/how_to/gui#image
  72908. */
  72909. get cellId(): number;
  72910. set cellId(value: number);
  72911. /**
  72912. * Creates a new Image
  72913. * @param name defines the control name
  72914. * @param url defines the image url
  72915. */
  72916. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72917. /**
  72918. * Tests if a given coordinates belong to the current control
  72919. * @param x defines x coordinate to test
  72920. * @param y defines y coordinate to test
  72921. * @returns true if the coordinates are inside the control
  72922. */
  72923. contains(x: number, y: number): boolean;
  72924. protected _getTypeName(): string;
  72925. /** Force the control to synchronize with its content */
  72926. synchronizeSizeWithContent(): void;
  72927. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72928. private _prepareWorkingCanvasForOpaqueDetection;
  72929. private _drawImage;
  72930. _draw(context: CanvasRenderingContext2D): void;
  72931. private _renderCornerPatch;
  72932. private _renderNinePatch;
  72933. dispose(): void;
  72934. /** STRETCH_NONE */
  72935. static readonly STRETCH_NONE: number;
  72936. /** STRETCH_FILL */
  72937. static readonly STRETCH_FILL: number;
  72938. /** STRETCH_UNIFORM */
  72939. static readonly STRETCH_UNIFORM: number;
  72940. /** STRETCH_EXTEND */
  72941. static readonly STRETCH_EXTEND: number;
  72942. /** NINE_PATCH */
  72943. static readonly STRETCH_NINE_PATCH: number;
  72944. }
  72945. }
  72946. declare module BABYLON.GUI {
  72947. /**
  72948. * Class used to create 2D buttons
  72949. */
  72950. export class Button extends Rectangle {
  72951. name?: string | undefined;
  72952. /**
  72953. * Function called to generate a pointer enter animation
  72954. */
  72955. pointerEnterAnimation: () => void;
  72956. /**
  72957. * Function called to generate a pointer out animation
  72958. */
  72959. pointerOutAnimation: () => void;
  72960. /**
  72961. * Function called to generate a pointer down animation
  72962. */
  72963. pointerDownAnimation: () => void;
  72964. /**
  72965. * Function called to generate a pointer up animation
  72966. */
  72967. pointerUpAnimation: () => void;
  72968. /**
  72969. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72970. */
  72971. delegatePickingToChildren: boolean;
  72972. private _image;
  72973. /**
  72974. * Returns the image part of the button (if any)
  72975. */
  72976. get image(): BABYLON.Nullable<Image>;
  72977. private _textBlock;
  72978. /**
  72979. * Returns the image part of the button (if any)
  72980. */
  72981. get textBlock(): BABYLON.Nullable<TextBlock>;
  72982. /**
  72983. * Creates a new Button
  72984. * @param name defines the name of the button
  72985. */
  72986. constructor(name?: string | undefined);
  72987. protected _getTypeName(): string;
  72988. /** @hidden */
  72989. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72990. /** @hidden */
  72991. _onPointerEnter(target: Control): boolean;
  72992. /** @hidden */
  72993. _onPointerOut(target: Control, force?: boolean): void;
  72994. /** @hidden */
  72995. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72996. /** @hidden */
  72997. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72998. /**
  72999. * Creates a new button made with an image and a text
  73000. * @param name defines the name of the button
  73001. * @param text defines the text of the button
  73002. * @param imageUrl defines the url of the image
  73003. * @returns a new Button
  73004. */
  73005. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  73006. /**
  73007. * Creates a new button made with an image
  73008. * @param name defines the name of the button
  73009. * @param imageUrl defines the url of the image
  73010. * @returns a new Button
  73011. */
  73012. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  73013. /**
  73014. * Creates a new button made with a text
  73015. * @param name defines the name of the button
  73016. * @param text defines the text of the button
  73017. * @returns a new Button
  73018. */
  73019. static CreateSimpleButton(name: string, text: string): Button;
  73020. /**
  73021. * Creates a new button made with an image and a centered text
  73022. * @param name defines the name of the button
  73023. * @param text defines the text of the button
  73024. * @param imageUrl defines the url of the image
  73025. * @returns a new Button
  73026. */
  73027. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  73028. }
  73029. }
  73030. declare module BABYLON.GUI {
  73031. /**
  73032. * Class used to create a 2D stack panel container
  73033. */
  73034. export class StackPanel extends Container {
  73035. name?: string | undefined;
  73036. private _isVertical;
  73037. private _manualWidth;
  73038. private _manualHeight;
  73039. private _doNotTrackManualChanges;
  73040. /**
  73041. * Gets or sets a boolean indicating that layou warnings should be ignored
  73042. */
  73043. ignoreLayoutWarnings: boolean;
  73044. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  73045. get isVertical(): boolean;
  73046. set isVertical(value: boolean);
  73047. /**
  73048. * Gets or sets panel width.
  73049. * This value should not be set when in horizontal mode as it will be computed automatically
  73050. */
  73051. set width(value: string | number);
  73052. get width(): string | number;
  73053. /**
  73054. * Gets or sets panel height.
  73055. * This value should not be set when in vertical mode as it will be computed automatically
  73056. */
  73057. set height(value: string | number);
  73058. get height(): string | number;
  73059. /**
  73060. * Creates a new StackPanel
  73061. * @param name defines control name
  73062. */
  73063. constructor(name?: string | undefined);
  73064. protected _getTypeName(): string;
  73065. /** @hidden */
  73066. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73067. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73068. protected _postMeasure(): void;
  73069. }
  73070. }
  73071. declare module BABYLON.GUI {
  73072. /**
  73073. * Class used to represent a 2D checkbox
  73074. */
  73075. export class Checkbox extends Control {
  73076. name?: string | undefined;
  73077. private _isChecked;
  73078. private _background;
  73079. private _checkSizeRatio;
  73080. private _thickness;
  73081. /** Gets or sets border thickness */
  73082. get thickness(): number;
  73083. set thickness(value: number);
  73084. /**
  73085. * BABYLON.Observable raised when isChecked property changes
  73086. */
  73087. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73088. /** Gets or sets a value indicating the ratio between overall size and check size */
  73089. get checkSizeRatio(): number;
  73090. set checkSizeRatio(value: number);
  73091. /** Gets or sets background color */
  73092. get background(): string;
  73093. set background(value: string);
  73094. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73095. get isChecked(): boolean;
  73096. set isChecked(value: boolean);
  73097. /**
  73098. * Creates a new CheckBox
  73099. * @param name defines the control name
  73100. */
  73101. constructor(name?: string | undefined);
  73102. protected _getTypeName(): string;
  73103. /** @hidden */
  73104. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73105. /** @hidden */
  73106. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73107. /**
  73108. * Utility function to easily create a checkbox with a header
  73109. * @param title defines the label to use for the header
  73110. * @param onValueChanged defines the callback to call when value changes
  73111. * @returns a StackPanel containing the checkbox and a textBlock
  73112. */
  73113. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73114. }
  73115. }
  73116. declare module BABYLON.GUI {
  73117. /**
  73118. * Class used to store key control properties
  73119. */
  73120. export class KeyPropertySet {
  73121. /** Width */
  73122. width?: string;
  73123. /** Height */
  73124. height?: string;
  73125. /** Left padding */
  73126. paddingLeft?: string;
  73127. /** Right padding */
  73128. paddingRight?: string;
  73129. /** Top padding */
  73130. paddingTop?: string;
  73131. /** Bottom padding */
  73132. paddingBottom?: string;
  73133. /** Foreground color */
  73134. color?: string;
  73135. /** Background color */
  73136. background?: string;
  73137. }
  73138. /**
  73139. * Class used to create virtual keyboard
  73140. */
  73141. export class VirtualKeyboard extends StackPanel {
  73142. /** BABYLON.Observable raised when a key is pressed */
  73143. onKeyPressObservable: BABYLON.Observable<string>;
  73144. /** Gets or sets default key button width */
  73145. defaultButtonWidth: string;
  73146. /** Gets or sets default key button height */
  73147. defaultButtonHeight: string;
  73148. /** Gets or sets default key button left padding */
  73149. defaultButtonPaddingLeft: string;
  73150. /** Gets or sets default key button right padding */
  73151. defaultButtonPaddingRight: string;
  73152. /** Gets or sets default key button top padding */
  73153. defaultButtonPaddingTop: string;
  73154. /** Gets or sets default key button bottom padding */
  73155. defaultButtonPaddingBottom: string;
  73156. /** Gets or sets default key button foreground color */
  73157. defaultButtonColor: string;
  73158. /** Gets or sets default key button background color */
  73159. defaultButtonBackground: string;
  73160. /** Gets or sets shift button foreground color */
  73161. shiftButtonColor: string;
  73162. /** Gets or sets shift button thickness*/
  73163. selectedShiftThickness: number;
  73164. /** Gets shift key state */
  73165. shiftState: number;
  73166. protected _getTypeName(): string;
  73167. private _createKey;
  73168. /**
  73169. * Adds a new row of keys
  73170. * @param keys defines the list of keys to add
  73171. * @param propertySets defines the associated property sets
  73172. */
  73173. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73174. /**
  73175. * Set the shift key to a specific state
  73176. * @param shiftState defines the new shift state
  73177. */
  73178. applyShiftState(shiftState: number): void;
  73179. private _currentlyConnectedInputText;
  73180. private _connectedInputTexts;
  73181. private _onKeyPressObserver;
  73182. /** Gets the input text control currently attached to the keyboard */
  73183. get connectedInputText(): BABYLON.Nullable<InputText>;
  73184. /**
  73185. * Connects the keyboard with an input text control
  73186. *
  73187. * @param input defines the target control
  73188. */
  73189. connect(input: InputText): void;
  73190. /**
  73191. * Disconnects the keyboard from connected InputText controls
  73192. *
  73193. * @param input optionally defines a target control, otherwise all are disconnected
  73194. */
  73195. disconnect(input?: InputText): void;
  73196. private _removeConnectedInputObservables;
  73197. /**
  73198. * Release all resources
  73199. */
  73200. dispose(): void;
  73201. /**
  73202. * Creates a new keyboard using a default layout
  73203. *
  73204. * @param name defines control name
  73205. * @returns a new VirtualKeyboard
  73206. */
  73207. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73208. }
  73209. }
  73210. declare module BABYLON.GUI {
  73211. /**
  73212. * Class used to create input text control
  73213. */
  73214. export class InputText extends Control implements IFocusableControl {
  73215. name?: string | undefined;
  73216. private _text;
  73217. private _placeholderText;
  73218. private _background;
  73219. private _focusedBackground;
  73220. private _focusedColor;
  73221. private _placeholderColor;
  73222. private _thickness;
  73223. private _margin;
  73224. private _autoStretchWidth;
  73225. private _maxWidth;
  73226. private _isFocused;
  73227. private _blinkTimeout;
  73228. private _blinkIsEven;
  73229. private _cursorOffset;
  73230. private _scrollLeft;
  73231. private _textWidth;
  73232. private _clickedCoordinate;
  73233. private _deadKey;
  73234. private _addKey;
  73235. private _currentKey;
  73236. private _isTextHighlightOn;
  73237. private _textHighlightColor;
  73238. private _highligherOpacity;
  73239. private _highlightedText;
  73240. private _startHighlightIndex;
  73241. private _endHighlightIndex;
  73242. private _cursorIndex;
  73243. private _onFocusSelectAll;
  73244. private _isPointerDown;
  73245. private _onClipboardObserver;
  73246. private _onPointerDblTapObserver;
  73247. /** @hidden */
  73248. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73249. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73250. promptMessage: string;
  73251. /** Force disable prompt on mobile device */
  73252. disableMobilePrompt: boolean;
  73253. /** BABYLON.Observable raised when the text changes */
  73254. onTextChangedObservable: BABYLON.Observable<InputText>;
  73255. /** BABYLON.Observable raised just before an entered character is to be added */
  73256. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73257. /** BABYLON.Observable raised when the control gets the focus */
  73258. onFocusObservable: BABYLON.Observable<InputText>;
  73259. /** BABYLON.Observable raised when the control loses the focus */
  73260. onBlurObservable: BABYLON.Observable<InputText>;
  73261. /**Observable raised when the text is highlighted */
  73262. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73263. /**Observable raised when copy event is triggered */
  73264. onTextCopyObservable: BABYLON.Observable<InputText>;
  73265. /** BABYLON.Observable raised when cut event is triggered */
  73266. onTextCutObservable: BABYLON.Observable<InputText>;
  73267. /** BABYLON.Observable raised when paste event is triggered */
  73268. onTextPasteObservable: BABYLON.Observable<InputText>;
  73269. /** BABYLON.Observable raised when a key event was processed */
  73270. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73271. /** Gets or sets the maximum width allowed by the control */
  73272. get maxWidth(): string | number;
  73273. /** Gets the maximum width allowed by the control in pixels */
  73274. get maxWidthInPixels(): number;
  73275. set maxWidth(value: string | number);
  73276. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73277. get highligherOpacity(): number;
  73278. set highligherOpacity(value: number);
  73279. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73280. get onFocusSelectAll(): boolean;
  73281. set onFocusSelectAll(value: boolean);
  73282. /** Gets or sets the text hightlight color */
  73283. get textHighlightColor(): string;
  73284. set textHighlightColor(value: string);
  73285. /** Gets or sets control margin */
  73286. get margin(): string;
  73287. /** Gets control margin in pixels */
  73288. get marginInPixels(): number;
  73289. set margin(value: string);
  73290. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73291. get autoStretchWidth(): boolean;
  73292. set autoStretchWidth(value: boolean);
  73293. /** Gets or sets border thickness */
  73294. get thickness(): number;
  73295. set thickness(value: number);
  73296. /** Gets or sets the background color when focused */
  73297. get focusedBackground(): string;
  73298. set focusedBackground(value: string);
  73299. /** Gets or sets the background color when focused */
  73300. get focusedColor(): string;
  73301. set focusedColor(value: string);
  73302. /** Gets or sets the background color */
  73303. get background(): string;
  73304. set background(value: string);
  73305. /** Gets or sets the placeholder color */
  73306. get placeholderColor(): string;
  73307. set placeholderColor(value: string);
  73308. /** Gets or sets the text displayed when the control is empty */
  73309. get placeholderText(): string;
  73310. set placeholderText(value: string);
  73311. /** Gets or sets the dead key flag */
  73312. get deadKey(): boolean;
  73313. set deadKey(flag: boolean);
  73314. /** Gets or sets the highlight text */
  73315. get highlightedText(): string;
  73316. set highlightedText(text: string);
  73317. /** Gets or sets if the current key should be added */
  73318. get addKey(): boolean;
  73319. set addKey(flag: boolean);
  73320. /** Gets or sets the value of the current key being entered */
  73321. get currentKey(): string;
  73322. set currentKey(key: string);
  73323. /** Gets or sets the text displayed in the control */
  73324. get text(): string;
  73325. set text(value: string);
  73326. /** Gets or sets control width */
  73327. get width(): string | number;
  73328. set width(value: string | number);
  73329. /**
  73330. * Creates a new InputText
  73331. * @param name defines the control name
  73332. * @param text defines the text of the control
  73333. */
  73334. constructor(name?: string | undefined, text?: string);
  73335. /** @hidden */
  73336. onBlur(): void;
  73337. /** @hidden */
  73338. onFocus(): void;
  73339. protected _getTypeName(): string;
  73340. /**
  73341. * Function called to get the list of controls that should not steal the focus from this control
  73342. * @returns an array of controls
  73343. */
  73344. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73345. /** @hidden */
  73346. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73347. /** @hidden */
  73348. private _updateValueFromCursorIndex;
  73349. /** @hidden */
  73350. private _processDblClick;
  73351. /** @hidden */
  73352. private _selectAllText;
  73353. /**
  73354. * Handles the keyboard event
  73355. * @param evt Defines the KeyboardEvent
  73356. */
  73357. processKeyboard(evt: KeyboardEvent): void;
  73358. /** @hidden */
  73359. private _onCopyText;
  73360. /** @hidden */
  73361. private _onCutText;
  73362. /** @hidden */
  73363. private _onPasteText;
  73364. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73365. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73366. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73367. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73368. protected _beforeRenderText(text: string): string;
  73369. dispose(): void;
  73370. }
  73371. }
  73372. declare module BABYLON.GUI {
  73373. /**
  73374. * Class used to create a 2D grid container
  73375. */
  73376. export class Grid extends Container {
  73377. name?: string | undefined;
  73378. private _rowDefinitions;
  73379. private _columnDefinitions;
  73380. private _cells;
  73381. private _childControls;
  73382. /**
  73383. * Gets the number of columns
  73384. */
  73385. get columnCount(): number;
  73386. /**
  73387. * Gets the number of rows
  73388. */
  73389. get rowCount(): number;
  73390. /** Gets the list of children */
  73391. get children(): Control[];
  73392. /** Gets the list of cells (e.g. the containers) */
  73393. get cells(): {
  73394. [key: string]: Container;
  73395. };
  73396. /**
  73397. * Gets the definition of a specific row
  73398. * @param index defines the index of the row
  73399. * @returns the row definition
  73400. */
  73401. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73402. /**
  73403. * Gets the definition of a specific column
  73404. * @param index defines the index of the column
  73405. * @returns the column definition
  73406. */
  73407. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73408. /**
  73409. * Adds a new row to the grid
  73410. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73411. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73412. * @returns the current grid
  73413. */
  73414. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73415. /**
  73416. * Adds a new column to the grid
  73417. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73418. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73419. * @returns the current grid
  73420. */
  73421. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73422. /**
  73423. * Update a row definition
  73424. * @param index defines the index of the row to update
  73425. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73426. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73427. * @returns the current grid
  73428. */
  73429. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73430. /**
  73431. * Update a column definition
  73432. * @param index defines the index of the column to update
  73433. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73434. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73435. * @returns the current grid
  73436. */
  73437. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73438. /**
  73439. * Gets the list of children stored in a specific cell
  73440. * @param row defines the row to check
  73441. * @param column defines the column to check
  73442. * @returns the list of controls
  73443. */
  73444. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73445. /**
  73446. * Gets a string representing the child cell info (row x column)
  73447. * @param child defines the control to get info from
  73448. * @returns a string containing the child cell info (row x column)
  73449. */
  73450. getChildCellInfo(child: Control): string;
  73451. private _removeCell;
  73452. private _offsetCell;
  73453. /**
  73454. * Remove a column definition at specified index
  73455. * @param index defines the index of the column to remove
  73456. * @returns the current grid
  73457. */
  73458. removeColumnDefinition(index: number): Grid;
  73459. /**
  73460. * Remove a row definition at specified index
  73461. * @param index defines the index of the row to remove
  73462. * @returns the current grid
  73463. */
  73464. removeRowDefinition(index: number): Grid;
  73465. /**
  73466. * Adds a new control to the current grid
  73467. * @param control defines the control to add
  73468. * @param row defines the row where to add the control (0 by default)
  73469. * @param column defines the column where to add the control (0 by default)
  73470. * @returns the current grid
  73471. */
  73472. addControl(control: Control, row?: number, column?: number): Grid;
  73473. /**
  73474. * Removes a control from the current container
  73475. * @param control defines the control to remove
  73476. * @returns the current container
  73477. */
  73478. removeControl(control: Control): Container;
  73479. /**
  73480. * Creates a new Grid
  73481. * @param name defines control name
  73482. */
  73483. constructor(name?: string | undefined);
  73484. protected _getTypeName(): string;
  73485. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73486. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73487. _flagDescendantsAsMatrixDirty(): void;
  73488. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73489. /** Releases associated resources */
  73490. dispose(): void;
  73491. }
  73492. }
  73493. declare module BABYLON.GUI {
  73494. /** Class used to create color pickers */
  73495. export class ColorPicker extends Control {
  73496. name?: string | undefined;
  73497. private static _Epsilon;
  73498. private _colorWheelCanvas;
  73499. private _value;
  73500. private _tmpColor;
  73501. private _pointerStartedOnSquare;
  73502. private _pointerStartedOnWheel;
  73503. private _squareLeft;
  73504. private _squareTop;
  73505. private _squareSize;
  73506. private _h;
  73507. private _s;
  73508. private _v;
  73509. private _lastPointerDownID;
  73510. /**
  73511. * BABYLON.Observable raised when the value changes
  73512. */
  73513. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73514. /** Gets or sets the color of the color picker */
  73515. get value(): BABYLON.Color3;
  73516. set value(value: BABYLON.Color3);
  73517. /**
  73518. * Gets or sets control width
  73519. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73520. */
  73521. get width(): string | number;
  73522. set width(value: string | number);
  73523. /**
  73524. * Gets or sets control height
  73525. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73526. */
  73527. get height(): string | number;
  73528. /** Gets or sets control height */
  73529. set height(value: string | number);
  73530. /** Gets or sets control size */
  73531. get size(): string | number;
  73532. set size(value: string | number);
  73533. /**
  73534. * Creates a new ColorPicker
  73535. * @param name defines the control name
  73536. */
  73537. constructor(name?: string | undefined);
  73538. protected _getTypeName(): string;
  73539. /** @hidden */
  73540. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73541. private _updateSquareProps;
  73542. private _drawGradientSquare;
  73543. private _drawCircle;
  73544. private _createColorWheelCanvas;
  73545. /** @hidden */
  73546. _draw(context: CanvasRenderingContext2D): void;
  73547. private _pointerIsDown;
  73548. private _updateValueFromPointer;
  73549. private _isPointOnSquare;
  73550. private _isPointOnWheel;
  73551. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73552. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73553. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73554. /**
  73555. * This function expands the color picker by creating a color picker dialog with manual
  73556. * color value input and the ability to save colors into an array to be used later in
  73557. * subsequent launches of the dialogue.
  73558. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73559. * @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.
  73560. * @returns picked color as a hex string and the saved colors array as hex strings.
  73561. */
  73562. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73563. pickerWidth?: string;
  73564. pickerHeight?: string;
  73565. headerHeight?: string;
  73566. lastColor?: string;
  73567. swatchLimit?: number;
  73568. numSwatchesPerLine?: number;
  73569. savedColors?: Array<string>;
  73570. }): Promise<{
  73571. savedColors?: string[];
  73572. pickedColor: string;
  73573. }>;
  73574. }
  73575. }
  73576. declare module BABYLON.GUI {
  73577. /** Class used to create 2D ellipse containers */
  73578. export class Ellipse extends Container {
  73579. name?: string | undefined;
  73580. private _thickness;
  73581. /** Gets or sets border thickness */
  73582. get thickness(): number;
  73583. set thickness(value: number);
  73584. /**
  73585. * Creates a new Ellipse
  73586. * @param name defines the control name
  73587. */
  73588. constructor(name?: string | undefined);
  73589. protected _getTypeName(): string;
  73590. protected _localDraw(context: CanvasRenderingContext2D): void;
  73591. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73592. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73593. }
  73594. }
  73595. declare module BABYLON.GUI {
  73596. /**
  73597. * Class used to create a password control
  73598. */
  73599. export class InputPassword extends InputText {
  73600. protected _beforeRenderText(text: string): string;
  73601. }
  73602. }
  73603. declare module BABYLON.GUI {
  73604. /** Class used to render 2D lines */
  73605. export class Line extends Control {
  73606. name?: string | undefined;
  73607. private _lineWidth;
  73608. private _x1;
  73609. private _y1;
  73610. private _x2;
  73611. private _y2;
  73612. private _dash;
  73613. private _connectedControl;
  73614. private _connectedControlDirtyObserver;
  73615. /** Gets or sets the dash pattern */
  73616. get dash(): Array<number>;
  73617. set dash(value: Array<number>);
  73618. /** Gets or sets the control connected with the line end */
  73619. get connectedControl(): Control;
  73620. set connectedControl(value: Control);
  73621. /** Gets or sets start coordinates on X axis */
  73622. get x1(): string | number;
  73623. set x1(value: string | number);
  73624. /** Gets or sets start coordinates on Y axis */
  73625. get y1(): string | number;
  73626. set y1(value: string | number);
  73627. /** Gets or sets end coordinates on X axis */
  73628. get x2(): string | number;
  73629. set x2(value: string | number);
  73630. /** Gets or sets end coordinates on Y axis */
  73631. get y2(): string | number;
  73632. set y2(value: string | number);
  73633. /** Gets or sets line width */
  73634. get lineWidth(): number;
  73635. set lineWidth(value: number);
  73636. /** Gets or sets horizontal alignment */
  73637. set horizontalAlignment(value: number);
  73638. /** Gets or sets vertical alignment */
  73639. set verticalAlignment(value: number);
  73640. private get _effectiveX2();
  73641. private get _effectiveY2();
  73642. /**
  73643. * Creates a new Line
  73644. * @param name defines the control name
  73645. */
  73646. constructor(name?: string | undefined);
  73647. protected _getTypeName(): string;
  73648. _draw(context: CanvasRenderingContext2D): void;
  73649. _measure(): void;
  73650. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73651. /**
  73652. * Move one end of the line given 3D cartesian coordinates.
  73653. * @param position Targeted world position
  73654. * @param scene BABYLON.Scene
  73655. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73656. */
  73657. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73658. /**
  73659. * Move one end of the line to a position in screen absolute space.
  73660. * @param projectedPosition Position in screen absolute space (X, Y)
  73661. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73662. */
  73663. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73664. }
  73665. }
  73666. declare module BABYLON.GUI {
  73667. /**
  73668. * Class used to store a point for a MultiLine object.
  73669. * The point can be pure 2D coordinates, a mesh or a control
  73670. */
  73671. export class MultiLinePoint {
  73672. private _multiLine;
  73673. private _x;
  73674. private _y;
  73675. private _control;
  73676. private _mesh;
  73677. private _controlObserver;
  73678. private _meshObserver;
  73679. /** @hidden */
  73680. _point: BABYLON.Vector2;
  73681. /**
  73682. * Creates a new MultiLinePoint
  73683. * @param multiLine defines the source MultiLine object
  73684. */
  73685. constructor(multiLine: MultiLine);
  73686. /** Gets or sets x coordinate */
  73687. get x(): string | number;
  73688. set x(value: string | number);
  73689. /** Gets or sets y coordinate */
  73690. get y(): string | number;
  73691. set y(value: string | number);
  73692. /** Gets or sets the control associated with this point */
  73693. get control(): BABYLON.Nullable<Control>;
  73694. set control(value: BABYLON.Nullable<Control>);
  73695. /** Gets or sets the mesh associated with this point */
  73696. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73697. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73698. /** Resets links */
  73699. resetLinks(): void;
  73700. /**
  73701. * Gets a translation vector
  73702. * @returns the translation vector
  73703. */
  73704. translate(): BABYLON.Vector2;
  73705. private _translatePoint;
  73706. /** Release associated resources */
  73707. dispose(): void;
  73708. }
  73709. }
  73710. declare module BABYLON.GUI {
  73711. /**
  73712. * Class used to create multi line control
  73713. */
  73714. export class MultiLine extends Control {
  73715. name?: string | undefined;
  73716. private _lineWidth;
  73717. private _dash;
  73718. private _points;
  73719. private _minX;
  73720. private _minY;
  73721. private _maxX;
  73722. private _maxY;
  73723. /**
  73724. * Creates a new MultiLine
  73725. * @param name defines the control name
  73726. */
  73727. constructor(name?: string | undefined);
  73728. /** Gets or sets dash pattern */
  73729. get dash(): Array<number>;
  73730. set dash(value: Array<number>);
  73731. /**
  73732. * Gets point stored at specified index
  73733. * @param index defines the index to look for
  73734. * @returns the requested point if found
  73735. */
  73736. getAt(index: number): MultiLinePoint;
  73737. /** Function called when a point is updated */
  73738. onPointUpdate: () => void;
  73739. /**
  73740. * Adds new points to the point collection
  73741. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73742. * @returns the list of created MultiLinePoint
  73743. */
  73744. add(...items: (AbstractMesh | Control | {
  73745. x: string | number;
  73746. y: string | number;
  73747. })[]): MultiLinePoint[];
  73748. /**
  73749. * Adds a new point to the point collection
  73750. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73751. * @returns the created MultiLinePoint
  73752. */
  73753. push(item?: (AbstractMesh | Control | {
  73754. x: string | number;
  73755. y: string | number;
  73756. })): MultiLinePoint;
  73757. /**
  73758. * Remove a specific value or point from the active point collection
  73759. * @param value defines the value or point to remove
  73760. */
  73761. remove(value: number | MultiLinePoint): void;
  73762. /**
  73763. * Resets this object to initial state (no point)
  73764. */
  73765. reset(): void;
  73766. /**
  73767. * Resets all links
  73768. */
  73769. resetLinks(): void;
  73770. /** Gets or sets line width */
  73771. get lineWidth(): number;
  73772. set lineWidth(value: number);
  73773. set horizontalAlignment(value: number);
  73774. set verticalAlignment(value: number);
  73775. protected _getTypeName(): string;
  73776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73777. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73778. _measure(): void;
  73779. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73780. dispose(): void;
  73781. }
  73782. }
  73783. declare module BABYLON.GUI {
  73784. /**
  73785. * Class used to create radio button controls
  73786. */
  73787. export class RadioButton extends Control {
  73788. name?: string | undefined;
  73789. private _isChecked;
  73790. private _background;
  73791. private _checkSizeRatio;
  73792. private _thickness;
  73793. /** Gets or sets border thickness */
  73794. get thickness(): number;
  73795. set thickness(value: number);
  73796. /** Gets or sets group name */
  73797. group: string;
  73798. /** BABYLON.Observable raised when isChecked is changed */
  73799. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73800. /** Gets or sets a value indicating the ratio between overall size and check size */
  73801. get checkSizeRatio(): number;
  73802. set checkSizeRatio(value: number);
  73803. /** Gets or sets background color */
  73804. get background(): string;
  73805. set background(value: string);
  73806. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73807. get isChecked(): boolean;
  73808. set isChecked(value: boolean);
  73809. /**
  73810. * Creates a new RadioButton
  73811. * @param name defines the control name
  73812. */
  73813. constructor(name?: string | undefined);
  73814. protected _getTypeName(): string;
  73815. _draw(context: CanvasRenderingContext2D): void;
  73816. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73817. /**
  73818. * Utility function to easily create a radio button with a header
  73819. * @param title defines the label to use for the header
  73820. * @param group defines the group to use for the radio button
  73821. * @param isChecked defines the initial state of the radio button
  73822. * @param onValueChanged defines the callback to call when value changes
  73823. * @returns a StackPanel containing the radio button and a textBlock
  73824. */
  73825. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73826. }
  73827. }
  73828. declare module BABYLON.GUI {
  73829. /**
  73830. * Class used to create slider controls
  73831. */
  73832. export class BaseSlider extends Control {
  73833. name?: string | undefined;
  73834. protected _thumbWidth: ValueAndUnit;
  73835. private _minimum;
  73836. private _maximum;
  73837. private _value;
  73838. private _isVertical;
  73839. protected _barOffset: ValueAndUnit;
  73840. private _isThumbClamped;
  73841. protected _displayThumb: boolean;
  73842. private _step;
  73843. private _lastPointerDownID;
  73844. protected _effectiveBarOffset: number;
  73845. protected _renderLeft: number;
  73846. protected _renderTop: number;
  73847. protected _renderWidth: number;
  73848. protected _renderHeight: number;
  73849. protected _backgroundBoxLength: number;
  73850. protected _backgroundBoxThickness: number;
  73851. protected _effectiveThumbThickness: number;
  73852. /** BABYLON.Observable raised when the sldier value changes */
  73853. onValueChangedObservable: BABYLON.Observable<number>;
  73854. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73855. get displayThumb(): boolean;
  73856. set displayThumb(value: boolean);
  73857. /** Gets or sets a step to apply to values (0 by default) */
  73858. get step(): number;
  73859. set step(value: number);
  73860. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73861. get barOffset(): string | number;
  73862. /** Gets main bar offset in pixels*/
  73863. get barOffsetInPixels(): number;
  73864. set barOffset(value: string | number);
  73865. /** Gets or sets thumb width */
  73866. get thumbWidth(): string | number;
  73867. /** Gets thumb width in pixels */
  73868. get thumbWidthInPixels(): number;
  73869. set thumbWidth(value: string | number);
  73870. /** Gets or sets minimum value */
  73871. get minimum(): number;
  73872. set minimum(value: number);
  73873. /** Gets or sets maximum value */
  73874. get maximum(): number;
  73875. set maximum(value: number);
  73876. /** Gets or sets current value */
  73877. get value(): number;
  73878. set value(value: number);
  73879. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73880. get isVertical(): boolean;
  73881. set isVertical(value: boolean);
  73882. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73883. get isThumbClamped(): boolean;
  73884. set isThumbClamped(value: boolean);
  73885. /**
  73886. * Creates a new BaseSlider
  73887. * @param name defines the control name
  73888. */
  73889. constructor(name?: string | undefined);
  73890. protected _getTypeName(): string;
  73891. protected _getThumbPosition(): number;
  73892. protected _getThumbThickness(type: string): number;
  73893. protected _prepareRenderingData(type: string): void;
  73894. private _pointerIsDown;
  73895. /** @hidden */
  73896. protected _updateValueFromPointer(x: number, y: number): void;
  73897. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73898. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73899. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73900. }
  73901. }
  73902. declare module BABYLON.GUI {
  73903. /**
  73904. * Class used to create slider controls
  73905. */
  73906. export class Slider extends BaseSlider {
  73907. name?: string | undefined;
  73908. private _background;
  73909. private _borderColor;
  73910. private _isThumbCircle;
  73911. protected _displayValueBar: boolean;
  73912. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73913. get displayValueBar(): boolean;
  73914. set displayValueBar(value: boolean);
  73915. /** Gets or sets border color */
  73916. get borderColor(): string;
  73917. set borderColor(value: string);
  73918. /** Gets or sets background color */
  73919. get background(): string;
  73920. set background(value: string);
  73921. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73922. get isThumbCircle(): boolean;
  73923. set isThumbCircle(value: boolean);
  73924. /**
  73925. * Creates a new Slider
  73926. * @param name defines the control name
  73927. */
  73928. constructor(name?: string | undefined);
  73929. protected _getTypeName(): string;
  73930. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73931. }
  73932. }
  73933. declare module BABYLON.GUI {
  73934. /** Class used to create a RadioGroup
  73935. * which contains groups of radio buttons
  73936. */
  73937. export class SelectorGroup {
  73938. /** name of SelectorGroup */
  73939. name: string;
  73940. private _groupPanel;
  73941. private _selectors;
  73942. private _groupHeader;
  73943. /**
  73944. * Creates a new SelectorGroup
  73945. * @param name of group, used as a group heading
  73946. */
  73947. constructor(
  73948. /** name of SelectorGroup */
  73949. name: string);
  73950. /** Gets the groupPanel of the SelectorGroup */
  73951. get groupPanel(): StackPanel;
  73952. /** Gets the selectors array */
  73953. get selectors(): StackPanel[];
  73954. /** Gets and sets the group header */
  73955. get header(): string;
  73956. set header(label: string);
  73957. /** @hidden */
  73958. private _addGroupHeader;
  73959. /** @hidden*/
  73960. _getSelector(selectorNb: number): StackPanel | undefined;
  73961. /** Removes the selector at the given position
  73962. * @param selectorNb the position of the selector within the group
  73963. */
  73964. removeSelector(selectorNb: number): void;
  73965. }
  73966. /** Class used to create a CheckboxGroup
  73967. * which contains groups of checkbox buttons
  73968. */
  73969. export class CheckboxGroup extends SelectorGroup {
  73970. /** Adds a checkbox as a control
  73971. * @param text is the label for the selector
  73972. * @param func is the function called when the Selector is checked
  73973. * @param checked is true when Selector is checked
  73974. */
  73975. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73976. /** @hidden */
  73977. _setSelectorLabel(selectorNb: number, label: string): void;
  73978. /** @hidden */
  73979. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73980. /** @hidden */
  73981. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73982. /** @hidden */
  73983. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73984. }
  73985. /** Class used to create a RadioGroup
  73986. * which contains groups of radio buttons
  73987. */
  73988. export class RadioGroup extends SelectorGroup {
  73989. private _selectNb;
  73990. /** Adds a radio button as a control
  73991. * @param label is the label for the selector
  73992. * @param func is the function called when the Selector is checked
  73993. * @param checked is true when Selector is checked
  73994. */
  73995. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73996. /** @hidden */
  73997. _setSelectorLabel(selectorNb: number, label: string): void;
  73998. /** @hidden */
  73999. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74000. /** @hidden */
  74001. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74002. /** @hidden */
  74003. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74004. }
  74005. /** Class used to create a SliderGroup
  74006. * which contains groups of slider buttons
  74007. */
  74008. export class SliderGroup extends SelectorGroup {
  74009. /**
  74010. * Adds a slider to the SelectorGroup
  74011. * @param label is the label for the SliderBar
  74012. * @param func is the function called when the Slider moves
  74013. * @param unit is a string describing the units used, eg degrees or metres
  74014. * @param min is the minimum value for the Slider
  74015. * @param max is the maximum value for the Slider
  74016. * @param value is the start value for the Slider between min and max
  74017. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  74018. */
  74019. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  74020. /** @hidden */
  74021. _setSelectorLabel(selectorNb: number, label: string): void;
  74022. /** @hidden */
  74023. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74024. /** @hidden */
  74025. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74026. /** @hidden */
  74027. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74028. }
  74029. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  74030. * @see http://doc.babylonjs.com/how_to/selector
  74031. */
  74032. export class SelectionPanel extends Rectangle {
  74033. /** name of SelectionPanel */
  74034. name: string;
  74035. /** an array of SelectionGroups */
  74036. groups: SelectorGroup[];
  74037. private _panel;
  74038. private _buttonColor;
  74039. private _buttonBackground;
  74040. private _headerColor;
  74041. private _barColor;
  74042. private _barHeight;
  74043. private _spacerHeight;
  74044. private _labelColor;
  74045. private _groups;
  74046. private _bars;
  74047. /**
  74048. * Creates a new SelectionPanel
  74049. * @param name of SelectionPanel
  74050. * @param groups is an array of SelectionGroups
  74051. */
  74052. constructor(
  74053. /** name of SelectionPanel */
  74054. name: string,
  74055. /** an array of SelectionGroups */
  74056. groups?: SelectorGroup[]);
  74057. protected _getTypeName(): string;
  74058. /** Gets or sets the headerColor */
  74059. get headerColor(): string;
  74060. set headerColor(color: string);
  74061. private _setHeaderColor;
  74062. /** Gets or sets the button color */
  74063. get buttonColor(): string;
  74064. set buttonColor(color: string);
  74065. private _setbuttonColor;
  74066. /** Gets or sets the label color */
  74067. get labelColor(): string;
  74068. set labelColor(color: string);
  74069. private _setLabelColor;
  74070. /** Gets or sets the button background */
  74071. get buttonBackground(): string;
  74072. set buttonBackground(color: string);
  74073. private _setButtonBackground;
  74074. /** Gets or sets the color of separator bar */
  74075. get barColor(): string;
  74076. set barColor(color: string);
  74077. private _setBarColor;
  74078. /** Gets or sets the height of separator bar */
  74079. get barHeight(): string;
  74080. set barHeight(value: string);
  74081. private _setBarHeight;
  74082. /** Gets or sets the height of spacers*/
  74083. get spacerHeight(): string;
  74084. set spacerHeight(value: string);
  74085. private _setSpacerHeight;
  74086. /** Adds a bar between groups */
  74087. private _addSpacer;
  74088. /** Add a group to the selection panel
  74089. * @param group is the selector group to add
  74090. */
  74091. addGroup(group: SelectorGroup): void;
  74092. /** Remove the group from the given position
  74093. * @param groupNb is the position of the group in the list
  74094. */
  74095. removeGroup(groupNb: number): void;
  74096. /** Change a group header label
  74097. * @param label is the new group header label
  74098. * @param groupNb is the number of the group to relabel
  74099. * */
  74100. setHeaderName(label: string, groupNb: number): void;
  74101. /** Change selector label to the one given
  74102. * @param label is the new selector label
  74103. * @param groupNb is the number of the groupcontaining the selector
  74104. * @param selectorNb is the number of the selector within a group to relabel
  74105. * */
  74106. relabel(label: string, groupNb: number, selectorNb: number): void;
  74107. /** For a given group position remove the selector at the given position
  74108. * @param groupNb is the number of the group to remove the selector from
  74109. * @param selectorNb is the number of the selector within the group
  74110. */
  74111. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74112. /** For a given group position of correct type add a checkbox button
  74113. * @param groupNb is the number of the group to remove the selector from
  74114. * @param label is the label for the selector
  74115. * @param func is the function called when the Selector is checked
  74116. * @param checked is true when Selector is checked
  74117. */
  74118. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74119. /** For a given group position of correct type add a radio button
  74120. * @param groupNb is the number of the group to remove the selector from
  74121. * @param label is the label for the selector
  74122. * @param func is the function called when the Selector is checked
  74123. * @param checked is true when Selector is checked
  74124. */
  74125. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74126. /**
  74127. * For a given slider group add a slider
  74128. * @param groupNb is the number of the group to add the slider to
  74129. * @param label is the label for the Slider
  74130. * @param func is the function called when the Slider moves
  74131. * @param unit is a string describing the units used, eg degrees or metres
  74132. * @param min is the minimum value for the Slider
  74133. * @param max is the maximum value for the Slider
  74134. * @param value is the start value for the Slider between min and max
  74135. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74136. */
  74137. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74138. }
  74139. }
  74140. declare module BABYLON.GUI {
  74141. /**
  74142. * Class used to hold a the container for ScrollViewer
  74143. * @hidden
  74144. */
  74145. export class _ScrollViewerWindow extends Container {
  74146. parentClientWidth: number;
  74147. parentClientHeight: number;
  74148. private _freezeControls;
  74149. private _parentMeasure;
  74150. private _oldLeft;
  74151. private _oldTop;
  74152. get freezeControls(): boolean;
  74153. set freezeControls(value: boolean);
  74154. private _bucketWidth;
  74155. private _bucketHeight;
  74156. private _buckets;
  74157. private _bucketLen;
  74158. get bucketWidth(): number;
  74159. get bucketHeight(): number;
  74160. setBucketSizes(width: number, height: number): void;
  74161. private _useBuckets;
  74162. private _makeBuckets;
  74163. private _dispatchInBuckets;
  74164. private _updateMeasures;
  74165. private _updateChildrenMeasures;
  74166. private _restoreMeasures;
  74167. /**
  74168. * Creates a new ScrollViewerWindow
  74169. * @param name of ScrollViewerWindow
  74170. */
  74171. constructor(name?: string);
  74172. protected _getTypeName(): string;
  74173. /** @hidden */
  74174. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74175. /** @hidden */
  74176. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74177. private _scrollChildren;
  74178. private _scrollChildrenWithBuckets;
  74179. /** @hidden */
  74180. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74181. protected _postMeasure(): void;
  74182. }
  74183. }
  74184. declare module BABYLON.GUI {
  74185. /**
  74186. * Class used to create slider controls
  74187. */
  74188. export class ScrollBar extends BaseSlider {
  74189. name?: string | undefined;
  74190. private _background;
  74191. private _borderColor;
  74192. private _tempMeasure;
  74193. /** Gets or sets border color */
  74194. get borderColor(): string;
  74195. set borderColor(value: string);
  74196. /** Gets or sets background color */
  74197. get background(): string;
  74198. set background(value: string);
  74199. /**
  74200. * Creates a new Slider
  74201. * @param name defines the control name
  74202. */
  74203. constructor(name?: string | undefined);
  74204. protected _getTypeName(): string;
  74205. protected _getThumbThickness(): number;
  74206. _draw(context: CanvasRenderingContext2D): void;
  74207. private _first;
  74208. private _originX;
  74209. private _originY;
  74210. /** @hidden */
  74211. protected _updateValueFromPointer(x: number, y: number): void;
  74212. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74213. }
  74214. }
  74215. declare module BABYLON.GUI {
  74216. /**
  74217. * Class used to create slider controls
  74218. */
  74219. export class ImageScrollBar extends BaseSlider {
  74220. name?: string | undefined;
  74221. private _backgroundBaseImage;
  74222. private _backgroundImage;
  74223. private _thumbImage;
  74224. private _thumbBaseImage;
  74225. private _thumbLength;
  74226. private _thumbHeight;
  74227. private _barImageHeight;
  74228. private _tempMeasure;
  74229. /** Number of 90° rotation to apply on the images when in vertical mode */
  74230. num90RotationInVerticalMode: number;
  74231. /**
  74232. * Gets or sets the image used to render the background for horizontal bar
  74233. */
  74234. get backgroundImage(): Image;
  74235. set backgroundImage(value: Image);
  74236. /**
  74237. * Gets or sets the image used to render the thumb
  74238. */
  74239. get thumbImage(): Image;
  74240. set thumbImage(value: Image);
  74241. /**
  74242. * Gets or sets the length of the thumb
  74243. */
  74244. get thumbLength(): number;
  74245. set thumbLength(value: number);
  74246. /**
  74247. * Gets or sets the height of the thumb
  74248. */
  74249. get thumbHeight(): number;
  74250. set thumbHeight(value: number);
  74251. /**
  74252. * Gets or sets the height of the bar image
  74253. */
  74254. get barImageHeight(): number;
  74255. set barImageHeight(value: number);
  74256. /**
  74257. * Creates a new ImageScrollBar
  74258. * @param name defines the control name
  74259. */
  74260. constructor(name?: string | undefined);
  74261. protected _getTypeName(): string;
  74262. protected _getThumbThickness(): number;
  74263. _draw(context: CanvasRenderingContext2D): void;
  74264. private _first;
  74265. private _originX;
  74266. private _originY;
  74267. /** @hidden */
  74268. protected _updateValueFromPointer(x: number, y: number): void;
  74269. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74270. }
  74271. }
  74272. declare module BABYLON.GUI {
  74273. /**
  74274. * Class used to hold a viewer window and sliders in a grid
  74275. */
  74276. export class ScrollViewer extends Rectangle {
  74277. private _grid;
  74278. private _horizontalBarSpace;
  74279. private _verticalBarSpace;
  74280. private _dragSpace;
  74281. private _horizontalBar;
  74282. private _verticalBar;
  74283. private _barColor;
  74284. private _barBackground;
  74285. private _barImage;
  74286. private _horizontalBarImage;
  74287. private _verticalBarImage;
  74288. private _barBackgroundImage;
  74289. private _horizontalBarBackgroundImage;
  74290. private _verticalBarBackgroundImage;
  74291. private _barSize;
  74292. private _window;
  74293. private _pointerIsOver;
  74294. private _wheelPrecision;
  74295. private _onWheelObserver;
  74296. private _clientWidth;
  74297. private _clientHeight;
  74298. private _useImageBar;
  74299. private _thumbLength;
  74300. private _thumbHeight;
  74301. private _barImageHeight;
  74302. private _horizontalBarImageHeight;
  74303. private _verticalBarImageHeight;
  74304. private _oldWindowContentsWidth;
  74305. private _oldWindowContentsHeight;
  74306. /**
  74307. * Gets the horizontal scrollbar
  74308. */
  74309. get horizontalBar(): ScrollBar | ImageScrollBar;
  74310. /**
  74311. * Gets the vertical scrollbar
  74312. */
  74313. get verticalBar(): ScrollBar | ImageScrollBar;
  74314. /**
  74315. * Adds a new control to the current container
  74316. * @param control defines the control to add
  74317. * @returns the current container
  74318. */
  74319. addControl(control: BABYLON.Nullable<Control>): Container;
  74320. /**
  74321. * Removes a control from the current container
  74322. * @param control defines the control to remove
  74323. * @returns the current container
  74324. */
  74325. removeControl(control: Control): Container;
  74326. /** Gets the list of children */
  74327. get children(): Control[];
  74328. _flagDescendantsAsMatrixDirty(): void;
  74329. /**
  74330. * Freezes or unfreezes the controls in the window.
  74331. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74332. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74333. */
  74334. get freezeControls(): boolean;
  74335. set freezeControls(value: boolean);
  74336. /** Gets the bucket width */
  74337. get bucketWidth(): number;
  74338. /** Gets the bucket height */
  74339. get bucketHeight(): number;
  74340. /**
  74341. * Sets the bucket sizes.
  74342. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74343. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74344. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74345. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74346. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74347. * used), that's why it is not enabled by default.
  74348. * @param width width of the bucket
  74349. * @param height height of the bucket
  74350. */
  74351. setBucketSizes(width: number, height: number): void;
  74352. private _forceHorizontalBar;
  74353. private _forceVerticalBar;
  74354. /**
  74355. * Forces the horizontal scroll bar to be displayed
  74356. */
  74357. get forceHorizontalBar(): boolean;
  74358. set forceHorizontalBar(value: boolean);
  74359. /**
  74360. * Forces the vertical scroll bar to be displayed
  74361. */
  74362. get forceVerticalBar(): boolean;
  74363. set forceVerticalBar(value: boolean);
  74364. /**
  74365. * Creates a new ScrollViewer
  74366. * @param name of ScrollViewer
  74367. */
  74368. constructor(name?: string, isImageBased?: boolean);
  74369. /** Reset the scroll viewer window to initial size */
  74370. resetWindow(): void;
  74371. protected _getTypeName(): string;
  74372. private _buildClientSizes;
  74373. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74374. protected _postMeasure(): void;
  74375. /**
  74376. * Gets or sets the mouse wheel precision
  74377. * from 0 to 1 with a default value of 0.05
  74378. * */
  74379. get wheelPrecision(): number;
  74380. set wheelPrecision(value: number);
  74381. /** Gets or sets the scroll bar container background color */
  74382. get scrollBackground(): string;
  74383. set scrollBackground(color: string);
  74384. /** Gets or sets the bar color */
  74385. get barColor(): string;
  74386. set barColor(color: string);
  74387. /** Gets or sets the bar image */
  74388. get thumbImage(): Image;
  74389. set thumbImage(value: Image);
  74390. /** Gets or sets the horizontal bar image */
  74391. get horizontalThumbImage(): Image;
  74392. set horizontalThumbImage(value: Image);
  74393. /** Gets or sets the vertical bar image */
  74394. get verticalThumbImage(): Image;
  74395. set verticalThumbImage(value: Image);
  74396. /** Gets or sets the size of the bar */
  74397. get barSize(): number;
  74398. set barSize(value: number);
  74399. /** Gets or sets the length of the thumb */
  74400. get thumbLength(): number;
  74401. set thumbLength(value: number);
  74402. /** Gets or sets the height of the thumb */
  74403. get thumbHeight(): number;
  74404. set thumbHeight(value: number);
  74405. /** Gets or sets the height of the bar image */
  74406. get barImageHeight(): number;
  74407. set barImageHeight(value: number);
  74408. /** Gets or sets the height of the horizontal bar image */
  74409. get horizontalBarImageHeight(): number;
  74410. set horizontalBarImageHeight(value: number);
  74411. /** Gets or sets the height of the vertical bar image */
  74412. get verticalBarImageHeight(): number;
  74413. set verticalBarImageHeight(value: number);
  74414. /** Gets or sets the bar background */
  74415. get barBackground(): string;
  74416. set barBackground(color: string);
  74417. /** Gets or sets the bar background image */
  74418. get barImage(): Image;
  74419. set barImage(value: Image);
  74420. /** Gets or sets the horizontal bar background image */
  74421. get horizontalBarImage(): Image;
  74422. set horizontalBarImage(value: Image);
  74423. /** Gets or sets the vertical bar background image */
  74424. get verticalBarImage(): Image;
  74425. set verticalBarImage(value: Image);
  74426. private _setWindowPosition;
  74427. /** @hidden */
  74428. private _updateScroller;
  74429. _link(host: AdvancedDynamicTexture): void;
  74430. /** @hidden */
  74431. private _addBar;
  74432. /** @hidden */
  74433. private _attachWheel;
  74434. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74435. /** Releases associated resources */
  74436. dispose(): void;
  74437. }
  74438. }
  74439. declare module BABYLON.GUI {
  74440. /** Class used to render a grid */
  74441. export class DisplayGrid extends Control {
  74442. name?: string | undefined;
  74443. private _cellWidth;
  74444. private _cellHeight;
  74445. private _minorLineTickness;
  74446. private _minorLineColor;
  74447. private _majorLineTickness;
  74448. private _majorLineColor;
  74449. private _majorLineFrequency;
  74450. private _background;
  74451. private _displayMajorLines;
  74452. private _displayMinorLines;
  74453. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74454. get displayMinorLines(): boolean;
  74455. set displayMinorLines(value: boolean);
  74456. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74457. get displayMajorLines(): boolean;
  74458. set displayMajorLines(value: boolean);
  74459. /** Gets or sets background color (Black by default) */
  74460. get background(): string;
  74461. set background(value: string);
  74462. /** Gets or sets the width of each cell (20 by default) */
  74463. get cellWidth(): number;
  74464. set cellWidth(value: number);
  74465. /** Gets or sets the height of each cell (20 by default) */
  74466. get cellHeight(): number;
  74467. set cellHeight(value: number);
  74468. /** Gets or sets the tickness of minor lines (1 by default) */
  74469. get minorLineTickness(): number;
  74470. set minorLineTickness(value: number);
  74471. /** Gets or sets the color of minor lines (DarkGray by default) */
  74472. get minorLineColor(): string;
  74473. set minorLineColor(value: string);
  74474. /** Gets or sets the tickness of major lines (2 by default) */
  74475. get majorLineTickness(): number;
  74476. set majorLineTickness(value: number);
  74477. /** Gets or sets the color of major lines (White by default) */
  74478. get majorLineColor(): string;
  74479. set majorLineColor(value: string);
  74480. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74481. get majorLineFrequency(): number;
  74482. set majorLineFrequency(value: number);
  74483. /**
  74484. * Creates a new GridDisplayRectangle
  74485. * @param name defines the control name
  74486. */
  74487. constructor(name?: string | undefined);
  74488. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74489. protected _getTypeName(): string;
  74490. }
  74491. }
  74492. declare module BABYLON.GUI {
  74493. /**
  74494. * Class used to create slider controls based on images
  74495. */
  74496. export class ImageBasedSlider extends BaseSlider {
  74497. name?: string | undefined;
  74498. private _backgroundImage;
  74499. private _thumbImage;
  74500. private _valueBarImage;
  74501. private _tempMeasure;
  74502. get displayThumb(): boolean;
  74503. set displayThumb(value: boolean);
  74504. /**
  74505. * Gets or sets the image used to render the background
  74506. */
  74507. get backgroundImage(): Image;
  74508. set backgroundImage(value: Image);
  74509. /**
  74510. * Gets or sets the image used to render the value bar
  74511. */
  74512. get valueBarImage(): Image;
  74513. set valueBarImage(value: Image);
  74514. /**
  74515. * Gets or sets the image used to render the thumb
  74516. */
  74517. get thumbImage(): Image;
  74518. set thumbImage(value: Image);
  74519. /**
  74520. * Creates a new ImageBasedSlider
  74521. * @param name defines the control name
  74522. */
  74523. constructor(name?: string | undefined);
  74524. protected _getTypeName(): string;
  74525. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74526. }
  74527. }
  74528. declare module BABYLON.GUI {
  74529. /**
  74530. * Forcing an export so that this code will execute
  74531. * @hidden
  74532. */
  74533. const name = "Statics";
  74534. }
  74535. declare module BABYLON.GUI {
  74536. /**
  74537. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74538. */
  74539. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74540. /**
  74541. * Define the instrumented AdvancedDynamicTexture.
  74542. */
  74543. texture: AdvancedDynamicTexture;
  74544. private _captureRenderTime;
  74545. private _renderTime;
  74546. private _captureLayoutTime;
  74547. private _layoutTime;
  74548. private _onBeginRenderObserver;
  74549. private _onEndRenderObserver;
  74550. private _onBeginLayoutObserver;
  74551. private _onEndLayoutObserver;
  74552. /**
  74553. * Gets the perf counter used to capture render time
  74554. */
  74555. get renderTimeCounter(): BABYLON.PerfCounter;
  74556. /**
  74557. * Gets the perf counter used to capture layout time
  74558. */
  74559. get layoutTimeCounter(): BABYLON.PerfCounter;
  74560. /**
  74561. * Enable or disable the render time capture
  74562. */
  74563. get captureRenderTime(): boolean;
  74564. set captureRenderTime(value: boolean);
  74565. /**
  74566. * Enable or disable the layout time capture
  74567. */
  74568. get captureLayoutTime(): boolean;
  74569. set captureLayoutTime(value: boolean);
  74570. /**
  74571. * Instantiates a new advanced dynamic texture instrumentation.
  74572. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74573. * @param texture Defines the AdvancedDynamicTexture to instrument
  74574. */
  74575. constructor(
  74576. /**
  74577. * Define the instrumented AdvancedDynamicTexture.
  74578. */
  74579. texture: AdvancedDynamicTexture);
  74580. /**
  74581. * Dispose and release associated resources.
  74582. */
  74583. dispose(): void;
  74584. }
  74585. }
  74586. declare module BABYLON.GUI {
  74587. /**
  74588. * Class used to load GUI via XML.
  74589. */
  74590. export class XmlLoader {
  74591. private _nodes;
  74592. private _nodeTypes;
  74593. private _isLoaded;
  74594. private _objectAttributes;
  74595. private _parentClass;
  74596. /**
  74597. * Create a new xml loader
  74598. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74599. */
  74600. constructor(parentClass?: null);
  74601. private _getChainElement;
  74602. private _getClassAttribute;
  74603. private _createGuiElement;
  74604. private _parseGrid;
  74605. private _parseElement;
  74606. private _prepareSourceElement;
  74607. private _parseElementsFromSource;
  74608. private _parseXml;
  74609. /**
  74610. * Gets if the loading has finished.
  74611. * @returns whether the loading has finished or not
  74612. */
  74613. isLoaded(): boolean;
  74614. /**
  74615. * Gets a loaded node / control by id.
  74616. * @param id the Controls id set in the xml
  74617. * @returns element of type Control
  74618. */
  74619. getNodeById(id: string): any;
  74620. /**
  74621. * Gets all loaded nodes / controls
  74622. * @returns Array of controls
  74623. */
  74624. getNodes(): any;
  74625. /**
  74626. * Initiates the xml layout loading
  74627. * @param xmlFile defines the xml layout to load
  74628. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74629. * @param callback defines the callback called on layout load.
  74630. */
  74631. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74632. }
  74633. }
  74634. declare module BABYLON.GUI {
  74635. /**
  74636. * Class used to create containers for controls
  74637. */
  74638. export class Container3D extends Control3D {
  74639. private _blockLayout;
  74640. /**
  74641. * Gets the list of child controls
  74642. */
  74643. protected _children: Control3D[];
  74644. /**
  74645. * Gets the list of child controls
  74646. */
  74647. get children(): Array<Control3D>;
  74648. /**
  74649. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74650. * This is helpful to optimize layout operation when adding multiple children in a row
  74651. */
  74652. get blockLayout(): boolean;
  74653. set blockLayout(value: boolean);
  74654. /**
  74655. * Creates a new container
  74656. * @param name defines the container name
  74657. */
  74658. constructor(name?: string);
  74659. /**
  74660. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74661. * @returns the current container
  74662. */
  74663. updateLayout(): Container3D;
  74664. /**
  74665. * Gets a boolean indicating if the given control is in the children of this control
  74666. * @param control defines the control to check
  74667. * @returns true if the control is in the child list
  74668. */
  74669. containsControl(control: Control3D): boolean;
  74670. /**
  74671. * Adds a control to the children of this control
  74672. * @param control defines the control to add
  74673. * @returns the current container
  74674. */
  74675. addControl(control: Control3D): Container3D;
  74676. /**
  74677. * This function will be called everytime a new control is added
  74678. */
  74679. protected _arrangeChildren(): void;
  74680. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74681. /**
  74682. * Removes a control from the children of this control
  74683. * @param control defines the control to remove
  74684. * @returns the current container
  74685. */
  74686. removeControl(control: Control3D): Container3D;
  74687. protected _getTypeName(): string;
  74688. /**
  74689. * Releases all associated resources
  74690. */
  74691. dispose(): void;
  74692. /** Control rotation will remain unchanged */
  74693. static readonly UNSET_ORIENTATION: number;
  74694. /** Control will rotate to make it look at sphere central axis */
  74695. static readonly FACEORIGIN_ORIENTATION: number;
  74696. /** Control will rotate to make it look back at sphere central axis */
  74697. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74698. /** Control will rotate to look at z axis (0, 0, 1) */
  74699. static readonly FACEFORWARD_ORIENTATION: number;
  74700. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74701. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74702. }
  74703. }
  74704. declare module BABYLON.GUI {
  74705. /**
  74706. * Class used to manage 3D user interface
  74707. * @see http://doc.babylonjs.com/how_to/gui3d
  74708. */
  74709. export class GUI3DManager implements BABYLON.IDisposable {
  74710. private _scene;
  74711. private _sceneDisposeObserver;
  74712. private _utilityLayer;
  74713. private _rootContainer;
  74714. private _pointerObserver;
  74715. private _pointerOutObserver;
  74716. /** @hidden */
  74717. _lastPickedControl: Control3D;
  74718. /** @hidden */
  74719. _lastControlOver: {
  74720. [pointerId: number]: Control3D;
  74721. };
  74722. /** @hidden */
  74723. _lastControlDown: {
  74724. [pointerId: number]: Control3D;
  74725. };
  74726. /**
  74727. * BABYLON.Observable raised when the point picked by the pointer events changed
  74728. */
  74729. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74730. /** @hidden */
  74731. _sharedMaterials: {
  74732. [key: string]: BABYLON.Material;
  74733. };
  74734. /** Gets the hosting scene */
  74735. get scene(): BABYLON.Scene;
  74736. /** Gets associated utility layer */
  74737. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74738. /**
  74739. * Creates a new GUI3DManager
  74740. * @param scene
  74741. */
  74742. constructor(scene?: BABYLON.Scene);
  74743. private _handlePointerOut;
  74744. private _doPicking;
  74745. /**
  74746. * Gets the root container
  74747. */
  74748. get rootContainer(): Container3D;
  74749. /**
  74750. * Gets a boolean indicating if the given control is in the root child list
  74751. * @param control defines the control to check
  74752. * @returns true if the control is in the root child list
  74753. */
  74754. containsControl(control: Control3D): boolean;
  74755. /**
  74756. * Adds a control to the root child list
  74757. * @param control defines the control to add
  74758. * @returns the current manager
  74759. */
  74760. addControl(control: Control3D): GUI3DManager;
  74761. /**
  74762. * Removes a control from the root child list
  74763. * @param control defines the control to remove
  74764. * @returns the current container
  74765. */
  74766. removeControl(control: Control3D): GUI3DManager;
  74767. /**
  74768. * Releases all associated resources
  74769. */
  74770. dispose(): void;
  74771. }
  74772. }
  74773. declare module BABYLON.GUI {
  74774. /**
  74775. * Class used to transport BABYLON.Vector3 information for pointer events
  74776. */
  74777. export class Vector3WithInfo extends BABYLON.Vector3 {
  74778. /** defines the current mouse button index */
  74779. buttonIndex: number;
  74780. /**
  74781. * Creates a new Vector3WithInfo
  74782. * @param source defines the vector3 data to transport
  74783. * @param buttonIndex defines the current mouse button index
  74784. */
  74785. constructor(source: BABYLON.Vector3,
  74786. /** defines the current mouse button index */
  74787. buttonIndex?: number);
  74788. }
  74789. }
  74790. declare module BABYLON.GUI {
  74791. /**
  74792. * Class used as base class for controls
  74793. */
  74794. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74795. /** Defines the control name */
  74796. name?: string | undefined;
  74797. /** @hidden */
  74798. _host: GUI3DManager;
  74799. private _node;
  74800. private _downCount;
  74801. private _enterCount;
  74802. private _downPointerIds;
  74803. private _isVisible;
  74804. /** Gets or sets the control position in world space */
  74805. get position(): BABYLON.Vector3;
  74806. set position(value: BABYLON.Vector3);
  74807. /** Gets or sets the control scaling in world space */
  74808. get scaling(): BABYLON.Vector3;
  74809. set scaling(value: BABYLON.Vector3);
  74810. /** Callback used to start pointer enter animation */
  74811. pointerEnterAnimation: () => void;
  74812. /** Callback used to start pointer out animation */
  74813. pointerOutAnimation: () => void;
  74814. /** Callback used to start pointer down animation */
  74815. pointerDownAnimation: () => void;
  74816. /** Callback used to start pointer up animation */
  74817. pointerUpAnimation: () => void;
  74818. /**
  74819. * An event triggered when the pointer move over the control
  74820. */
  74821. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74822. /**
  74823. * An event triggered when the pointer move out of the control
  74824. */
  74825. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74826. /**
  74827. * An event triggered when the pointer taps the control
  74828. */
  74829. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74830. /**
  74831. * An event triggered when pointer is up
  74832. */
  74833. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74834. /**
  74835. * An event triggered when a control is clicked on (with a mouse)
  74836. */
  74837. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74838. /**
  74839. * An event triggered when pointer enters the control
  74840. */
  74841. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74842. /**
  74843. * Gets or sets the parent container
  74844. */
  74845. parent: BABYLON.Nullable<Container3D>;
  74846. private _behaviors;
  74847. /**
  74848. * Gets the list of attached behaviors
  74849. * @see http://doc.babylonjs.com/features/behaviour
  74850. */
  74851. get behaviors(): BABYLON.Behavior<Control3D>[];
  74852. /**
  74853. * Attach a behavior to the control
  74854. * @see http://doc.babylonjs.com/features/behaviour
  74855. * @param behavior defines the behavior to attach
  74856. * @returns the current control
  74857. */
  74858. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74859. /**
  74860. * Remove an attached behavior
  74861. * @see http://doc.babylonjs.com/features/behaviour
  74862. * @param behavior defines the behavior to attach
  74863. * @returns the current control
  74864. */
  74865. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74866. /**
  74867. * Gets an attached behavior by name
  74868. * @param name defines the name of the behavior to look for
  74869. * @see http://doc.babylonjs.com/features/behaviour
  74870. * @returns null if behavior was not found else the requested behavior
  74871. */
  74872. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74873. /** Gets or sets a boolean indicating if the control is visible */
  74874. get isVisible(): boolean;
  74875. set isVisible(value: boolean);
  74876. /**
  74877. * Creates a new control
  74878. * @param name defines the control name
  74879. */
  74880. constructor(
  74881. /** Defines the control name */
  74882. name?: string | undefined);
  74883. /**
  74884. * Gets a string representing the class name
  74885. */
  74886. get typeName(): string;
  74887. /**
  74888. * Get the current class name of the control.
  74889. * @returns current class name
  74890. */
  74891. getClassName(): string;
  74892. protected _getTypeName(): string;
  74893. /**
  74894. * Gets the transform node used by this control
  74895. */
  74896. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74897. /**
  74898. * Gets the mesh used to render this control
  74899. */
  74900. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74901. /**
  74902. * Link the control as child of the given node
  74903. * @param node defines the node to link to. Use null to unlink the control
  74904. * @returns the current control
  74905. */
  74906. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74907. /** @hidden **/
  74908. _prepareNode(scene: BABYLON.Scene): void;
  74909. /**
  74910. * Node creation.
  74911. * Can be overriden by children
  74912. * @param scene defines the scene where the node must be attached
  74913. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74914. */
  74915. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74916. /**
  74917. * Affect a material to the given mesh
  74918. * @param mesh defines the mesh which will represent the control
  74919. */
  74920. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74921. /** @hidden */
  74922. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74923. /** @hidden */
  74924. _onPointerEnter(target: Control3D): boolean;
  74925. /** @hidden */
  74926. _onPointerOut(target: Control3D): void;
  74927. /** @hidden */
  74928. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74929. /** @hidden */
  74930. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74931. /** @hidden */
  74932. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74933. /** @hidden */
  74934. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74935. /** @hidden */
  74936. _disposeNode(): void;
  74937. /**
  74938. * Releases all associated resources
  74939. */
  74940. dispose(): void;
  74941. }
  74942. }
  74943. declare module BABYLON.GUI {
  74944. /**
  74945. * Class used as a root to all buttons
  74946. */
  74947. export class AbstractButton3D extends Control3D {
  74948. /**
  74949. * Creates a new button
  74950. * @param name defines the control name
  74951. */
  74952. constructor(name?: string);
  74953. protected _getTypeName(): string;
  74954. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74955. }
  74956. }
  74957. declare module BABYLON.GUI {
  74958. /**
  74959. * Class used to create a button in 3D
  74960. */
  74961. export class Button3D extends AbstractButton3D {
  74962. /** @hidden */
  74963. protected _currentMaterial: BABYLON.Material;
  74964. private _facadeTexture;
  74965. private _content;
  74966. private _contentResolution;
  74967. private _contentScaleRatio;
  74968. /**
  74969. * Gets or sets the texture resolution used to render content (512 by default)
  74970. */
  74971. get contentResolution(): BABYLON.int;
  74972. set contentResolution(value: BABYLON.int);
  74973. /**
  74974. * Gets or sets the texture scale ratio used to render content (2 by default)
  74975. */
  74976. get contentScaleRatio(): number;
  74977. set contentScaleRatio(value: number);
  74978. protected _disposeFacadeTexture(): void;
  74979. protected _resetContent(): void;
  74980. /**
  74981. * Creates a new button
  74982. * @param name defines the control name
  74983. */
  74984. constructor(name?: string);
  74985. /**
  74986. * Gets or sets the GUI 2D content used to display the button's facade
  74987. */
  74988. get content(): Control;
  74989. set content(value: Control);
  74990. /**
  74991. * Apply the facade texture (created from the content property).
  74992. * This function can be overloaded by child classes
  74993. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74994. */
  74995. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74996. protected _getTypeName(): string;
  74997. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74998. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74999. /**
  75000. * Releases all associated resources
  75001. */
  75002. dispose(): void;
  75003. }
  75004. }
  75005. declare module BABYLON.GUI {
  75006. /**
  75007. * Abstract class used to create a container panel deployed on the surface of a volume
  75008. */
  75009. export abstract class VolumeBasedPanel extends Container3D {
  75010. private _columns;
  75011. private _rows;
  75012. private _rowThenColum;
  75013. private _orientation;
  75014. protected _cellWidth: number;
  75015. protected _cellHeight: number;
  75016. /**
  75017. * Gets or sets the distance between elements
  75018. */
  75019. margin: number;
  75020. /**
  75021. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  75022. * | Value | Type | Description |
  75023. * | ----- | ----------------------------------- | ----------- |
  75024. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  75025. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  75026. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  75027. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  75028. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  75029. */
  75030. get orientation(): number;
  75031. set orientation(value: number);
  75032. /**
  75033. * Gets or sets the number of columns requested (10 by default).
  75034. * The panel will automatically compute the number of rows based on number of child controls.
  75035. */
  75036. get columns(): BABYLON.int;
  75037. set columns(value: BABYLON.int);
  75038. /**
  75039. * Gets or sets a the number of rows requested.
  75040. * The panel will automatically compute the number of columns based on number of child controls.
  75041. */
  75042. get rows(): BABYLON.int;
  75043. set rows(value: BABYLON.int);
  75044. /**
  75045. * Creates new VolumeBasedPanel
  75046. */
  75047. constructor();
  75048. protected _arrangeChildren(): void;
  75049. /** Child classes must implement this function to provide correct control positioning */
  75050. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75051. /** Child classes can implement this function to provide additional processing */
  75052. protected _finalProcessing(): void;
  75053. }
  75054. }
  75055. declare module BABYLON.GUI {
  75056. /**
  75057. * Class used to create a container panel deployed on the surface of a cylinder
  75058. */
  75059. export class CylinderPanel extends VolumeBasedPanel {
  75060. private _radius;
  75061. /**
  75062. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  75063. */
  75064. get radius(): BABYLON.float;
  75065. set radius(value: BABYLON.float);
  75066. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75067. private _cylindricalMapping;
  75068. }
  75069. }
  75070. declare module BABYLON.GUI {
  75071. /** @hidden */
  75072. export var fluentVertexShader: {
  75073. name: string;
  75074. shader: string;
  75075. };
  75076. }
  75077. declare module BABYLON.GUI {
  75078. /** @hidden */
  75079. export var fluentPixelShader: {
  75080. name: string;
  75081. shader: string;
  75082. };
  75083. }
  75084. declare module BABYLON.GUI {
  75085. /** @hidden */
  75086. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75087. INNERGLOW: boolean;
  75088. BORDER: boolean;
  75089. HOVERLIGHT: boolean;
  75090. TEXTURE: boolean;
  75091. constructor();
  75092. }
  75093. /**
  75094. * Class used to render controls with fluent desgin
  75095. */
  75096. export class FluentMaterial extends BABYLON.PushMaterial {
  75097. /**
  75098. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75099. */
  75100. innerGlowColorIntensity: number;
  75101. /**
  75102. * Gets or sets the inner glow color (white by default)
  75103. */
  75104. innerGlowColor: BABYLON.Color3;
  75105. /**
  75106. * Gets or sets alpha value (default is 1.0)
  75107. */
  75108. alpha: number;
  75109. /**
  75110. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75111. */
  75112. albedoColor: BABYLON.Color3;
  75113. /**
  75114. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75115. */
  75116. renderBorders: boolean;
  75117. /**
  75118. * Gets or sets border width (default is 0.5)
  75119. */
  75120. borderWidth: number;
  75121. /**
  75122. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75123. */
  75124. edgeSmoothingValue: number;
  75125. /**
  75126. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75127. */
  75128. borderMinValue: number;
  75129. /**
  75130. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75131. */
  75132. renderHoverLight: boolean;
  75133. /**
  75134. * Gets or sets the radius used to render the hover light (default is 1.0)
  75135. */
  75136. hoverRadius: number;
  75137. /**
  75138. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75139. */
  75140. hoverColor: BABYLON.Color4;
  75141. /**
  75142. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75143. */
  75144. hoverPosition: BABYLON.Vector3;
  75145. private _albedoTexture;
  75146. /** Gets or sets the texture to use for albedo color */
  75147. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75148. /**
  75149. * Creates a new Fluent material
  75150. * @param name defines the name of the material
  75151. * @param scene defines the hosting scene
  75152. */
  75153. constructor(name: string, scene: BABYLON.Scene);
  75154. needAlphaBlending(): boolean;
  75155. needAlphaTesting(): boolean;
  75156. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75157. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75158. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75159. getActiveTextures(): BABYLON.BaseTexture[];
  75160. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75161. dispose(forceDisposeEffect?: boolean): void;
  75162. clone(name: string): FluentMaterial;
  75163. serialize(): any;
  75164. getClassName(): string;
  75165. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75166. }
  75167. }
  75168. declare module BABYLON.GUI {
  75169. /**
  75170. * Class used to create a holographic button in 3D
  75171. */
  75172. export class HolographicButton extends Button3D {
  75173. private _backPlate;
  75174. private _textPlate;
  75175. private _frontPlate;
  75176. private _text;
  75177. private _imageUrl;
  75178. private _shareMaterials;
  75179. private _frontMaterial;
  75180. private _backMaterial;
  75181. private _plateMaterial;
  75182. private _pickedPointObserver;
  75183. private _tooltipFade;
  75184. private _tooltipTextBlock;
  75185. private _tooltipTexture;
  75186. private _tooltipMesh;
  75187. private _tooltipHoverObserver;
  75188. private _tooltipOutObserver;
  75189. private _disposeTooltip;
  75190. /**
  75191. * Rendering ground id of all the mesh in the button
  75192. */
  75193. set renderingGroupId(id: number);
  75194. get renderingGroupId(): number;
  75195. /**
  75196. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75197. */
  75198. set tooltipText(text: BABYLON.Nullable<string>);
  75199. get tooltipText(): BABYLON.Nullable<string>;
  75200. /**
  75201. * Gets or sets text for the button
  75202. */
  75203. get text(): string;
  75204. set text(value: string);
  75205. /**
  75206. * Gets or sets the image url for the button
  75207. */
  75208. get imageUrl(): string;
  75209. set imageUrl(value: string);
  75210. /**
  75211. * Gets the back material used by this button
  75212. */
  75213. get backMaterial(): FluentMaterial;
  75214. /**
  75215. * Gets the front material used by this button
  75216. */
  75217. get frontMaterial(): FluentMaterial;
  75218. /**
  75219. * Gets the plate material used by this button
  75220. */
  75221. get plateMaterial(): BABYLON.StandardMaterial;
  75222. /**
  75223. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75224. */
  75225. get shareMaterials(): boolean;
  75226. /**
  75227. * Creates a new button
  75228. * @param name defines the control name
  75229. */
  75230. constructor(name?: string, shareMaterials?: boolean);
  75231. protected _getTypeName(): string;
  75232. private _rebuildContent;
  75233. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75234. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75235. private _createBackMaterial;
  75236. private _createFrontMaterial;
  75237. private _createPlateMaterial;
  75238. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75239. /**
  75240. * Releases all associated resources
  75241. */
  75242. dispose(): void;
  75243. }
  75244. }
  75245. declare module BABYLON.GUI {
  75246. /**
  75247. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75248. */
  75249. export class MeshButton3D extends Button3D {
  75250. /** @hidden */
  75251. protected _currentMesh: BABYLON.Mesh;
  75252. /**
  75253. * Creates a new 3D button based on a mesh
  75254. * @param mesh mesh to become a 3D button
  75255. * @param name defines the control name
  75256. */
  75257. constructor(mesh: BABYLON.Mesh, name?: string);
  75258. protected _getTypeName(): string;
  75259. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75260. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75261. }
  75262. }
  75263. declare module BABYLON.GUI {
  75264. /**
  75265. * Class used to create a container panel deployed on the surface of a plane
  75266. */
  75267. export class PlanePanel extends VolumeBasedPanel {
  75268. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75269. }
  75270. }
  75271. declare module BABYLON.GUI {
  75272. /**
  75273. * Class used to create a container panel where items get randomized planar mapping
  75274. */
  75275. export class ScatterPanel extends VolumeBasedPanel {
  75276. private _iteration;
  75277. /**
  75278. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75279. */
  75280. get iteration(): BABYLON.float;
  75281. set iteration(value: BABYLON.float);
  75282. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75283. private _scatterMapping;
  75284. protected _finalProcessing(): void;
  75285. }
  75286. }
  75287. declare module BABYLON.GUI {
  75288. /**
  75289. * Class used to create a container panel deployed on the surface of a sphere
  75290. */
  75291. export class SpherePanel extends VolumeBasedPanel {
  75292. private _radius;
  75293. /**
  75294. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75295. */
  75296. get radius(): BABYLON.float;
  75297. set radius(value: BABYLON.float);
  75298. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75299. private _sphericalMapping;
  75300. }
  75301. }
  75302. declare module BABYLON.GUI {
  75303. /**
  75304. * Class used to create a stack panel in 3D on XY plane
  75305. */
  75306. export class StackPanel3D extends Container3D {
  75307. private _isVertical;
  75308. /**
  75309. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75310. */
  75311. get isVertical(): boolean;
  75312. set isVertical(value: boolean);
  75313. /**
  75314. * Gets or sets the distance between elements
  75315. */
  75316. margin: number;
  75317. /**
  75318. * Creates new StackPanel
  75319. * @param isVertical
  75320. */
  75321. constructor(isVertical?: boolean);
  75322. protected _arrangeChildren(): void;
  75323. }
  75324. }
  75325. declare module BABYLON {
  75326. /**
  75327. * Configuration for glTF validation
  75328. */
  75329. export interface IGLTFValidationConfiguration {
  75330. /**
  75331. * The url of the glTF validator.
  75332. */
  75333. url: string;
  75334. }
  75335. /**
  75336. * glTF validation
  75337. */
  75338. export class GLTFValidation {
  75339. /**
  75340. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75341. */
  75342. static Configuration: IGLTFValidationConfiguration;
  75343. private static _LoadScriptPromise;
  75344. /**
  75345. * Validate a glTF asset using the glTF-Validator.
  75346. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75347. * @param rootUrl The root url for the glTF
  75348. * @param fileName The file name for the glTF
  75349. * @param getExternalResource The callback to get external resources for the glTF validator
  75350. * @returns A promise that resolves with the glTF validation results once complete
  75351. */
  75352. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75353. }
  75354. }
  75355. declare module BABYLON {
  75356. /**
  75357. * Mode that determines the coordinate system to use.
  75358. */
  75359. export enum GLTFLoaderCoordinateSystemMode {
  75360. /**
  75361. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75362. */
  75363. AUTO = 0,
  75364. /**
  75365. * Sets the useRightHandedSystem flag on the scene.
  75366. */
  75367. FORCE_RIGHT_HANDED = 1
  75368. }
  75369. /**
  75370. * Mode that determines what animations will start.
  75371. */
  75372. export enum GLTFLoaderAnimationStartMode {
  75373. /**
  75374. * No animation will start.
  75375. */
  75376. NONE = 0,
  75377. /**
  75378. * The first animation will start.
  75379. */
  75380. FIRST = 1,
  75381. /**
  75382. * All animations will start.
  75383. */
  75384. ALL = 2
  75385. }
  75386. /**
  75387. * Interface that contains the data for the glTF asset.
  75388. */
  75389. export interface IGLTFLoaderData {
  75390. /**
  75391. * The object that represents the glTF JSON.
  75392. */
  75393. json: Object;
  75394. /**
  75395. * The BIN chunk of a binary glTF.
  75396. */
  75397. bin: Nullable<IDataBuffer>;
  75398. }
  75399. /**
  75400. * Interface for extending the loader.
  75401. */
  75402. export interface IGLTFLoaderExtension {
  75403. /**
  75404. * The name of this extension.
  75405. */
  75406. readonly name: string;
  75407. /**
  75408. * Defines whether this extension is enabled.
  75409. */
  75410. enabled: boolean;
  75411. /**
  75412. * Defines the order of this extension.
  75413. * The loader sorts the extensions using these values when loading.
  75414. */
  75415. order?: number;
  75416. }
  75417. /**
  75418. * Loader state.
  75419. */
  75420. export enum GLTFLoaderState {
  75421. /**
  75422. * The asset is loading.
  75423. */
  75424. LOADING = 0,
  75425. /**
  75426. * The asset is ready for rendering.
  75427. */
  75428. READY = 1,
  75429. /**
  75430. * The asset is completely loaded.
  75431. */
  75432. COMPLETE = 2
  75433. }
  75434. /** @hidden */
  75435. export interface IImportMeshAsyncOutput {
  75436. meshes: AbstractMesh[];
  75437. particleSystems: IParticleSystem[];
  75438. skeletons: Skeleton[];
  75439. animationGroups: AnimationGroup[];
  75440. lights: Light[];
  75441. transformNodes: TransformNode[];
  75442. }
  75443. /** @hidden */
  75444. export interface IGLTFLoader extends IDisposable {
  75445. readonly state: Nullable<GLTFLoaderState>;
  75446. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75447. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75448. }
  75449. /**
  75450. * File loader for loading glTF files into a scene.
  75451. */
  75452. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75453. /** @hidden */
  75454. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75455. /** @hidden */
  75456. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75457. /**
  75458. * Raised when the asset has been parsed
  75459. */
  75460. onParsedObservable: Observable<IGLTFLoaderData>;
  75461. private _onParsedObserver;
  75462. /**
  75463. * Raised when the asset has been parsed
  75464. */
  75465. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75466. /**
  75467. * 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.
  75468. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75469. * Defaults to true.
  75470. * @hidden
  75471. */
  75472. static IncrementalLoading: boolean;
  75473. /**
  75474. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75475. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75476. * @hidden
  75477. */
  75478. static HomogeneousCoordinates: boolean;
  75479. /**
  75480. * The coordinate system mode. Defaults to AUTO.
  75481. */
  75482. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75483. /**
  75484. * The animation start mode. Defaults to FIRST.
  75485. */
  75486. animationStartMode: GLTFLoaderAnimationStartMode;
  75487. /**
  75488. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75489. */
  75490. compileMaterials: boolean;
  75491. /**
  75492. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75493. */
  75494. useClipPlane: boolean;
  75495. /**
  75496. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75497. */
  75498. compileShadowGenerators: boolean;
  75499. /**
  75500. * Defines if the Alpha blended materials are only applied as coverage.
  75501. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75502. * If true, no extra effects are applied to transparent pixels.
  75503. */
  75504. transparencyAsCoverage: boolean;
  75505. /**
  75506. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75507. * Enabling will disable offline support and glTF validator.
  75508. * Defaults to false.
  75509. */
  75510. useRangeRequests: boolean;
  75511. /**
  75512. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75513. */
  75514. createInstances: boolean;
  75515. /**
  75516. * Function called before loading a url referenced by the asset.
  75517. */
  75518. preprocessUrlAsync: (url: string) => Promise<string>;
  75519. /**
  75520. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75521. */
  75522. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75523. private _onMeshLoadedObserver;
  75524. /**
  75525. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75526. */
  75527. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75528. /**
  75529. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75530. */
  75531. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75532. private _onTextureLoadedObserver;
  75533. /**
  75534. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75535. */
  75536. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75537. /**
  75538. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75539. */
  75540. readonly onMaterialLoadedObservable: Observable<Material>;
  75541. private _onMaterialLoadedObserver;
  75542. /**
  75543. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75544. */
  75545. set onMaterialLoaded(callback: (material: Material) => void);
  75546. /**
  75547. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75548. */
  75549. readonly onCameraLoadedObservable: Observable<Camera>;
  75550. private _onCameraLoadedObserver;
  75551. /**
  75552. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75553. */
  75554. set onCameraLoaded(callback: (camera: Camera) => void);
  75555. /**
  75556. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75557. * For assets with LODs, raised when all of the LODs are complete.
  75558. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75559. */
  75560. readonly onCompleteObservable: Observable<void>;
  75561. private _onCompleteObserver;
  75562. /**
  75563. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75564. * For assets with LODs, raised when all of the LODs are complete.
  75565. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75566. */
  75567. set onComplete(callback: () => void);
  75568. /**
  75569. * Observable raised when an error occurs.
  75570. */
  75571. readonly onErrorObservable: Observable<any>;
  75572. private _onErrorObserver;
  75573. /**
  75574. * Callback raised when an error occurs.
  75575. */
  75576. set onError(callback: (reason: any) => void);
  75577. /**
  75578. * Observable raised after the loader is disposed.
  75579. */
  75580. readonly onDisposeObservable: Observable<void>;
  75581. private _onDisposeObserver;
  75582. /**
  75583. * Callback raised after the loader is disposed.
  75584. */
  75585. set onDispose(callback: () => void);
  75586. /**
  75587. * Observable raised after a loader extension is created.
  75588. * Set additional options for a loader extension in this event.
  75589. */
  75590. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75591. private _onExtensionLoadedObserver;
  75592. /**
  75593. * Callback raised after a loader extension is created.
  75594. */
  75595. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75596. /**
  75597. * Defines if the loader logging is enabled.
  75598. */
  75599. get loggingEnabled(): boolean;
  75600. set loggingEnabled(value: boolean);
  75601. /**
  75602. * Defines if the loader should capture performance counters.
  75603. */
  75604. get capturePerformanceCounters(): boolean;
  75605. set capturePerformanceCounters(value: boolean);
  75606. /**
  75607. * Defines if the loader should validate the asset.
  75608. */
  75609. validate: boolean;
  75610. /**
  75611. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75612. */
  75613. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75614. private _onValidatedObserver;
  75615. /**
  75616. * Callback raised after a loader extension is created.
  75617. */
  75618. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75619. private _loader;
  75620. /**
  75621. * Name of the loader ("gltf")
  75622. */
  75623. name: string;
  75624. /** @hidden */
  75625. extensions: ISceneLoaderPluginExtensions;
  75626. /**
  75627. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75628. */
  75629. dispose(): void;
  75630. /** @hidden */
  75631. _clear(): void;
  75632. /** @hidden */
  75633. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75634. /** @hidden */
  75635. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75636. /** @hidden */
  75637. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75638. meshes: AbstractMesh[];
  75639. particleSystems: IParticleSystem[];
  75640. skeletons: Skeleton[];
  75641. animationGroups: AnimationGroup[];
  75642. }>;
  75643. /** @hidden */
  75644. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75645. /** @hidden */
  75646. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75647. /** @hidden */
  75648. canDirectLoad(data: string): boolean;
  75649. /** @hidden */
  75650. directLoad(scene: Scene, data: string): any;
  75651. /**
  75652. * The callback that allows custom handling of the root url based on the response url.
  75653. * @param rootUrl the original root url
  75654. * @param responseURL the response url if available
  75655. * @returns the new root url
  75656. */
  75657. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75658. /** @hidden */
  75659. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75660. /**
  75661. * The loader state or null if the loader is not active.
  75662. */
  75663. get loaderState(): Nullable<GLTFLoaderState>;
  75664. /**
  75665. * Returns a promise that resolves when the asset is completely loaded.
  75666. * @returns a promise that resolves when the asset is completely loaded.
  75667. */
  75668. whenCompleteAsync(): Promise<void>;
  75669. private _validate;
  75670. private _getLoader;
  75671. private _parseJson;
  75672. private _unpackBinaryAsync;
  75673. private _unpackBinaryV1Async;
  75674. private _unpackBinaryV2Async;
  75675. private static _parseVersion;
  75676. private static _compareVersion;
  75677. private static readonly _logSpaces;
  75678. private _logIndentLevel;
  75679. private _loggingEnabled;
  75680. /** @hidden */
  75681. _log: (message: string) => void;
  75682. /** @hidden */
  75683. _logOpen(message: string): void;
  75684. /** @hidden */
  75685. _logClose(): void;
  75686. private _logEnabled;
  75687. private _logDisabled;
  75688. private _capturePerformanceCounters;
  75689. /** @hidden */
  75690. _startPerformanceCounter: (counterName: string) => void;
  75691. /** @hidden */
  75692. _endPerformanceCounter: (counterName: string) => void;
  75693. private _startPerformanceCounterEnabled;
  75694. private _startPerformanceCounterDisabled;
  75695. private _endPerformanceCounterEnabled;
  75696. private _endPerformanceCounterDisabled;
  75697. }
  75698. }
  75699. declare module BABYLON.GLTF1 {
  75700. /**
  75701. * Enums
  75702. * @hidden
  75703. */
  75704. export enum EComponentType {
  75705. BYTE = 5120,
  75706. UNSIGNED_BYTE = 5121,
  75707. SHORT = 5122,
  75708. UNSIGNED_SHORT = 5123,
  75709. FLOAT = 5126
  75710. }
  75711. /** @hidden */
  75712. export enum EShaderType {
  75713. FRAGMENT = 35632,
  75714. VERTEX = 35633
  75715. }
  75716. /** @hidden */
  75717. export enum EParameterType {
  75718. BYTE = 5120,
  75719. UNSIGNED_BYTE = 5121,
  75720. SHORT = 5122,
  75721. UNSIGNED_SHORT = 5123,
  75722. INT = 5124,
  75723. UNSIGNED_INT = 5125,
  75724. FLOAT = 5126,
  75725. FLOAT_VEC2 = 35664,
  75726. FLOAT_VEC3 = 35665,
  75727. FLOAT_VEC4 = 35666,
  75728. INT_VEC2 = 35667,
  75729. INT_VEC3 = 35668,
  75730. INT_VEC4 = 35669,
  75731. BOOL = 35670,
  75732. BOOL_VEC2 = 35671,
  75733. BOOL_VEC3 = 35672,
  75734. BOOL_VEC4 = 35673,
  75735. FLOAT_MAT2 = 35674,
  75736. FLOAT_MAT3 = 35675,
  75737. FLOAT_MAT4 = 35676,
  75738. SAMPLER_2D = 35678
  75739. }
  75740. /** @hidden */
  75741. export enum ETextureWrapMode {
  75742. CLAMP_TO_EDGE = 33071,
  75743. MIRRORED_REPEAT = 33648,
  75744. REPEAT = 10497
  75745. }
  75746. /** @hidden */
  75747. export enum ETextureFilterType {
  75748. NEAREST = 9728,
  75749. LINEAR = 9728,
  75750. NEAREST_MIPMAP_NEAREST = 9984,
  75751. LINEAR_MIPMAP_NEAREST = 9985,
  75752. NEAREST_MIPMAP_LINEAR = 9986,
  75753. LINEAR_MIPMAP_LINEAR = 9987
  75754. }
  75755. /** @hidden */
  75756. export enum ETextureFormat {
  75757. ALPHA = 6406,
  75758. RGB = 6407,
  75759. RGBA = 6408,
  75760. LUMINANCE = 6409,
  75761. LUMINANCE_ALPHA = 6410
  75762. }
  75763. /** @hidden */
  75764. export enum ECullingType {
  75765. FRONT = 1028,
  75766. BACK = 1029,
  75767. FRONT_AND_BACK = 1032
  75768. }
  75769. /** @hidden */
  75770. export enum EBlendingFunction {
  75771. ZERO = 0,
  75772. ONE = 1,
  75773. SRC_COLOR = 768,
  75774. ONE_MINUS_SRC_COLOR = 769,
  75775. DST_COLOR = 774,
  75776. ONE_MINUS_DST_COLOR = 775,
  75777. SRC_ALPHA = 770,
  75778. ONE_MINUS_SRC_ALPHA = 771,
  75779. DST_ALPHA = 772,
  75780. ONE_MINUS_DST_ALPHA = 773,
  75781. CONSTANT_COLOR = 32769,
  75782. ONE_MINUS_CONSTANT_COLOR = 32770,
  75783. CONSTANT_ALPHA = 32771,
  75784. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75785. SRC_ALPHA_SATURATE = 776
  75786. }
  75787. /** @hidden */
  75788. export interface IGLTFProperty {
  75789. extensions?: {
  75790. [key: string]: any;
  75791. };
  75792. extras?: Object;
  75793. }
  75794. /** @hidden */
  75795. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75796. name?: string;
  75797. }
  75798. /** @hidden */
  75799. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75800. bufferView: string;
  75801. byteOffset: number;
  75802. byteStride: number;
  75803. count: number;
  75804. type: string;
  75805. componentType: EComponentType;
  75806. max?: number[];
  75807. min?: number[];
  75808. name?: string;
  75809. }
  75810. /** @hidden */
  75811. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75812. buffer: string;
  75813. byteOffset: number;
  75814. byteLength: number;
  75815. byteStride: number;
  75816. target?: number;
  75817. }
  75818. /** @hidden */
  75819. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75820. uri: string;
  75821. byteLength?: number;
  75822. type?: string;
  75823. }
  75824. /** @hidden */
  75825. export interface IGLTFShader extends IGLTFChildRootProperty {
  75826. uri: string;
  75827. type: EShaderType;
  75828. }
  75829. /** @hidden */
  75830. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75831. attributes: string[];
  75832. fragmentShader: string;
  75833. vertexShader: string;
  75834. }
  75835. /** @hidden */
  75836. export interface IGLTFTechniqueParameter {
  75837. type: number;
  75838. count?: number;
  75839. semantic?: string;
  75840. node?: string;
  75841. value?: number | boolean | string | Array<any>;
  75842. source?: string;
  75843. babylonValue?: any;
  75844. }
  75845. /** @hidden */
  75846. export interface IGLTFTechniqueCommonProfile {
  75847. lightingModel: string;
  75848. texcoordBindings: Object;
  75849. parameters?: Array<any>;
  75850. }
  75851. /** @hidden */
  75852. export interface IGLTFTechniqueStatesFunctions {
  75853. blendColor?: number[];
  75854. blendEquationSeparate?: number[];
  75855. blendFuncSeparate?: number[];
  75856. colorMask: boolean[];
  75857. cullFace: number[];
  75858. }
  75859. /** @hidden */
  75860. export interface IGLTFTechniqueStates {
  75861. enable: number[];
  75862. functions: IGLTFTechniqueStatesFunctions;
  75863. }
  75864. /** @hidden */
  75865. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75866. parameters: {
  75867. [key: string]: IGLTFTechniqueParameter;
  75868. };
  75869. program: string;
  75870. attributes: {
  75871. [key: string]: string;
  75872. };
  75873. uniforms: {
  75874. [key: string]: string;
  75875. };
  75876. states: IGLTFTechniqueStates;
  75877. }
  75878. /** @hidden */
  75879. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75880. technique?: string;
  75881. values: string[];
  75882. }
  75883. /** @hidden */
  75884. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75885. attributes: {
  75886. [key: string]: string;
  75887. };
  75888. indices: string;
  75889. material: string;
  75890. mode?: number;
  75891. }
  75892. /** @hidden */
  75893. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75894. primitives: IGLTFMeshPrimitive[];
  75895. }
  75896. /** @hidden */
  75897. export interface IGLTFImage extends IGLTFChildRootProperty {
  75898. uri: string;
  75899. }
  75900. /** @hidden */
  75901. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75902. magFilter?: number;
  75903. minFilter?: number;
  75904. wrapS?: number;
  75905. wrapT?: number;
  75906. }
  75907. /** @hidden */
  75908. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75909. sampler: string;
  75910. source: string;
  75911. format?: ETextureFormat;
  75912. internalFormat?: ETextureFormat;
  75913. target?: number;
  75914. type?: number;
  75915. babylonTexture?: Texture;
  75916. }
  75917. /** @hidden */
  75918. export interface IGLTFAmbienLight {
  75919. color?: number[];
  75920. }
  75921. /** @hidden */
  75922. export interface IGLTFDirectionalLight {
  75923. color?: number[];
  75924. }
  75925. /** @hidden */
  75926. export interface IGLTFPointLight {
  75927. color?: number[];
  75928. constantAttenuation?: number;
  75929. linearAttenuation?: number;
  75930. quadraticAttenuation?: number;
  75931. }
  75932. /** @hidden */
  75933. export interface IGLTFSpotLight {
  75934. color?: number[];
  75935. constantAttenuation?: number;
  75936. fallOfAngle?: number;
  75937. fallOffExponent?: number;
  75938. linearAttenuation?: number;
  75939. quadraticAttenuation?: number;
  75940. }
  75941. /** @hidden */
  75942. export interface IGLTFLight extends IGLTFChildRootProperty {
  75943. type: string;
  75944. }
  75945. /** @hidden */
  75946. export interface IGLTFCameraOrthographic {
  75947. xmag: number;
  75948. ymag: number;
  75949. zfar: number;
  75950. znear: number;
  75951. }
  75952. /** @hidden */
  75953. export interface IGLTFCameraPerspective {
  75954. aspectRatio: number;
  75955. yfov: number;
  75956. zfar: number;
  75957. znear: number;
  75958. }
  75959. /** @hidden */
  75960. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75961. type: string;
  75962. }
  75963. /** @hidden */
  75964. export interface IGLTFAnimationChannelTarget {
  75965. id: string;
  75966. path: string;
  75967. }
  75968. /** @hidden */
  75969. export interface IGLTFAnimationChannel {
  75970. sampler: string;
  75971. target: IGLTFAnimationChannelTarget;
  75972. }
  75973. /** @hidden */
  75974. export interface IGLTFAnimationSampler {
  75975. input: string;
  75976. output: string;
  75977. interpolation?: string;
  75978. }
  75979. /** @hidden */
  75980. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75981. channels?: IGLTFAnimationChannel[];
  75982. parameters?: {
  75983. [key: string]: string;
  75984. };
  75985. samplers?: {
  75986. [key: string]: IGLTFAnimationSampler;
  75987. };
  75988. }
  75989. /** @hidden */
  75990. export interface IGLTFNodeInstanceSkin {
  75991. skeletons: string[];
  75992. skin: string;
  75993. meshes: string[];
  75994. }
  75995. /** @hidden */
  75996. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75997. bindShapeMatrix: number[];
  75998. inverseBindMatrices: string;
  75999. jointNames: string[];
  76000. babylonSkeleton?: Skeleton;
  76001. }
  76002. /** @hidden */
  76003. export interface IGLTFNode extends IGLTFChildRootProperty {
  76004. camera?: string;
  76005. children: string[];
  76006. skin?: string;
  76007. jointName?: string;
  76008. light?: string;
  76009. matrix: number[];
  76010. mesh?: string;
  76011. meshes?: string[];
  76012. rotation?: number[];
  76013. scale?: number[];
  76014. translation?: number[];
  76015. babylonNode?: Node;
  76016. }
  76017. /** @hidden */
  76018. export interface IGLTFScene extends IGLTFChildRootProperty {
  76019. nodes: string[];
  76020. }
  76021. /** @hidden */
  76022. export interface IGLTFRuntime {
  76023. extensions: {
  76024. [key: string]: any;
  76025. };
  76026. accessors: {
  76027. [key: string]: IGLTFAccessor;
  76028. };
  76029. buffers: {
  76030. [key: string]: IGLTFBuffer;
  76031. };
  76032. bufferViews: {
  76033. [key: string]: IGLTFBufferView;
  76034. };
  76035. meshes: {
  76036. [key: string]: IGLTFMesh;
  76037. };
  76038. lights: {
  76039. [key: string]: IGLTFLight;
  76040. };
  76041. cameras: {
  76042. [key: string]: IGLTFCamera;
  76043. };
  76044. nodes: {
  76045. [key: string]: IGLTFNode;
  76046. };
  76047. images: {
  76048. [key: string]: IGLTFImage;
  76049. };
  76050. textures: {
  76051. [key: string]: IGLTFTexture;
  76052. };
  76053. shaders: {
  76054. [key: string]: IGLTFShader;
  76055. };
  76056. programs: {
  76057. [key: string]: IGLTFProgram;
  76058. };
  76059. samplers: {
  76060. [key: string]: IGLTFSampler;
  76061. };
  76062. techniques: {
  76063. [key: string]: IGLTFTechnique;
  76064. };
  76065. materials: {
  76066. [key: string]: IGLTFMaterial;
  76067. };
  76068. animations: {
  76069. [key: string]: IGLTFAnimation;
  76070. };
  76071. skins: {
  76072. [key: string]: IGLTFSkins;
  76073. };
  76074. currentScene?: Object;
  76075. scenes: {
  76076. [key: string]: IGLTFScene;
  76077. };
  76078. extensionsUsed: string[];
  76079. extensionsRequired?: string[];
  76080. buffersCount: number;
  76081. shaderscount: number;
  76082. scene: Scene;
  76083. rootUrl: string;
  76084. loadedBufferCount: number;
  76085. loadedBufferViews: {
  76086. [name: string]: ArrayBufferView;
  76087. };
  76088. loadedShaderCount: number;
  76089. importOnlyMeshes: boolean;
  76090. importMeshesNames?: string[];
  76091. dummyNodes: Node[];
  76092. forAssetContainer: boolean;
  76093. }
  76094. /** @hidden */
  76095. export interface INodeToRoot {
  76096. bone: Bone;
  76097. node: IGLTFNode;
  76098. id: string;
  76099. }
  76100. /** @hidden */
  76101. export interface IJointNode {
  76102. node: IGLTFNode;
  76103. id: string;
  76104. }
  76105. }
  76106. declare module BABYLON.GLTF1 {
  76107. /**
  76108. * Utils functions for GLTF
  76109. * @hidden
  76110. */
  76111. export class GLTFUtils {
  76112. /**
  76113. * Sets the given "parameter" matrix
  76114. * @param scene: the Scene object
  76115. * @param source: the source node where to pick the matrix
  76116. * @param parameter: the GLTF technique parameter
  76117. * @param uniformName: the name of the shader's uniform
  76118. * @param shaderMaterial: the shader material
  76119. */
  76120. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76121. /**
  76122. * Sets the given "parameter" matrix
  76123. * @param shaderMaterial: the shader material
  76124. * @param uniform: the name of the shader's uniform
  76125. * @param value: the value of the uniform
  76126. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76127. */
  76128. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76129. /**
  76130. * Returns the wrap mode of the texture
  76131. * @param mode: the mode value
  76132. */
  76133. static GetWrapMode(mode: number): number;
  76134. /**
  76135. * Returns the byte stride giving an accessor
  76136. * @param accessor: the GLTF accessor objet
  76137. */
  76138. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76139. /**
  76140. * Returns the texture filter mode giving a mode value
  76141. * @param mode: the filter mode value
  76142. */
  76143. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76144. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76145. /**
  76146. * Returns a buffer from its accessor
  76147. * @param gltfRuntime: the GLTF runtime
  76148. * @param accessor: the GLTF accessor
  76149. */
  76150. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76151. /**
  76152. * Decodes a buffer view into a string
  76153. * @param view: the buffer view
  76154. */
  76155. static DecodeBufferToText(view: ArrayBufferView): string;
  76156. /**
  76157. * Returns the default material of gltf. Related to
  76158. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76159. * @param scene: the Babylon.js scene
  76160. */
  76161. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76162. private static _DefaultMaterial;
  76163. }
  76164. }
  76165. declare module BABYLON.GLTF1 {
  76166. /**
  76167. * Implementation of the base glTF spec
  76168. * @hidden
  76169. */
  76170. export class GLTFLoaderBase {
  76171. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76172. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76173. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76174. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76175. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76176. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76177. }
  76178. /**
  76179. * glTF V1 Loader
  76180. * @hidden
  76181. */
  76182. export class GLTFLoader implements IGLTFLoader {
  76183. static Extensions: {
  76184. [name: string]: GLTFLoaderExtension;
  76185. };
  76186. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76187. state: Nullable<GLTFLoaderState>;
  76188. dispose(): void;
  76189. private _importMeshAsync;
  76190. /**
  76191. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76192. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76193. * @param scene the scene the meshes should be added to
  76194. * @param forAssetContainer defines if the entities must be stored in the scene
  76195. * @param data gltf data containing information of the meshes in a loaded file
  76196. * @param rootUrl root url to load from
  76197. * @param onProgress event that fires when loading progress has occured
  76198. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76199. */
  76200. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76201. private _loadAsync;
  76202. /**
  76203. * Imports all objects from a loaded gltf file and adds them to the scene
  76204. * @param scene the scene the objects should be added to
  76205. * @param data gltf data containing information of the meshes in a loaded file
  76206. * @param rootUrl root url to load from
  76207. * @param onProgress event that fires when loading progress has occured
  76208. * @returns a promise which completes when objects have been loaded to the scene
  76209. */
  76210. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76211. private _loadShadersAsync;
  76212. private _loadBuffersAsync;
  76213. private _createNodes;
  76214. }
  76215. /** @hidden */
  76216. export abstract class GLTFLoaderExtension {
  76217. private _name;
  76218. constructor(name: string);
  76219. get name(): string;
  76220. /**
  76221. * Defines an override for loading the runtime
  76222. * Return true to stop further extensions from loading the runtime
  76223. */
  76224. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76225. /**
  76226. * Defines an onverride for creating gltf runtime
  76227. * Return true to stop further extensions from creating the runtime
  76228. */
  76229. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76230. /**
  76231. * Defines an override for loading buffers
  76232. * Return true to stop further extensions from loading this buffer
  76233. */
  76234. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76235. /**
  76236. * Defines an override for loading texture buffers
  76237. * Return true to stop further extensions from loading this texture data
  76238. */
  76239. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76240. /**
  76241. * Defines an override for creating textures
  76242. * Return true to stop further extensions from loading this texture
  76243. */
  76244. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76245. /**
  76246. * Defines an override for loading shader strings
  76247. * Return true to stop further extensions from loading this shader data
  76248. */
  76249. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76250. /**
  76251. * Defines an override for loading materials
  76252. * Return true to stop further extensions from loading this material
  76253. */
  76254. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76255. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76256. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76257. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76258. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76259. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76260. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76261. private static LoadTextureBufferAsync;
  76262. private static CreateTextureAsync;
  76263. private static ApplyExtensions;
  76264. }
  76265. }
  76266. declare module BABYLON.GLTF1 {
  76267. /** @hidden */
  76268. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76269. private _bin;
  76270. constructor();
  76271. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76272. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76273. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76274. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76275. }
  76276. }
  76277. declare module BABYLON.GLTF1 {
  76278. /** @hidden */
  76279. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76280. constructor();
  76281. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76282. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76283. private _loadTexture;
  76284. }
  76285. }
  76286. declare module BABYLON.GLTF2.Loader {
  76287. /**
  76288. * Loader interface with an index field.
  76289. */
  76290. export interface IArrayItem {
  76291. /**
  76292. * The index of this item in the array.
  76293. */
  76294. index: number;
  76295. }
  76296. /**
  76297. * Loader interface with additional members.
  76298. */
  76299. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76300. /** @hidden */
  76301. _data?: Promise<ArrayBufferView>;
  76302. /** @hidden */
  76303. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76304. }
  76305. /**
  76306. * Loader interface with additional members.
  76307. */
  76308. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76309. }
  76310. /** @hidden */
  76311. export interface _IAnimationSamplerData {
  76312. input: Float32Array;
  76313. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76314. output: Float32Array;
  76315. }
  76316. /**
  76317. * Loader interface with additional members.
  76318. */
  76319. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76320. /** @hidden */
  76321. _data?: Promise<_IAnimationSamplerData>;
  76322. }
  76323. /**
  76324. * Loader interface with additional members.
  76325. */
  76326. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76327. channels: IAnimationChannel[];
  76328. samplers: IAnimationSampler[];
  76329. /** @hidden */
  76330. _babylonAnimationGroup?: AnimationGroup;
  76331. }
  76332. /**
  76333. * Loader interface with additional members.
  76334. */
  76335. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76336. /** @hidden */
  76337. _data?: Promise<ArrayBufferView>;
  76338. }
  76339. /**
  76340. * Loader interface with additional members.
  76341. */
  76342. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76343. /** @hidden */
  76344. _data?: Promise<ArrayBufferView>;
  76345. /** @hidden */
  76346. _babylonBuffer?: Promise<Buffer>;
  76347. }
  76348. /**
  76349. * Loader interface with additional members.
  76350. */
  76351. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76352. }
  76353. /**
  76354. * Loader interface with additional members.
  76355. */
  76356. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76357. /** @hidden */
  76358. _data?: Promise<ArrayBufferView>;
  76359. }
  76360. /**
  76361. * Loader interface with additional members.
  76362. */
  76363. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76364. }
  76365. /**
  76366. * Loader interface with additional members.
  76367. */
  76368. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76369. }
  76370. /**
  76371. * Loader interface with additional members.
  76372. */
  76373. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76374. baseColorTexture?: ITextureInfo;
  76375. metallicRoughnessTexture?: ITextureInfo;
  76376. }
  76377. /**
  76378. * Loader interface with additional members.
  76379. */
  76380. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76381. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76382. normalTexture?: IMaterialNormalTextureInfo;
  76383. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76384. emissiveTexture?: ITextureInfo;
  76385. /** @hidden */
  76386. _data?: {
  76387. [babylonDrawMode: number]: {
  76388. babylonMaterial: Material;
  76389. babylonMeshes: AbstractMesh[];
  76390. promise: Promise<void>;
  76391. };
  76392. };
  76393. }
  76394. /**
  76395. * Loader interface with additional members.
  76396. */
  76397. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76398. primitives: IMeshPrimitive[];
  76399. }
  76400. /**
  76401. * Loader interface with additional members.
  76402. */
  76403. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76404. /** @hidden */
  76405. _instanceData?: {
  76406. babylonSourceMesh: Mesh;
  76407. promise: Promise<any>;
  76408. };
  76409. }
  76410. /**
  76411. * Loader interface with additional members.
  76412. */
  76413. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76414. /**
  76415. * The parent glTF node.
  76416. */
  76417. parent?: INode;
  76418. /** @hidden */
  76419. _babylonTransformNode?: TransformNode;
  76420. /** @hidden */
  76421. _primitiveBabylonMeshes?: AbstractMesh[];
  76422. /** @hidden */
  76423. _babylonBones?: Bone[];
  76424. /** @hidden */
  76425. _numMorphTargets?: number;
  76426. }
  76427. /** @hidden */
  76428. export interface _ISamplerData {
  76429. noMipMaps: boolean;
  76430. samplingMode: number;
  76431. wrapU: number;
  76432. wrapV: number;
  76433. }
  76434. /**
  76435. * Loader interface with additional members.
  76436. */
  76437. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76438. /** @hidden */
  76439. _data?: _ISamplerData;
  76440. }
  76441. /**
  76442. * Loader interface with additional members.
  76443. */
  76444. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76445. }
  76446. /**
  76447. * Loader interface with additional members.
  76448. */
  76449. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76450. /** @hidden */
  76451. _data?: {
  76452. babylonSkeleton: Skeleton;
  76453. promise: Promise<void>;
  76454. };
  76455. }
  76456. /**
  76457. * Loader interface with additional members.
  76458. */
  76459. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76460. }
  76461. /**
  76462. * Loader interface with additional members.
  76463. */
  76464. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76465. }
  76466. /**
  76467. * Loader interface with additional members.
  76468. */
  76469. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76470. accessors?: IAccessor[];
  76471. animations?: IAnimation[];
  76472. buffers?: IBuffer[];
  76473. bufferViews?: IBufferView[];
  76474. cameras?: ICamera[];
  76475. images?: IImage[];
  76476. materials?: IMaterial[];
  76477. meshes?: IMesh[];
  76478. nodes?: INode[];
  76479. samplers?: ISampler[];
  76480. scenes?: IScene[];
  76481. skins?: ISkin[];
  76482. textures?: ITexture[];
  76483. }
  76484. }
  76485. declare module BABYLON.GLTF2 {
  76486. /**
  76487. * Interface for a glTF loader extension.
  76488. */
  76489. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76490. /**
  76491. * Called after the loader state changes to LOADING.
  76492. */
  76493. onLoading?(): void;
  76494. /**
  76495. * Called after the loader state changes to READY.
  76496. */
  76497. onReady?(): void;
  76498. /**
  76499. * Define this method to modify the default behavior when loading scenes.
  76500. * @param context The context when loading the asset
  76501. * @param scene The glTF scene property
  76502. * @returns A promise that resolves when the load is complete or null if not handled
  76503. */
  76504. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76505. /**
  76506. * Define this method to modify the default behavior when loading nodes.
  76507. * @param context The context when loading the asset
  76508. * @param node The glTF node property
  76509. * @param assign A function called synchronously after parsing the glTF properties
  76510. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76511. */
  76512. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76513. /**
  76514. * Define this method to modify the default behavior when loading cameras.
  76515. * @param context The context when loading the asset
  76516. * @param camera The glTF camera property
  76517. * @param assign A function called synchronously after parsing the glTF properties
  76518. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76519. */
  76520. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76521. /**
  76522. * @hidden
  76523. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76524. * @param context The context when loading the asset
  76525. * @param primitive The glTF mesh primitive property
  76526. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76527. */
  76528. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76529. /**
  76530. * @hidden
  76531. * Define this method to modify the default behavior when loading data for mesh primitives.
  76532. * @param context The context when loading the asset
  76533. * @param name The mesh name when loading the asset
  76534. * @param node The glTF node when loading the asset
  76535. * @param mesh The glTF mesh when loading the asset
  76536. * @param primitive The glTF mesh primitive property
  76537. * @param assign A function called synchronously after parsing the glTF properties
  76538. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76539. */
  76540. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76541. /**
  76542. * @hidden
  76543. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76544. * @param context The context when loading the asset
  76545. * @param material The glTF material property
  76546. * @param assign A function called synchronously after parsing the glTF properties
  76547. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76548. */
  76549. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76550. /**
  76551. * Define this method to modify the default behavior when creating materials.
  76552. * @param context The context when loading the asset
  76553. * @param material The glTF material property
  76554. * @param babylonDrawMode The draw mode for the Babylon material
  76555. * @returns The Babylon material or null if not handled
  76556. */
  76557. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76558. /**
  76559. * Define this method to modify the default behavior when loading material properties.
  76560. * @param context The context when loading the asset
  76561. * @param material The glTF material property
  76562. * @param babylonMaterial The Babylon material
  76563. * @returns A promise that resolves when the load is complete or null if not handled
  76564. */
  76565. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76566. /**
  76567. * Define this method to modify the default behavior when loading texture infos.
  76568. * @param context The context when loading the asset
  76569. * @param textureInfo The glTF texture info property
  76570. * @param assign A function called synchronously after parsing the glTF properties
  76571. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76572. */
  76573. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76574. /**
  76575. * @hidden
  76576. * Define this method to modify the default behavior when loading textures.
  76577. * @param context The context when loading the asset
  76578. * @param texture The glTF texture property
  76579. * @param assign A function called synchronously after parsing the glTF properties
  76580. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76581. */
  76582. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76583. /**
  76584. * Define this method to modify the default behavior when loading animations.
  76585. * @param context The context when loading the asset
  76586. * @param animation The glTF animation property
  76587. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76588. */
  76589. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76590. /**
  76591. * @hidden
  76592. * Define this method to modify the default behavior when loading skins.
  76593. * @param context The context when loading the asset
  76594. * @param node The glTF node property
  76595. * @param skin The glTF skin property
  76596. * @returns A promise that resolves when the load is complete or null if not handled
  76597. */
  76598. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76599. /**
  76600. * @hidden
  76601. * Define this method to modify the default behavior when loading uris.
  76602. * @param context The context when loading the asset
  76603. * @param property The glTF property associated with the uri
  76604. * @param uri The uri to load
  76605. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76606. */
  76607. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76608. /**
  76609. * Define this method to modify the default behavior when loading buffer views.
  76610. * @param context The context when loading the asset
  76611. * @param bufferView The glTF buffer view property
  76612. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76613. */
  76614. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76615. /**
  76616. * Define this method to modify the default behavior when loading buffers.
  76617. * @param context The context when loading the asset
  76618. * @param buffer The glTF buffer property
  76619. * @param byteOffset The byte offset to load
  76620. * @param byteLength The byte length to load
  76621. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76622. */
  76623. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76624. }
  76625. }
  76626. declare module BABYLON.GLTF2 {
  76627. /**
  76628. * Helper class for working with arrays when loading the glTF asset
  76629. */
  76630. export class ArrayItem {
  76631. /**
  76632. * Gets an item from the given array.
  76633. * @param context The context when loading the asset
  76634. * @param array The array to get the item from
  76635. * @param index The index to the array
  76636. * @returns The array item
  76637. */
  76638. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76639. /**
  76640. * Assign an `index` field to each item of the given array.
  76641. * @param array The array of items
  76642. */
  76643. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76644. }
  76645. /**
  76646. * The glTF 2.0 loader
  76647. */
  76648. export class GLTFLoader implements IGLTFLoader {
  76649. /** @hidden */
  76650. _completePromises: Promise<any>[];
  76651. /** @hidden */
  76652. _forAssetContainer: boolean;
  76653. /** Storage */
  76654. _babylonLights: Light[];
  76655. private _disposed;
  76656. private _parent;
  76657. private _state;
  76658. private _extensions;
  76659. private _rootUrl;
  76660. private _fileName;
  76661. private _uniqueRootUrl;
  76662. private _gltf;
  76663. private _bin;
  76664. private _babylonScene;
  76665. private _rootBabylonMesh;
  76666. private _defaultBabylonMaterialData;
  76667. private _progressCallback?;
  76668. private _requests;
  76669. private static _RegisteredExtensions;
  76670. /**
  76671. * The default glTF sampler.
  76672. */
  76673. static readonly DefaultSampler: ISampler;
  76674. /**
  76675. * Registers a loader extension.
  76676. * @param name The name of the loader extension.
  76677. * @param factory The factory function that creates the loader extension.
  76678. */
  76679. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76680. /**
  76681. * Unregisters a loader extension.
  76682. * @param name The name of the loader extension.
  76683. * @returns A boolean indicating whether the extension has been unregistered
  76684. */
  76685. static UnregisterExtension(name: string): boolean;
  76686. /**
  76687. * The loader state.
  76688. */
  76689. get state(): Nullable<GLTFLoaderState>;
  76690. /**
  76691. * The object that represents the glTF JSON.
  76692. */
  76693. get gltf(): IGLTF;
  76694. /**
  76695. * The BIN chunk of a binary glTF.
  76696. */
  76697. get bin(): Nullable<IDataBuffer>;
  76698. /**
  76699. * The parent file loader.
  76700. */
  76701. get parent(): GLTFFileLoader;
  76702. /**
  76703. * The Babylon scene when loading the asset.
  76704. */
  76705. get babylonScene(): Scene;
  76706. /**
  76707. * The root Babylon mesh when loading the asset.
  76708. */
  76709. get rootBabylonMesh(): Mesh;
  76710. /** @hidden */
  76711. constructor(parent: GLTFFileLoader);
  76712. /** @hidden */
  76713. dispose(): void;
  76714. /** @hidden */
  76715. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76716. /** @hidden */
  76717. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76718. private _loadAsync;
  76719. private _loadData;
  76720. private _setupData;
  76721. private _loadExtensions;
  76722. private _checkExtensions;
  76723. private _setState;
  76724. private _createRootNode;
  76725. /**
  76726. * Loads a glTF scene.
  76727. * @param context The context when loading the asset
  76728. * @param scene The glTF scene property
  76729. * @returns A promise that resolves when the load is complete
  76730. */
  76731. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76732. private _forEachPrimitive;
  76733. private _getMeshes;
  76734. private _getTransformNodes;
  76735. private _getSkeletons;
  76736. private _getAnimationGroups;
  76737. private _startAnimations;
  76738. /**
  76739. * Loads a glTF node.
  76740. * @param context The context when loading the asset
  76741. * @param node The glTF node property
  76742. * @param assign A function called synchronously after parsing the glTF properties
  76743. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76744. */
  76745. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76746. private _loadMeshAsync;
  76747. /**
  76748. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76749. * @param context The context when loading the asset
  76750. * @param name The mesh name when loading the asset
  76751. * @param node The glTF node when loading the asset
  76752. * @param mesh The glTF mesh when loading the asset
  76753. * @param primitive The glTF mesh primitive property
  76754. * @param assign A function called synchronously after parsing the glTF properties
  76755. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76756. */
  76757. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76758. private _loadVertexDataAsync;
  76759. private _createMorphTargets;
  76760. private _loadMorphTargetsAsync;
  76761. private _loadMorphTargetVertexDataAsync;
  76762. private static _LoadTransform;
  76763. private _loadSkinAsync;
  76764. private _loadBones;
  76765. private _loadBone;
  76766. private _loadSkinInverseBindMatricesDataAsync;
  76767. private _updateBoneMatrices;
  76768. private _getNodeMatrix;
  76769. /**
  76770. * Loads a glTF camera.
  76771. * @param context The context when loading the asset
  76772. * @param camera The glTF camera property
  76773. * @param assign A function called synchronously after parsing the glTF properties
  76774. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76775. */
  76776. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76777. private _loadAnimationsAsync;
  76778. /**
  76779. * Loads a glTF animation.
  76780. * @param context The context when loading the asset
  76781. * @param animation The glTF animation property
  76782. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76783. */
  76784. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76785. /**
  76786. * @hidden Loads a glTF animation channel.
  76787. * @param context The context when loading the asset
  76788. * @param animationContext The context of the animation when loading the asset
  76789. * @param animation The glTF animation property
  76790. * @param channel The glTF animation channel property
  76791. * @param babylonAnimationGroup The babylon animation group property
  76792. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76793. * @returns A void promise when the channel load is complete
  76794. */
  76795. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76796. private _loadAnimationSamplerAsync;
  76797. private _loadBufferAsync;
  76798. /**
  76799. * Loads a glTF buffer view.
  76800. * @param context The context when loading the asset
  76801. * @param bufferView The glTF buffer view property
  76802. * @returns A promise that resolves with the loaded data when the load is complete
  76803. */
  76804. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76805. private _loadAccessorAsync;
  76806. /** @hidden */
  76807. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76808. private _loadIndicesAccessorAsync;
  76809. private _loadVertexBufferViewAsync;
  76810. private _loadVertexAccessorAsync;
  76811. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76812. /** @hidden */
  76813. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76814. private _createDefaultMaterial;
  76815. /**
  76816. * Creates a Babylon material from a glTF material.
  76817. * @param context The context when loading the asset
  76818. * @param material The glTF material property
  76819. * @param babylonDrawMode The draw mode for the Babylon material
  76820. * @returns The Babylon material
  76821. */
  76822. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76823. /**
  76824. * Loads properties from a glTF material into a Babylon material.
  76825. * @param context The context when loading the asset
  76826. * @param material The glTF material property
  76827. * @param babylonMaterial The Babylon material
  76828. * @returns A promise that resolves when the load is complete
  76829. */
  76830. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76831. /**
  76832. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76833. * @param context The context when loading the asset
  76834. * @param material The glTF material property
  76835. * @param babylonMaterial The Babylon material
  76836. * @returns A promise that resolves when the load is complete
  76837. */
  76838. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76839. /**
  76840. * Loads the alpha properties from a glTF material into a Babylon material.
  76841. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76842. * @param context The context when loading the asset
  76843. * @param material The glTF material property
  76844. * @param babylonMaterial The Babylon material
  76845. */
  76846. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76847. /**
  76848. * Loads a glTF texture info.
  76849. * @param context The context when loading the asset
  76850. * @param textureInfo The glTF texture info property
  76851. * @param assign A function called synchronously after parsing the glTF properties
  76852. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76853. */
  76854. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76855. /** @hidden */
  76856. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76857. /** @hidden */
  76858. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76859. private _loadSampler;
  76860. /**
  76861. * Loads a glTF image.
  76862. * @param context The context when loading the asset
  76863. * @param image The glTF image property
  76864. * @returns A promise that resolves with the loaded data when the load is complete
  76865. */
  76866. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76867. /**
  76868. * Loads a glTF uri.
  76869. * @param context The context when loading the asset
  76870. * @param property The glTF property associated with the uri
  76871. * @param uri The base64 or relative uri
  76872. * @returns A promise that resolves with the loaded data when the load is complete
  76873. */
  76874. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76875. private _onProgress;
  76876. /**
  76877. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76878. * @param babylonObject the Babylon object with metadata
  76879. * @param pointer the JSON pointer
  76880. */
  76881. static AddPointerMetadata(babylonObject: {
  76882. metadata: any;
  76883. }, pointer: string): void;
  76884. private static _GetTextureWrapMode;
  76885. private static _GetTextureSamplingMode;
  76886. private static _GetTypedArrayConstructor;
  76887. private static _GetTypedArray;
  76888. private static _GetNumComponents;
  76889. private static _ValidateUri;
  76890. private static _GetDrawMode;
  76891. private _compileMaterialsAsync;
  76892. private _compileShadowGeneratorsAsync;
  76893. private _forEachExtensions;
  76894. private _applyExtensions;
  76895. private _extensionsOnLoading;
  76896. private _extensionsOnReady;
  76897. private _extensionsLoadSceneAsync;
  76898. private _extensionsLoadNodeAsync;
  76899. private _extensionsLoadCameraAsync;
  76900. private _extensionsLoadVertexDataAsync;
  76901. private _extensionsLoadMeshPrimitiveAsync;
  76902. private _extensionsLoadMaterialAsync;
  76903. private _extensionsCreateMaterial;
  76904. private _extensionsLoadMaterialPropertiesAsync;
  76905. private _extensionsLoadTextureInfoAsync;
  76906. private _extensionsLoadTextureAsync;
  76907. private _extensionsLoadAnimationAsync;
  76908. private _extensionsLoadSkinAsync;
  76909. private _extensionsLoadUriAsync;
  76910. private _extensionsLoadBufferViewAsync;
  76911. private _extensionsLoadBufferAsync;
  76912. /**
  76913. * Helper method called by a loader extension to load an glTF extension.
  76914. * @param context The context when loading the asset
  76915. * @param property The glTF property to load the extension from
  76916. * @param extensionName The name of the extension to load
  76917. * @param actionAsync The action to run
  76918. * @returns The promise returned by actionAsync or null if the extension does not exist
  76919. */
  76920. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76921. /**
  76922. * Helper method called by a loader extension to load a glTF extra.
  76923. * @param context The context when loading the asset
  76924. * @param property The glTF property to load the extra from
  76925. * @param extensionName The name of the extension to load
  76926. * @param actionAsync The action to run
  76927. * @returns The promise returned by actionAsync or null if the extra does not exist
  76928. */
  76929. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76930. /**
  76931. * Checks for presence of an extension.
  76932. * @param name The name of the extension to check
  76933. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76934. */
  76935. isExtensionUsed(name: string): boolean;
  76936. /**
  76937. * Increments the indentation level and logs a message.
  76938. * @param message The message to log
  76939. */
  76940. logOpen(message: string): void;
  76941. /**
  76942. * Decrements the indentation level.
  76943. */
  76944. logClose(): void;
  76945. /**
  76946. * Logs a message
  76947. * @param message The message to log
  76948. */
  76949. log(message: string): void;
  76950. /**
  76951. * Starts a performance counter.
  76952. * @param counterName The name of the performance counter
  76953. */
  76954. startPerformanceCounter(counterName: string): void;
  76955. /**
  76956. * Ends a performance counter.
  76957. * @param counterName The name of the performance counter
  76958. */
  76959. endPerformanceCounter(counterName: string): void;
  76960. }
  76961. }
  76962. declare module BABYLON.GLTF2.Loader.Extensions {
  76963. /**
  76964. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76965. */
  76966. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76967. /**
  76968. * The name of this extension.
  76969. */
  76970. readonly name: string;
  76971. /**
  76972. * Defines whether this extension is enabled.
  76973. */
  76974. enabled: boolean;
  76975. private _loader;
  76976. private _lights?;
  76977. /** @hidden */
  76978. constructor(loader: GLTFLoader);
  76979. /** @hidden */
  76980. dispose(): void;
  76981. /** @hidden */
  76982. onLoading(): void;
  76983. /** @hidden */
  76984. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76985. private _loadLightAsync;
  76986. }
  76987. }
  76988. declare module BABYLON.GLTF2.Loader.Extensions {
  76989. /**
  76990. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76991. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  76992. * !!! Experimental Extension Subject to Changes !!!
  76993. */
  76994. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  76995. /**
  76996. * The name of this extension.
  76997. */
  76998. readonly name: string;
  76999. /**
  77000. * Defines whether this extension is enabled.
  77001. */
  77002. enabled: boolean;
  77003. private _loader;
  77004. /** @hidden */
  77005. constructor(loader: GLTFLoader);
  77006. /** @hidden */
  77007. dispose(): void;
  77008. /** @hidden */
  77009. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77010. }
  77011. }
  77012. declare module BABYLON.GLTF2.Loader.Extensions {
  77013. /**
  77014. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  77015. */
  77016. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  77017. /**
  77018. * The name of this extension.
  77019. */
  77020. readonly name: string;
  77021. /**
  77022. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  77023. */
  77024. dracoCompression?: DracoCompression;
  77025. /**
  77026. * Defines whether this extension is enabled.
  77027. */
  77028. enabled: boolean;
  77029. private _loader;
  77030. /** @hidden */
  77031. constructor(loader: GLTFLoader);
  77032. /** @hidden */
  77033. dispose(): void;
  77034. /** @hidden */
  77035. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77036. }
  77037. }
  77038. declare module BABYLON.GLTF2.Loader.Extensions {
  77039. /**
  77040. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  77041. */
  77042. export class KHR_lights implements IGLTFLoaderExtension {
  77043. /**
  77044. * The name of this extension.
  77045. */
  77046. readonly name: string;
  77047. /**
  77048. * Defines whether this extension is enabled.
  77049. */
  77050. enabled: boolean;
  77051. private _loader;
  77052. private _lights?;
  77053. /** @hidden */
  77054. constructor(loader: GLTFLoader);
  77055. /** @hidden */
  77056. dispose(): void;
  77057. /** @hidden */
  77058. onLoading(): void;
  77059. /** @hidden */
  77060. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77061. }
  77062. }
  77063. declare module BABYLON.GLTF2.Loader.Extensions {
  77064. /**
  77065. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  77066. */
  77067. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  77068. /**
  77069. * The name of this extension.
  77070. */
  77071. readonly name: string;
  77072. /**
  77073. * Defines whether this extension is enabled.
  77074. */
  77075. enabled: boolean;
  77076. /**
  77077. * Defines a number that determines the order the extensions are applied.
  77078. */
  77079. order: number;
  77080. private _loader;
  77081. /** @hidden */
  77082. constructor(loader: GLTFLoader);
  77083. /** @hidden */
  77084. dispose(): void;
  77085. /** @hidden */
  77086. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77087. private _loadSpecularGlossinessPropertiesAsync;
  77088. }
  77089. }
  77090. declare module BABYLON.GLTF2.Loader.Extensions {
  77091. /**
  77092. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77093. */
  77094. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77095. /**
  77096. * The name of this extension.
  77097. */
  77098. readonly name: string;
  77099. /**
  77100. * Defines whether this extension is enabled.
  77101. */
  77102. enabled: boolean;
  77103. /**
  77104. * Defines a number that determines the order the extensions are applied.
  77105. */
  77106. order: number;
  77107. private _loader;
  77108. /** @hidden */
  77109. constructor(loader: GLTFLoader);
  77110. /** @hidden */
  77111. dispose(): void;
  77112. /** @hidden */
  77113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77114. private _loadUnlitPropertiesAsync;
  77115. }
  77116. }
  77117. declare module BABYLON.GLTF2.Loader.Extensions {
  77118. /**
  77119. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77120. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77121. * !!! Experimental Extension Subject to Changes !!!
  77122. */
  77123. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77124. /**
  77125. * The name of this extension.
  77126. */
  77127. readonly name: string;
  77128. /**
  77129. * Defines whether this extension is enabled.
  77130. */
  77131. enabled: boolean;
  77132. /**
  77133. * Defines a number that determines the order the extensions are applied.
  77134. */
  77135. order: number;
  77136. private _loader;
  77137. /** @hidden */
  77138. constructor(loader: GLTFLoader);
  77139. /** @hidden */
  77140. dispose(): void;
  77141. /** @hidden */
  77142. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77143. private _loadClearCoatPropertiesAsync;
  77144. }
  77145. }
  77146. declare module BABYLON.GLTF2.Loader.Extensions {
  77147. /**
  77148. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77149. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77150. * !!! Experimental Extension Subject to Changes !!!
  77151. */
  77152. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77153. /**
  77154. * The name of this extension.
  77155. */
  77156. readonly name: string;
  77157. /**
  77158. * Defines whether this extension is enabled.
  77159. */
  77160. enabled: boolean;
  77161. /**
  77162. * Defines a number that determines the order the extensions are applied.
  77163. */
  77164. order: number;
  77165. private _loader;
  77166. /** @hidden */
  77167. constructor(loader: GLTFLoader);
  77168. /** @hidden */
  77169. dispose(): void;
  77170. /** @hidden */
  77171. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77172. private _loadSheenPropertiesAsync;
  77173. }
  77174. }
  77175. declare module BABYLON.GLTF2.Loader.Extensions {
  77176. /**
  77177. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77178. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77179. * !!! Experimental Extension Subject to Changes !!!
  77180. */
  77181. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77182. /**
  77183. * The name of this extension.
  77184. */
  77185. readonly name: string;
  77186. /**
  77187. * Defines whether this extension is enabled.
  77188. */
  77189. enabled: boolean;
  77190. /**
  77191. * Defines a number that determines the order the extensions are applied.
  77192. */
  77193. order: number;
  77194. private _loader;
  77195. /** @hidden */
  77196. constructor(loader: GLTFLoader);
  77197. /** @hidden */
  77198. dispose(): void;
  77199. /** @hidden */
  77200. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77201. private _loadSpecularPropertiesAsync;
  77202. }
  77203. }
  77204. declare module BABYLON.GLTF2.Loader.Extensions {
  77205. /**
  77206. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77207. */
  77208. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77209. /**
  77210. * The name of this extension.
  77211. */
  77212. readonly name: string;
  77213. /**
  77214. * Defines whether this extension is enabled.
  77215. */
  77216. enabled: boolean;
  77217. /** @hidden */
  77218. constructor(loader: GLTFLoader);
  77219. /** @hidden */
  77220. dispose(): void;
  77221. }
  77222. }
  77223. declare module BABYLON.GLTF2.Loader.Extensions {
  77224. /**
  77225. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77226. * !!! Experimental Extension Subject to Changes !!!
  77227. */
  77228. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77229. /** The name of this extension. */
  77230. readonly name: string;
  77231. /** Defines whether this extension is enabled. */
  77232. enabled: boolean;
  77233. private _loader;
  77234. /** @hidden */
  77235. constructor(loader: GLTFLoader);
  77236. /** @hidden */
  77237. dispose(): void;
  77238. /** @hidden */
  77239. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77240. }
  77241. }
  77242. declare module BABYLON.GLTF2.Loader.Extensions {
  77243. /**
  77244. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77245. */
  77246. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77247. /**
  77248. * The name of this extension.
  77249. */
  77250. readonly name: string;
  77251. /**
  77252. * Defines whether this extension is enabled.
  77253. */
  77254. enabled: boolean;
  77255. private _loader;
  77256. /** @hidden */
  77257. constructor(loader: GLTFLoader);
  77258. /** @hidden */
  77259. dispose(): void;
  77260. /** @hidden */
  77261. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77262. }
  77263. }
  77264. declare module BABYLON.GLTF2.Loader.Extensions {
  77265. /**
  77266. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77267. */
  77268. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77269. /**
  77270. * The name of this extension.
  77271. */
  77272. readonly name: string;
  77273. /**
  77274. * Defines whether this extension is enabled.
  77275. */
  77276. enabled: boolean;
  77277. private _loader;
  77278. private _clips;
  77279. private _emitters;
  77280. /** @hidden */
  77281. constructor(loader: GLTFLoader);
  77282. /** @hidden */
  77283. dispose(): void;
  77284. /** @hidden */
  77285. onLoading(): void;
  77286. /** @hidden */
  77287. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77288. /** @hidden */
  77289. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77290. /** @hidden */
  77291. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77292. private _loadClipAsync;
  77293. private _loadEmitterAsync;
  77294. private _getEventAction;
  77295. private _loadAnimationEventAsync;
  77296. }
  77297. }
  77298. declare module BABYLON.GLTF2.Loader.Extensions {
  77299. /**
  77300. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77301. */
  77302. export class MSFT_lod implements IGLTFLoaderExtension {
  77303. /**
  77304. * The name of this extension.
  77305. */
  77306. readonly name: string;
  77307. /**
  77308. * Defines whether this extension is enabled.
  77309. */
  77310. enabled: boolean;
  77311. /**
  77312. * Defines a number that determines the order the extensions are applied.
  77313. */
  77314. order: number;
  77315. /**
  77316. * Maximum number of LODs to load, starting from the lowest LOD.
  77317. */
  77318. maxLODsToLoad: number;
  77319. /**
  77320. * Observable raised when all node LODs of one level are loaded.
  77321. * The event data is the index of the loaded LOD starting from zero.
  77322. * Dispose the loader to cancel the loading of the next level of LODs.
  77323. */
  77324. onNodeLODsLoadedObservable: Observable<number>;
  77325. /**
  77326. * Observable raised when all material LODs of one level are loaded.
  77327. * The event data is the index of the loaded LOD starting from zero.
  77328. * Dispose the loader to cancel the loading of the next level of LODs.
  77329. */
  77330. onMaterialLODsLoadedObservable: Observable<number>;
  77331. private _loader;
  77332. private _nodeIndexLOD;
  77333. private _nodeSignalLODs;
  77334. private _nodePromiseLODs;
  77335. private _materialIndexLOD;
  77336. private _materialSignalLODs;
  77337. private _materialPromiseLODs;
  77338. private _indexLOD;
  77339. private _bufferLODs;
  77340. /** @hidden */
  77341. constructor(loader: GLTFLoader);
  77342. /** @hidden */
  77343. dispose(): void;
  77344. /** @hidden */
  77345. onReady(): void;
  77346. /** @hidden */
  77347. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77348. /** @hidden */
  77349. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77350. /** @hidden */
  77351. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77352. /** @hidden */
  77353. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77354. /** @hidden */
  77355. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77356. private _loadBufferLOD;
  77357. /**
  77358. * Gets an array of LOD properties from lowest to highest.
  77359. */
  77360. private _getLODs;
  77361. private _disposeTransformNode;
  77362. private _disposeMaterials;
  77363. }
  77364. }
  77365. declare module BABYLON.GLTF2.Loader.Extensions {
  77366. /** @hidden */
  77367. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77368. readonly name: string;
  77369. enabled: boolean;
  77370. private _loader;
  77371. constructor(loader: GLTFLoader);
  77372. dispose(): void;
  77373. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77374. }
  77375. }
  77376. declare module BABYLON.GLTF2.Loader.Extensions {
  77377. /** @hidden */
  77378. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77379. readonly name: string;
  77380. enabled: boolean;
  77381. private _loader;
  77382. constructor(loader: GLTFLoader);
  77383. dispose(): void;
  77384. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77385. }
  77386. }
  77387. declare module BABYLON.GLTF2.Loader.Extensions {
  77388. /**
  77389. * Store glTF extras (if present) in BJS objects' metadata
  77390. */
  77391. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77392. /**
  77393. * The name of this extension.
  77394. */
  77395. readonly name: string;
  77396. /**
  77397. * Defines whether this extension is enabled.
  77398. */
  77399. enabled: boolean;
  77400. private _loader;
  77401. private _assignExtras;
  77402. /** @hidden */
  77403. constructor(loader: GLTFLoader);
  77404. /** @hidden */
  77405. dispose(): void;
  77406. /** @hidden */
  77407. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77408. /** @hidden */
  77409. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77410. /** @hidden */
  77411. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77412. }
  77413. }
  77414. declare module BABYLON {
  77415. /**
  77416. * Class reading and parsing the MTL file bundled with the obj file.
  77417. */
  77418. export class MTLFileLoader {
  77419. /**
  77420. * Invert Y-Axis of referenced textures on load
  77421. */
  77422. static INVERT_TEXTURE_Y: boolean;
  77423. /**
  77424. * All material loaded from the mtl will be set here
  77425. */
  77426. materials: StandardMaterial[];
  77427. /**
  77428. * This function will read the mtl file and create each material described inside
  77429. * This function could be improve by adding :
  77430. * -some component missing (Ni, Tf...)
  77431. * -including the specific options available
  77432. *
  77433. * @param scene defines the scene the material will be created in
  77434. * @param data defines the mtl data to parse
  77435. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77436. * @param forAssetContainer defines if the material should be registered in the scene
  77437. */
  77438. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77439. /**
  77440. * Gets the texture for the material.
  77441. *
  77442. * If the material is imported from input file,
  77443. * We sanitize the url to ensure it takes the textre from aside the material.
  77444. *
  77445. * @param rootUrl The root url to load from
  77446. * @param value The value stored in the mtl
  77447. * @return The Texture
  77448. */
  77449. private static _getTexture;
  77450. }
  77451. }
  77452. declare module BABYLON {
  77453. /**
  77454. * Options for loading OBJ/MTL files
  77455. */
  77456. type MeshLoadOptions = {
  77457. /**
  77458. * Defines if UVs are optimized by default during load.
  77459. */
  77460. OptimizeWithUV: boolean;
  77461. /**
  77462. * Defines custom scaling of UV coordinates of loaded meshes.
  77463. */
  77464. UVScaling: Vector2;
  77465. /**
  77466. * Invert model on y-axis (does a model scaling inversion)
  77467. */
  77468. InvertY: boolean;
  77469. /**
  77470. * Invert Y-Axis of referenced textures on load
  77471. */
  77472. InvertTextureY: boolean;
  77473. /**
  77474. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77475. */
  77476. ImportVertexColors: boolean;
  77477. /**
  77478. * Compute the normals for the model, even if normals are present in the file.
  77479. */
  77480. ComputeNormals: boolean;
  77481. /**
  77482. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77483. */
  77484. SkipMaterials: boolean;
  77485. /**
  77486. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77487. */
  77488. MaterialLoadingFailsSilently: boolean;
  77489. };
  77490. /**
  77491. * OBJ file type loader.
  77492. * This is a babylon scene loader plugin.
  77493. */
  77494. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77495. /**
  77496. * Defines if UVs are optimized by default during load.
  77497. */
  77498. static OPTIMIZE_WITH_UV: boolean;
  77499. /**
  77500. * Invert model on y-axis (does a model scaling inversion)
  77501. */
  77502. static INVERT_Y: boolean;
  77503. /**
  77504. * Invert Y-Axis of referenced textures on load
  77505. */
  77506. static get INVERT_TEXTURE_Y(): boolean;
  77507. static set INVERT_TEXTURE_Y(value: boolean);
  77508. /**
  77509. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77510. */
  77511. static IMPORT_VERTEX_COLORS: boolean;
  77512. /**
  77513. * Compute the normals for the model, even if normals are present in the file.
  77514. */
  77515. static COMPUTE_NORMALS: boolean;
  77516. /**
  77517. * Defines custom scaling of UV coordinates of loaded meshes.
  77518. */
  77519. static UV_SCALING: Vector2;
  77520. /**
  77521. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77522. */
  77523. static SKIP_MATERIALS: boolean;
  77524. /**
  77525. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77526. *
  77527. * Defaults to true for backwards compatibility.
  77528. */
  77529. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77530. /**
  77531. * Defines the name of the plugin.
  77532. */
  77533. name: string;
  77534. /**
  77535. * Defines the extension the plugin is able to load.
  77536. */
  77537. extensions: string;
  77538. /** @hidden */
  77539. obj: RegExp;
  77540. /** @hidden */
  77541. group: RegExp;
  77542. /** @hidden */
  77543. mtllib: RegExp;
  77544. /** @hidden */
  77545. usemtl: RegExp;
  77546. /** @hidden */
  77547. smooth: RegExp;
  77548. /** @hidden */
  77549. vertexPattern: RegExp;
  77550. /** @hidden */
  77551. normalPattern: RegExp;
  77552. /** @hidden */
  77553. uvPattern: RegExp;
  77554. /** @hidden */
  77555. facePattern1: RegExp;
  77556. /** @hidden */
  77557. facePattern2: RegExp;
  77558. /** @hidden */
  77559. facePattern3: RegExp;
  77560. /** @hidden */
  77561. facePattern4: RegExp;
  77562. /** @hidden */
  77563. facePattern5: RegExp;
  77564. private _forAssetContainer;
  77565. private _meshLoadOptions;
  77566. /**
  77567. * Creates loader for .OBJ files
  77568. *
  77569. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77570. */
  77571. constructor(meshLoadOptions?: MeshLoadOptions);
  77572. private static get currentMeshLoadOptions();
  77573. /**
  77574. * Calls synchronously the MTL file attached to this obj.
  77575. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77576. * Without this function materials are not displayed in the first frame (but displayed after).
  77577. * In consequence it is impossible to get material information in your HTML file
  77578. *
  77579. * @param url The URL of the MTL file
  77580. * @param rootUrl
  77581. * @param onSuccess Callback function to be called when the MTL file is loaded
  77582. * @private
  77583. */
  77584. private _loadMTL;
  77585. /**
  77586. * Instantiates a OBJ file loader plugin.
  77587. * @returns the created plugin
  77588. */
  77589. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77590. /**
  77591. * If the data string can be loaded directly.
  77592. *
  77593. * @param data string containing the file data
  77594. * @returns if the data can be loaded directly
  77595. */
  77596. canDirectLoad(data: string): boolean;
  77597. /**
  77598. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77599. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77600. * @param scene the scene the meshes should be added to
  77601. * @param data the OBJ data to load
  77602. * @param rootUrl root url to load from
  77603. * @param onProgress event that fires when loading progress has occured
  77604. * @param fileName Defines the name of the file to load
  77605. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77606. */
  77607. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77608. meshes: AbstractMesh[];
  77609. particleSystems: IParticleSystem[];
  77610. skeletons: Skeleton[];
  77611. animationGroups: AnimationGroup[];
  77612. }>;
  77613. /**
  77614. * Imports all objects from the loaded OBJ data and adds them to the scene
  77615. * @param scene the scene the objects should be added to
  77616. * @param data the OBJ data to load
  77617. * @param rootUrl root url to load from
  77618. * @param onProgress event that fires when loading progress has occured
  77619. * @param fileName Defines the name of the file to load
  77620. * @returns a promise which completes when objects have been loaded to the scene
  77621. */
  77622. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77623. /**
  77624. * Load into an asset container.
  77625. * @param scene The scene to load into
  77626. * @param data The data to import
  77627. * @param rootUrl The root url for scene and resources
  77628. * @param onProgress The callback when the load progresses
  77629. * @param fileName Defines the name of the file to load
  77630. * @returns The loaded asset container
  77631. */
  77632. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77633. /**
  77634. * Read the OBJ file and create an Array of meshes.
  77635. * Each mesh contains all information given by the OBJ and the MTL file.
  77636. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77637. *
  77638. * @param meshesNames
  77639. * @param scene Scene The scene where are displayed the data
  77640. * @param data String The content of the obj file
  77641. * @param rootUrl String The path to the folder
  77642. * @returns Array<AbstractMesh>
  77643. * @private
  77644. */
  77645. private _parseSolid;
  77646. }
  77647. }
  77648. declare module BABYLON {
  77649. /**
  77650. * STL file type loader.
  77651. * This is a babylon scene loader plugin.
  77652. */
  77653. export class STLFileLoader implements ISceneLoaderPlugin {
  77654. /** @hidden */
  77655. solidPattern: RegExp;
  77656. /** @hidden */
  77657. facetsPattern: RegExp;
  77658. /** @hidden */
  77659. normalPattern: RegExp;
  77660. /** @hidden */
  77661. vertexPattern: RegExp;
  77662. /**
  77663. * Defines the name of the plugin.
  77664. */
  77665. name: string;
  77666. /**
  77667. * Defines the extensions the stl loader is able to load.
  77668. * force data to come in as an ArrayBuffer
  77669. * we'll convert to string if it looks like it's an ASCII .stl
  77670. */
  77671. extensions: ISceneLoaderPluginExtensions;
  77672. /**
  77673. * Import meshes into a scene.
  77674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77675. * @param scene The scene to import into
  77676. * @param data The data to import
  77677. * @param rootUrl The root url for scene and resources
  77678. * @param meshes The meshes array to import into
  77679. * @param particleSystems The particle systems array to import into
  77680. * @param skeletons The skeletons array to import into
  77681. * @param onError The callback when import fails
  77682. * @returns True if successful or false otherwise
  77683. */
  77684. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77685. /**
  77686. * Load into a scene.
  77687. * @param scene The scene to load into
  77688. * @param data The data to import
  77689. * @param rootUrl The root url for scene and resources
  77690. * @param onError The callback when import fails
  77691. * @returns true if successful or false otherwise
  77692. */
  77693. load(scene: Scene, data: any, rootUrl: string): boolean;
  77694. /**
  77695. * Load into an asset container.
  77696. * @param scene The scene to load into
  77697. * @param data The data to import
  77698. * @param rootUrl The root url for scene and resources
  77699. * @param onError The callback when import fails
  77700. * @returns The loaded asset container
  77701. */
  77702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77703. private _isBinary;
  77704. private _parseBinary;
  77705. private _parseASCII;
  77706. }
  77707. }
  77708. declare module BABYLON {
  77709. /**
  77710. * Class for generating OBJ data from a Babylon scene.
  77711. */
  77712. export class OBJExport {
  77713. /**
  77714. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77715. * @param mesh defines the list of meshes to serialize
  77716. * @param materials defines if materials should be exported
  77717. * @param matlibname defines the name of the associated mtl file
  77718. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77719. * @returns the OBJ content
  77720. */
  77721. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77722. /**
  77723. * Exports the material(s) of a mesh in .MTL file format (text)
  77724. * @param mesh defines the mesh to extract the material from
  77725. * @returns the mtl content
  77726. */
  77727. static MTL(mesh: Mesh): string;
  77728. }
  77729. }
  77730. declare module BABYLON {
  77731. /** @hidden */
  77732. export var __IGLTFExporterExtension: number;
  77733. /**
  77734. * Interface for extending the exporter
  77735. * @hidden
  77736. */
  77737. export interface IGLTFExporterExtension {
  77738. /**
  77739. * The name of this extension
  77740. */
  77741. readonly name: string;
  77742. /**
  77743. * Defines whether this extension is enabled
  77744. */
  77745. enabled: boolean;
  77746. /**
  77747. * Defines whether this extension is required
  77748. */
  77749. required: boolean;
  77750. }
  77751. }
  77752. declare module BABYLON.GLTF2.Exporter {
  77753. /** @hidden */
  77754. export var __IGLTFExporterExtensionV2: number;
  77755. /**
  77756. * Interface for a glTF exporter extension
  77757. * @hidden
  77758. */
  77759. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77760. /**
  77761. * Define this method to modify the default behavior before exporting a texture
  77762. * @param context The context when loading the asset
  77763. * @param babylonTexture The Babylon.js texture
  77764. * @param mimeType The mime-type of the generated image
  77765. * @returns A promise that resolves with the exported texture
  77766. */
  77767. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77768. /**
  77769. * Define this method to get notified when a texture info is created
  77770. * @param context The context when loading the asset
  77771. * @param textureInfo The glTF texture info
  77772. * @param babylonTexture The Babylon.js texture
  77773. */
  77774. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77775. /**
  77776. * Define this method to modify the default behavior when exporting texture info
  77777. * @param context The context when loading the asset
  77778. * @param meshPrimitive glTF mesh primitive
  77779. * @param babylonSubMesh Babylon submesh
  77780. * @param binaryWriter glTF serializer binary writer instance
  77781. * @returns nullable IMeshPrimitive promise
  77782. */
  77783. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77784. /**
  77785. * Define this method to modify the default behavior when exporting a node
  77786. * @param context The context when exporting the node
  77787. * @param node glTF node
  77788. * @param babylonNode BabylonJS node
  77789. * @returns nullable INode promise
  77790. */
  77791. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77792. [key: number]: number;
  77793. }): Promise<Nullable<INode>>;
  77794. /**
  77795. * Define this method to modify the default behavior when exporting a material
  77796. * @param material glTF material
  77797. * @param babylonMaterial BabylonJS material
  77798. * @returns nullable IMaterial promise
  77799. */
  77800. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77801. /**
  77802. * Define this method to return additional textures to export from a material
  77803. * @param material glTF material
  77804. * @param babylonMaterial BabylonJS material
  77805. * @returns List of textures
  77806. */
  77807. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77808. /** Gets a boolean indicating that this extension was used */
  77809. wasUsed: boolean;
  77810. /** Gets a boolean indicating that this extension is required for the file to work */
  77811. required: boolean;
  77812. /**
  77813. * Called after the exporter state changes to EXPORTING
  77814. */
  77815. onExporting?(): void;
  77816. }
  77817. }
  77818. declare module BABYLON.GLTF2.Exporter {
  77819. /**
  77820. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77821. * @hidden
  77822. */
  77823. export class _GLTFMaterialExporter {
  77824. /**
  77825. * Represents the dielectric specular values for R, G and B
  77826. */
  77827. private static readonly _DielectricSpecular;
  77828. /**
  77829. * Allows the maximum specular power to be defined for material calculations
  77830. */
  77831. private static readonly _MaxSpecularPower;
  77832. /**
  77833. * Mapping to store textures
  77834. */
  77835. private _textureMap;
  77836. /**
  77837. * Numeric tolerance value
  77838. */
  77839. private static readonly _Epsilon;
  77840. /**
  77841. * Reference to the glTF Exporter
  77842. */
  77843. private _exporter;
  77844. constructor(exporter: _Exporter);
  77845. /**
  77846. * Specifies if two colors are approximately equal in value
  77847. * @param color1 first color to compare to
  77848. * @param color2 second color to compare to
  77849. * @param epsilon threshold value
  77850. */
  77851. private static FuzzyEquals;
  77852. /**
  77853. * Gets the materials from a Babylon scene and converts them to glTF materials
  77854. * @param scene babylonjs scene
  77855. * @param mimeType texture mime type
  77856. * @param images array of images
  77857. * @param textures array of textures
  77858. * @param materials array of materials
  77859. * @param imageData mapping of texture names to base64 textures
  77860. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77861. */
  77862. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77863. /**
  77864. * Makes a copy of the glTF material without the texture parameters
  77865. * @param originalMaterial original glTF material
  77866. * @returns glTF material without texture parameters
  77867. */
  77868. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77869. /**
  77870. * Specifies if the material has any texture parameters present
  77871. * @param material glTF Material
  77872. * @returns boolean specifying if texture parameters are present
  77873. */
  77874. _hasTexturesPresent(material: IMaterial): boolean;
  77875. /**
  77876. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77877. * @param babylonStandardMaterial
  77878. * @returns glTF Metallic Roughness Material representation
  77879. */
  77880. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77881. /**
  77882. * Computes the metallic factor
  77883. * @param diffuse diffused value
  77884. * @param specular specular value
  77885. * @param oneMinusSpecularStrength one minus the specular strength
  77886. * @returns metallic value
  77887. */
  77888. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77889. /**
  77890. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77891. * @param glTFMaterial glTF material
  77892. * @param babylonMaterial Babylon material
  77893. */
  77894. private static _SetAlphaMode;
  77895. /**
  77896. * Converts a Babylon Standard Material to a glTF Material
  77897. * @param babylonStandardMaterial BJS Standard Material
  77898. * @param mimeType mime type to use for the textures
  77899. * @param images array of glTF image interfaces
  77900. * @param textures array of glTF texture interfaces
  77901. * @param materials array of glTF material interfaces
  77902. * @param imageData map of image file name to data
  77903. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77904. */
  77905. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77906. private _finishMaterial;
  77907. /**
  77908. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77909. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77910. * @param mimeType mime type to use for the textures
  77911. * @param images array of glTF image interfaces
  77912. * @param textures array of glTF texture interfaces
  77913. * @param materials array of glTF material interfaces
  77914. * @param imageData map of image file name to data
  77915. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77916. */
  77917. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77918. /**
  77919. * Converts an image typed array buffer to a base64 image
  77920. * @param buffer typed array buffer
  77921. * @param width width of the image
  77922. * @param height height of the image
  77923. * @param mimeType mimetype of the image
  77924. * @returns base64 image string
  77925. */
  77926. private _createBase64FromCanvasAsync;
  77927. /**
  77928. * Generates a white texture based on the specified width and height
  77929. * @param width width of the texture in pixels
  77930. * @param height height of the texture in pixels
  77931. * @param scene babylonjs scene
  77932. * @returns white texture
  77933. */
  77934. private _createWhiteTexture;
  77935. /**
  77936. * 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
  77937. * @param texture1 first texture to resize
  77938. * @param texture2 second texture to resize
  77939. * @param scene babylonjs scene
  77940. * @returns resized textures or null
  77941. */
  77942. private _resizeTexturesToSameDimensions;
  77943. /**
  77944. * Converts an array of pixels to a Float32Array
  77945. * Throws an error if the pixel format is not supported
  77946. * @param pixels - array buffer containing pixel values
  77947. * @returns Float32 of pixels
  77948. */
  77949. private _convertPixelArrayToFloat32;
  77950. /**
  77951. * Convert Specular Glossiness Textures to Metallic Roughness
  77952. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77953. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77954. * @param diffuseTexture texture used to store diffuse information
  77955. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77956. * @param factors specular glossiness material factors
  77957. * @param mimeType the mime type to use for the texture
  77958. * @returns pbr metallic roughness interface or null
  77959. */
  77960. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77961. /**
  77962. * Converts specular glossiness material properties to metallic roughness
  77963. * @param specularGlossiness interface with specular glossiness material properties
  77964. * @returns interface with metallic roughness material properties
  77965. */
  77966. private _convertSpecularGlossinessToMetallicRoughness;
  77967. /**
  77968. * Calculates the surface reflectance, independent of lighting conditions
  77969. * @param color Color source to calculate brightness from
  77970. * @returns number representing the perceived brightness, or zero if color is undefined
  77971. */
  77972. private _getPerceivedBrightness;
  77973. /**
  77974. * Returns the maximum color component value
  77975. * @param color
  77976. * @returns maximum color component value, or zero if color is null or undefined
  77977. */
  77978. private _getMaxComponent;
  77979. /**
  77980. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77981. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77982. * @param mimeType mime type to use for the textures
  77983. * @param images array of glTF image interfaces
  77984. * @param textures array of glTF texture interfaces
  77985. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77986. * @param imageData map of image file name to data
  77987. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77988. * @returns glTF PBR Metallic Roughness factors
  77989. */
  77990. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77991. private _getGLTFTextureSampler;
  77992. private _getGLTFTextureWrapMode;
  77993. private _getGLTFTextureWrapModesSampler;
  77994. /**
  77995. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77996. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77997. * @param mimeType mime type to use for the textures
  77998. * @param images array of glTF image interfaces
  77999. * @param textures array of glTF texture interfaces
  78000. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78001. * @param imageData map of image file name to data
  78002. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78003. * @returns glTF PBR Metallic Roughness factors
  78004. */
  78005. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  78006. /**
  78007. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  78008. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78009. * @param mimeType mime type to use for the textures
  78010. * @param images array of glTF image interfaces
  78011. * @param textures array of glTF texture interfaces
  78012. * @param materials array of glTF material interfaces
  78013. * @param imageData map of image file name to data
  78014. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78015. */
  78016. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  78017. private setMetallicRoughnessPbrMaterial;
  78018. private getPixelsFromTexture;
  78019. /**
  78020. * Extracts a texture from a Babylon texture into file data and glTF data
  78021. * @param babylonTexture Babylon texture to extract
  78022. * @param mimeType Mime Type of the babylonTexture
  78023. * @return glTF texture info, or null if the texture format is not supported
  78024. */
  78025. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78026. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78027. /**
  78028. * Builds a texture from base64 string
  78029. * @param base64Texture base64 texture string
  78030. * @param baseTextureName Name to use for the texture
  78031. * @param mimeType image mime type for the texture
  78032. * @param images array of images
  78033. * @param textures array of textures
  78034. * @param imageData map of image data
  78035. * @returns glTF texture info, or null if the texture format is not supported
  78036. */
  78037. private _getTextureInfoFromBase64;
  78038. }
  78039. }
  78040. declare module BABYLON {
  78041. /**
  78042. * Class for holding and downloading glTF file data
  78043. */
  78044. export class GLTFData {
  78045. /**
  78046. * Object which contains the file name as the key and its data as the value
  78047. */
  78048. glTFFiles: {
  78049. [fileName: string]: string | Blob;
  78050. };
  78051. /**
  78052. * Initializes the glTF file object
  78053. */
  78054. constructor();
  78055. /**
  78056. * Downloads the glTF data as files based on their names and data
  78057. */
  78058. downloadFiles(): void;
  78059. }
  78060. }
  78061. declare module BABYLON {
  78062. /**
  78063. * Holds a collection of exporter options and parameters
  78064. */
  78065. export interface IExportOptions {
  78066. /**
  78067. * Function which indicates whether a babylon node should be exported or not
  78068. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78069. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78070. */
  78071. shouldExportNode?(node: Node): boolean;
  78072. /**
  78073. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78074. * @param metadata source metadata to read from
  78075. * @returns the data to store to glTF node extras
  78076. */
  78077. metadataSelector?(metadata: any): any;
  78078. /**
  78079. * The sample rate to bake animation curves
  78080. */
  78081. animationSampleRate?: number;
  78082. /**
  78083. * Begin serialization without waiting for the scene to be ready
  78084. */
  78085. exportWithoutWaitingForScene?: boolean;
  78086. /**
  78087. * Indicates if coordinate system swapping root nodes should be included in export
  78088. */
  78089. includeCoordinateSystemConversionNodes?: boolean;
  78090. }
  78091. /**
  78092. * Class for generating glTF data from a Babylon scene.
  78093. */
  78094. export class GLTF2Export {
  78095. /**
  78096. * Exports the geometry of the scene to .gltf file format asynchronously
  78097. * @param scene Babylon scene with scene hierarchy information
  78098. * @param filePrefix File prefix to use when generating the glTF file
  78099. * @param options Exporter options
  78100. * @returns Returns an object with a .gltf file and associates texture names
  78101. * as keys and their data and paths as values
  78102. */
  78103. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78104. private static _PreExportAsync;
  78105. private static _PostExportAsync;
  78106. /**
  78107. * Exports the geometry of the scene to .glb file format asychronously
  78108. * @param scene Babylon scene with scene hierarchy information
  78109. * @param filePrefix File prefix to use when generating glb file
  78110. * @param options Exporter options
  78111. * @returns Returns an object with a .glb filename as key and data as value
  78112. */
  78113. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78114. }
  78115. }
  78116. declare module BABYLON.GLTF2.Exporter {
  78117. /**
  78118. * @hidden
  78119. */
  78120. export class _GLTFUtilities {
  78121. /**
  78122. * Creates a buffer view based on the supplied arguments
  78123. * @param bufferIndex index value of the specified buffer
  78124. * @param byteOffset byte offset value
  78125. * @param byteLength byte length of the bufferView
  78126. * @param byteStride byte distance between conequential elements
  78127. * @param name name of the buffer view
  78128. * @returns bufferView for glTF
  78129. */
  78130. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78131. /**
  78132. * Creates an accessor based on the supplied arguments
  78133. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78134. * @param name The name of the accessor
  78135. * @param type The type of the accessor
  78136. * @param componentType The datatype of components in the attribute
  78137. * @param count The number of attributes referenced by this accessor
  78138. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78139. * @param min Minimum value of each component in this attribute
  78140. * @param max Maximum value of each component in this attribute
  78141. * @returns accessor for glTF
  78142. */
  78143. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78144. /**
  78145. * Calculates the minimum and maximum values of an array of position floats
  78146. * @param positions Positions array of a mesh
  78147. * @param vertexStart Starting vertex offset to calculate min and max values
  78148. * @param vertexCount Number of vertices to check for min and max values
  78149. * @returns min number array and max number array
  78150. */
  78151. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78152. min: number[];
  78153. max: number[];
  78154. };
  78155. /**
  78156. * Converts a new right-handed Vector3
  78157. * @param vector vector3 array
  78158. * @returns right-handed Vector3
  78159. */
  78160. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78161. /**
  78162. * Converts a Vector3 to right-handed
  78163. * @param vector Vector3 to convert to right-handed
  78164. */
  78165. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78166. /**
  78167. * Converts a three element number array to right-handed
  78168. * @param vector number array to convert to right-handed
  78169. */
  78170. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78171. /**
  78172. * Converts a new right-handed Vector3
  78173. * @param vector vector3 array
  78174. * @returns right-handed Vector3
  78175. */
  78176. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78177. /**
  78178. * Converts a Vector3 to right-handed
  78179. * @param vector Vector3 to convert to right-handed
  78180. */
  78181. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78182. /**
  78183. * Converts a three element number array to right-handed
  78184. * @param vector number array to convert to right-handed
  78185. */
  78186. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78187. /**
  78188. * Converts a Vector4 to right-handed
  78189. * @param vector Vector4 to convert to right-handed
  78190. */
  78191. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78192. /**
  78193. * Converts a Vector4 to right-handed
  78194. * @param vector Vector4 to convert to right-handed
  78195. */
  78196. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78197. /**
  78198. * Converts a Quaternion to right-handed
  78199. * @param quaternion Source quaternion to convert to right-handed
  78200. */
  78201. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78202. /**
  78203. * Converts a Quaternion to right-handed
  78204. * @param quaternion Source quaternion to convert to right-handed
  78205. */
  78206. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78207. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78208. }
  78209. }
  78210. declare module BABYLON.GLTF2.Exporter {
  78211. /**
  78212. * Converts Babylon Scene into glTF 2.0.
  78213. * @hidden
  78214. */
  78215. export class _Exporter {
  78216. /**
  78217. * Stores the glTF to export
  78218. */
  78219. _glTF: IGLTF;
  78220. /**
  78221. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78222. */
  78223. _bufferViews: IBufferView[];
  78224. /**
  78225. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78226. */
  78227. _accessors: IAccessor[];
  78228. /**
  78229. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78230. */
  78231. _nodes: INode[];
  78232. /**
  78233. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78234. */
  78235. private _scenes;
  78236. /**
  78237. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78238. */
  78239. private _meshes;
  78240. /**
  78241. * Stores all the generated material information, which represents the appearance of each primitive
  78242. */
  78243. _materials: IMaterial[];
  78244. _materialMap: {
  78245. [materialID: number]: number;
  78246. };
  78247. /**
  78248. * Stores all the generated texture information, which is referenced by glTF materials
  78249. */
  78250. _textures: ITexture[];
  78251. /**
  78252. * Stores all the generated image information, which is referenced by glTF textures
  78253. */
  78254. _images: IImage[];
  78255. /**
  78256. * Stores all the texture samplers
  78257. */
  78258. _samplers: ISampler[];
  78259. /**
  78260. * Stores all the generated animation samplers, which is referenced by glTF animations
  78261. */
  78262. /**
  78263. * Stores the animations for glTF models
  78264. */
  78265. private _animations;
  78266. /**
  78267. * Stores the total amount of bytes stored in the glTF buffer
  78268. */
  78269. private _totalByteLength;
  78270. /**
  78271. * Stores a reference to the Babylon scene containing the source geometry and material information
  78272. */
  78273. _babylonScene: Scene;
  78274. /**
  78275. * Stores a map of the image data, where the key is the file name and the value
  78276. * is the image data
  78277. */
  78278. _imageData: {
  78279. [fileName: string]: {
  78280. data: Uint8Array;
  78281. mimeType: ImageMimeType;
  78282. };
  78283. };
  78284. /**
  78285. * Stores a map of the unique id of a node to its index in the node array
  78286. */
  78287. _nodeMap: {
  78288. [key: number]: number;
  78289. };
  78290. /**
  78291. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78292. */
  78293. _convertToRightHandedSystem: boolean;
  78294. /**
  78295. * Specifies if a Babylon node should be converted to right-handed on export
  78296. */
  78297. _convertToRightHandedSystemMap: {
  78298. [nodeId: number]: boolean;
  78299. };
  78300. _includeCoordinateSystemConversionNodes: boolean;
  78301. /**
  78302. * Baked animation sample rate
  78303. */
  78304. private _animationSampleRate;
  78305. private _options;
  78306. private _localEngine;
  78307. _glTFMaterialExporter: _GLTFMaterialExporter;
  78308. private _extensions;
  78309. private static _ExtensionNames;
  78310. private static _ExtensionFactories;
  78311. private _applyExtension;
  78312. private _applyExtensions;
  78313. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78314. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78315. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78316. [key: number]: number;
  78317. }): Promise<Nullable<INode>>;
  78318. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78319. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78320. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78321. private _forEachExtensions;
  78322. private _extensionsOnExporting;
  78323. /**
  78324. * Load glTF serializer extensions
  78325. */
  78326. private _loadExtensions;
  78327. /**
  78328. * Creates a glTF Exporter instance, which can accept optional exporter options
  78329. * @param babylonScene Babylon scene object
  78330. * @param options Options to modify the behavior of the exporter
  78331. */
  78332. constructor(babylonScene: Scene, options?: IExportOptions);
  78333. dispose(): void;
  78334. /**
  78335. * Registers a glTF exporter extension
  78336. * @param name Name of the extension to export
  78337. * @param factory The factory function that creates the exporter extension
  78338. */
  78339. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78340. /**
  78341. * Un-registers an exporter extension
  78342. * @param name The name fo the exporter extension
  78343. * @returns A boolean indicating whether the extension has been un-registered
  78344. */
  78345. static UnregisterExtension(name: string): boolean;
  78346. /**
  78347. * Lazy load a local engine
  78348. */
  78349. _getLocalEngine(): Engine;
  78350. private reorderIndicesBasedOnPrimitiveMode;
  78351. /**
  78352. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78353. * clock-wise during export to glTF
  78354. * @param submesh BabylonJS submesh
  78355. * @param primitiveMode Primitive mode of the mesh
  78356. * @param sideOrientation the winding order of the submesh
  78357. * @param vertexBufferKind The type of vertex attribute
  78358. * @param meshAttributeArray The vertex attribute data
  78359. * @param byteOffset The offset to the binary data
  78360. * @param binaryWriter The binary data for the glTF file
  78361. * @param convertToRightHandedSystem Converts the values to right-handed
  78362. */
  78363. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78364. /**
  78365. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78366. * clock-wise during export to glTF
  78367. * @param submesh BabylonJS submesh
  78368. * @param primitiveMode Primitive mode of the mesh
  78369. * @param sideOrientation the winding order of the submesh
  78370. * @param vertexBufferKind The type of vertex attribute
  78371. * @param meshAttributeArray The vertex attribute data
  78372. * @param byteOffset The offset to the binary data
  78373. * @param binaryWriter The binary data for the glTF file
  78374. * @param convertToRightHandedSystem Converts the values to right-handed
  78375. */
  78376. private reorderTriangleFillMode;
  78377. /**
  78378. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78379. * clock-wise during export to glTF
  78380. * @param submesh BabylonJS submesh
  78381. * @param primitiveMode Primitive mode of the mesh
  78382. * @param sideOrientation the winding order of the submesh
  78383. * @param vertexBufferKind The type of vertex attribute
  78384. * @param meshAttributeArray The vertex attribute data
  78385. * @param byteOffset The offset to the binary data
  78386. * @param binaryWriter The binary data for the glTF file
  78387. * @param convertToRightHandedSystem Converts the values to right-handed
  78388. */
  78389. private reorderTriangleStripDrawMode;
  78390. /**
  78391. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78392. * clock-wise during export to glTF
  78393. * @param submesh BabylonJS submesh
  78394. * @param primitiveMode Primitive mode of the mesh
  78395. * @param sideOrientation the winding order of the submesh
  78396. * @param vertexBufferKind The type of vertex attribute
  78397. * @param meshAttributeArray The vertex attribute data
  78398. * @param byteOffset The offset to the binary data
  78399. * @param binaryWriter The binary data for the glTF file
  78400. * @param convertToRightHandedSystem Converts the values to right-handed
  78401. */
  78402. private reorderTriangleFanMode;
  78403. /**
  78404. * Writes the vertex attribute data to binary
  78405. * @param vertices The vertices to write to the binary writer
  78406. * @param byteOffset The offset into the binary writer to overwrite binary data
  78407. * @param vertexAttributeKind The vertex attribute type
  78408. * @param meshAttributeArray The vertex attribute data
  78409. * @param binaryWriter The writer containing the binary data
  78410. * @param convertToRightHandedSystem Converts the values to right-handed
  78411. */
  78412. private writeVertexAttributeData;
  78413. /**
  78414. * Writes mesh attribute data to a data buffer
  78415. * Returns the bytelength of the data
  78416. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78417. * @param meshAttributeArray Array containing the attribute data
  78418. * @param binaryWriter The buffer to write the binary data to
  78419. * @param indices Used to specify the order of the vertex data
  78420. * @param convertToRightHandedSystem Converts the values to right-handed
  78421. */
  78422. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78423. /**
  78424. * Generates glTF json data
  78425. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78426. * @param glTFPrefix Text to use when prefixing a glTF file
  78427. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78428. * @returns json data as string
  78429. */
  78430. private generateJSON;
  78431. /**
  78432. * Generates data for .gltf and .bin files based on the glTF prefix string
  78433. * @param glTFPrefix Text to use when prefixing a glTF file
  78434. * @param dispose Dispose the exporter
  78435. * @returns GLTFData with glTF file data
  78436. */
  78437. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78438. /**
  78439. * Creates a binary buffer for glTF
  78440. * @returns array buffer for binary data
  78441. */
  78442. private _generateBinaryAsync;
  78443. /**
  78444. * Pads the number to a multiple of 4
  78445. * @param num number to pad
  78446. * @returns padded number
  78447. */
  78448. private _getPadding;
  78449. /**
  78450. * @hidden
  78451. */
  78452. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78453. /**
  78454. * Sets the TRS for each node
  78455. * @param node glTF Node for storing the transformation data
  78456. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78457. * @param convertToRightHandedSystem Converts the values to right-handed
  78458. */
  78459. private setNodeTransformation;
  78460. private getVertexBufferFromMesh;
  78461. /**
  78462. * Creates a bufferview based on the vertices type for the Babylon mesh
  78463. * @param kind Indicates the type of vertices data
  78464. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78465. * @param binaryWriter The buffer to write the bufferview data to
  78466. * @param convertToRightHandedSystem Converts the values to right-handed
  78467. */
  78468. private createBufferViewKind;
  78469. /**
  78470. * The primitive mode of the Babylon mesh
  78471. * @param babylonMesh The BabylonJS mesh
  78472. */
  78473. private getMeshPrimitiveMode;
  78474. /**
  78475. * Sets the primitive mode of the glTF mesh primitive
  78476. * @param meshPrimitive glTF mesh primitive
  78477. * @param primitiveMode The primitive mode
  78478. */
  78479. private setPrimitiveMode;
  78480. /**
  78481. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78482. * @param meshPrimitive glTF mesh primitive
  78483. * @param attributeKind vertex attribute
  78484. * @returns boolean specifying if uv coordinates are present
  78485. */
  78486. private setAttributeKind;
  78487. /**
  78488. * Sets data for the primitive attributes of each submesh
  78489. * @param mesh glTF Mesh object to store the primitive attribute information
  78490. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78491. * @param binaryWriter Buffer to write the attribute data to
  78492. * @param convertToRightHandedSystem Converts the values to right-handed
  78493. */
  78494. private setPrimitiveAttributesAsync;
  78495. /**
  78496. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78497. * @param node The node to check
  78498. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78499. */
  78500. private isBabylonCoordinateSystemConvertingNode;
  78501. /**
  78502. * Creates a glTF scene based on the array of meshes
  78503. * Returns the the total byte offset
  78504. * @param babylonScene Babylon scene to get the mesh data from
  78505. * @param binaryWriter Buffer to write binary data to
  78506. */
  78507. private createSceneAsync;
  78508. /**
  78509. * Creates a mapping of Node unique id to node index and handles animations
  78510. * @param babylonScene Babylon Scene
  78511. * @param nodes Babylon transform nodes
  78512. * @param binaryWriter Buffer to write binary data to
  78513. * @returns Node mapping of unique id to index
  78514. */
  78515. private createNodeMapAndAnimationsAsync;
  78516. /**
  78517. * Creates a glTF node from a Babylon mesh
  78518. * @param babylonMesh Source Babylon mesh
  78519. * @param binaryWriter Buffer for storing geometry data
  78520. * @param convertToRightHandedSystem Converts the values to right-handed
  78521. * @param nodeMap Node mapping of unique id to glTF node index
  78522. * @returns glTF node
  78523. */
  78524. private createNodeAsync;
  78525. }
  78526. /**
  78527. * @hidden
  78528. *
  78529. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78530. */
  78531. export class _BinaryWriter {
  78532. /**
  78533. * Array buffer which stores all binary data
  78534. */
  78535. private _arrayBuffer;
  78536. /**
  78537. * View of the array buffer
  78538. */
  78539. private _dataView;
  78540. /**
  78541. * byte offset of data in array buffer
  78542. */
  78543. private _byteOffset;
  78544. /**
  78545. * Initialize binary writer with an initial byte length
  78546. * @param byteLength Initial byte length of the array buffer
  78547. */
  78548. constructor(byteLength: number);
  78549. /**
  78550. * Resize the array buffer to the specified byte length
  78551. * @param byteLength
  78552. */
  78553. private resizeBuffer;
  78554. /**
  78555. * Get an array buffer with the length of the byte offset
  78556. * @returns ArrayBuffer resized to the byte offset
  78557. */
  78558. getArrayBuffer(): ArrayBuffer;
  78559. /**
  78560. * Get the byte offset of the array buffer
  78561. * @returns byte offset
  78562. */
  78563. getByteOffset(): number;
  78564. /**
  78565. * Stores an UInt8 in the array buffer
  78566. * @param entry
  78567. * @param byteOffset If defined, specifies where to set the value as an offset.
  78568. */
  78569. setUInt8(entry: number, byteOffset?: number): void;
  78570. /**
  78571. * Gets an UInt32 in the array buffer
  78572. * @param entry
  78573. * @param byteOffset If defined, specifies where to set the value as an offset.
  78574. */
  78575. getUInt32(byteOffset: number): number;
  78576. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78577. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78578. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78579. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78580. /**
  78581. * Stores a Float32 in the array buffer
  78582. * @param entry
  78583. */
  78584. setFloat32(entry: number, byteOffset?: number): void;
  78585. /**
  78586. * Stores an UInt32 in the array buffer
  78587. * @param entry
  78588. * @param byteOffset If defined, specifies where to set the value as an offset.
  78589. */
  78590. setUInt32(entry: number, byteOffset?: number): void;
  78591. }
  78592. }
  78593. declare module BABYLON.GLTF2.Exporter {
  78594. /**
  78595. * @hidden
  78596. * Interface to store animation data.
  78597. */
  78598. export interface _IAnimationData {
  78599. /**
  78600. * Keyframe data.
  78601. */
  78602. inputs: number[];
  78603. /**
  78604. * Value data.
  78605. */
  78606. outputs: number[][];
  78607. /**
  78608. * Animation interpolation data.
  78609. */
  78610. samplerInterpolation: AnimationSamplerInterpolation;
  78611. /**
  78612. * Minimum keyframe value.
  78613. */
  78614. inputsMin: number;
  78615. /**
  78616. * Maximum keyframe value.
  78617. */
  78618. inputsMax: number;
  78619. }
  78620. /**
  78621. * @hidden
  78622. */
  78623. export interface _IAnimationInfo {
  78624. /**
  78625. * The target channel for the animation
  78626. */
  78627. animationChannelTargetPath: AnimationChannelTargetPath;
  78628. /**
  78629. * The glTF accessor type for the data.
  78630. */
  78631. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78632. /**
  78633. * Specifies if quaternions should be used.
  78634. */
  78635. useQuaternion: boolean;
  78636. }
  78637. /**
  78638. * @hidden
  78639. * Utility class for generating glTF animation data from BabylonJS.
  78640. */
  78641. export class _GLTFAnimation {
  78642. /**
  78643. * @ignore
  78644. *
  78645. * Creates glTF channel animation from BabylonJS animation.
  78646. * @param babylonTransformNode - BabylonJS mesh.
  78647. * @param animation - animation.
  78648. * @param animationChannelTargetPath - The target animation channel.
  78649. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78650. * @param useQuaternion - Specifies if quaternions are used.
  78651. * @returns nullable IAnimationData
  78652. */
  78653. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78654. private static _DeduceAnimationInfo;
  78655. /**
  78656. * @ignore
  78657. * Create node animations from the transform node animations
  78658. * @param babylonNode
  78659. * @param runtimeGLTFAnimation
  78660. * @param idleGLTFAnimations
  78661. * @param nodeMap
  78662. * @param nodes
  78663. * @param binaryWriter
  78664. * @param bufferViews
  78665. * @param accessors
  78666. * @param convertToRightHandedSystem
  78667. * @param animationSampleRate
  78668. */
  78669. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78670. [key: number]: number;
  78671. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78672. /**
  78673. * @ignore
  78674. * Create node animations from the animation groups
  78675. * @param babylonScene
  78676. * @param glTFAnimations
  78677. * @param nodeMap
  78678. * @param nodes
  78679. * @param binaryWriter
  78680. * @param bufferViews
  78681. * @param accessors
  78682. * @param convertToRightHandedSystemMap
  78683. * @param animationSampleRate
  78684. */
  78685. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78686. [key: number]: number;
  78687. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78688. [nodeId: number]: boolean;
  78689. }, animationSampleRate: number): void;
  78690. private static AddAnimation;
  78691. /**
  78692. * Create a baked animation
  78693. * @param babylonTransformNode BabylonJS mesh
  78694. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78695. * @param animationChannelTargetPath animation target channel
  78696. * @param minFrame minimum animation frame
  78697. * @param maxFrame maximum animation frame
  78698. * @param fps frames per second of the animation
  78699. * @param inputs input key frames of the animation
  78700. * @param outputs output key frame data of the animation
  78701. * @param convertToRightHandedSystem converts the values to right-handed
  78702. * @param useQuaternion specifies if quaternions should be used
  78703. */
  78704. private static _CreateBakedAnimation;
  78705. private static _ConvertFactorToVector3OrQuaternion;
  78706. private static _SetInterpolatedValue;
  78707. /**
  78708. * Creates linear animation from the animation key frames
  78709. * @param babylonTransformNode BabylonJS mesh
  78710. * @param animation BabylonJS animation
  78711. * @param animationChannelTargetPath The target animation channel
  78712. * @param frameDelta The difference between the last and first frame of the animation
  78713. * @param inputs Array to store the key frame times
  78714. * @param outputs Array to store the key frame data
  78715. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78716. * @param useQuaternion Specifies if quaternions are used in the animation
  78717. */
  78718. private static _CreateLinearOrStepAnimation;
  78719. /**
  78720. * Creates cubic spline animation from the animation key frames
  78721. * @param babylonTransformNode BabylonJS mesh
  78722. * @param animation BabylonJS animation
  78723. * @param animationChannelTargetPath The target animation channel
  78724. * @param frameDelta The difference between the last and first frame of the animation
  78725. * @param inputs Array to store the key frame times
  78726. * @param outputs Array to store the key frame data
  78727. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78728. * @param useQuaternion Specifies if quaternions are used in the animation
  78729. */
  78730. private static _CreateCubicSplineAnimation;
  78731. private static _GetBasePositionRotationOrScale;
  78732. /**
  78733. * Adds a key frame value
  78734. * @param keyFrame
  78735. * @param animation
  78736. * @param outputs
  78737. * @param animationChannelTargetPath
  78738. * @param basePositionRotationOrScale
  78739. * @param convertToRightHandedSystem
  78740. * @param useQuaternion
  78741. */
  78742. private static _AddKeyframeValue;
  78743. /**
  78744. * Determine the interpolation based on the key frames
  78745. * @param keyFrames
  78746. * @param animationChannelTargetPath
  78747. * @param useQuaternion
  78748. */
  78749. private static _DeduceInterpolation;
  78750. /**
  78751. * Adds an input tangent or output tangent to the output data
  78752. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78753. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78754. * @param outputs The animation data by keyframe
  78755. * @param animationChannelTargetPath The target animation channel
  78756. * @param interpolation The interpolation type
  78757. * @param keyFrame The key frame with the animation data
  78758. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78759. * @param useQuaternion Specifies if quaternions are used
  78760. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78761. */
  78762. private static AddSplineTangent;
  78763. /**
  78764. * Get the minimum and maximum key frames' frame values
  78765. * @param keyFrames animation key frames
  78766. * @returns the minimum and maximum key frame value
  78767. */
  78768. private static calculateMinMaxKeyFrames;
  78769. }
  78770. }
  78771. declare module BABYLON.GLTF2.Exporter {
  78772. /** @hidden */
  78773. export var textureTransformPixelShader: {
  78774. name: string;
  78775. shader: string;
  78776. };
  78777. }
  78778. declare module BABYLON.GLTF2.Exporter.Extensions {
  78779. /**
  78780. * @hidden
  78781. */
  78782. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78783. private _recordedTextures;
  78784. /** Name of this extension */
  78785. readonly name: string;
  78786. /** Defines whether this extension is enabled */
  78787. enabled: boolean;
  78788. /** Defines whether this extension is required */
  78789. required: boolean;
  78790. /** Reference to the glTF exporter */
  78791. private _wasUsed;
  78792. constructor(exporter: _Exporter);
  78793. dispose(): void;
  78794. /** @hidden */
  78795. get wasUsed(): boolean;
  78796. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78797. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78798. /**
  78799. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78800. * @param babylonTexture
  78801. * @param offset
  78802. * @param rotation
  78803. * @param scale
  78804. * @param scene
  78805. */
  78806. private _textureTransformTextureAsync;
  78807. }
  78808. }
  78809. declare module BABYLON.GLTF2.Exporter.Extensions {
  78810. /**
  78811. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78812. */
  78813. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78814. /** The name of this extension. */
  78815. readonly name: string;
  78816. /** Defines whether this extension is enabled. */
  78817. enabled: boolean;
  78818. /** Defines whether this extension is required */
  78819. required: boolean;
  78820. /** Reference to the glTF exporter */
  78821. private _exporter;
  78822. private _lights;
  78823. /** @hidden */
  78824. constructor(exporter: _Exporter);
  78825. /** @hidden */
  78826. dispose(): void;
  78827. /** @hidden */
  78828. get wasUsed(): boolean;
  78829. /** @hidden */
  78830. onExporting(): void;
  78831. /**
  78832. * Define this method to modify the default behavior when exporting a node
  78833. * @param context The context when exporting the node
  78834. * @param node glTF node
  78835. * @param babylonNode BabylonJS node
  78836. * @param nodeMap Node mapping of unique id to glTF node index
  78837. * @returns nullable INode promise
  78838. */
  78839. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78840. [key: number]: number;
  78841. }): Promise<Nullable<INode>>;
  78842. }
  78843. }
  78844. declare module BABYLON.GLTF2.Exporter.Extensions {
  78845. /**
  78846. * @hidden
  78847. */
  78848. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78849. /** Name of this extension */
  78850. readonly name: string;
  78851. /** Defines whether this extension is enabled */
  78852. enabled: boolean;
  78853. /** Defines whether this extension is required */
  78854. required: boolean;
  78855. /** Reference to the glTF exporter */
  78856. private _textureInfos;
  78857. private _exportedTextures;
  78858. private _wasUsed;
  78859. constructor(exporter: _Exporter);
  78860. dispose(): void;
  78861. /** @hidden */
  78862. get wasUsed(): boolean;
  78863. private _getTextureIndex;
  78864. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78865. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78866. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78867. }
  78868. }
  78869. declare module BABYLON {
  78870. /**
  78871. * Class for generating STL data from a Babylon scene.
  78872. */
  78873. export class STLExport {
  78874. /**
  78875. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78876. * @param meshes list defines the mesh to serialize
  78877. * @param download triggers the automatic download of the file.
  78878. * @param fileName changes the downloads fileName.
  78879. * @param binary changes the STL to a binary type.
  78880. * @param isLittleEndian toggle for binary type exporter.
  78881. * @returns the STL as UTF8 string
  78882. */
  78883. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78884. }
  78885. }
  78886. declare module "babylonjs-gltf2interface" {
  78887. export = BABYLON.GLTF2;
  78888. }
  78889. /**
  78890. * Module for glTF 2.0 Interface
  78891. */
  78892. declare module BABYLON.GLTF2 {
  78893. /**
  78894. * The datatype of the components in the attribute
  78895. */
  78896. const enum AccessorComponentType {
  78897. /**
  78898. * Byte
  78899. */
  78900. BYTE = 5120,
  78901. /**
  78902. * Unsigned Byte
  78903. */
  78904. UNSIGNED_BYTE = 5121,
  78905. /**
  78906. * Short
  78907. */
  78908. SHORT = 5122,
  78909. /**
  78910. * Unsigned Short
  78911. */
  78912. UNSIGNED_SHORT = 5123,
  78913. /**
  78914. * Unsigned Int
  78915. */
  78916. UNSIGNED_INT = 5125,
  78917. /**
  78918. * Float
  78919. */
  78920. FLOAT = 5126,
  78921. }
  78922. /**
  78923. * Specifies if the attirbute is a scalar, vector, or matrix
  78924. */
  78925. const enum AccessorType {
  78926. /**
  78927. * Scalar
  78928. */
  78929. SCALAR = "SCALAR",
  78930. /**
  78931. * Vector2
  78932. */
  78933. VEC2 = "VEC2",
  78934. /**
  78935. * Vector3
  78936. */
  78937. VEC3 = "VEC3",
  78938. /**
  78939. * Vector4
  78940. */
  78941. VEC4 = "VEC4",
  78942. /**
  78943. * Matrix2x2
  78944. */
  78945. MAT2 = "MAT2",
  78946. /**
  78947. * Matrix3x3
  78948. */
  78949. MAT3 = "MAT3",
  78950. /**
  78951. * Matrix4x4
  78952. */
  78953. MAT4 = "MAT4",
  78954. }
  78955. /**
  78956. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78957. */
  78958. const enum AnimationChannelTargetPath {
  78959. /**
  78960. * Translation
  78961. */
  78962. TRANSLATION = "translation",
  78963. /**
  78964. * Rotation
  78965. */
  78966. ROTATION = "rotation",
  78967. /**
  78968. * Scale
  78969. */
  78970. SCALE = "scale",
  78971. /**
  78972. * Weights
  78973. */
  78974. WEIGHTS = "weights",
  78975. }
  78976. /**
  78977. * Interpolation algorithm
  78978. */
  78979. const enum AnimationSamplerInterpolation {
  78980. /**
  78981. * The animated values are linearly interpolated between keyframes
  78982. */
  78983. LINEAR = "LINEAR",
  78984. /**
  78985. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78986. */
  78987. STEP = "STEP",
  78988. /**
  78989. * The animation's interpolation is computed using a cubic spline with specified tangents
  78990. */
  78991. CUBICSPLINE = "CUBICSPLINE",
  78992. }
  78993. /**
  78994. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78995. */
  78996. const enum CameraType {
  78997. /**
  78998. * A perspective camera containing properties to create a perspective projection matrix
  78999. */
  79000. PERSPECTIVE = "perspective",
  79001. /**
  79002. * An orthographic camera containing properties to create an orthographic projection matrix
  79003. */
  79004. ORTHOGRAPHIC = "orthographic",
  79005. }
  79006. /**
  79007. * The mime-type of the image
  79008. */
  79009. const enum ImageMimeType {
  79010. /**
  79011. * JPEG Mime-type
  79012. */
  79013. JPEG = "image/jpeg",
  79014. /**
  79015. * PNG Mime-type
  79016. */
  79017. PNG = "image/png",
  79018. }
  79019. /**
  79020. * The alpha rendering mode of the material
  79021. */
  79022. const enum MaterialAlphaMode {
  79023. /**
  79024. * The alpha value is ignored and the rendered output is fully opaque
  79025. */
  79026. OPAQUE = "OPAQUE",
  79027. /**
  79028. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  79029. */
  79030. MASK = "MASK",
  79031. /**
  79032. * 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)
  79033. */
  79034. BLEND = "BLEND",
  79035. }
  79036. /**
  79037. * The type of the primitives to render
  79038. */
  79039. const enum MeshPrimitiveMode {
  79040. /**
  79041. * Points
  79042. */
  79043. POINTS = 0,
  79044. /**
  79045. * Lines
  79046. */
  79047. LINES = 1,
  79048. /**
  79049. * Line Loop
  79050. */
  79051. LINE_LOOP = 2,
  79052. /**
  79053. * Line Strip
  79054. */
  79055. LINE_STRIP = 3,
  79056. /**
  79057. * Triangles
  79058. */
  79059. TRIANGLES = 4,
  79060. /**
  79061. * Triangle Strip
  79062. */
  79063. TRIANGLE_STRIP = 5,
  79064. /**
  79065. * Triangle Fan
  79066. */
  79067. TRIANGLE_FAN = 6,
  79068. }
  79069. /**
  79070. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79071. */
  79072. const enum TextureMagFilter {
  79073. /**
  79074. * Nearest
  79075. */
  79076. NEAREST = 9728,
  79077. /**
  79078. * Linear
  79079. */
  79080. LINEAR = 9729,
  79081. }
  79082. /**
  79083. * Minification filter. All valid values correspond to WebGL enums
  79084. */
  79085. const enum TextureMinFilter {
  79086. /**
  79087. * Nearest
  79088. */
  79089. NEAREST = 9728,
  79090. /**
  79091. * Linear
  79092. */
  79093. LINEAR = 9729,
  79094. /**
  79095. * Nearest Mip-Map Nearest
  79096. */
  79097. NEAREST_MIPMAP_NEAREST = 9984,
  79098. /**
  79099. * Linear Mipmap Nearest
  79100. */
  79101. LINEAR_MIPMAP_NEAREST = 9985,
  79102. /**
  79103. * Nearest Mipmap Linear
  79104. */
  79105. NEAREST_MIPMAP_LINEAR = 9986,
  79106. /**
  79107. * Linear Mipmap Linear
  79108. */
  79109. LINEAR_MIPMAP_LINEAR = 9987,
  79110. }
  79111. /**
  79112. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79113. */
  79114. const enum TextureWrapMode {
  79115. /**
  79116. * Clamp to Edge
  79117. */
  79118. CLAMP_TO_EDGE = 33071,
  79119. /**
  79120. * Mirrored Repeat
  79121. */
  79122. MIRRORED_REPEAT = 33648,
  79123. /**
  79124. * Repeat
  79125. */
  79126. REPEAT = 10497,
  79127. }
  79128. /**
  79129. * glTF Property
  79130. */
  79131. interface IProperty {
  79132. /**
  79133. * Dictionary object with extension-specific objects
  79134. */
  79135. extensions?: {
  79136. [key: string]: any;
  79137. };
  79138. /**
  79139. * Application-Specific data
  79140. */
  79141. extras?: any;
  79142. }
  79143. /**
  79144. * glTF Child of Root Property
  79145. */
  79146. interface IChildRootProperty extends IProperty {
  79147. /**
  79148. * The user-defined name of this object
  79149. */
  79150. name?: string;
  79151. }
  79152. /**
  79153. * Indices of those attributes that deviate from their initialization value
  79154. */
  79155. interface IAccessorSparseIndices extends IProperty {
  79156. /**
  79157. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79158. */
  79159. bufferView: number;
  79160. /**
  79161. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79162. */
  79163. byteOffset?: number;
  79164. /**
  79165. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79166. */
  79167. componentType: AccessorComponentType;
  79168. }
  79169. /**
  79170. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79171. */
  79172. interface IAccessorSparseValues extends IProperty {
  79173. /**
  79174. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79175. */
  79176. bufferView: number;
  79177. /**
  79178. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79179. */
  79180. byteOffset?: number;
  79181. }
  79182. /**
  79183. * Sparse storage of attributes that deviate from their initialization value
  79184. */
  79185. interface IAccessorSparse extends IProperty {
  79186. /**
  79187. * The number of attributes encoded in this sparse accessor
  79188. */
  79189. count: number;
  79190. /**
  79191. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79192. */
  79193. indices: IAccessorSparseIndices;
  79194. /**
  79195. * 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
  79196. */
  79197. values: IAccessorSparseValues;
  79198. }
  79199. /**
  79200. * 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
  79201. */
  79202. interface IAccessor extends IChildRootProperty {
  79203. /**
  79204. * The index of the bufferview
  79205. */
  79206. bufferView?: number;
  79207. /**
  79208. * The offset relative to the start of the bufferView in bytes
  79209. */
  79210. byteOffset?: number;
  79211. /**
  79212. * The datatype of components in the attribute
  79213. */
  79214. componentType: AccessorComponentType;
  79215. /**
  79216. * Specifies whether integer data values should be normalized
  79217. */
  79218. normalized?: boolean;
  79219. /**
  79220. * The number of attributes referenced by this accessor
  79221. */
  79222. count: number;
  79223. /**
  79224. * Specifies if the attribute is a scalar, vector, or matrix
  79225. */
  79226. type: AccessorType;
  79227. /**
  79228. * Maximum value of each component in this attribute
  79229. */
  79230. max?: number[];
  79231. /**
  79232. * Minimum value of each component in this attribute
  79233. */
  79234. min?: number[];
  79235. /**
  79236. * Sparse storage of attributes that deviate from their initialization value
  79237. */
  79238. sparse?: IAccessorSparse;
  79239. }
  79240. /**
  79241. * Targets an animation's sampler at a node's property
  79242. */
  79243. interface IAnimationChannel extends IProperty {
  79244. /**
  79245. * The index of a sampler in this animation used to compute the value for the target
  79246. */
  79247. sampler: number;
  79248. /**
  79249. * The index of the node and TRS property to target
  79250. */
  79251. target: IAnimationChannelTarget;
  79252. }
  79253. /**
  79254. * The index of the node and TRS property that an animation channel targets
  79255. */
  79256. interface IAnimationChannelTarget extends IProperty {
  79257. /**
  79258. * The index of the node to target
  79259. */
  79260. node: number;
  79261. /**
  79262. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79263. */
  79264. path: AnimationChannelTargetPath;
  79265. }
  79266. /**
  79267. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79268. */
  79269. interface IAnimationSampler extends IProperty {
  79270. /**
  79271. * The index of an accessor containing keyframe input values, e.g., time
  79272. */
  79273. input: number;
  79274. /**
  79275. * Interpolation algorithm
  79276. */
  79277. interpolation?: AnimationSamplerInterpolation;
  79278. /**
  79279. * The index of an accessor, containing keyframe output values
  79280. */
  79281. output: number;
  79282. }
  79283. /**
  79284. * A keyframe animation
  79285. */
  79286. interface IAnimation extends IChildRootProperty {
  79287. /**
  79288. * An array of channels, each of which targets an animation's sampler at a node's property
  79289. */
  79290. channels: IAnimationChannel[];
  79291. /**
  79292. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79293. */
  79294. samplers: IAnimationSampler[];
  79295. }
  79296. /**
  79297. * Metadata about the glTF asset
  79298. */
  79299. interface IAsset extends IChildRootProperty {
  79300. /**
  79301. * A copyright message suitable for display to credit the content creator
  79302. */
  79303. copyright?: string;
  79304. /**
  79305. * Tool that generated this glTF model. Useful for debugging
  79306. */
  79307. generator?: string;
  79308. /**
  79309. * The glTF version that this asset targets
  79310. */
  79311. version: string;
  79312. /**
  79313. * The minimum glTF version that this asset targets
  79314. */
  79315. minVersion?: string;
  79316. }
  79317. /**
  79318. * A buffer points to binary geometry, animation, or skins
  79319. */
  79320. interface IBuffer extends IChildRootProperty {
  79321. /**
  79322. * 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
  79323. */
  79324. uri?: string;
  79325. /**
  79326. * The length of the buffer in bytes
  79327. */
  79328. byteLength: number;
  79329. }
  79330. /**
  79331. * A view into a buffer generally representing a subset of the buffer
  79332. */
  79333. interface IBufferView extends IChildRootProperty {
  79334. /**
  79335. * The index of the buffer
  79336. */
  79337. buffer: number;
  79338. /**
  79339. * The offset into the buffer in bytes
  79340. */
  79341. byteOffset?: number;
  79342. /**
  79343. * The lenth of the bufferView in bytes
  79344. */
  79345. byteLength: number;
  79346. /**
  79347. * The stride, in bytes
  79348. */
  79349. byteStride?: number;
  79350. }
  79351. /**
  79352. * An orthographic camera containing properties to create an orthographic projection matrix
  79353. */
  79354. interface ICameraOrthographic extends IProperty {
  79355. /**
  79356. * The floating-point horizontal magnification of the view. Must not be zero
  79357. */
  79358. xmag: number;
  79359. /**
  79360. * The floating-point vertical magnification of the view. Must not be zero
  79361. */
  79362. ymag: number;
  79363. /**
  79364. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79365. */
  79366. zfar: number;
  79367. /**
  79368. * The floating-point distance to the near clipping plane
  79369. */
  79370. znear: number;
  79371. }
  79372. /**
  79373. * A perspective camera containing properties to create a perspective projection matrix
  79374. */
  79375. interface ICameraPerspective extends IProperty {
  79376. /**
  79377. * The floating-point aspect ratio of the field of view
  79378. */
  79379. aspectRatio?: number;
  79380. /**
  79381. * The floating-point vertical field of view in radians
  79382. */
  79383. yfov: number;
  79384. /**
  79385. * The floating-point distance to the far clipping plane
  79386. */
  79387. zfar?: number;
  79388. /**
  79389. * The floating-point distance to the near clipping plane
  79390. */
  79391. znear: number;
  79392. }
  79393. /**
  79394. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79395. */
  79396. interface ICamera extends IChildRootProperty {
  79397. /**
  79398. * An orthographic camera containing properties to create an orthographic projection matrix
  79399. */
  79400. orthographic?: ICameraOrthographic;
  79401. /**
  79402. * A perspective camera containing properties to create a perspective projection matrix
  79403. */
  79404. perspective?: ICameraPerspective;
  79405. /**
  79406. * Specifies if the camera uses a perspective or orthographic projection
  79407. */
  79408. type: CameraType;
  79409. }
  79410. /**
  79411. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79412. */
  79413. interface IImage extends IChildRootProperty {
  79414. /**
  79415. * 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
  79416. */
  79417. uri?: string;
  79418. /**
  79419. * The image's MIME type
  79420. */
  79421. mimeType?: ImageMimeType;
  79422. /**
  79423. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79424. */
  79425. bufferView?: number;
  79426. }
  79427. /**
  79428. * Material Normal Texture Info
  79429. */
  79430. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79431. /**
  79432. * The scalar multiplier applied to each normal vector of the normal texture
  79433. */
  79434. scale?: number;
  79435. }
  79436. /**
  79437. * Material Occlusion Texture Info
  79438. */
  79439. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79440. /**
  79441. * A scalar multiplier controlling the amount of occlusion applied
  79442. */
  79443. strength?: number;
  79444. }
  79445. /**
  79446. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79447. */
  79448. interface IMaterialPbrMetallicRoughness {
  79449. /**
  79450. * The material's base color factor
  79451. */
  79452. baseColorFactor?: number[];
  79453. /**
  79454. * The base color texture
  79455. */
  79456. baseColorTexture?: ITextureInfo;
  79457. /**
  79458. * The metalness of the material
  79459. */
  79460. metallicFactor?: number;
  79461. /**
  79462. * The roughness of the material
  79463. */
  79464. roughnessFactor?: number;
  79465. /**
  79466. * The metallic-roughness texture
  79467. */
  79468. metallicRoughnessTexture?: ITextureInfo;
  79469. }
  79470. /**
  79471. * The material appearance of a primitive
  79472. */
  79473. interface IMaterial extends IChildRootProperty {
  79474. /**
  79475. * 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
  79476. */
  79477. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79478. /**
  79479. * The normal map texture
  79480. */
  79481. normalTexture?: IMaterialNormalTextureInfo;
  79482. /**
  79483. * The occlusion map texture
  79484. */
  79485. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79486. /**
  79487. * The emissive map texture
  79488. */
  79489. emissiveTexture?: ITextureInfo;
  79490. /**
  79491. * 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
  79492. */
  79493. emissiveFactor?: number[];
  79494. /**
  79495. * The alpha rendering mode of the material
  79496. */
  79497. alphaMode?: MaterialAlphaMode;
  79498. /**
  79499. * The alpha cutoff value of the material
  79500. */
  79501. alphaCutoff?: number;
  79502. /**
  79503. * Specifies whether the material is double sided
  79504. */
  79505. doubleSided?: boolean;
  79506. }
  79507. /**
  79508. * Geometry to be rendered with the given material
  79509. */
  79510. interface IMeshPrimitive extends IProperty {
  79511. /**
  79512. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79513. */
  79514. attributes: {
  79515. [name: string]: number;
  79516. };
  79517. /**
  79518. * The index of the accessor that contains the indices
  79519. */
  79520. indices?: number;
  79521. /**
  79522. * The index of the material to apply to this primitive when rendering
  79523. */
  79524. material?: number;
  79525. /**
  79526. * The type of primitives to render. All valid values correspond to WebGL enums
  79527. */
  79528. mode?: MeshPrimitiveMode;
  79529. /**
  79530. * 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
  79531. */
  79532. targets?: {
  79533. [name: string]: number;
  79534. }[];
  79535. }
  79536. /**
  79537. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79538. */
  79539. interface IMesh extends IChildRootProperty {
  79540. /**
  79541. * An array of primitives, each defining geometry to be rendered with a material
  79542. */
  79543. primitives: IMeshPrimitive[];
  79544. /**
  79545. * Array of weights to be applied to the Morph Targets
  79546. */
  79547. weights?: number[];
  79548. }
  79549. /**
  79550. * A node in the node hierarchy
  79551. */
  79552. interface INode extends IChildRootProperty {
  79553. /**
  79554. * The index of the camera referenced by this node
  79555. */
  79556. camera?: number;
  79557. /**
  79558. * The indices of this node's children
  79559. */
  79560. children?: number[];
  79561. /**
  79562. * The index of the skin referenced by this node
  79563. */
  79564. skin?: number;
  79565. /**
  79566. * A floating-point 4x4 transformation matrix stored in column-major order
  79567. */
  79568. matrix?: number[];
  79569. /**
  79570. * The index of the mesh in this node
  79571. */
  79572. mesh?: number;
  79573. /**
  79574. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79575. */
  79576. rotation?: number[];
  79577. /**
  79578. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79579. */
  79580. scale?: number[];
  79581. /**
  79582. * The node's translation along the x, y, and z axes
  79583. */
  79584. translation?: number[];
  79585. /**
  79586. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79587. */
  79588. weights?: number[];
  79589. }
  79590. /**
  79591. * Texture sampler properties for filtering and wrapping modes
  79592. */
  79593. interface ISampler extends IChildRootProperty {
  79594. /**
  79595. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79596. */
  79597. magFilter?: TextureMagFilter;
  79598. /**
  79599. * Minification filter. All valid values correspond to WebGL enums
  79600. */
  79601. minFilter?: TextureMinFilter;
  79602. /**
  79603. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79604. */
  79605. wrapS?: TextureWrapMode;
  79606. /**
  79607. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79608. */
  79609. wrapT?: TextureWrapMode;
  79610. }
  79611. /**
  79612. * The root nodes of a scene
  79613. */
  79614. interface IScene extends IChildRootProperty {
  79615. /**
  79616. * The indices of each root node
  79617. */
  79618. nodes: number[];
  79619. }
  79620. /**
  79621. * Joints and matrices defining a skin
  79622. */
  79623. interface ISkin extends IChildRootProperty {
  79624. /**
  79625. * 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
  79626. */
  79627. inverseBindMatrices?: number;
  79628. /**
  79629. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79630. */
  79631. skeleton?: number;
  79632. /**
  79633. * 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)
  79634. */
  79635. joints: number[];
  79636. }
  79637. /**
  79638. * A texture and its sampler
  79639. */
  79640. interface ITexture extends IChildRootProperty {
  79641. /**
  79642. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79643. */
  79644. sampler?: number;
  79645. /**
  79646. * The index of the image used by this texture
  79647. */
  79648. source: number;
  79649. }
  79650. /**
  79651. * Reference to a texture
  79652. */
  79653. interface ITextureInfo extends IProperty {
  79654. /**
  79655. * The index of the texture
  79656. */
  79657. index: number;
  79658. /**
  79659. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79660. */
  79661. texCoord?: number;
  79662. }
  79663. /**
  79664. * The root object for a glTF asset
  79665. */
  79666. interface IGLTF extends IProperty {
  79667. /**
  79668. * An array of accessors. An accessor is a typed view into a bufferView
  79669. */
  79670. accessors?: IAccessor[];
  79671. /**
  79672. * An array of keyframe animations
  79673. */
  79674. animations?: IAnimation[];
  79675. /**
  79676. * Metadata about the glTF asset
  79677. */
  79678. asset: IAsset;
  79679. /**
  79680. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79681. */
  79682. buffers?: IBuffer[];
  79683. /**
  79684. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79685. */
  79686. bufferViews?: IBufferView[];
  79687. /**
  79688. * An array of cameras
  79689. */
  79690. cameras?: ICamera[];
  79691. /**
  79692. * Names of glTF extensions used somewhere in this asset
  79693. */
  79694. extensionsUsed?: string[];
  79695. /**
  79696. * Names of glTF extensions required to properly load this asset
  79697. */
  79698. extensionsRequired?: string[];
  79699. /**
  79700. * An array of images. An image defines data used to create a texture
  79701. */
  79702. images?: IImage[];
  79703. /**
  79704. * An array of materials. A material defines the appearance of a primitive
  79705. */
  79706. materials?: IMaterial[];
  79707. /**
  79708. * An array of meshes. A mesh is a set of primitives to be rendered
  79709. */
  79710. meshes?: IMesh[];
  79711. /**
  79712. * An array of nodes
  79713. */
  79714. nodes?: INode[];
  79715. /**
  79716. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79717. */
  79718. samplers?: ISampler[];
  79719. /**
  79720. * The index of the default scene
  79721. */
  79722. scene?: number;
  79723. /**
  79724. * An array of scenes
  79725. */
  79726. scenes?: IScene[];
  79727. /**
  79728. * An array of skins. A skin is defined by joints and matrices
  79729. */
  79730. skins?: ISkin[];
  79731. /**
  79732. * An array of textures
  79733. */
  79734. textures?: ITexture[];
  79735. }
  79736. /**
  79737. * The glTF validation results
  79738. * @ignore
  79739. */
  79740. interface IGLTFValidationResults {
  79741. info: {
  79742. generator: string;
  79743. hasAnimations: boolean;
  79744. hasDefaultScene: boolean;
  79745. hasMaterials: boolean;
  79746. hasMorphTargets: boolean;
  79747. hasSkins: boolean;
  79748. hasTextures: boolean;
  79749. maxAttributesUsed: number;
  79750. primitivesCount: number
  79751. };
  79752. issues: {
  79753. messages: Array<string>;
  79754. numErrors: number;
  79755. numHints: number;
  79756. numInfos: number;
  79757. numWarnings: number;
  79758. truncated: boolean
  79759. };
  79760. mimeType: string;
  79761. uri: string;
  79762. validatedAt: string;
  79763. validatorVersion: string;
  79764. }
  79765. /**
  79766. * The glTF validation options
  79767. */
  79768. interface IGLTFValidationOptions {
  79769. /** Uri to use */
  79770. uri?: string;
  79771. /** Function used to load external resources */
  79772. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79773. /** Boolean indicating that we need to validate accessor data */
  79774. validateAccessorData?: boolean;
  79775. /** max number of issues allowed */
  79776. maxIssues?: number;
  79777. /** Ignored issues */
  79778. ignoredIssues?: Array<string>;
  79779. /** Value to override severy settings */
  79780. severityOverrides?: Object;
  79781. }
  79782. /**
  79783. * The glTF validator object
  79784. * @ignore
  79785. */
  79786. interface IGLTFValidator {
  79787. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79788. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79789. }
  79790. }
  79791. declare module BABYLON {
  79792. /** @hidden */
  79793. export var cellPixelShader: {
  79794. name: string;
  79795. shader: string;
  79796. };
  79797. }
  79798. declare module BABYLON {
  79799. /** @hidden */
  79800. export var cellVertexShader: {
  79801. name: string;
  79802. shader: string;
  79803. };
  79804. }
  79805. declare module BABYLON {
  79806. export class CellMaterial extends BABYLON.PushMaterial {
  79807. private _diffuseTexture;
  79808. diffuseTexture: BABYLON.BaseTexture;
  79809. diffuseColor: BABYLON.Color3;
  79810. _computeHighLevel: boolean;
  79811. computeHighLevel: boolean;
  79812. private _disableLighting;
  79813. disableLighting: boolean;
  79814. private _maxSimultaneousLights;
  79815. maxSimultaneousLights: number;
  79816. constructor(name: string, scene: BABYLON.Scene);
  79817. needAlphaBlending(): boolean;
  79818. needAlphaTesting(): boolean;
  79819. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79820. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79821. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79822. getAnimatables(): BABYLON.IAnimatable[];
  79823. getActiveTextures(): BABYLON.BaseTexture[];
  79824. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79825. dispose(forceDisposeEffect?: boolean): void;
  79826. getClassName(): string;
  79827. clone(name: string): CellMaterial;
  79828. serialize(): any;
  79829. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79830. }
  79831. }
  79832. declare module BABYLON {
  79833. export class CustomShaderStructure {
  79834. FragmentStore: string;
  79835. VertexStore: string;
  79836. constructor();
  79837. }
  79838. export class ShaderSpecialParts {
  79839. constructor();
  79840. Fragment_Begin: string;
  79841. Fragment_Definitions: string;
  79842. Fragment_MainBegin: string;
  79843. Fragment_Custom_Diffuse: string;
  79844. Fragment_Before_Lights: string;
  79845. Fragment_Before_Fog: string;
  79846. Fragment_Custom_Alpha: string;
  79847. Fragment_Before_FragColor: string;
  79848. Vertex_Begin: string;
  79849. Vertex_Definitions: string;
  79850. Vertex_MainBegin: string;
  79851. Vertex_Before_PositionUpdated: string;
  79852. Vertex_Before_NormalUpdated: string;
  79853. Vertex_After_WorldPosComputed: string;
  79854. Vertex_MainEnd: string;
  79855. }
  79856. export class CustomMaterial extends BABYLON.StandardMaterial {
  79857. static ShaderIndexer: number;
  79858. CustomParts: ShaderSpecialParts;
  79859. _isCreatedShader: boolean;
  79860. _createdShaderName: string;
  79861. _customUniform: string[];
  79862. _newUniforms: string[];
  79863. _newUniformInstances: {
  79864. [name: string]: any;
  79865. };
  79866. _newSamplerInstances: {
  79867. [name: string]: BABYLON.Texture;
  79868. };
  79869. _customAttributes: string[];
  79870. FragmentShader: string;
  79871. VertexShader: string;
  79872. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79873. ReviewUniform(name: string, arr: string[]): string[];
  79874. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79875. constructor(name: string, scene: BABYLON.Scene);
  79876. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79877. AddAttribute(name: string): CustomMaterial;
  79878. Fragment_Begin(shaderPart: string): CustomMaterial;
  79879. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79880. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79881. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79882. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79883. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79884. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79885. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79886. Vertex_Begin(shaderPart: string): CustomMaterial;
  79887. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79888. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79889. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79890. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79891. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79892. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79893. }
  79894. }
  79895. declare module BABYLON {
  79896. export class ShaderAlebdoParts {
  79897. constructor();
  79898. Fragment_Begin: string;
  79899. Fragment_Definitions: string;
  79900. Fragment_MainBegin: string;
  79901. Fragment_Custom_Albedo: string;
  79902. Fragment_Before_Lights: string;
  79903. Fragment_Custom_MetallicRoughness: string;
  79904. Fragment_Custom_MicroSurface: string;
  79905. Fragment_Before_Fog: string;
  79906. Fragment_Custom_Alpha: string;
  79907. Fragment_Before_FragColor: string;
  79908. Vertex_Begin: string;
  79909. Vertex_Definitions: string;
  79910. Vertex_MainBegin: string;
  79911. Vertex_Before_PositionUpdated: string;
  79912. Vertex_Before_NormalUpdated: string;
  79913. Vertex_After_WorldPosComputed: string;
  79914. Vertex_MainEnd: string;
  79915. }
  79916. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79917. static ShaderIndexer: number;
  79918. CustomParts: ShaderAlebdoParts;
  79919. _isCreatedShader: boolean;
  79920. _createdShaderName: string;
  79921. _customUniform: string[];
  79922. _newUniforms: string[];
  79923. _newUniformInstances: {
  79924. [name: string]: any;
  79925. };
  79926. _newSamplerInstances: {
  79927. [name: string]: BABYLON.Texture;
  79928. };
  79929. _customAttributes: string[];
  79930. FragmentShader: string;
  79931. VertexShader: string;
  79932. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79933. ReviewUniform(name: string, arr: string[]): string[];
  79934. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79935. constructor(name: string, scene: BABYLON.Scene);
  79936. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79937. AddAttribute(name: string): PBRCustomMaterial;
  79938. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79939. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79940. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79941. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79942. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79943. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79944. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79945. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79946. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79947. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79948. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79949. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79950. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79951. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79952. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79953. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79954. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79955. }
  79956. }
  79957. declare module BABYLON {
  79958. /** @hidden */
  79959. export var firePixelShader: {
  79960. name: string;
  79961. shader: string;
  79962. };
  79963. }
  79964. declare module BABYLON {
  79965. /** @hidden */
  79966. export var fireVertexShader: {
  79967. name: string;
  79968. shader: string;
  79969. };
  79970. }
  79971. declare module BABYLON {
  79972. export class FireMaterial extends BABYLON.PushMaterial {
  79973. private _diffuseTexture;
  79974. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79975. private _distortionTexture;
  79976. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79977. private _opacityTexture;
  79978. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79979. diffuseColor: BABYLON.Color3;
  79980. speed: number;
  79981. private _scaledDiffuse;
  79982. private _lastTime;
  79983. constructor(name: string, scene: BABYLON.Scene);
  79984. needAlphaBlending(): boolean;
  79985. needAlphaTesting(): boolean;
  79986. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79987. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79988. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79989. getAnimatables(): BABYLON.IAnimatable[];
  79990. getActiveTextures(): BABYLON.BaseTexture[];
  79991. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79992. getClassName(): string;
  79993. dispose(forceDisposeEffect?: boolean): void;
  79994. clone(name: string): FireMaterial;
  79995. serialize(): any;
  79996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79997. }
  79998. }
  79999. declare module BABYLON {
  80000. /** @hidden */
  80001. export var furPixelShader: {
  80002. name: string;
  80003. shader: string;
  80004. };
  80005. }
  80006. declare module BABYLON {
  80007. /** @hidden */
  80008. export var furVertexShader: {
  80009. name: string;
  80010. shader: string;
  80011. };
  80012. }
  80013. declare module BABYLON {
  80014. export class FurMaterial extends BABYLON.PushMaterial {
  80015. private _diffuseTexture;
  80016. diffuseTexture: BABYLON.BaseTexture;
  80017. private _heightTexture;
  80018. heightTexture: BABYLON.BaseTexture;
  80019. diffuseColor: BABYLON.Color3;
  80020. furLength: number;
  80021. furAngle: number;
  80022. furColor: BABYLON.Color3;
  80023. furOffset: number;
  80024. furSpacing: number;
  80025. furGravity: BABYLON.Vector3;
  80026. furSpeed: number;
  80027. furDensity: number;
  80028. furOcclusion: number;
  80029. furTexture: BABYLON.DynamicTexture;
  80030. private _disableLighting;
  80031. disableLighting: boolean;
  80032. private _maxSimultaneousLights;
  80033. maxSimultaneousLights: number;
  80034. highLevelFur: boolean;
  80035. _meshes: BABYLON.AbstractMesh[];
  80036. private _furTime;
  80037. constructor(name: string, scene: BABYLON.Scene);
  80038. get furTime(): number;
  80039. set furTime(furTime: number);
  80040. needAlphaBlending(): boolean;
  80041. needAlphaTesting(): boolean;
  80042. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80043. updateFur(): void;
  80044. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80045. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80046. getAnimatables(): BABYLON.IAnimatable[];
  80047. getActiveTextures(): BABYLON.BaseTexture[];
  80048. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80049. dispose(forceDisposeEffect?: boolean): void;
  80050. clone(name: string): FurMaterial;
  80051. serialize(): any;
  80052. getClassName(): string;
  80053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  80054. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  80055. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  80056. }
  80057. }
  80058. declare module BABYLON {
  80059. /** @hidden */
  80060. export var gradientPixelShader: {
  80061. name: string;
  80062. shader: string;
  80063. };
  80064. }
  80065. declare module BABYLON {
  80066. /** @hidden */
  80067. export var gradientVertexShader: {
  80068. name: string;
  80069. shader: string;
  80070. };
  80071. }
  80072. declare module BABYLON {
  80073. export class GradientMaterial extends BABYLON.PushMaterial {
  80074. private _maxSimultaneousLights;
  80075. maxSimultaneousLights: number;
  80076. topColor: BABYLON.Color3;
  80077. topColorAlpha: number;
  80078. bottomColor: BABYLON.Color3;
  80079. bottomColorAlpha: number;
  80080. offset: number;
  80081. scale: number;
  80082. smoothness: number;
  80083. private _disableLighting;
  80084. disableLighting: boolean;
  80085. constructor(name: string, scene: BABYLON.Scene);
  80086. needAlphaBlending(): boolean;
  80087. needAlphaTesting(): boolean;
  80088. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80089. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80090. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80091. getAnimatables(): BABYLON.IAnimatable[];
  80092. dispose(forceDisposeEffect?: boolean): void;
  80093. clone(name: string): GradientMaterial;
  80094. serialize(): any;
  80095. getClassName(): string;
  80096. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80097. }
  80098. }
  80099. declare module BABYLON {
  80100. /** @hidden */
  80101. export var gridPixelShader: {
  80102. name: string;
  80103. shader: string;
  80104. };
  80105. }
  80106. declare module BABYLON {
  80107. /** @hidden */
  80108. export var gridVertexShader: {
  80109. name: string;
  80110. shader: string;
  80111. };
  80112. }
  80113. declare module BABYLON {
  80114. /**
  80115. * The grid materials allows you to wrap any shape with a grid.
  80116. * Colors are customizable.
  80117. */
  80118. export class GridMaterial extends BABYLON.PushMaterial {
  80119. /**
  80120. * Main color of the grid (e.g. between lines)
  80121. */
  80122. mainColor: BABYLON.Color3;
  80123. /**
  80124. * Color of the grid lines.
  80125. */
  80126. lineColor: BABYLON.Color3;
  80127. /**
  80128. * The scale of the grid compared to unit.
  80129. */
  80130. gridRatio: number;
  80131. /**
  80132. * Allows setting an offset for the grid lines.
  80133. */
  80134. gridOffset: BABYLON.Vector3;
  80135. /**
  80136. * The frequency of thicker lines.
  80137. */
  80138. majorUnitFrequency: number;
  80139. /**
  80140. * The visibility of minor units in the grid.
  80141. */
  80142. minorUnitVisibility: number;
  80143. /**
  80144. * The grid opacity outside of the lines.
  80145. */
  80146. opacity: number;
  80147. /**
  80148. * Determine RBG output is premultiplied by alpha value.
  80149. */
  80150. preMultiplyAlpha: boolean;
  80151. private _opacityTexture;
  80152. opacityTexture: BABYLON.BaseTexture;
  80153. private _gridControl;
  80154. /**
  80155. * constructor
  80156. * @param name The name given to the material in order to identify it afterwards.
  80157. * @param scene The scene the material is used in.
  80158. */
  80159. constructor(name: string, scene: BABYLON.Scene);
  80160. /**
  80161. * Returns wehter or not the grid requires alpha blending.
  80162. */
  80163. needAlphaBlending(): boolean;
  80164. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80165. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80166. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80167. /**
  80168. * Dispose the material and its associated resources.
  80169. * @param forceDisposeEffect will also dispose the used effect when true
  80170. */
  80171. dispose(forceDisposeEffect?: boolean): void;
  80172. clone(name: string): GridMaterial;
  80173. serialize(): any;
  80174. getClassName(): string;
  80175. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80176. }
  80177. }
  80178. declare module BABYLON {
  80179. /** @hidden */
  80180. export var lavaPixelShader: {
  80181. name: string;
  80182. shader: string;
  80183. };
  80184. }
  80185. declare module BABYLON {
  80186. /** @hidden */
  80187. export var lavaVertexShader: {
  80188. name: string;
  80189. shader: string;
  80190. };
  80191. }
  80192. declare module BABYLON {
  80193. export class LavaMaterial extends BABYLON.PushMaterial {
  80194. private _diffuseTexture;
  80195. diffuseTexture: BABYLON.BaseTexture;
  80196. noiseTexture: BABYLON.BaseTexture;
  80197. fogColor: BABYLON.Color3;
  80198. speed: number;
  80199. movingSpeed: number;
  80200. lowFrequencySpeed: number;
  80201. fogDensity: number;
  80202. private _lastTime;
  80203. diffuseColor: BABYLON.Color3;
  80204. private _disableLighting;
  80205. disableLighting: boolean;
  80206. private _unlit;
  80207. unlit: boolean;
  80208. private _maxSimultaneousLights;
  80209. maxSimultaneousLights: number;
  80210. private _scaledDiffuse;
  80211. constructor(name: string, scene: BABYLON.Scene);
  80212. needAlphaBlending(): boolean;
  80213. needAlphaTesting(): boolean;
  80214. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80215. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80216. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80217. getAnimatables(): BABYLON.IAnimatable[];
  80218. getActiveTextures(): BABYLON.BaseTexture[];
  80219. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80220. dispose(forceDisposeEffect?: boolean): void;
  80221. clone(name: string): LavaMaterial;
  80222. serialize(): any;
  80223. getClassName(): string;
  80224. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80225. }
  80226. }
  80227. declare module BABYLON {
  80228. /** @hidden */
  80229. export var mixPixelShader: {
  80230. name: string;
  80231. shader: string;
  80232. };
  80233. }
  80234. declare module BABYLON {
  80235. /** @hidden */
  80236. export var mixVertexShader: {
  80237. name: string;
  80238. shader: string;
  80239. };
  80240. }
  80241. declare module BABYLON {
  80242. export class MixMaterial extends BABYLON.PushMaterial {
  80243. /**
  80244. * Mix textures
  80245. */
  80246. private _mixTexture1;
  80247. mixTexture1: BABYLON.BaseTexture;
  80248. private _mixTexture2;
  80249. mixTexture2: BABYLON.BaseTexture;
  80250. /**
  80251. * Diffuse textures
  80252. */
  80253. private _diffuseTexture1;
  80254. diffuseTexture1: BABYLON.Texture;
  80255. private _diffuseTexture2;
  80256. diffuseTexture2: BABYLON.Texture;
  80257. private _diffuseTexture3;
  80258. diffuseTexture3: BABYLON.Texture;
  80259. private _diffuseTexture4;
  80260. diffuseTexture4: BABYLON.Texture;
  80261. private _diffuseTexture5;
  80262. diffuseTexture5: BABYLON.Texture;
  80263. private _diffuseTexture6;
  80264. diffuseTexture6: BABYLON.Texture;
  80265. private _diffuseTexture7;
  80266. diffuseTexture7: BABYLON.Texture;
  80267. private _diffuseTexture8;
  80268. diffuseTexture8: BABYLON.Texture;
  80269. /**
  80270. * Uniforms
  80271. */
  80272. diffuseColor: BABYLON.Color3;
  80273. specularColor: BABYLON.Color3;
  80274. specularPower: number;
  80275. private _disableLighting;
  80276. disableLighting: boolean;
  80277. private _maxSimultaneousLights;
  80278. maxSimultaneousLights: number;
  80279. constructor(name: string, scene: BABYLON.Scene);
  80280. needAlphaBlending(): boolean;
  80281. needAlphaTesting(): boolean;
  80282. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80285. getAnimatables(): BABYLON.IAnimatable[];
  80286. getActiveTextures(): BABYLON.BaseTexture[];
  80287. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80288. dispose(forceDisposeEffect?: boolean): void;
  80289. clone(name: string): MixMaterial;
  80290. serialize(): any;
  80291. getClassName(): string;
  80292. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80293. }
  80294. }
  80295. declare module BABYLON {
  80296. /** @hidden */
  80297. export var normalPixelShader: {
  80298. name: string;
  80299. shader: string;
  80300. };
  80301. }
  80302. declare module BABYLON {
  80303. /** @hidden */
  80304. export var normalVertexShader: {
  80305. name: string;
  80306. shader: string;
  80307. };
  80308. }
  80309. declare module BABYLON {
  80310. export class NormalMaterial extends BABYLON.PushMaterial {
  80311. private _diffuseTexture;
  80312. diffuseTexture: BABYLON.BaseTexture;
  80313. diffuseColor: BABYLON.Color3;
  80314. private _disableLighting;
  80315. disableLighting: boolean;
  80316. private _maxSimultaneousLights;
  80317. maxSimultaneousLights: number;
  80318. constructor(name: string, scene: BABYLON.Scene);
  80319. needAlphaBlending(): boolean;
  80320. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80321. needAlphaTesting(): boolean;
  80322. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80323. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80324. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80325. getAnimatables(): BABYLON.IAnimatable[];
  80326. getActiveTextures(): BABYLON.BaseTexture[];
  80327. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80328. dispose(forceDisposeEffect?: boolean): void;
  80329. clone(name: string): NormalMaterial;
  80330. serialize(): any;
  80331. getClassName(): string;
  80332. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80333. }
  80334. }
  80335. declare module BABYLON {
  80336. /** @hidden */
  80337. export var shadowOnlyPixelShader: {
  80338. name: string;
  80339. shader: string;
  80340. };
  80341. }
  80342. declare module BABYLON {
  80343. /** @hidden */
  80344. export var shadowOnlyVertexShader: {
  80345. name: string;
  80346. shader: string;
  80347. };
  80348. }
  80349. declare module BABYLON {
  80350. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80351. private _activeLight;
  80352. constructor(name: string, scene: BABYLON.Scene);
  80353. shadowColor: BABYLON.Color3;
  80354. needAlphaBlending(): boolean;
  80355. needAlphaTesting(): boolean;
  80356. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80357. get activeLight(): BABYLON.IShadowLight;
  80358. set activeLight(light: BABYLON.IShadowLight);
  80359. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80360. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80361. clone(name: string): ShadowOnlyMaterial;
  80362. serialize(): any;
  80363. getClassName(): string;
  80364. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80365. }
  80366. }
  80367. declare module BABYLON {
  80368. /** @hidden */
  80369. export var simplePixelShader: {
  80370. name: string;
  80371. shader: string;
  80372. };
  80373. }
  80374. declare module BABYLON {
  80375. /** @hidden */
  80376. export var simpleVertexShader: {
  80377. name: string;
  80378. shader: string;
  80379. };
  80380. }
  80381. declare module BABYLON {
  80382. export class SimpleMaterial extends BABYLON.PushMaterial {
  80383. private _diffuseTexture;
  80384. diffuseTexture: BABYLON.BaseTexture;
  80385. diffuseColor: BABYLON.Color3;
  80386. private _disableLighting;
  80387. disableLighting: boolean;
  80388. private _maxSimultaneousLights;
  80389. maxSimultaneousLights: number;
  80390. constructor(name: string, scene: BABYLON.Scene);
  80391. needAlphaBlending(): boolean;
  80392. needAlphaTesting(): boolean;
  80393. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80394. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80395. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80396. getAnimatables(): BABYLON.IAnimatable[];
  80397. getActiveTextures(): BABYLON.BaseTexture[];
  80398. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80399. dispose(forceDisposeEffect?: boolean): void;
  80400. clone(name: string): SimpleMaterial;
  80401. serialize(): any;
  80402. getClassName(): string;
  80403. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80404. }
  80405. }
  80406. declare module BABYLON {
  80407. /** @hidden */
  80408. export var skyPixelShader: {
  80409. name: string;
  80410. shader: string;
  80411. };
  80412. }
  80413. declare module BABYLON {
  80414. /** @hidden */
  80415. export var skyVertexShader: {
  80416. name: string;
  80417. shader: string;
  80418. };
  80419. }
  80420. declare module BABYLON {
  80421. /**
  80422. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80423. * @see https://doc.babylonjs.com/extensions/sky
  80424. */
  80425. export class SkyMaterial extends BABYLON.PushMaterial {
  80426. /**
  80427. * Defines the overall luminance of sky in interval ]0, 1[.
  80428. */
  80429. luminance: number;
  80430. /**
  80431. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80432. */
  80433. turbidity: number;
  80434. /**
  80435. * Defines the sky appearance (light intensity).
  80436. */
  80437. rayleigh: number;
  80438. /**
  80439. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80440. */
  80441. mieCoefficient: number;
  80442. /**
  80443. * Defines the amount of haze particles following the Mie scattering theory.
  80444. */
  80445. mieDirectionalG: number;
  80446. /**
  80447. * Defines the distance of the sun according to the active scene camera.
  80448. */
  80449. distance: number;
  80450. /**
  80451. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80452. * "inclined".
  80453. */
  80454. inclination: number;
  80455. /**
  80456. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80457. * an object direction and a reference direction.
  80458. */
  80459. azimuth: number;
  80460. /**
  80461. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80462. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80463. */
  80464. sunPosition: BABYLON.Vector3;
  80465. /**
  80466. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80467. * .sunPosition property.
  80468. */
  80469. useSunPosition: boolean;
  80470. /**
  80471. * Defines an offset vector used to get a horizon offset.
  80472. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80473. */
  80474. cameraOffset: BABYLON.Vector3;
  80475. private _cameraPosition;
  80476. /**
  80477. * Instantiates a new sky material.
  80478. * This material allows to create dynamic and texture free
  80479. * effects for skyboxes by taking care of the atmosphere state.
  80480. * @see https://doc.babylonjs.com/extensions/sky
  80481. * @param name Define the name of the material in the scene
  80482. * @param scene Define the scene the material belong to
  80483. */
  80484. constructor(name: string, scene: BABYLON.Scene);
  80485. /**
  80486. * Specifies if the material will require alpha blending
  80487. * @returns a boolean specifying if alpha blending is needed
  80488. */
  80489. needAlphaBlending(): boolean;
  80490. /**
  80491. * Specifies if this material should be rendered in alpha test mode
  80492. * @returns false as the sky material doesn't need alpha testing.
  80493. */
  80494. needAlphaTesting(): boolean;
  80495. /**
  80496. * Get the texture used for alpha test purpose.
  80497. * @returns null as the sky material has no texture.
  80498. */
  80499. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80500. /**
  80501. * Get if the submesh is ready to be used and all its information available.
  80502. * Child classes can use it to update shaders
  80503. * @param mesh defines the mesh to check
  80504. * @param subMesh defines which submesh to check
  80505. * @param useInstances specifies that instances should be used
  80506. * @returns a boolean indicating that the submesh is ready or not
  80507. */
  80508. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80509. /**
  80510. * Binds the submesh to this material by preparing the effect and shader to draw
  80511. * @param world defines the world transformation matrix
  80512. * @param mesh defines the mesh containing the submesh
  80513. * @param subMesh defines the submesh to bind the material to
  80514. */
  80515. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80516. /**
  80517. * Get the list of animatables in the material.
  80518. * @returns the list of animatables object used in the material
  80519. */
  80520. getAnimatables(): BABYLON.IAnimatable[];
  80521. /**
  80522. * Disposes the material
  80523. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80524. */
  80525. dispose(forceDisposeEffect?: boolean): void;
  80526. /**
  80527. * Makes a duplicate of the material, and gives it a new name
  80528. * @param name defines the new name for the duplicated material
  80529. * @returns the cloned material
  80530. */
  80531. clone(name: string): SkyMaterial;
  80532. /**
  80533. * Serializes this material in a JSON representation
  80534. * @returns the serialized material object
  80535. */
  80536. serialize(): any;
  80537. /**
  80538. * Gets the current class name of the material e.g. "SkyMaterial"
  80539. * Mainly use in serialization.
  80540. * @returns the class name
  80541. */
  80542. getClassName(): string;
  80543. /**
  80544. * Creates a sky material from parsed material data
  80545. * @param source defines the JSON representation of the material
  80546. * @param scene defines the hosting scene
  80547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80548. * @returns a new sky material
  80549. */
  80550. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80551. }
  80552. }
  80553. declare module BABYLON {
  80554. /** @hidden */
  80555. export var terrainPixelShader: {
  80556. name: string;
  80557. shader: string;
  80558. };
  80559. }
  80560. declare module BABYLON {
  80561. /** @hidden */
  80562. export var terrainVertexShader: {
  80563. name: string;
  80564. shader: string;
  80565. };
  80566. }
  80567. declare module BABYLON {
  80568. export class TerrainMaterial extends BABYLON.PushMaterial {
  80569. private _mixTexture;
  80570. mixTexture: BABYLON.BaseTexture;
  80571. private _diffuseTexture1;
  80572. diffuseTexture1: BABYLON.Texture;
  80573. private _diffuseTexture2;
  80574. diffuseTexture2: BABYLON.Texture;
  80575. private _diffuseTexture3;
  80576. diffuseTexture3: BABYLON.Texture;
  80577. private _bumpTexture1;
  80578. bumpTexture1: BABYLON.Texture;
  80579. private _bumpTexture2;
  80580. bumpTexture2: BABYLON.Texture;
  80581. private _bumpTexture3;
  80582. bumpTexture3: BABYLON.Texture;
  80583. diffuseColor: BABYLON.Color3;
  80584. specularColor: BABYLON.Color3;
  80585. specularPower: number;
  80586. private _disableLighting;
  80587. disableLighting: boolean;
  80588. private _maxSimultaneousLights;
  80589. maxSimultaneousLights: number;
  80590. constructor(name: string, scene: BABYLON.Scene);
  80591. needAlphaBlending(): boolean;
  80592. needAlphaTesting(): boolean;
  80593. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80594. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80595. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80596. getAnimatables(): BABYLON.IAnimatable[];
  80597. getActiveTextures(): BABYLON.BaseTexture[];
  80598. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80599. dispose(forceDisposeEffect?: boolean): void;
  80600. clone(name: string): TerrainMaterial;
  80601. serialize(): any;
  80602. getClassName(): string;
  80603. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80604. }
  80605. }
  80606. declare module BABYLON {
  80607. /** @hidden */
  80608. export var triplanarPixelShader: {
  80609. name: string;
  80610. shader: string;
  80611. };
  80612. }
  80613. declare module BABYLON {
  80614. /** @hidden */
  80615. export var triplanarVertexShader: {
  80616. name: string;
  80617. shader: string;
  80618. };
  80619. }
  80620. declare module BABYLON {
  80621. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80622. mixTexture: BABYLON.BaseTexture;
  80623. private _diffuseTextureX;
  80624. diffuseTextureX: BABYLON.BaseTexture;
  80625. private _diffuseTextureY;
  80626. diffuseTextureY: BABYLON.BaseTexture;
  80627. private _diffuseTextureZ;
  80628. diffuseTextureZ: BABYLON.BaseTexture;
  80629. private _normalTextureX;
  80630. normalTextureX: BABYLON.BaseTexture;
  80631. private _normalTextureY;
  80632. normalTextureY: BABYLON.BaseTexture;
  80633. private _normalTextureZ;
  80634. normalTextureZ: BABYLON.BaseTexture;
  80635. tileSize: number;
  80636. diffuseColor: BABYLON.Color3;
  80637. specularColor: BABYLON.Color3;
  80638. specularPower: number;
  80639. private _disableLighting;
  80640. disableLighting: boolean;
  80641. private _maxSimultaneousLights;
  80642. maxSimultaneousLights: number;
  80643. constructor(name: string, scene: BABYLON.Scene);
  80644. needAlphaBlending(): boolean;
  80645. needAlphaTesting(): boolean;
  80646. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80647. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80648. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80649. getAnimatables(): BABYLON.IAnimatable[];
  80650. getActiveTextures(): BABYLON.BaseTexture[];
  80651. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80652. dispose(forceDisposeEffect?: boolean): void;
  80653. clone(name: string): TriPlanarMaterial;
  80654. serialize(): any;
  80655. getClassName(): string;
  80656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80657. }
  80658. }
  80659. declare module BABYLON {
  80660. /** @hidden */
  80661. export var waterPixelShader: {
  80662. name: string;
  80663. shader: string;
  80664. };
  80665. }
  80666. declare module BABYLON {
  80667. /** @hidden */
  80668. export var waterVertexShader: {
  80669. name: string;
  80670. shader: string;
  80671. };
  80672. }
  80673. declare module BABYLON {
  80674. export class WaterMaterial extends BABYLON.PushMaterial {
  80675. renderTargetSize: BABYLON.Vector2;
  80676. private _bumpTexture;
  80677. bumpTexture: BABYLON.BaseTexture;
  80678. diffuseColor: BABYLON.Color3;
  80679. specularColor: BABYLON.Color3;
  80680. specularPower: number;
  80681. private _disableLighting;
  80682. disableLighting: boolean;
  80683. private _maxSimultaneousLights;
  80684. maxSimultaneousLights: number;
  80685. /**
  80686. * @param {number}: Represents the wind force
  80687. */
  80688. windForce: number;
  80689. /**
  80690. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80691. */
  80692. windDirection: BABYLON.Vector2;
  80693. /**
  80694. * @param {number}: Wave height, represents the height of the waves
  80695. */
  80696. waveHeight: number;
  80697. /**
  80698. * @param {number}: Bump height, represents the bump height related to the bump map
  80699. */
  80700. bumpHeight: number;
  80701. /**
  80702. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80703. */
  80704. private _bumpSuperimpose;
  80705. bumpSuperimpose: boolean;
  80706. /**
  80707. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80708. */
  80709. private _fresnelSeparate;
  80710. fresnelSeparate: boolean;
  80711. /**
  80712. * @param {boolean}: bump Waves modify the reflection.
  80713. */
  80714. private _bumpAffectsReflection;
  80715. bumpAffectsReflection: boolean;
  80716. /**
  80717. * @param {number}: The water color blended with the refraction (near)
  80718. */
  80719. waterColor: BABYLON.Color3;
  80720. /**
  80721. * @param {number}: The blend factor related to the water color
  80722. */
  80723. colorBlendFactor: number;
  80724. /**
  80725. * @param {number}: The water color blended with the reflection (far)
  80726. */
  80727. waterColor2: BABYLON.Color3;
  80728. /**
  80729. * @param {number}: The blend factor related to the water color (reflection, far)
  80730. */
  80731. colorBlendFactor2: number;
  80732. /**
  80733. * @param {number}: Represents the maximum length of a wave
  80734. */
  80735. waveLength: number;
  80736. /**
  80737. * @param {number}: Defines the waves speed
  80738. */
  80739. waveSpeed: number;
  80740. /**
  80741. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80742. * will avoid calculating useless pixels in the pixel shader of the water material.
  80743. */
  80744. disableClipPlane: boolean;
  80745. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80746. private _mesh;
  80747. private _refractionRTT;
  80748. private _reflectionRTT;
  80749. private _reflectionTransform;
  80750. private _lastTime;
  80751. private _lastDeltaTime;
  80752. private _useLogarithmicDepth;
  80753. private _waitingRenderList;
  80754. private _imageProcessingConfiguration;
  80755. private _imageProcessingObserver;
  80756. /**
  80757. * Gets a boolean indicating that current material needs to register RTT
  80758. */
  80759. get hasRenderTargetTextures(): boolean;
  80760. /**
  80761. * Constructor
  80762. */
  80763. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80764. get useLogarithmicDepth(): boolean;
  80765. set useLogarithmicDepth(value: boolean);
  80766. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80767. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80768. addToRenderList(node: any): void;
  80769. enableRenderTargets(enable: boolean): void;
  80770. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80771. get renderTargetsEnabled(): boolean;
  80772. needAlphaBlending(): boolean;
  80773. needAlphaTesting(): boolean;
  80774. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80775. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80776. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80777. private _createRenderTargets;
  80778. getAnimatables(): BABYLON.IAnimatable[];
  80779. getActiveTextures(): BABYLON.BaseTexture[];
  80780. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80781. dispose(forceDisposeEffect?: boolean): void;
  80782. clone(name: string): WaterMaterial;
  80783. serialize(): any;
  80784. getClassName(): string;
  80785. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80786. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80787. }
  80788. }
  80789. declare module BABYLON {
  80790. /** @hidden */
  80791. export var asciiartPixelShader: {
  80792. name: string;
  80793. shader: string;
  80794. };
  80795. }
  80796. declare module BABYLON {
  80797. /**
  80798. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80799. *
  80800. * It basically takes care rendering the font front the given font size to a texture.
  80801. * This is used later on in the postprocess.
  80802. */
  80803. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80804. private _font;
  80805. private _text;
  80806. private _charSize;
  80807. /**
  80808. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80809. */
  80810. get charSize(): number;
  80811. /**
  80812. * Create a new instance of the Ascii Art FontTexture class
  80813. * @param name the name of the texture
  80814. * @param font the font to use, use the W3C CSS notation
  80815. * @param text the caracter set to use in the rendering.
  80816. * @param scene the scene that owns the texture
  80817. */
  80818. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80819. /**
  80820. * Gets the max char width of a font.
  80821. * @param font the font to use, use the W3C CSS notation
  80822. * @return the max char width
  80823. */
  80824. private getFontWidth;
  80825. /**
  80826. * Gets the max char height of a font.
  80827. * @param font the font to use, use the W3C CSS notation
  80828. * @return the max char height
  80829. */
  80830. private getFontHeight;
  80831. /**
  80832. * Clones the current AsciiArtTexture.
  80833. * @return the clone of the texture.
  80834. */
  80835. clone(): AsciiArtFontTexture;
  80836. /**
  80837. * Parses a json object representing the texture and returns an instance of it.
  80838. * @param source the source JSON representation
  80839. * @param scene the scene to create the texture for
  80840. * @return the parsed texture
  80841. */
  80842. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80843. }
  80844. /**
  80845. * Option available in the Ascii Art Post Process.
  80846. */
  80847. export interface IAsciiArtPostProcessOptions {
  80848. /**
  80849. * The font to use following the w3c font definition.
  80850. */
  80851. font?: string;
  80852. /**
  80853. * The character set to use in the postprocess.
  80854. */
  80855. characterSet?: string;
  80856. /**
  80857. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80858. * This number is defined between 0 and 1;
  80859. */
  80860. mixToTile?: number;
  80861. /**
  80862. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80863. * This number is defined between 0 and 1;
  80864. */
  80865. mixToNormal?: number;
  80866. }
  80867. /**
  80868. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80869. *
  80870. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80871. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80872. */
  80873. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80874. /**
  80875. * The font texture used to render the char in the post process.
  80876. */
  80877. private _asciiArtFontTexture;
  80878. /**
  80879. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80880. * This number is defined between 0 and 1;
  80881. */
  80882. mixToTile: number;
  80883. /**
  80884. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80885. * This number is defined between 0 and 1;
  80886. */
  80887. mixToNormal: number;
  80888. /**
  80889. * Instantiates a new Ascii Art Post Process.
  80890. * @param name the name to give to the postprocess
  80891. * @camera the camera to apply the post process to.
  80892. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80893. */
  80894. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80895. }
  80896. }
  80897. declare module BABYLON {
  80898. /** @hidden */
  80899. export var digitalrainPixelShader: {
  80900. name: string;
  80901. shader: string;
  80902. };
  80903. }
  80904. declare module BABYLON {
  80905. /**
  80906. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80907. *
  80908. * It basically takes care rendering the font front the given font size to a texture.
  80909. * This is used later on in the postprocess.
  80910. */
  80911. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80912. private _font;
  80913. private _text;
  80914. private _charSize;
  80915. /**
  80916. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80917. */
  80918. get charSize(): number;
  80919. /**
  80920. * Create a new instance of the Digital Rain FontTexture class
  80921. * @param name the name of the texture
  80922. * @param font the font to use, use the W3C CSS notation
  80923. * @param text the caracter set to use in the rendering.
  80924. * @param scene the scene that owns the texture
  80925. */
  80926. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80927. /**
  80928. * Gets the max char width of a font.
  80929. * @param font the font to use, use the W3C CSS notation
  80930. * @return the max char width
  80931. */
  80932. private getFontWidth;
  80933. /**
  80934. * Gets the max char height of a font.
  80935. * @param font the font to use, use the W3C CSS notation
  80936. * @return the max char height
  80937. */
  80938. private getFontHeight;
  80939. /**
  80940. * Clones the current DigitalRainFontTexture.
  80941. * @return the clone of the texture.
  80942. */
  80943. clone(): DigitalRainFontTexture;
  80944. /**
  80945. * Parses a json object representing the texture and returns an instance of it.
  80946. * @param source the source JSON representation
  80947. * @param scene the scene to create the texture for
  80948. * @return the parsed texture
  80949. */
  80950. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80951. }
  80952. /**
  80953. * Option available in the Digital Rain Post Process.
  80954. */
  80955. export interface IDigitalRainPostProcessOptions {
  80956. /**
  80957. * The font to use following the w3c font definition.
  80958. */
  80959. font?: string;
  80960. /**
  80961. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80962. * This number is defined between 0 and 1;
  80963. */
  80964. mixToTile?: number;
  80965. /**
  80966. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80967. * This number is defined between 0 and 1;
  80968. */
  80969. mixToNormal?: number;
  80970. }
  80971. /**
  80972. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80973. *
  80974. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80975. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80976. */
  80977. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80978. /**
  80979. * The font texture used to render the char in the post process.
  80980. */
  80981. private _digitalRainFontTexture;
  80982. /**
  80983. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80984. * This number is defined between 0 and 1;
  80985. */
  80986. mixToTile: number;
  80987. /**
  80988. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80989. * This number is defined between 0 and 1;
  80990. */
  80991. mixToNormal: number;
  80992. /**
  80993. * Instantiates a new Digital Rain Post Process.
  80994. * @param name the name to give to the postprocess
  80995. * @camera the camera to apply the post process to.
  80996. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80997. */
  80998. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80999. }
  81000. }
  81001. declare module BABYLON {
  81002. /** @hidden */
  81003. export var brickProceduralTexturePixelShader: {
  81004. name: string;
  81005. shader: string;
  81006. };
  81007. }
  81008. declare module BABYLON {
  81009. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  81010. private _numberOfBricksHeight;
  81011. private _numberOfBricksWidth;
  81012. private _jointColor;
  81013. private _brickColor;
  81014. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81015. updateShaderUniforms(): void;
  81016. get numberOfBricksHeight(): number;
  81017. set numberOfBricksHeight(value: number);
  81018. get numberOfBricksWidth(): number;
  81019. set numberOfBricksWidth(value: number);
  81020. get jointColor(): BABYLON.Color3;
  81021. set jointColor(value: BABYLON.Color3);
  81022. get brickColor(): BABYLON.Color3;
  81023. set brickColor(value: BABYLON.Color3);
  81024. /**
  81025. * Serializes this brick procedural texture
  81026. * @returns a serialized brick procedural texture object
  81027. */
  81028. serialize(): any;
  81029. /**
  81030. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  81031. * @param parsedTexture defines parsed texture data
  81032. * @param scene defines the current scene
  81033. * @param rootUrl defines the root URL containing brick procedural texture information
  81034. * @returns a parsed Brick Procedural BABYLON.Texture
  81035. */
  81036. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  81037. }
  81038. }
  81039. declare module BABYLON {
  81040. /** @hidden */
  81041. export var cloudProceduralTexturePixelShader: {
  81042. name: string;
  81043. shader: string;
  81044. };
  81045. }
  81046. declare module BABYLON {
  81047. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  81048. private _skyColor;
  81049. private _cloudColor;
  81050. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81051. updateShaderUniforms(): void;
  81052. get skyColor(): BABYLON.Color4;
  81053. set skyColor(value: BABYLON.Color4);
  81054. get cloudColor(): BABYLON.Color4;
  81055. set cloudColor(value: BABYLON.Color4);
  81056. /**
  81057. * Serializes this cloud procedural texture
  81058. * @returns a serialized cloud procedural texture object
  81059. */
  81060. serialize(): any;
  81061. /**
  81062. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  81063. * @param parsedTexture defines parsed texture data
  81064. * @param scene defines the current scene
  81065. * @param rootUrl defines the root URL containing cloud procedural texture information
  81066. * @returns a parsed Cloud Procedural BABYLON.Texture
  81067. */
  81068. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  81069. }
  81070. }
  81071. declare module BABYLON {
  81072. /** @hidden */
  81073. export var fireProceduralTexturePixelShader: {
  81074. name: string;
  81075. shader: string;
  81076. };
  81077. }
  81078. declare module BABYLON {
  81079. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81080. private _time;
  81081. private _speed;
  81082. private _autoGenerateTime;
  81083. private _fireColors;
  81084. private _alphaThreshold;
  81085. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81086. updateShaderUniforms(): void;
  81087. render(useCameraPostProcess?: boolean): void;
  81088. static get PurpleFireColors(): BABYLON.Color3[];
  81089. static get GreenFireColors(): BABYLON.Color3[];
  81090. static get RedFireColors(): BABYLON.Color3[];
  81091. static get BlueFireColors(): BABYLON.Color3[];
  81092. get autoGenerateTime(): boolean;
  81093. set autoGenerateTime(value: boolean);
  81094. get fireColors(): BABYLON.Color3[];
  81095. set fireColors(value: BABYLON.Color3[]);
  81096. get time(): number;
  81097. set time(value: number);
  81098. get speed(): BABYLON.Vector2;
  81099. set speed(value: BABYLON.Vector2);
  81100. get alphaThreshold(): number;
  81101. set alphaThreshold(value: number);
  81102. /**
  81103. * Serializes this fire procedural texture
  81104. * @returns a serialized fire procedural texture object
  81105. */
  81106. serialize(): any;
  81107. /**
  81108. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81109. * @param parsedTexture defines parsed texture data
  81110. * @param scene defines the current scene
  81111. * @param rootUrl defines the root URL containing fire procedural texture information
  81112. * @returns a parsed Fire Procedural BABYLON.Texture
  81113. */
  81114. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81115. }
  81116. }
  81117. declare module BABYLON {
  81118. /** @hidden */
  81119. export var grassProceduralTexturePixelShader: {
  81120. name: string;
  81121. shader: string;
  81122. };
  81123. }
  81124. declare module BABYLON {
  81125. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81126. private _grassColors;
  81127. private _groundColor;
  81128. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81129. updateShaderUniforms(): void;
  81130. get grassColors(): BABYLON.Color3[];
  81131. set grassColors(value: BABYLON.Color3[]);
  81132. get groundColor(): BABYLON.Color3;
  81133. set groundColor(value: BABYLON.Color3);
  81134. /**
  81135. * Serializes this grass procedural texture
  81136. * @returns a serialized grass procedural texture object
  81137. */
  81138. serialize(): any;
  81139. /**
  81140. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81141. * @param parsedTexture defines parsed texture data
  81142. * @param scene defines the current scene
  81143. * @param rootUrl defines the root URL containing grass procedural texture information
  81144. * @returns a parsed Grass Procedural BABYLON.Texture
  81145. */
  81146. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81147. }
  81148. }
  81149. declare module BABYLON {
  81150. /** @hidden */
  81151. export var marbleProceduralTexturePixelShader: {
  81152. name: string;
  81153. shader: string;
  81154. };
  81155. }
  81156. declare module BABYLON {
  81157. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81158. private _numberOfTilesHeight;
  81159. private _numberOfTilesWidth;
  81160. private _amplitude;
  81161. private _jointColor;
  81162. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81163. updateShaderUniforms(): void;
  81164. get numberOfTilesHeight(): number;
  81165. set numberOfTilesHeight(value: number);
  81166. get amplitude(): number;
  81167. set amplitude(value: number);
  81168. get numberOfTilesWidth(): number;
  81169. set numberOfTilesWidth(value: number);
  81170. get jointColor(): BABYLON.Color3;
  81171. set jointColor(value: BABYLON.Color3);
  81172. /**
  81173. * Serializes this marble procedural texture
  81174. * @returns a serialized marble procedural texture object
  81175. */
  81176. serialize(): any;
  81177. /**
  81178. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81179. * @param parsedTexture defines parsed texture data
  81180. * @param scene defines the current scene
  81181. * @param rootUrl defines the root URL containing marble procedural texture information
  81182. * @returns a parsed Marble Procedural BABYLON.Texture
  81183. */
  81184. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81185. }
  81186. }
  81187. declare module BABYLON {
  81188. /** @hidden */
  81189. export var normalMapProceduralTexturePixelShader: {
  81190. name: string;
  81191. shader: string;
  81192. };
  81193. }
  81194. declare module BABYLON {
  81195. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81196. private _baseTexture;
  81197. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81198. updateShaderUniforms(): void;
  81199. render(useCameraPostProcess?: boolean): void;
  81200. resize(size: any, generateMipMaps: any): void;
  81201. get baseTexture(): BABYLON.Texture;
  81202. set baseTexture(texture: BABYLON.Texture);
  81203. /**
  81204. * Serializes this normal map procedural texture
  81205. * @returns a serialized normal map procedural texture object
  81206. */
  81207. serialize(): any;
  81208. /**
  81209. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81210. * @param parsedTexture defines parsed texture data
  81211. * @param scene defines the current scene
  81212. * @param rootUrl defines the root URL containing normal map procedural texture information
  81213. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81214. */
  81215. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81216. }
  81217. }
  81218. declare module BABYLON {
  81219. /** @hidden */
  81220. export var perlinNoiseProceduralTexturePixelShader: {
  81221. name: string;
  81222. shader: string;
  81223. };
  81224. }
  81225. declare module BABYLON {
  81226. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81227. time: number;
  81228. timeScale: number;
  81229. translationSpeed: number;
  81230. private _currentTranslation;
  81231. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81232. updateShaderUniforms(): void;
  81233. render(useCameraPostProcess?: boolean): void;
  81234. resize(size: any, generateMipMaps: any): void;
  81235. /**
  81236. * Serializes this perlin noise procedural texture
  81237. * @returns a serialized perlin noise procedural texture object
  81238. */
  81239. serialize(): any;
  81240. /**
  81241. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81242. * @param parsedTexture defines parsed texture data
  81243. * @param scene defines the current scene
  81244. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81245. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81246. */
  81247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81248. }
  81249. }
  81250. declare module BABYLON {
  81251. /** @hidden */
  81252. export var roadProceduralTexturePixelShader: {
  81253. name: string;
  81254. shader: string;
  81255. };
  81256. }
  81257. declare module BABYLON {
  81258. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81259. private _roadColor;
  81260. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81261. updateShaderUniforms(): void;
  81262. get roadColor(): BABYLON.Color3;
  81263. set roadColor(value: BABYLON.Color3);
  81264. /**
  81265. * Serializes this road procedural texture
  81266. * @returns a serialized road procedural texture object
  81267. */
  81268. serialize(): any;
  81269. /**
  81270. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81271. * @param parsedTexture defines parsed texture data
  81272. * @param scene defines the current scene
  81273. * @param rootUrl defines the root URL containing road procedural texture information
  81274. * @returns a parsed Road Procedural BABYLON.Texture
  81275. */
  81276. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81277. }
  81278. }
  81279. declare module BABYLON {
  81280. /** @hidden */
  81281. export var starfieldProceduralTexturePixelShader: {
  81282. name: string;
  81283. shader: string;
  81284. };
  81285. }
  81286. declare module BABYLON {
  81287. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81288. private _time;
  81289. private _alpha;
  81290. private _beta;
  81291. private _zoom;
  81292. private _formuparam;
  81293. private _stepsize;
  81294. private _tile;
  81295. private _brightness;
  81296. private _darkmatter;
  81297. private _distfading;
  81298. private _saturation;
  81299. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81300. updateShaderUniforms(): void;
  81301. get time(): number;
  81302. set time(value: number);
  81303. get alpha(): number;
  81304. set alpha(value: number);
  81305. get beta(): number;
  81306. set beta(value: number);
  81307. get formuparam(): number;
  81308. set formuparam(value: number);
  81309. get stepsize(): number;
  81310. set stepsize(value: number);
  81311. get zoom(): number;
  81312. set zoom(value: number);
  81313. get tile(): number;
  81314. set tile(value: number);
  81315. get brightness(): number;
  81316. set brightness(value: number);
  81317. get darkmatter(): number;
  81318. set darkmatter(value: number);
  81319. get distfading(): number;
  81320. set distfading(value: number);
  81321. get saturation(): number;
  81322. set saturation(value: number);
  81323. /**
  81324. * Serializes this starfield procedural texture
  81325. * @returns a serialized starfield procedural texture object
  81326. */
  81327. serialize(): any;
  81328. /**
  81329. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81330. * @param parsedTexture defines parsed texture data
  81331. * @param scene defines the current scene
  81332. * @param rootUrl defines the root URL containing startfield procedural texture information
  81333. * @returns a parsed Starfield Procedural BABYLON.Texture
  81334. */
  81335. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81336. }
  81337. }
  81338. declare module BABYLON {
  81339. /** @hidden */
  81340. export var woodProceduralTexturePixelShader: {
  81341. name: string;
  81342. shader: string;
  81343. };
  81344. }
  81345. declare module BABYLON {
  81346. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81347. private _ampScale;
  81348. private _woodColor;
  81349. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81350. updateShaderUniforms(): void;
  81351. get ampScale(): number;
  81352. set ampScale(value: number);
  81353. get woodColor(): BABYLON.Color3;
  81354. set woodColor(value: BABYLON.Color3);
  81355. /**
  81356. * Serializes this wood procedural texture
  81357. * @returns a serialized wood procedural texture object
  81358. */
  81359. serialize(): any;
  81360. /**
  81361. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81362. * @param parsedTexture defines parsed texture data
  81363. * @param scene defines the current scene
  81364. * @param rootUrl defines the root URL containing wood procedural texture information
  81365. * @returns a parsed Wood Procedural BABYLON.Texture
  81366. */
  81367. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81368. }
  81369. }